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
abe2f470
Commit
abe2f470
authored
Apr 30, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: simplify bch2_trans_start_alloc_update()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
0acf2169
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
46 deletions
+37
-46
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.c
+27
-21
fs/bcachefs/alloc_background.h
fs/bcachefs/alloc_background.h
+3
-1
fs/bcachefs/buckets.c
fs/bcachefs/buckets.c
+4
-11
fs/bcachefs/ec.c
fs/bcachefs/ec.c
+3
-13
No files found.
fs/bcachefs/alloc_background.c
View file @
abe2f470
...
...
@@ -429,22 +429,18 @@ struct bkey_i_alloc_v4 *bch2_alloc_to_v4_mut(struct btree_trans *trans, struct b
}
struct
bkey_i_alloc_v4
*
bch2_trans_start_alloc_update
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
,
struct
bpos
pos
)
bch2_trans_start_alloc_update
_noupdate
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
,
struct
bpos
pos
)
{
struct
bkey_s_c
k
;
struct
bkey_i_alloc_v4
*
a
;
int
ret
;
k
=
bch2_bkey_get_iter
(
trans
,
iter
,
BTREE_ID_alloc
,
pos
,
BTREE_ITER_with_updates
|
BTREE_ITER_cached
|
BTREE_ITER_intent
);
ret
=
bkey_err
(
k
);
struct
bkey_s_c
k
=
bch2_bkey_get_iter
(
trans
,
iter
,
BTREE_ID_alloc
,
pos
,
BTREE_ITER_with_updates
|
BTREE_ITER_cached
|
BTREE_ITER_intent
);
int
ret
=
bkey_err
(
k
);
if
(
unlikely
(
ret
))
return
ERR_PTR
(
ret
);
a
=
bch2_alloc_to_v4_mut_inlined
(
trans
,
k
);
struct
bkey_i_alloc_v4
*
a
=
bch2_alloc_to_v4_mut_inlined
(
trans
,
k
);
ret
=
PTR_ERR_OR_ZERO
(
a
);
if
(
unlikely
(
ret
))
goto
err
;
...
...
@@ -454,6 +450,20 @@ bch2_trans_start_alloc_update(struct btree_trans *trans, struct btree_iter *iter
return
ERR_PTR
(
ret
);
}
__flatten
struct
bkey_i_alloc_v4
*
bch2_trans_start_alloc_update
(
struct
btree_trans
*
trans
,
struct
bpos
pos
)
{
struct
btree_iter
iter
;
struct
bkey_i_alloc_v4
*
a
=
bch2_trans_start_alloc_update_noupdate
(
trans
,
&
iter
,
pos
);
int
ret
=
PTR_ERR_OR_ZERO
(
a
);
if
(
ret
)
return
ERR_PTR
(
ret
);
ret
=
bch2_trans_update
(
trans
,
&
iter
,
&
a
->
k_i
,
0
);
bch2_trans_iter_exit
(
trans
,
&
iter
);
return
unlikely
(
ret
)
?
ERR_PTR
(
ret
)
:
a
;
}
static
struct
bpos
alloc_gens_pos
(
struct
bpos
pos
,
unsigned
*
offset
)
{
*
offset
=
pos
.
offset
&
KEY_TYPE_BUCKET_GENS_MASK
;
...
...
@@ -1908,7 +1918,6 @@ static int invalidate_one_bucket(struct btree_trans *trans,
s64
*
nr_to_invalidate
)
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
btree_iter
alloc_iter
=
{
NULL
};
struct
bkey_i_alloc_v4
*
a
=
NULL
;
struct
printbuf
buf
=
PRINTBUF
;
struct
bpos
bucket
=
u64_to_bucket
(
lru_k
.
k
->
p
.
offset
);
...
...
@@ -1926,7 +1935,7 @@ static int invalidate_one_bucket(struct btree_trans *trans,
if
(
bch2_bucket_is_open_safe
(
c
,
bucket
.
inode
,
bucket
.
offset
))
return
0
;
a
=
bch2_trans_start_alloc_update
(
trans
,
&
alloc_iter
,
bucket
);
a
=
bch2_trans_start_alloc_update
(
trans
,
bucket
);
ret
=
PTR_ERR_OR_ZERO
(
a
);
if
(
ret
)
goto
out
;
...
...
@@ -1951,18 +1960,15 @@ static int invalidate_one_bucket(struct btree_trans *trans,
a
->
v
.
io_time
[
READ
]
=
atomic64_read
(
&
c
->
io_clock
[
READ
].
now
);
a
->
v
.
io_time
[
WRITE
]
=
atomic64_read
(
&
c
->
io_clock
[
WRITE
].
now
);
ret
=
bch2_trans_update
(
trans
,
&
alloc_iter
,
&
a
->
k_i
,
BTREE_TRIGGER_bucket_invalidate
)
?:
bch2_trans_commit
(
trans
,
NULL
,
NULL
,
BCH_WATERMARK_btree
|
BCH_TRANS_COMMIT_no_enospc
);
ret
=
bch2_trans_commit
(
trans
,
NULL
,
NULL
,
BCH_WATERMARK_btree
|
BCH_TRANS_COMMIT_no_enospc
);
if
(
ret
)
goto
out
;
trace_and_count
(
c
,
bucket_invalidate
,
c
,
bucket
.
inode
,
bucket
.
offset
,
cached_sectors
);
--*
nr_to_invalidate
;
out:
bch2_trans_iter_exit
(
trans
,
&
alloc_iter
);
printbuf_exit
(
&
buf
);
return
ret
;
err:
...
...
@@ -2175,7 +2181,7 @@ int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,
if
(
bch2_trans_relock
(
trans
))
bch2_trans_begin
(
trans
);
a
=
bch2_trans_start_alloc_update
(
trans
,
&
iter
,
POS
(
dev
,
bucket_nr
));
a
=
bch2_trans_start_alloc_update
_noupdate
(
trans
,
&
iter
,
POS
(
dev
,
bucket_nr
));
ret
=
PTR_ERR_OR_ZERO
(
a
);
if
(
ret
)
return
ret
;
...
...
fs/bcachefs/alloc_background.h
View file @
abe2f470
...
...
@@ -179,7 +179,9 @@ static inline void set_alloc_v4_u64s(struct bkey_i_alloc_v4 *a)
}
struct
bkey_i_alloc_v4
*
bch2_trans_start_alloc_update
(
struct
btree_trans
*
,
struct
btree_iter
*
,
struct
bpos
);
bch2_trans_start_alloc_update_noupdate
(
struct
btree_trans
*
,
struct
btree_iter
*
,
struct
bpos
);
struct
bkey_i_alloc_v4
*
bch2_trans_start_alloc_update
(
struct
btree_trans
*
,
struct
bpos
);
void
__bch2_alloc_to_v4
(
struct
bkey_s_c
,
struct
bch_alloc_v4
*
);
...
...
fs/bcachefs/buckets.c
View file @
abe2f470
...
...
@@ -973,16 +973,9 @@ static int bch2_trigger_pointer(struct btree_trans *trans,
*
sectors
=
insert
?
bp
.
bucket_len
:
-
((
s64
)
bp
.
bucket_len
);
if
(
flags
&
BTREE_TRIGGER_transactional
)
{
struct
btree_iter
iter
;
struct
bkey_i_alloc_v4
*
a
=
bch2_trans_start_alloc_update
(
trans
,
&
iter
,
bucket
);
int
ret
=
PTR_ERR_OR_ZERO
(
a
);
if
(
ret
)
return
ret
;
ret
=
__mark_pointer
(
trans
,
k
,
&
p
.
ptr
,
*
sectors
,
bp
.
data_type
,
&
a
->
v
)
?:
bch2_trans_update
(
trans
,
&
iter
,
&
a
->
k_i
,
0
);
bch2_trans_iter_exit
(
trans
,
&
iter
);
struct
bkey_i_alloc_v4
*
a
=
bch2_trans_start_alloc_update
(
trans
,
bucket
);
int
ret
=
PTR_ERR_OR_ZERO
(
a
)
?:
__mark_pointer
(
trans
,
k
,
&
p
.
ptr
,
*
sectors
,
bp
.
data_type
,
&
a
->
v
);
if
(
ret
)
return
ret
;
...
...
@@ -1266,7 +1259,7 @@ static int __bch2_trans_mark_metadata_bucket(struct btree_trans *trans,
int
ret
=
0
;
struct
bkey_i_alloc_v4
*
a
=
bch2_trans_start_alloc_update
(
trans
,
&
iter
,
POS
(
ca
->
dev_idx
,
b
));
bch2_trans_start_alloc_update
_noupdate
(
trans
,
&
iter
,
POS
(
ca
->
dev_idx
,
b
));
if
(
IS_ERR
(
a
))
return
PTR_ERR
(
a
);
...
...
fs/bcachefs/ec.c
View file @
abe2f470
...
...
@@ -269,20 +269,10 @@ static int mark_stripe_bucket(struct btree_trans *trans,
struct
bpos
bucket
=
PTR_BUCKET_POS
(
c
,
ptr
);
if
(
flags
&
BTREE_TRIGGER_transactional
)
{
struct
btree_iter
iter
;
struct
bkey_i_alloc_v4
*
a
=
bch2_trans_start_alloc_update
(
trans
,
&
iter
,
bucket
);
int
ret
=
PTR_ERR_OR_ZERO
(
a
)
?:
__mark_stripe_bucket
(
trans
,
s
,
ptr_idx
,
deleting
,
iter
.
pos
,
&
a
->
v
);
if
(
ret
)
goto
err
;
ret
=
bch2_trans_update
(
trans
,
&
iter
,
&
a
->
k_i
,
0
);
if
(
ret
)
goto
err
;
err:
bch2_trans_iter_exit
(
trans
,
&
iter
);
return
ret
;
bch2_trans_start_alloc_update
(
trans
,
bucket
);
return
PTR_ERR_OR_ZERO
(
a
)
?:
__mark_stripe_bucket
(
trans
,
s
,
ptr_idx
,
deleting
,
bucket
,
&
a
->
v
);
}
if
(
flags
&
BTREE_TRIGGER_gc
)
{
...
...
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