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
9b02d1c4
Commit
9b02d1c4
authored
Sep 08, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Optimize calls to bch2_btree_iter_traverse()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
5a8a52d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
17 deletions
+22
-17
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.c
+12
-16
fs/bcachefs/btree_iter.h
fs/bcachefs/btree_iter.h
+10
-1
No files found.
fs/bcachefs/btree_iter.c
View file @
9b02d1c4
...
@@ -955,10 +955,10 @@ static void btree_iter_up(struct btree_iter *iter)
...
@@ -955,10 +955,10 @@ static void btree_iter_up(struct btree_iter *iter)
btree_node_unlock
(
iter
,
iter
->
level
++
);
btree_node_unlock
(
iter
,
iter
->
level
++
);
}
}
int
__must_check
__bch2_btree_iter_travers
e
(
struct
btree_iter
*
);
static
int
btree_iter_traverse_on
e
(
struct
btree_iter
*
);
static
int
__btree_iter_traverse_all
(
struct
btree_trans
*
trans
,
static
int
__btree_iter_traverse_all
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
orig_iter
,
int
ret
)
struct
btree_iter
*
orig_iter
,
int
ret
)
{
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
bch_fs
*
c
=
trans
->
c
;
struct
btree_iter
*
iter
;
struct
btree_iter
*
iter
;
...
@@ -1002,7 +1002,7 @@ static int __btree_iter_traverse_all(struct btree_trans *trans,
...
@@ -1002,7 +1002,7 @@ static int __btree_iter_traverse_all(struct btree_trans *trans,
iter
=
&
trans
->
iters
[
sorted
[
i
]];
iter
=
&
trans
->
iters
[
sorted
[
i
]];
do
{
do
{
ret
=
__bch2_btree_iter_travers
e
(
iter
);
ret
=
btree_iter_traverse_on
e
(
iter
);
}
while
(
ret
==
-
EINTR
);
}
while
(
ret
==
-
EINTR
);
if
(
ret
)
if
(
ret
)
...
@@ -1047,7 +1047,7 @@ static unsigned btree_iter_up_until_locked(struct btree_iter *iter,
...
@@ -1047,7 +1047,7 @@ static unsigned btree_iter_up_until_locked(struct btree_iter *iter,
* On error, caller (peek_node()/peek_key()) must return NULL; the error is
* On error, caller (peek_node()/peek_key()) must return NULL; the error is
* stashed in the iterator and returned from bch2_trans_exit().
* stashed in the iterator and returned from bch2_trans_exit().
*/
*/
int
__must_check
__bch2_btree_iter_travers
e
(
struct
btree_iter
*
iter
)
static
int
btree_iter_traverse_on
e
(
struct
btree_iter
*
iter
)
{
{
unsigned
depth_want
=
iter
->
level
;
unsigned
depth_want
=
iter
->
level
;
...
@@ -1099,12 +1099,12 @@ int __must_check __bch2_btree_iter_traverse(struct btree_iter *iter)
...
@@ -1099,12 +1099,12 @@ int __must_check __bch2_btree_iter_traverse(struct btree_iter *iter)
return
0
;
return
0
;
}
}
int
__must_check
bch2_btree_iter_traverse
(
struct
btree_iter
*
iter
)
int
__must_check
__
bch2_btree_iter_traverse
(
struct
btree_iter
*
iter
)
{
{
int
ret
;
int
ret
;
ret
=
bch2_trans_cond_resched
(
iter
->
trans
)
?:
ret
=
bch2_trans_cond_resched
(
iter
->
trans
)
?:
__bch2_btree_iter_travers
e
(
iter
);
btree_iter_traverse_on
e
(
iter
);
if
(
unlikely
(
ret
))
if
(
unlikely
(
ret
))
ret
=
__btree_iter_traverse_all
(
iter
->
trans
,
iter
,
ret
);
ret
=
__btree_iter_traverse_all
(
iter
->
trans
,
iter
,
ret
);
...
@@ -1296,11 +1296,9 @@ struct bkey_s_c bch2_btree_iter_peek(struct btree_iter *iter)
...
@@ -1296,11 +1296,9 @@ struct bkey_s_c bch2_btree_iter_peek(struct btree_iter *iter)
return
btree_iter_peek_uptodate
(
iter
);
return
btree_iter_peek_uptodate
(
iter
);
while
(
1
)
{
while
(
1
)
{
if
(
iter
->
uptodate
>=
BTREE_ITER_NEED_RELOCK
)
{
ret
=
bch2_btree_iter_traverse
(
iter
);
ret
=
bch2_btree_iter_traverse
(
iter
);
if
(
unlikely
(
ret
))
if
(
unlikely
(
ret
))
return
bkey_s_c_err
(
ret
);
return
bkey_s_c_err
(
ret
);
}
k
=
__btree_iter_peek
(
iter
,
l
);
k
=
__btree_iter_peek
(
iter
,
l
);
if
(
likely
(
k
.
k
))
if
(
likely
(
k
.
k
))
...
@@ -1564,11 +1562,9 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter)
...
@@ -1564,11 +1562,9 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter)
if
(
iter
->
uptodate
==
BTREE_ITER_UPTODATE
)
if
(
iter
->
uptodate
==
BTREE_ITER_UPTODATE
)
return
btree_iter_peek_uptodate
(
iter
);
return
btree_iter_peek_uptodate
(
iter
);
if
(
iter
->
uptodate
>=
BTREE_ITER_NEED_RELOCK
)
{
ret
=
bch2_btree_iter_traverse
(
iter
);
ret
=
bch2_btree_iter_traverse
(
iter
);
if
(
unlikely
(
ret
))
if
(
unlikely
(
ret
))
return
bkey_s_c_err
(
ret
);
return
bkey_s_c_err
(
ret
);
}
return
__bch2_btree_iter_peek_slot
(
iter
);
return
__bch2_btree_iter_peek_slot
(
iter
);
}
}
...
...
fs/bcachefs/btree_iter.h
View file @
9b02d1c4
...
@@ -134,7 +134,16 @@ void bch2_btree_iter_node_drop(struct btree_iter *, struct btree *);
...
@@ -134,7 +134,16 @@ void bch2_btree_iter_node_drop(struct btree_iter *, struct btree *);
void
bch2_btree_iter_reinit_node
(
struct
btree_iter
*
,
struct
btree
*
);
void
bch2_btree_iter_reinit_node
(
struct
btree_iter
*
,
struct
btree
*
);
int
__must_check
bch2_btree_iter_traverse
(
struct
btree_iter
*
);
int
__must_check
__bch2_btree_iter_traverse
(
struct
btree_iter
*
);
static
inline
int
__must_check
bch2_btree_iter_traverse
(
struct
btree_iter
*
iter
)
{
return
iter
->
uptodate
>=
BTREE_ITER_NEED_RELOCK
?
__bch2_btree_iter_traverse
(
iter
)
:
0
;
}
int
bch2_btree_iter_traverse_all
(
struct
btree_trans
*
);
int
bch2_btree_iter_traverse_all
(
struct
btree_trans
*
);
struct
btree
*
bch2_btree_iter_peek_node
(
struct
btree_iter
*
);
struct
btree
*
bch2_btree_iter_peek_node
(
struct
btree_iter
*
);
...
...
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