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
f0431c5f
Commit
f0431c5f
authored
Dec 31, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Combine .trans_trigger, .atomic_trigger
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
4f9ec59f
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
61 additions
and
91 deletions
+61
-91
fs/bcachefs/alloc_background.h
fs/bcachefs/alloc_background.h
+4
-8
fs/bcachefs/bkey_methods.h
fs/bcachefs/bkey_methods.h
+18
-32
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_gc.c
+1
-1
fs/bcachefs/btree_trans_commit.c
fs/bcachefs/btree_trans_commit.c
+13
-18
fs/bcachefs/btree_update_interior.c
fs/bcachefs/btree_update_interior.c
+10
-9
fs/bcachefs/ec.h
fs/bcachefs/ec.h
+1
-2
fs/bcachefs/extents.h
fs/bcachefs/extents.h
+4
-8
fs/bcachefs/inode.h
fs/bcachefs/inode.h
+3
-6
fs/bcachefs/reflink.c
fs/bcachefs/reflink.c
+3
-1
fs/bcachefs/reflink.h
fs/bcachefs/reflink.h
+3
-5
fs/bcachefs/snapshot.h
fs/bcachefs/snapshot.h
+1
-1
No files found.
fs/bcachefs/alloc_background.h
View file @
f0431c5f
...
...
@@ -182,24 +182,21 @@ void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
#define bch2_bkey_ops_alloc ((struct bkey_ops) { \
.key_invalid = bch2_alloc_v1_invalid, \
.val_to_text = bch2_alloc_to_text, \
.trans_trigger = bch2_trigger_alloc, \
.atomic_trigger = bch2_trigger_alloc, \
.trigger = bch2_trigger_alloc, \
.min_val_size = 8, \
})
#define bch2_bkey_ops_alloc_v2 ((struct bkey_ops) { \
.key_invalid = bch2_alloc_v2_invalid, \
.val_to_text = bch2_alloc_to_text, \
.trans_trigger = bch2_trigger_alloc, \
.atomic_trigger = bch2_trigger_alloc, \
.trigger = bch2_trigger_alloc, \
.min_val_size = 8, \
})
#define bch2_bkey_ops_alloc_v3 ((struct bkey_ops) { \
.key_invalid = bch2_alloc_v3_invalid, \
.val_to_text = bch2_alloc_to_text, \
.trans_trigger = bch2_trigger_alloc, \
.atomic_trigger = bch2_trigger_alloc, \
.trigger = bch2_trigger_alloc, \
.min_val_size = 16, \
})
...
...
@@ -207,8 +204,7 @@ void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
.key_invalid = bch2_alloc_v4_invalid, \
.val_to_text = bch2_alloc_to_text, \
.swab = bch2_alloc_v4_swab, \
.trans_trigger = bch2_trigger_alloc, \
.atomic_trigger = bch2_trigger_alloc, \
.trigger = bch2_trigger_alloc, \
.min_val_size = 48, \
})
...
...
fs/bcachefs/bkey_methods.h
View file @
f0431c5f
...
...
@@ -28,10 +28,8 @@ struct bkey_ops {
void
(
*
swab
)(
struct
bkey_s
);
bool
(
*
key_normalize
)(
struct
bch_fs
*
,
struct
bkey_s
);
bool
(
*
key_merge
)(
struct
bch_fs
*
,
struct
bkey_s
,
struct
bkey_s_c
);
int
(
*
trans_trigger
)(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
int
(
*
atomic_trigger
)(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
int
(
*
trigger
)(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
void
(
*
compat
)(
enum
btree_id
id
,
unsigned
version
,
unsigned
big_endian
,
int
write
,
struct
bkey_s
);
...
...
@@ -78,18 +76,6 @@ static inline bool bch2_bkey_maybe_mergable(const struct bkey *l, const struct b
bool
bch2_bkey_merge
(
struct
bch_fs
*
,
struct
bkey_s
,
struct
bkey_s_c
);
static
inline
int
bch2_mark_key
(
struct
btree_trans
*
trans
,
enum
btree_id
btree
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
{
const
struct
bkey_ops
*
ops
=
bch2_bkey_type_ops
(
old
.
k
->
type
?:
new
.
k
->
type
);
return
ops
->
atomic_trigger
?
ops
->
atomic_trigger
(
trans
,
btree
,
level
,
old
,
new
,
flags
)
:
0
;
}
enum
btree_update_flags
{
__BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE
=
__BTREE_ITER_FLAGS_END
,
__BTREE_UPDATE_NOJOURNAL
,
...
...
@@ -134,42 +120,42 @@ enum btree_update_flags {
/* signal from bucket invalidate path to alloc trigger */
#define BTREE_TRIGGER_BUCKET_INVALIDATE (1U << __BTREE_TRIGGER_BUCKET_INVALIDATE)
static
inline
int
bch2_
trans_mark_key
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
static
inline
int
bch2_
key_trigger
(
struct
btree_trans
*
trans
,
enum
btree_id
btree
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
{
const
struct
bkey_ops
*
ops
=
bch2_bkey_type_ops
(
old
.
k
->
type
?:
new
.
k
->
type
);
return
ops
->
tr
ans_tr
igger
?
ops
->
tr
ans_trigger
(
trans
,
btree_id
,
level
,
old
,
new
,
flags
|
BTREE_TRIGGER_TRANSACTIONAL
)
return
ops
->
trigger
?
ops
->
tr
igger
(
trans
,
btree
,
level
,
old
,
new
,
flags
)
:
0
;
}
static
inline
int
bch2_
trans_mark
_old
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
unsigned
flags
)
static
inline
int
bch2_
key_trigger
_old
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
unsigned
flags
)
{
struct
bkey_i
deleted
;
bkey_init
(
&
deleted
.
k
);
deleted
.
k
.
p
=
old
.
k
->
p
;
return
bch2_
trans_mark_key
(
trans
,
btree_id
,
level
,
old
,
bkey_i_to_s
(
&
deleted
),
BTREE_TRIGGER_OVERWRITE
|
flags
);
return
bch2_
key_trigger
(
trans
,
btree_id
,
level
,
old
,
bkey_i_to_s
(
&
deleted
),
BTREE_TRIGGER_OVERWRITE
|
flags
);
}
static
inline
int
bch2_
trans_mark
_new
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s
new
,
unsigned
flags
)
static
inline
int
bch2_
key_trigger
_new
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s
new
,
unsigned
flags
)
{
struct
bkey_i
deleted
;
bkey_init
(
&
deleted
.
k
);
deleted
.
k
.
p
=
new
.
k
->
p
;
return
bch2_
trans_mark_key
(
trans
,
btree_id
,
level
,
bkey_i_to_s_c
(
&
deleted
),
new
,
BTREE_TRIGGER_INSERT
|
flags
);
return
bch2_
key_trigger
(
trans
,
btree_id
,
level
,
bkey_i_to_s_c
(
&
deleted
),
new
,
BTREE_TRIGGER_INSERT
|
flags
);
}
void
bch2_bkey_renumber
(
enum
btree_node_type
,
struct
bkey_packed
*
,
int
);
...
...
fs/bcachefs/btree_gc.c
View file @
f0431c5f
...
...
@@ -834,7 +834,7 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id,
}
ret
=
commit_do
(
trans
,
NULL
,
NULL
,
0
,
bch2_
mark_key
(
trans
,
btree_id
,
level
,
old
,
unsafe_bkey_s_c_to_s
(
*
k
),
BTREE_TRIGGER_GC
));
bch2_
key_trigger
(
trans
,
btree_id
,
level
,
old
,
unsafe_bkey_s_c_to_s
(
*
k
),
BTREE_TRIGGER_GC
));
fsck_err:
err:
bch_err_fn
(
c
,
ret
);
...
...
fs/bcachefs/btree_trans_commit.c
View file @
f0431c5f
...
...
@@ -451,20 +451,15 @@ static int run_one_mem_trigger(struct btree_trans *trans,
if
(
!
btree_node_type_needs_gc
(
__btree_node_type
(
i
->
level
,
i
->
btree_id
)))
return
0
;
if
(
old_ops
->
atomic_trigger
==
new_ops
->
atomic_
trigger
)
{
ret
=
bch2_
mark_key
(
trans
,
i
->
btree_id
,
i
->
level
,
if
(
old_ops
->
trigger
==
new_ops
->
trigger
)
{
ret
=
bch2_
key_trigger
(
trans
,
i
->
btree_id
,
i
->
level
,
old
,
bkey_i_to_s
(
new
),
BTREE_TRIGGER_INSERT
|
BTREE_TRIGGER_OVERWRITE
|
flags
);
}
else
{
struct
bkey
_deleted
=
POS_KEY
((
trans
->
paths
+
i
->
path
)
->
pos
);
struct
bkey_s
deleted
=
(
struct
bkey_s
)
{
{
{
&
_deleted
,
NULL
}
}
};
ret
=
bch2_mark_key
(
trans
,
i
->
btree_id
,
i
->
level
,
deleted
.
s_c
,
bkey_i_to_s
(
new
),
BTREE_TRIGGER_INSERT
|
flags
)
?:
bch2_mark_key
(
trans
,
i
->
btree_id
,
i
->
level
,
old
,
deleted
,
BTREE_TRIGGER_OVERWRITE
|
flags
);
ret
=
bch2_key_trigger_new
(
trans
,
i
->
btree_id
,
i
->
level
,
bkey_i_to_s
(
new
),
flags
)
?:
bch2_key_trigger_old
(
trans
,
i
->
btree_id
,
i
->
level
,
old
,
flags
);
}
return
ret
;
...
...
@@ -482,6 +477,7 @@ static int run_one_trans_trigger(struct btree_trans *trans, struct btree_insert_
struct
bkey_s_c
old
=
{
&
old_k
,
i
->
old_v
};
const
struct
bkey_ops
*
old_ops
=
bch2_bkey_type_ops
(
old
.
k
->
type
);
const
struct
bkey_ops
*
new_ops
=
bch2_bkey_type_ops
(
i
->
k
->
k
.
type
);
unsigned
flags
=
i
->
flags
|
BTREE_TRIGGER_TRANSACTIONAL
;
verify_update_old_key
(
trans
,
i
);
...
...
@@ -491,19 +487,18 @@ static int run_one_trans_trigger(struct btree_trans *trans, struct btree_insert_
if
(
!
i
->
insert_trigger_run
&&
!
i
->
overwrite_trigger_run
&&
old_ops
->
tr
ans_trigger
==
new_ops
->
trans_
trigger
)
{
old_ops
->
tr
igger
==
new_ops
->
trigger
)
{
i
->
overwrite_trigger_run
=
true
;
i
->
insert_trigger_run
=
true
;
return
bch2_trans_mark_key
(
trans
,
i
->
btree_id
,
i
->
level
,
old
,
bkey_i_to_s
(
i
->
k
),
BTREE_TRIGGER_INSERT
|
BTREE_TRIGGER_OVERWRITE
|
i
->
flags
)
?:
1
;
return
bch2_key_trigger
(
trans
,
i
->
btree_id
,
i
->
level
,
old
,
bkey_i_to_s
(
i
->
k
),
BTREE_TRIGGER_INSERT
|
BTREE_TRIGGER_OVERWRITE
|
flags
)
?:
1
;
}
else
if
(
overwrite
&&
!
i
->
overwrite_trigger_run
)
{
i
->
overwrite_trigger_run
=
true
;
return
bch2_
trans_mark_old
(
trans
,
i
->
btree_id
,
i
->
level
,
old
,
i
->
flags
)
?:
1
;
return
bch2_
key_trigger_old
(
trans
,
i
->
btree_id
,
i
->
level
,
old
,
flags
)
?:
1
;
}
else
if
(
!
overwrite
&&
!
i
->
insert_trigger_run
)
{
i
->
insert_trigger_run
=
true
;
return
bch2_
trans_mark_new
(
trans
,
i
->
btree_id
,
i
->
level
,
bkey_i_to_s
(
i
->
k
),
i
->
flags
)
?:
1
;
return
bch2_
key_trigger_new
(
trans
,
i
->
btree_id
,
i
->
level
,
bkey_i_to_s
(
i
->
k
),
flags
)
?:
1
;
}
else
{
return
0
;
}
...
...
fs/bcachefs/btree_update_interior.c
View file @
f0431c5f
...
...
@@ -568,7 +568,8 @@ static int btree_update_nodes_written_trans(struct btree_trans *trans,
for_each_keylist_key
(
&
as
->
old_keys
,
k
)
{
unsigned
level
=
bkey_i_to_btree_ptr_v2
(
k
)
->
v
.
mem_ptr
;
ret
=
bch2_trans_mark_old
(
trans
,
as
->
btree_id
,
level
,
bkey_i_to_s_c
(
k
),
0
);
ret
=
bch2_key_trigger_old
(
trans
,
as
->
btree_id
,
level
,
bkey_i_to_s_c
(
k
),
BTREE_TRIGGER_TRANSACTIONAL
);
if
(
ret
)
return
ret
;
}
...
...
@@ -576,7 +577,8 @@ static int btree_update_nodes_written_trans(struct btree_trans *trans,
for_each_keylist_key
(
&
as
->
new_keys
,
k
)
{
unsigned
level
=
bkey_i_to_btree_ptr_v2
(
k
)
->
v
.
mem_ptr
;
ret
=
bch2_trans_mark_new
(
trans
,
as
->
btree_id
,
level
,
bkey_i_to_s
(
k
),
0
);
ret
=
bch2_key_trigger_new
(
trans
,
as
->
btree_id
,
level
,
bkey_i_to_s
(
k
),
BTREE_TRIGGER_TRANSACTIONAL
);
if
(
ret
)
return
ret
;
}
...
...
@@ -2156,13 +2158,12 @@ static int __bch2_btree_node_update_key(struct btree_trans *trans,
int
ret
;
if
(
!
skip_triggers
)
{
ret
=
bch2_trans_mark_old
(
trans
,
b
->
c
.
btree_id
,
b
->
c
.
level
+
1
,
bkey_i_to_s_c
(
&
b
->
key
),
0
);
if
(
ret
)
return
ret
;
ret
=
bch2_trans_mark_new
(
trans
,
b
->
c
.
btree_id
,
b
->
c
.
level
+
1
,
bkey_i_to_s
(
new_key
),
0
);
ret
=
bch2_key_trigger_old
(
trans
,
b
->
c
.
btree_id
,
b
->
c
.
level
+
1
,
bkey_i_to_s_c
(
&
b
->
key
),
BTREE_TRIGGER_TRANSACTIONAL
)
?:
bch2_key_trigger_new
(
trans
,
b
->
c
.
btree_id
,
b
->
c
.
level
+
1
,
bkey_i_to_s
(
new_key
),
BTREE_TRIGGER_TRANSACTIONAL
);
if
(
ret
)
return
ret
;
}
...
...
fs/bcachefs/ec.h
View file @
f0431c5f
...
...
@@ -19,8 +19,7 @@ int bch2_trigger_stripe(struct btree_trans *, enum btree_id, unsigned,
.key_invalid = bch2_stripe_invalid, \
.val_to_text = bch2_stripe_to_text, \
.swab = bch2_ptr_swab, \
.trans_trigger = bch2_trigger_stripe, \
.atomic_trigger = bch2_trigger_stripe, \
.trigger = bch2_trigger_stripe, \
.min_val_size = 8, \
})
...
...
fs/bcachefs/extents.h
View file @
f0431c5f
...
...
@@ -415,8 +415,7 @@ void bch2_btree_ptr_v2_compat(enum btree_id, unsigned, unsigned,
.key_invalid = bch2_btree_ptr_invalid, \
.val_to_text = bch2_btree_ptr_to_text, \
.swab = bch2_ptr_swab, \
.trans_trigger = bch2_trigger_extent, \
.atomic_trigger = bch2_trigger_extent, \
.trigger = bch2_trigger_extent, \
})
#define bch2_bkey_ops_btree_ptr_v2 ((struct bkey_ops) { \
...
...
@@ -424,8 +423,7 @@ void bch2_btree_ptr_v2_compat(enum btree_id, unsigned, unsigned,
.val_to_text = bch2_btree_ptr_v2_to_text, \
.swab = bch2_ptr_swab, \
.compat = bch2_btree_ptr_v2_compat, \
.trans_trigger = bch2_trigger_extent, \
.atomic_trigger = bch2_trigger_extent, \
.trigger = bch2_trigger_extent, \
.min_val_size = 40, \
})
...
...
@@ -439,8 +437,7 @@ bool bch2_extent_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
.swab = bch2_ptr_swab, \
.key_normalize = bch2_extent_normalize, \
.key_merge = bch2_extent_merge, \
.trans_trigger = bch2_trigger_extent, \
.atomic_trigger = bch2_trigger_extent, \
.trigger = bch2_trigger_extent, \
})
/* KEY_TYPE_reservation: */
...
...
@@ -454,8 +451,7 @@ bool bch2_reservation_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
.key_invalid = bch2_reservation_invalid, \
.val_to_text = bch2_reservation_to_text, \
.key_merge = bch2_reservation_merge, \
.trans_trigger = bch2_trigger_reservation, \
.atomic_trigger = bch2_trigger_reservation, \
.trigger = bch2_trigger_reservation, \
.min_val_size = 8, \
})
...
...
fs/bcachefs/inode.h
View file @
f0431c5f
...
...
@@ -23,24 +23,21 @@ int bch2_trigger_inode(struct btree_trans *, enum btree_id, unsigned,
#define bch2_bkey_ops_inode ((struct bkey_ops) { \
.key_invalid = bch2_inode_invalid, \
.val_to_text = bch2_inode_to_text, \
.trans_trigger = bch2_trigger_inode, \
.atomic_trigger = bch2_trigger_inode, \
.trigger = bch2_trigger_inode, \
.min_val_size = 16, \
})
#define bch2_bkey_ops_inode_v2 ((struct bkey_ops) { \
.key_invalid = bch2_inode_v2_invalid, \
.val_to_text = bch2_inode_to_text, \
.trans_trigger = bch2_trigger_inode, \
.atomic_trigger = bch2_trigger_inode, \
.trigger = bch2_trigger_inode, \
.min_val_size = 32, \
})
#define bch2_bkey_ops_inode_v3 ((struct bkey_ops) { \
.key_invalid = bch2_inode_v3_invalid, \
.val_to_text = bch2_inode_to_text, \
.trans_trigger = bch2_trigger_inode, \
.atomic_trigger = bch2_trigger_inode, \
.trigger = bch2_trigger_inode, \
.min_val_size = 48, \
})
...
...
fs/bcachefs/reflink.c
View file @
f0431c5f
...
...
@@ -298,7 +298,9 @@ int bch2_trans_mark_reflink_v(struct btree_trans *trans,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
{
check_indirect_extent_deleting
(
new
,
&
flags
);
if
((
flags
&
BTREE_TRIGGER_TRANSACTIONAL
)
&&
(
flags
&
BTREE_TRIGGER_INSERT
))
check_indirect_extent_deleting
(
new
,
&
flags
);
if
(
old
.
k
->
type
==
KEY_TYPE_reflink_v
&&
new
.
k
->
type
==
KEY_TYPE_reflink_v
&&
...
...
fs/bcachefs/reflink.h
View file @
f0431c5f
...
...
@@ -16,8 +16,7 @@ int bch2_trigger_reflink_p(struct btree_trans *, enum btree_id, unsigned,
.key_invalid = bch2_reflink_p_invalid, \
.val_to_text = bch2_reflink_p_to_text, \
.key_merge = bch2_reflink_p_merge, \
.trans_trigger = bch2_trigger_reflink_p, \
.atomic_trigger = bch2_trigger_reflink_p, \
.trigger = bch2_trigger_reflink_p, \
.min_val_size = 16, \
})
...
...
@@ -32,8 +31,7 @@ int bch2_trans_mark_reflink_v(struct btree_trans *, enum btree_id, unsigned,
.key_invalid = bch2_reflink_v_invalid, \
.val_to_text = bch2_reflink_v_to_text, \
.swab = bch2_ptr_swab, \
.trans_trigger = bch2_trans_mark_reflink_v, \
.atomic_trigger = bch2_trigger_extent, \
.trigger = bch2_trans_mark_reflink_v, \
.min_val_size = 8, \
})
...
...
@@ -49,7 +47,7 @@ int bch2_trans_mark_indirect_inline_data(struct btree_trans *,
#define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) { \
.key_invalid = bch2_indirect_inline_data_invalid, \
.val_to_text = bch2_indirect_inline_data_to_text, \
.tr
ans_tr
igger = bch2_trans_mark_indirect_inline_data, \
.trigger = bch2_trans_mark_indirect_inline_data, \
.min_val_size = 8, \
})
...
...
fs/bcachefs/snapshot.h
View file @
f0431c5f
...
...
@@ -27,7 +27,7 @@ int bch2_mark_snapshot(struct btree_trans *, enum btree_id, unsigned,
#define bch2_bkey_ops_snapshot ((struct bkey_ops) { \
.key_invalid = bch2_snapshot_invalid, \
.val_to_text = bch2_snapshot_to_text, \
.
atomic_
trigger = bch2_mark_snapshot, \
.trigger = bch2_mark_snapshot, \
.min_val_size = 24, \
})
...
...
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