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
302c980a
Commit
302c980a
authored
Apr 30, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: extent_ptr_durability() -> bch2_dev_rcu()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
3793b3f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
5 deletions
+21
-5
fs/bcachefs/data_update.c
fs/bcachefs/data_update.c
+5
-0
fs/bcachefs/extents.c
fs/bcachefs/extents.c
+8
-4
fs/bcachefs/io_write.c
fs/bcachefs/io_write.c
+6
-1
fs/bcachefs/move.c
fs/bcachefs/move.c
+2
-0
No files found.
fs/bcachefs/data_update.c
View file @
302c980a
...
...
@@ -203,6 +203,8 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
/* Now, drop excess replicas: */
restart_drop_extra_replicas:
rcu_read_lock
();
bkey_for_each_ptr_decode
(
old
.
k
,
bch2_bkey_ptrs
(
bkey_i_to_s
(
insert
)),
p
,
entry
)
{
unsigned
ptr_durability
=
bch2_extent_ptr_durability
(
c
,
&
p
);
...
...
@@ -214,6 +216,7 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
goto
restart_drop_extra_replicas
;
}
}
rcu_read_unlock
();
/* Finally, add the pointers we just wrote: */
extent_for_each_ptr_decode
(
extent_i_to_s
(
new
),
p
,
entry
)
...
...
@@ -552,6 +555,7 @@ int bch2_data_update_init(struct btree_trans *trans,
struct
bpos
bucket
=
PTR_BUCKET_POS
(
ca
,
&
p
.
ptr
);
bool
locked
;
rcu_read_lock
();
if
(((
1U
<<
i
)
&
m
->
data_opts
.
rewrite_ptrs
))
{
BUG_ON
(
p
.
ptr
.
cached
);
...
...
@@ -565,6 +569,7 @@ int bch2_data_update_init(struct btree_trans *trans,
bch2_dev_list_add_dev
(
&
m
->
op
.
devs_have
,
p
.
ptr
.
dev
);
durability_have
+=
bch2_extent_ptr_durability
(
c
,
&
p
);
}
rcu_read_unlock
();
/*
* op->csum_type is normally initialized from the fs/file's
...
...
fs/bcachefs/extents.c
View file @
302c980a
...
...
@@ -675,16 +675,16 @@ static inline unsigned __extent_ptr_durability(struct bch_dev *ca, struct extent
unsigned
bch2_extent_ptr_desired_durability
(
struct
bch_fs
*
c
,
struct
extent_ptr_decoded
*
p
)
{
struct
bch_dev
*
ca
=
bch2_dev_
bkey_exists
(
c
,
p
->
ptr
.
dev
);
struct
bch_dev
*
ca
=
bch2_dev_
rcu
(
c
,
p
->
ptr
.
dev
);
return
__extent_ptr_durability
(
ca
,
p
)
;
return
ca
?
__extent_ptr_durability
(
ca
,
p
)
:
0
;
}
unsigned
bch2_extent_ptr_durability
(
struct
bch_fs
*
c
,
struct
extent_ptr_decoded
*
p
)
{
struct
bch_dev
*
ca
=
bch2_dev_
bkey_exists
(
c
,
p
->
ptr
.
dev
);
struct
bch_dev
*
ca
=
bch2_dev_
rcu
(
c
,
p
->
ptr
.
dev
);
if
(
ca
->
mi
.
state
==
BCH_MEMBER_STATE_failed
)
if
(
!
ca
||
ca
->
mi
.
state
==
BCH_MEMBER_STATE_failed
)
return
0
;
return
__extent_ptr_durability
(
ca
,
p
);
...
...
@@ -697,8 +697,10 @@ unsigned bch2_bkey_durability(struct bch_fs *c, struct bkey_s_c k)
struct
extent_ptr_decoded
p
;
unsigned
durability
=
0
;
rcu_read_lock
();
bkey_for_each_ptr_decode
(
k
.
k
,
ptrs
,
p
,
entry
)
durability
+=
bch2_extent_ptr_durability
(
c
,
&
p
);
rcu_read_unlock
();
return
durability
;
}
...
...
@@ -710,9 +712,11 @@ static unsigned bch2_bkey_durability_safe(struct bch_fs *c, struct bkey_s_c k)
struct
extent_ptr_decoded
p
;
unsigned
durability
=
0
;
rcu_read_lock
();
bkey_for_each_ptr_decode
(
k
.
k
,
ptrs
,
p
,
entry
)
if
(
p
.
ptr
.
dev
<
c
->
sb
.
nr_devices
&&
c
->
devs
[
p
.
ptr
.
dev
])
durability
+=
bch2_extent_ptr_durability
(
c
,
&
p
);
rcu_read_unlock
();
return
durability
;
}
...
...
fs/bcachefs/io_write.c
View file @
302c980a
...
...
@@ -1099,12 +1099,17 @@ static bool bch2_extent_is_writeable(struct bch_write_op *op,
return
false
;
e
=
bkey_s_c_to_extent
(
k
);
rcu_read_lock
();
extent_for_each_ptr_decode
(
e
,
p
,
entry
)
{
if
(
crc_is_encoded
(
p
.
crc
)
||
p
.
has_ec
)
if
(
crc_is_encoded
(
p
.
crc
)
||
p
.
has_ec
)
{
rcu_read_unlock
();
return
false
;
}
replicas
+=
bch2_extent_ptr_durability
(
c
,
&
p
);
}
rcu_read_unlock
();
return
replicas
>=
op
->
opts
.
data_replicas
;
}
...
...
fs/bcachefs/move.c
View file @
302c980a
...
...
@@ -1033,6 +1033,7 @@ static bool drop_extra_replicas_pred(struct bch_fs *c, void *arg,
struct
extent_ptr_decoded
p
;
unsigned
i
=
0
;
rcu_read_lock
();
bkey_for_each_ptr_decode
(
k
.
k
,
bch2_bkey_ptrs_c
(
k
),
p
,
entry
)
{
unsigned
d
=
bch2_extent_ptr_durability
(
c
,
&
p
);
...
...
@@ -1043,6 +1044,7 @@ static bool drop_extra_replicas_pred(struct bch_fs *c, void *arg,
i
++
;
}
rcu_read_unlock
();
return
data_opts
->
kill_ptrs
!=
0
;
}
...
...
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