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
08bc9590
Commit
08bc9590
authored
Dec 28, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: unify inode trigger
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
282e7c37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
50 deletions
+33
-50
fs/bcachefs/inode.c
fs/bcachefs/inode.c
+26
-41
fs/bcachefs/inode.h
fs/bcachefs/inode.h
+7
-9
No files found.
fs/bcachefs/inode.c
View file @
08bc9590
...
...
@@ -561,61 +561,46 @@ static inline bool bkey_is_deleted_inode(struct bkey_s_c k)
return
bkey_inode_flags
(
k
)
&
BCH_INODE_unlinked
;
}
int
bch2_tr
ans_mark
_inode
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
int
bch2_tr
igger
_inode
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
{
s64
nr
=
bkey_is_inode
(
new
.
k
)
-
bkey_is_inode
(
old
.
k
);
bool
old_deleted
=
bkey_is_deleted_inode
(
old
);
bool
new_deleted
=
bkey_is_deleted_inode
(
new
.
s_c
);
if
(
nr
)
{
int
ret
=
bch2_replicas_deltas_realloc
(
trans
,
0
);
struct
replicas_delta_list
*
d
=
trans
->
fs_usage_deltas
;
if
(
flags
&
BTREE_TRIGGER_TRANSACTIONAL
)
{
if
(
nr
)
{
int
ret
=
bch2_replicas_deltas_realloc
(
trans
,
0
);
if
(
ret
)
return
ret
;
if
(
ret
)
return
ret
;
d
->
nr_inodes
+=
nr
;
}
trans
->
fs_usage_deltas
->
nr_inodes
+=
nr
;
}
if
(
old_deleted
!=
new_deleted
)
{
int
ret
=
bch2_btree_bit_mod
(
trans
,
BTREE_ID_deleted_inodes
,
new
.
k
->
p
,
new_deleted
);
if
(
ret
)
return
ret
;
bool
old_deleted
=
bkey_is_deleted_inode
(
old
);
bool
new_deleted
=
bkey_is_deleted_inode
(
new
.
s_c
);
if
(
old_deleted
!=
new_deleted
)
{
int
ret
=
bch2_btree_bit_mod
(
trans
,
BTREE_ID_deleted_inodes
,
new
.
k
->
p
,
new_deleted
);
if
(
ret
)
return
ret
;
}
}
return
0
;
}
int
bch2_mark_inode
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
bch_fs_usage
*
fs_usage
;
u64
journal_seq
=
trans
->
journal_res
.
seq
;
if
(
flags
&
BTREE_TRIGGER_INSERT
)
{
BUG_ON
(
!
journal_seq
);
if
(
!
(
flags
&
BTREE_TRIGGER_TRANSACTIONAL
)
&&
(
flags
&
BTREE_TRIGGER_INSERT
))
{
BUG_ON
(
!
trans
->
journal_res
.
seq
);
bkey_s_to_inode_v3
(
new
).
v
->
bi_journal_seq
=
cpu_to_le64
(
journal_
seq
);
bkey_s_to_inode_v3
(
new
).
v
->
bi_journal_seq
=
cpu_to_le64
(
trans
->
journal_res
.
seq
);
}
if
(
flags
&
BTREE_TRIGGER_GC
)
{
percpu_down_read
(
&
c
->
mark_lock
);
preempt_disable
();
fs_usage
=
fs_usage_ptr
(
c
,
journal_seq
,
flags
&
BTREE_TRIGGER_GC
);
fs_usage
->
nr_inodes
+=
bkey_is_inode
(
new
.
k
);
fs_usage
->
nr_inodes
-=
bkey_is_inode
(
old
.
k
);
struct
bch_fs
*
c
=
trans
->
c
;
preempt_enable
();
percpu_down_read
(
&
c
->
mark_lock
);
this_cpu_add
(
c
->
usage_gc
->
nr_inodes
,
nr
);
percpu_up_read
(
&
c
->
mark_lock
);
}
return
0
;
}
...
...
fs/bcachefs/inode.h
View file @
08bc9590
...
...
@@ -17,32 +17,30 @@ int bch2_inode_v3_invalid(struct bch_fs *, struct bkey_s_c,
enum
bkey_invalid_flags
,
struct
printbuf
*
);
void
bch2_inode_to_text
(
struct
printbuf
*
,
struct
bch_fs
*
,
struct
bkey_s_c
);
int
bch2_tr
ans_mark
_inode
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
int
bch2_tr
igger
_inode
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
int
bch2_mark_inode
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
#define bch2_bkey_ops_inode ((struct bkey_ops) { \
.key_invalid = bch2_inode_invalid, \
.val_to_text = bch2_inode_to_text, \
.trans_trigger = bch2_tr
ans_mark_inode,
\
.atomic_trigger = bch2_
mark
_inode, \
.trans_trigger = bch2_tr
igger_inode,
\
.atomic_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_tr
ans_mark_inode,
\
.atomic_trigger = bch2_
mark
_inode, \
.trans_trigger = bch2_tr
igger_inode,
\
.atomic_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_tr
ans_mark_inode,
\
.atomic_trigger = bch2_
mark
_inode, \
.trans_trigger = bch2_tr
igger_inode,
\
.atomic_trigger = bch2_
trigger
_inode, \
.min_val_size = 48, \
})
...
...
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