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
a9422fd4
Commit
a9422fd4
authored
Apr 30, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: kill bch2_dev_bkey_exists() in bkey_pick_read_device()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
db39a35d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
fs/bcachefs/extents.c
fs/bcachefs/extents.c
+22
-15
No files found.
fs/bcachefs/extents.c
View file @
a9422fd4
...
...
@@ -71,6 +71,12 @@ void bch2_mark_io_failure(struct bch_io_failures *failed,
}
}
static
inline
u64
dev_latency
(
struct
bch_fs
*
c
,
unsigned
dev
)
{
struct
bch_dev
*
ca
=
bch2_dev_rcu
(
c
,
dev
);
return
ca
?
atomic64_read
(
&
ca
->
cur_latency
[
READ
])
:
S64_MAX
;
}
/*
* returns true if p1 is better than p2:
*/
...
...
@@ -79,11 +85,8 @@ static inline bool ptr_better(struct bch_fs *c,
const
struct
extent_ptr_decoded
p2
)
{
if
(
likely
(
!
p1
.
idx
&&
!
p2
.
idx
))
{
struct
bch_dev
*
dev1
=
bch2_dev_bkey_exists
(
c
,
p1
.
ptr
.
dev
);
struct
bch_dev
*
dev2
=
bch2_dev_bkey_exists
(
c
,
p2
.
ptr
.
dev
);
u64
l1
=
atomic64_read
(
&
dev1
->
cur_latency
[
READ
]);
u64
l2
=
atomic64_read
(
&
dev2
->
cur_latency
[
READ
]);
u64
l1
=
dev_latency
(
c
,
p1
.
ptr
.
dev
);
u64
l2
=
dev_latency
(
c
,
p2
.
ptr
.
dev
);
/* Pick at random, biased in favor of the faster device: */
...
...
@@ -109,21 +112,21 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
const
union
bch_extent_entry
*
entry
;
struct
extent_ptr_decoded
p
;
struct
bch_dev_io_failures
*
f
;
struct
bch_dev
*
ca
;
int
ret
=
0
;
if
(
k
.
k
->
type
==
KEY_TYPE_error
)
return
-
EIO
;
rcu_read_lock
();
bkey_for_each_ptr_decode
(
k
.
k
,
ptrs
,
p
,
entry
)
{
/*
* Unwritten extent: no need to actually read, treat it as a
* hole and return 0s:
*/
if
(
p
.
ptr
.
unwritten
)
ret
urn
0
;
ca
=
bch2_dev_bkey_exists
(
c
,
p
.
ptr
.
dev
);
if
(
p
.
ptr
.
unwritten
)
{
ret
=
0
;
break
;
}
/*
* If there are any dirty pointers it's an error if we can't
...
...
@@ -132,7 +135,9 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
if
(
!
ret
&&
!
p
.
ptr
.
cached
)
ret
=
-
EIO
;
if
(
p
.
ptr
.
cached
&&
dev_ptr_stale
(
ca
,
&
p
.
ptr
))
struct
bch_dev
*
ca
=
bch2_dev_rcu
(
c
,
p
.
ptr
.
dev
);
if
(
p
.
ptr
.
cached
&&
(
!
ca
||
dev_ptr_stale
(
ca
,
&
p
.
ptr
)))
continue
;
f
=
failed
?
dev_io_failures
(
failed
,
p
.
ptr
.
dev
)
:
NULL
;
...
...
@@ -141,12 +146,13 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
?
f
->
idx
:
f
->
idx
+
1
;
if
(
!
p
.
idx
&&
!
bch2_dev_is_readable
(
ca
))
if
(
!
p
.
idx
&&
!
ca
)
p
.
idx
++
;
if
(
bch2_force_reconstruct_read
&&
!
p
.
idx
&&
p
.
has_ec
)
if
(
!
p
.
idx
&&
p
.
has_ec
&&
bch2_force_reconstruct_read
)
p
.
idx
++
;
if
(
!
p
.
idx
&&
!
bch2_dev_is_readable
(
ca
))
p
.
idx
++
;
if
(
p
.
idx
>=
(
unsigned
)
p
.
has_ec
+
1
)
...
...
@@ -158,6 +164,7 @@ int bch2_bkey_pick_read_device(struct bch_fs *c, struct bkey_s_c k,
*
pick
=
p
;
ret
=
1
;
}
rcu_read_unlock
();
return
ret
;
}
...
...
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