Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
4ee202e2
Commit
4ee202e2
authored
May 21, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: better BTREE_INSERT_NO_CLEAR_REPLICAS
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
cdeeb75e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
25 deletions
+21
-25
fs/bcachefs/btree_update_leaf.c
fs/bcachefs/btree_update_leaf.c
+7
-8
fs/bcachefs/buckets.c
fs/bcachefs/buckets.c
+14
-17
No files found.
fs/bcachefs/btree_update_leaf.c
View file @
4ee202e2
...
@@ -544,13 +544,6 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
...
@@ -544,13 +544,6 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
struct
btree_insert_entry
*
i
;
struct
btree_insert_entry
*
i
;
int
ret
;
int
ret
;
if
(
likely
(
!
(
trans
->
flags
&
BTREE_INSERT_NO_CLEAR_REPLICAS
))
&&
trans
->
fs_usage_deltas
)
{
memset
(
&
trans
->
fs_usage_deltas
->
fs_usage
,
0
,
sizeof
(
trans
->
fs_usage_deltas
->
fs_usage
));
trans
->
fs_usage_deltas
->
used
=
0
;
}
trans_for_each_update_iter
(
trans
,
i
)
trans_for_each_update_iter
(
trans
,
i
)
BUG_ON
(
i
->
iter
->
uptodate
>=
BTREE_ITER_NEED_RELOCK
);
BUG_ON
(
i
->
iter
->
uptodate
>=
BTREE_ITER_NEED_RELOCK
);
...
@@ -561,7 +554,7 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
...
@@ -561,7 +554,7 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
if
(
ret
==
-
EINTR
)
if
(
ret
==
-
EINTR
)
trace_trans_restart_mark
(
trans
->
ip
);
trace_trans_restart_mark
(
trans
->
ip
);
if
(
ret
)
if
(
ret
)
return
ret
;
goto
out_clear_replicas
;
}
}
btree_trans_lock_write
(
c
,
trans
);
btree_trans_lock_write
(
c
,
trans
);
...
@@ -655,6 +648,12 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
...
@@ -655,6 +648,12 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
}
}
bch2_journal_res_put
(
&
c
->
journal
,
&
trans
->
journal_res
);
bch2_journal_res_put
(
&
c
->
journal
,
&
trans
->
journal_res
);
out_clear_replicas:
if
(
trans
->
fs_usage_deltas
)
{
memset
(
&
trans
->
fs_usage_deltas
->
fs_usage
,
0
,
sizeof
(
trans
->
fs_usage_deltas
->
fs_usage
));
trans
->
fs_usage_deltas
->
used
=
0
;
}
return
ret
;
return
ret
;
}
}
...
...
fs/bcachefs/buckets.c
View file @
4ee202e2
...
@@ -1260,30 +1260,31 @@ void bch2_trans_fs_usage_apply(struct btree_trans *trans,
...
@@ -1260,30 +1260,31 @@ void bch2_trans_fs_usage_apply(struct btree_trans *trans,
/* trans_mark: */
/* trans_mark: */
static
void
replicas_deltas_realloc
(
struct
btree_trans
*
trans
)
static
struct
replicas_delta_list
*
replicas_deltas_realloc
(
struct
btree_trans
*
trans
,
unsigned
more
)
{
{
struct
replicas_delta_list
*
d
=
trans
->
fs_usage_deltas
;
struct
replicas_delta_list
*
d
=
trans
->
fs_usage_deltas
;
unsigned
new_size
=
d
?
d
->
size
*
2
:
128
;
unsigned
new_size
=
d
?
(
d
->
size
+
more
)
*
2
:
128
;
if
(
!
d
||
d
->
used
+
more
>
d
->
size
)
{
d
=
krealloc
(
d
,
sizeof
(
*
d
)
+
new_size
,
GFP_NOIO
|
__GFP_ZERO
);
d
=
krealloc
(
d
,
sizeof
(
*
d
)
+
new_size
,
GFP_NOIO
|
__GFP_ZERO
);
BUG_ON
(
!
d
);
BUG_ON
(
!
d
);
d
->
size
=
new_size
;
d
->
size
=
new_size
;
trans
->
fs_usage_deltas
=
d
;
trans
->
fs_usage_deltas
=
d
;
}
return
d
;
}
}
static
inline
void
update_replicas_list
(
struct
btree_trans
*
trans
,
static
inline
void
update_replicas_list
(
struct
btree_trans
*
trans
,
struct
bch_replicas_entry
*
r
,
struct
bch_replicas_entry
*
r
,
s64
sectors
)
s64
sectors
)
{
{
struct
replicas_delta_list
*
d
=
trans
->
fs_usage_deltas
;
struct
replicas_delta_list
*
d
;
struct
replicas_delta
*
n
;
struct
replicas_delta
*
n
;
unsigned
b
=
replicas_entry_bytes
(
r
)
+
8
;
unsigned
b
=
replicas_entry_bytes
(
r
)
+
8
;
if
(
!
d
||
d
->
used
+
b
>
d
->
size
)
{
d
=
replicas_deltas_realloc
(
trans
,
b
);
replicas_deltas_realloc
(
trans
);
d
=
trans
->
fs_usage_deltas
;
}
n
=
(
void
*
)
d
->
d
+
d
->
used
;
n
=
(
void
*
)
d
->
d
+
d
->
used
;
n
->
delta
=
sectors
;
n
->
delta
=
sectors
;
...
@@ -1566,9 +1567,7 @@ int bch2_trans_mark_key(struct btree_trans *trans,
...
@@ -1566,9 +1567,7 @@ int bch2_trans_mark_key(struct btree_trans *trans,
return
bch2_trans_mark_extent
(
trans
,
k
,
return
bch2_trans_mark_extent
(
trans
,
k
,
sectors
,
BCH_DATA_USER
);
sectors
,
BCH_DATA_USER
);
case
KEY_TYPE_inode
:
case
KEY_TYPE_inode
:
if
(
!
trans
->
fs_usage_deltas
)
d
=
replicas_deltas_realloc
(
trans
,
0
);
replicas_deltas_realloc
(
trans
);
d
=
trans
->
fs_usage_deltas
;
if
(
inserting
)
if
(
inserting
)
d
->
fs_usage
.
nr_inodes
++
;
d
->
fs_usage
.
nr_inodes
++
;
...
@@ -1578,9 +1577,7 @@ int bch2_trans_mark_key(struct btree_trans *trans,
...
@@ -1578,9 +1577,7 @@ int bch2_trans_mark_key(struct btree_trans *trans,
case
KEY_TYPE_reservation
:
{
case
KEY_TYPE_reservation
:
{
unsigned
replicas
=
bkey_s_c_to_reservation
(
k
).
v
->
nr_replicas
;
unsigned
replicas
=
bkey_s_c_to_reservation
(
k
).
v
->
nr_replicas
;
if
(
!
trans
->
fs_usage_deltas
)
d
=
replicas_deltas_realloc
(
trans
,
0
);
replicas_deltas_realloc
(
trans
);
d
=
trans
->
fs_usage_deltas
;
sectors
*=
replicas
;
sectors
*=
replicas
;
replicas
=
clamp_t
(
unsigned
,
replicas
,
1
,
replicas
=
clamp_t
(
unsigned
,
replicas
,
1
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment