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
fa9bb741
Commit
fa9bb741
authored
Apr 30, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: alloc_data_type_set()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
2685c67d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
31 deletions
+36
-31
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.c
+3
-3
fs/bcachefs/alloc_background.h
fs/bcachefs/alloc_background.h
+31
-26
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_gc.c
+1
-1
fs/bcachefs/ec.c
fs/bcachefs/ec.c
+1
-1
No files found.
fs/bcachefs/alloc_background.c
View file @
fa9bb741
...
...
@@ -741,7 +741,7 @@ int bch2_trigger_alloc(struct btree_trans *trans,
if
(
flags
&
BTREE_TRIGGER_transactional
)
{
struct
bch_alloc_v4
*
new_a
=
bkey_s_to_alloc_v4
(
new
).
v
;
new_a
->
data_type
=
alloc_data_type
(
*
new_a
,
new_a
->
data_type
);
alloc_data_type_set
(
new_a
,
new_a
->
data_type
);
if
(
bch2_bucket_sectors
(
*
new_a
)
>
bch2_bucket_sectors
(
*
old_a
))
{
new_a
->
io_time
[
READ
]
=
max_t
(
u64
,
1
,
atomic64_read
(
&
c
->
io_clock
[
READ
].
now
));
...
...
@@ -1761,7 +1761,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
}
SET_BCH_ALLOC_V4_NEED_DISCARD
(
&
a
->
v
,
false
);
a
->
v
.
data_type
=
alloc_data_type
(
a
->
v
,
a
->
v
.
data_type
);
a
lloc_data_type_set
(
&
a
->
v
,
a
->
v
.
data_type
);
write:
ret
=
bch2_trans_update
(
trans
,
&
iter
,
&
a
->
k_i
,
0
)
?:
bch2_trans_commit
(
trans
,
NULL
,
NULL
,
...
...
@@ -1830,7 +1830,7 @@ static int bch2_clear_bucket_needs_discard(struct btree_trans *trans, struct bpo
BUG_ON
(
a
->
v
.
dirty_sectors
);
SET_BCH_ALLOC_V4_NEED_DISCARD
(
&
a
->
v
,
false
);
a
->
v
.
data_type
=
alloc_data_type
(
a
->
v
,
a
->
v
.
data_type
);
a
lloc_data_type_set
(
&
a
->
v
,
a
->
v
.
data_type
);
ret
=
bch2_trans_update
(
trans
,
&
iter
,
&
a
->
k_i
,
0
);
err:
...
...
fs/bcachefs/alloc_background.h
View file @
fa9bb741
...
...
@@ -39,32 +39,6 @@ static inline u8 alloc_gc_gen(struct bch_alloc_v4 a)
return
a
.
gen
-
a
.
oldest_gen
;
}
static
inline
enum
bch_data_type
__alloc_data_type
(
u32
dirty_sectors
,
u32
cached_sectors
,
u32
stripe
,
struct
bch_alloc_v4
a
,
enum
bch_data_type
data_type
)
{
if
(
stripe
)
return
data_type
==
BCH_DATA_parity
?
data_type
:
BCH_DATA_stripe
;
if
(
dirty_sectors
)
return
data_type
;
if
(
cached_sectors
)
return
BCH_DATA_cached
;
if
(
BCH_ALLOC_V4_NEED_DISCARD
(
&
a
))
return
BCH_DATA_need_discard
;
if
(
alloc_gc_gen
(
a
)
>=
BUCKET_GC_GEN_MAX
)
return
BCH_DATA_need_gc_gens
;
return
BCH_DATA_free
;
}
static
inline
enum
bch_data_type
alloc_data_type
(
struct
bch_alloc_v4
a
,
enum
bch_data_type
data_type
)
{
return
__alloc_data_type
(
a
.
dirty_sectors
,
a
.
cached_sectors
,
a
.
stripe
,
a
,
data_type
);
}
static
inline
enum
bch_data_type
bucket_data_type
(
enum
bch_data_type
data_type
)
{
switch
(
data_type
)
{
...
...
@@ -101,6 +75,37 @@ static inline unsigned bch2_bucket_sectors_fragmented(struct bch_dev *ca,
return
d
?
max
(
0
,
ca
->
mi
.
bucket_size
-
d
)
:
0
;
}
static
inline
enum
bch_data_type
__alloc_data_type
(
u32
dirty_sectors
,
u32
cached_sectors
,
u32
stripe
,
struct
bch_alloc_v4
a
,
enum
bch_data_type
data_type
)
{
if
(
stripe
)
return
data_type
==
BCH_DATA_parity
?
data_type
:
BCH_DATA_stripe
;
if
(
dirty_sectors
)
return
data_type
;
if
(
cached_sectors
)
return
BCH_DATA_cached
;
if
(
BCH_ALLOC_V4_NEED_DISCARD
(
&
a
))
return
BCH_DATA_need_discard
;
if
(
alloc_gc_gen
(
a
)
>=
BUCKET_GC_GEN_MAX
)
return
BCH_DATA_need_gc_gens
;
return
BCH_DATA_free
;
}
static
inline
enum
bch_data_type
alloc_data_type
(
struct
bch_alloc_v4
a
,
enum
bch_data_type
data_type
)
{
return
__alloc_data_type
(
a
.
dirty_sectors
,
a
.
cached_sectors
,
a
.
stripe
,
a
,
data_type
);
}
static
inline
void
alloc_data_type_set
(
struct
bch_alloc_v4
*
a
,
enum
bch_data_type
data_type
)
{
a
->
data_type
=
alloc_data_type
(
*
a
,
data_type
);
}
static
inline
u64
alloc_lru_idx_read
(
struct
bch_alloc_v4
a
)
{
return
a
.
data_type
==
BCH_DATA_cached
?
a
.
io_time
[
READ
]
:
0
;
...
...
fs/bcachefs/btree_gc.c
View file @
fa9bb741
...
...
@@ -1307,7 +1307,7 @@ static int bch2_alloc_write_oldest_gen(struct btree_trans *trans, struct btree_i
return
ret
;
a_mut
->
v
.
oldest_gen
=
ca
->
oldest_gen
[
iter
->
pos
.
offset
];
a
_mut
->
v
.
data_type
=
alloc_data_type
(
a_mut
->
v
,
a_mut
->
v
.
data_type
);
a
lloc_data_type_set
(
&
a_mut
->
v
,
a_mut
->
v
.
data_type
);
return
bch2_trans_update
(
trans
,
iter
,
&
a_mut
->
k_i
,
0
);
}
...
...
fs/bcachefs/ec.c
View file @
fa9bb741
...
...
@@ -290,7 +290,7 @@ static int mark_stripe_bucket(struct btree_trans *trans,
goto
err
;
if
(
deleting
)
a
->
v
.
data_type
=
alloc_data_type
(
a
->
v
,
BCH_DATA_user
);
a
lloc_data_type_set
(
&
a
->
v
,
BCH_DATA_user
);
ret
=
bch2_trans_update
(
trans
,
&
iter
,
&
a
->
k_i
,
0
);
if
(
ret
)
...
...
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