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
ad897d24
Commit
ad897d24
authored
Apr 30, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: kill bch2_dev_bkey_exists() in btree_gc.c
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
9cadb4ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
10 deletions
+31
-10
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_gc.c
+31
-10
No files found.
fs/bcachefs/btree_gc.c
View file @
ad897d24
...
...
@@ -993,19 +993,25 @@ static int bch2_gc_alloc_start(struct bch_fs *c)
rcu_assign_pointer
(
ca
->
buckets_gc
,
buckets
);
}
struct
bch_dev
*
ca
=
NULL
;
int
ret
=
bch2_trans_run
(
c
,
for_each_btree_key
(
trans
,
iter
,
BTREE_ID_alloc
,
POS_MIN
,
BTREE_ITER_prefetch
,
k
,
({
struct
bch_dev
*
ca
=
bch2_dev_bkey_exists
(
c
,
k
.
k
->
p
.
inode
);
struct
bucket
*
g
=
gc_bucket
(
ca
,
k
.
k
->
p
.
offset
);
ca
=
bch2_dev_iterate
(
c
,
ca
,
k
.
k
->
p
.
inode
);
if
(
!
ca
)
{
bch2_btree_iter_set_pos
(
&
iter
,
POS
(
k
.
k
->
p
.
inode
+
1
,
0
));
continue
;
}
struct
bch_alloc_v4
a_convert
;
const
struct
bch_alloc_v4
*
a
=
bch2_alloc_to_v4
(
k
,
&
a_convert
);
struct
bucket
*
g
=
gc_bucket
(
ca
,
k
.
k
->
p
.
offset
);
g
->
gen_valid
=
1
;
g
->
gen
=
a
->
gen
;
0
;
})));
bch2_dev_put
(
ca
);
bch_err_fn
(
c
,
ret
);
return
ret
;
}
...
...
@@ -1254,22 +1260,29 @@ static int gc_btree_gens_key(struct btree_trans *trans,
return
-
EROFS
;
percpu_down_read
(
&
c
->
mark_lock
);
rcu_read_lock
();
bkey_for_each_ptr
(
ptrs
,
ptr
)
{
struct
bch_dev
*
ca
=
bch2_dev_bkey_exists
(
c
,
ptr
->
dev
);
struct
bch_dev
*
ca
=
bch2_dev_rcu
(
c
,
ptr
->
dev
);
if
(
!
ca
)
continue
;
if
(
dev_ptr_stale
(
ca
,
ptr
)
>
16
)
{
rcu_read_unlock
();
percpu_up_read
(
&
c
->
mark_lock
);
goto
update
;
}
}
bkey_for_each_ptr
(
ptrs
,
ptr
)
{
struct
bch_dev
*
ca
=
bch2_dev_bkey_exists
(
c
,
ptr
->
dev
);
u8
*
gen
=
&
ca
->
oldest_gen
[
PTR_BUCKET_NR
(
ca
,
ptr
)];
struct
bch_dev
*
ca
=
bch2_dev_rcu
(
c
,
ptr
->
dev
);
if
(
!
ca
)
continue
;
u8
*
gen
=
&
ca
->
oldest_gen
[
PTR_BUCKET_NR
(
ca
,
ptr
)];
if
(
gen_after
(
*
gen
,
ptr
->
gen
))
*
gen
=
ptr
->
gen
;
}
rcu_read_unlock
();
percpu_up_read
(
&
c
->
mark_lock
);
return
0
;
update:
...
...
@@ -1282,10 +1295,9 @@ static int gc_btree_gens_key(struct btree_trans *trans,
return
0
;
}
static
int
bch2_alloc_write_oldest_gen
(
struct
btree_trans
*
trans
,
struct
b
tree_iter
*
iter
,
struct
bkey_s_c
k
)
static
int
bch2_alloc_write_oldest_gen
(
struct
btree_trans
*
trans
,
struct
b
ch_dev
*
ca
,
struct
b
tree_iter
*
iter
,
struct
b
key_s_c
k
)
{
struct
bch_dev
*
ca
=
bch2_dev_bkey_exists
(
trans
->
c
,
iter
->
pos
.
inode
);
struct
bch_alloc_v4
a_convert
;
const
struct
bch_alloc_v4
*
a
=
bch2_alloc_to_v4
(
k
,
&
a_convert
);
struct
bkey_i_alloc_v4
*
a_mut
;
...
...
@@ -1355,14 +1367,23 @@ int bch2_gc_gens(struct bch_fs *c)
goto
err
;
}
struct
bch_dev
*
ca
=
NULL
;
ret
=
bch2_trans_run
(
c
,
for_each_btree_key_commit
(
trans
,
iter
,
BTREE_ID_alloc
,
POS_MIN
,
BTREE_ITER_prefetch
,
k
,
NULL
,
NULL
,
BCH_TRANS_COMMIT_no_enospc
,
bch2_alloc_write_oldest_gen
(
trans
,
&
iter
,
k
)));
BCH_TRANS_COMMIT_no_enospc
,
({
ca
=
bch2_dev_iterate
(
c
,
ca
,
k
.
k
->
p
.
inode
);
if
(
!
ca
)
{
bch2_btree_iter_set_pos
(
&
iter
,
POS
(
k
.
k
->
p
.
inode
+
1
,
0
));
continue
;
}
bch2_alloc_write_oldest_gen
(
trans
,
ca
,
&
iter
,
k
);
})));
bch2_dev_put
(
ca
);
if
(
ret
)
goto
err
;
...
...
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