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
6cacd0c4
Commit
6cacd0c4
authored
Dec 28, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: unify reservation trigger
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
7bc4d18a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
63 deletions
+40
-63
fs/bcachefs/buckets.c
fs/bcachefs/buckets.c
+37
-59
fs/bcachefs/buckets.h
fs/bcachefs/buckets.h
+1
-2
fs/bcachefs/extents.h
fs/bcachefs/extents.h
+2
-2
No files found.
fs/bcachefs/buckets.c
View file @
6cacd0c4
...
...
@@ -1121,45 +1121,6 @@ int bch2_mark_stripe(struct btree_trans *trans,
return
0
;
}
static
int
__mark_reservation
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
k
,
unsigned
flags
)
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
bch_fs_usage
*
fs_usage
;
unsigned
replicas
=
bkey_s_c_to_reservation
(
k
).
v
->
nr_replicas
;
s64
sectors
=
(
s64
)
k
.
k
->
size
;
BUG_ON
(
!
(
flags
&
BTREE_TRIGGER_GC
));
if
(
flags
&
BTREE_TRIGGER_OVERWRITE
)
sectors
=
-
sectors
;
sectors
*=
replicas
;
percpu_down_read
(
&
c
->
mark_lock
);
preempt_disable
();
fs_usage
=
fs_usage_ptr
(
c
,
trans
->
journal_res
.
seq
,
flags
&
BTREE_TRIGGER_GC
);
replicas
=
clamp_t
(
unsigned
,
replicas
,
1
,
ARRAY_SIZE
(
fs_usage
->
persistent_reserved
));
fs_usage
->
reserved
+=
sectors
;
fs_usage
->
persistent_reserved
[
replicas
-
1
]
+=
sectors
;
preempt_enable
();
percpu_up_read
(
&
c
->
mark_lock
);
return
0
;
}
int
bch2_mark_reservation
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
{
return
trigger_run_overwrite_then_insert
(
__mark_reservation
,
trans
,
btree_id
,
level
,
old
,
new
,
flags
);
}
void
bch2_trans_fs_usage_revert
(
struct
btree_trans
*
trans
,
struct
replicas_delta_list
*
deltas
)
{
...
...
@@ -1593,40 +1554,57 @@ int bch2_trans_mark_stripe(struct btree_trans *trans,
return
ret
;
}
static
int
__trans_mark_reservation
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
k
,
unsigned
flags
)
/* KEY_TYPE_reservation */
static
int
__trigger_reservation
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
k
,
unsigned
flags
)
{
struct
bch_fs
*
c
=
trans
->
c
;
unsigned
replicas
=
bkey_s_c_to_reservation
(
k
).
v
->
nr_replicas
;
s64
sectors
=
(
s64
)
k
.
k
->
size
;
struct
replicas_delta_list
*
d
;
int
ret
;
s64
sectors
=
(
s64
)
k
.
k
->
size
*
replicas
;
if
(
flags
&
BTREE_TRIGGER_OVERWRITE
)
sectors
=
-
sectors
;
sectors
*=
replicas
;
ret
=
bch2_replicas_deltas_realloc
(
trans
,
0
);
if
(
ret
)
return
ret
;
if
(
flags
&
BTREE_TRIGGER_TRANSACTIONAL
)
{
int
ret
=
bch2_replicas_deltas_realloc
(
trans
,
0
);
if
(
ret
)
return
ret
;
d
=
trans
->
fs_usage_deltas
;
replicas
=
clamp_t
(
unsigned
,
replicas
,
1
,
ARRAY_SIZE
(
d
->
persistent_reserved
));
struct
replicas_delta_list
*
d
=
trans
->
fs_usage_deltas
;
replicas
=
min
(
replicas
,
ARRAY_SIZE
(
d
->
persistent_reserved
));
d
->
persistent_reserved
[
replicas
-
1
]
+=
sectors
;
}
if
(
flags
&
BTREE_TRIGGER_GC
)
{
percpu_down_read
(
&
c
->
mark_lock
);
preempt_disable
();
struct
bch_fs_usage
*
fs_usage
=
this_cpu_ptr
(
c
->
usage_gc
);
replicas
=
min
(
replicas
,
ARRAY_SIZE
(
fs_usage
->
persistent_reserved
));
fs_usage
->
reserved
+=
sectors
;
fs_usage
->
persistent_reserved
[
replicas
-
1
]
+=
sectors
;
preempt_enable
();
percpu_up_read
(
&
c
->
mark_lock
);
}
d
->
persistent_reserved
[
replicas
-
1
]
+=
sectors
;
return
0
;
}
int
bch2_trans_mark_reservation
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
int
bch2_trigger_reservation
(
struct
btree_trans
*
trans
,
enum
btree_id
btree_id
,
unsigned
level
,
struct
bkey_s_c
old
,
struct
bkey_s
new
,
unsigned
flags
)
{
return
trigger_run_overwrite_then_insert
(
__tr
ans_mark
_reservation
,
trans
,
btree_id
,
level
,
old
,
new
,
flags
);
return
trigger_run_overwrite_then_insert
(
__tr
igger
_reservation
,
trans
,
btree_id
,
level
,
old
,
new
,
flags
);
}
/* Mark superblocks: */
static
int
__bch2_trans_mark_metadata_bucket
(
struct
btree_trans
*
trans
,
struct
bch_dev
*
ca
,
size_t
b
,
enum
bch_data_type
type
,
...
...
fs/bcachefs/buckets.h
View file @
6cacd0c4
...
...
@@ -333,12 +333,11 @@ int bch2_mark_extent(struct btree_trans *, enum btree_id, unsigned,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
int
bch2_mark_stripe
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
int
bch2_
mark
_reservation
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
int
bch2_
trigger
_reservation
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
int
bch2_trans_mark_extent
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
int
bch2_trans_mark_stripe
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
int
bch2_trans_mark_reservation
(
struct
btree_trans
*
,
enum
btree_id
,
unsigned
,
struct
bkey_s_c
,
struct
bkey_s
,
unsigned
);
#define trigger_run_overwrite_then_insert(_fn, _trans, _btree_id, _level, _old, _new, _flags)\
({ \
int ret = 0; \
...
...
fs/bcachefs/extents.h
View file @
6cacd0c4
...
...
@@ -454,8 +454,8 @@ 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_tr
ans_mark
_reservation, \
.atomic_trigger = bch2_
mark
_reservation, \
.trans_trigger = bch2_tr
igger
_reservation, \
.atomic_trigger = bch2_
trigger
_reservation, \
.min_val_size = 8, \
})
...
...
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