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
8f196539
Commit
8f196539
authored
Oct 20, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Make btree_node_type_needs_gc() cheaper
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
77d63522
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
29 deletions
+24
-29
fs/bcachefs/btree_types.h
fs/bcachefs/btree_types.h
+14
-11
fs/bcachefs/btree_update.h
fs/bcachefs/btree_update.h
+0
-4
fs/bcachefs/btree_update_leaf.c
fs/bcachefs/btree_update_leaf.c
+10
-14
No files found.
fs/bcachefs/btree_types.h
View file @
8f196539
...
...
@@ -460,19 +460,22 @@ static inline bool btree_node_is_extents(struct btree *b)
return
btree_node_type_is_extents
(
btree_node_type
(
b
));
}
#define BTREE_NODE_TYPE_HAS_TRIGGERS \
((1U << BKEY_TYPE_EXTENTS)| \
(1U << BKEY_TYPE_ALLOC)| \
(1U << BKEY_TYPE_INODES)| \
(1U << BKEY_TYPE_REFLINK)| \
(1U << BKEY_TYPE_EC)| \
(1U << BKEY_TYPE_BTREE))
#define BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS \
((1U << BKEY_TYPE_EXTENTS)| \
(1U << BKEY_TYPE_INODES)| \
(1U << BKEY_TYPE_REFLINK))
static
inline
bool
btree_node_type_needs_gc
(
enum
btree_node_type
type
)
{
switch
(
type
)
{
case
BKEY_TYPE_ALLOC
:
case
BKEY_TYPE_BTREE
:
case
BKEY_TYPE_EXTENTS
:
case
BKEY_TYPE_INODES
:
case
BKEY_TYPE_EC
:
case
BKEY_TYPE_REFLINK
:
return
true
;
default:
return
false
;
}
return
BTREE_NODE_TYPE_HAS_TRIGGERS
&
(
1U
<<
type
);
}
struct
btree_root
{
...
...
fs/bcachefs/btree_update.h
View file @
8f196539
...
...
@@ -27,7 +27,6 @@ enum {
__BTREE_INSERT_JOURNAL_RESERVED
,
__BTREE_INSERT_NOMARK_OVERWRITES
,
__BTREE_INSERT_NOMARK
,
__BTREE_INSERT_MARK_INMEM
,
__BTREE_INSERT_NO_CLEAR_REPLICAS
,
__BTREE_INSERT_BUCKET_INVALIDATE
,
__BTREE_INSERT_NOWAIT
,
...
...
@@ -68,9 +67,6 @@ enum {
/* Don't call mark new key at all: */
#define BTREE_INSERT_NOMARK (1 << __BTREE_INSERT_NOMARK)
/* Don't mark transactionally: */
#define BTREE_INSERT_MARK_INMEM (1 << __BTREE_INSERT_MARK_INMEM)
#define BTREE_INSERT_NO_CLEAR_REPLICAS (1 << __BTREE_INSERT_NO_CLEAR_REPLICAS)
#define BTREE_INSERT_BUCKET_INVALIDATE (1 << __BTREE_INSERT_BUCKET_INVALIDATE)
...
...
fs/bcachefs/btree_update_leaf.c
View file @
8f196539
...
...
@@ -426,20 +426,16 @@ static inline void do_btree_insert_one(struct btree_trans *trans,
btree_insert_key_leaf
(
trans
,
insert
);
}
static
inline
bool
update_triggers_transactional
(
struct
btree_trans
*
trans
,
struct
btree_insert_entry
*
i
)
static
inline
bool
update_has_trans_triggers
(
struct
btree_insert_entry
*
i
)
{
return
likely
(
!
(
trans
->
flags
&
BTREE_INSERT_MARK_INMEM
))
&&
(
i
->
iter
->
btree_id
==
BTREE_ID_EXTENTS
||
i
->
iter
->
btree_id
==
BTREE_ID_INODES
||
i
->
iter
->
btree_id
==
BTREE_ID_REFLINK
);
return
BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS
&
(
1U
<<
i
->
iter
->
btree_id
);
}
static
inline
bool
update_has_triggers
(
struct
btree_trans
*
trans
,
struct
btree_insert_entry
*
i
)
static
inline
bool
update_has_nontrans_triggers
(
struct
btree_insert_entry
*
i
)
{
return
likely
(
!
(
trans
->
flags
&
BTREE_INSERT_NOMARK
))
&&
btree_node_type_needs_gc
(
i
->
iter
->
btree_id
);
return
(
BTREE_NODE_TYPE_HAS_TRIGGERS
&
~
BTREE_NODE_TYPE_HAS_TRANS_TRIGGERS
)
&
(
1U
<<
i
->
iter
->
btree_id
);
}
/*
...
...
@@ -465,8 +461,8 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
* updates as we're walking it:
*/
trans_for_each_update
(
trans
,
i
)
if
(
update_has_triggers
(
trans
,
i
)
&&
update_
triggers_transactional
(
trans
,
i
))
{
if
(
likely
(
!
(
trans
->
flags
&
BTREE_INSERT_NOMARK
)
)
&&
update_
has_trans_triggers
(
i
))
{
ret
=
bch2_trans_mark_update
(
trans
,
i
->
iter
,
i
->
k
);
if
(
ret
==
-
EINTR
)
trace_trans_restart_mark
(
trans
->
ip
);
...
...
@@ -551,8 +547,8 @@ static inline int do_btree_insert_at(struct btree_trans *trans,
}
trans_for_each_update
(
trans
,
i
)
if
(
update_has_triggers
(
trans
,
i
)
&&
!
update_triggers_transactional
(
trans
,
i
))
if
(
likely
(
!
(
trans
->
flags
&
BTREE_INSERT_NOMARK
)
)
&&
update_has_nontrans_triggers
(
i
))
bch2_mark_update
(
trans
,
i
,
&
fs_usage
->
u
,
mark_flags
);
if
(
fs_usage
&&
trans
->
fs_usage_deltas
)
...
...
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