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
a1fb08f5
Commit
a1fb08f5
authored
Mar 03, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Plumb alloc_reserve through stripe create path
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
91065976
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
29 deletions
+23
-29
fs/bcachefs/alloc_foreground.c
fs/bcachefs/alloc_foreground.c
+3
-4
fs/bcachefs/ec.c
fs/bcachefs/ec.c
+17
-23
fs/bcachefs/ec.h
fs/bcachefs/ec.h
+3
-2
No files found.
fs/bcachefs/alloc_foreground.c
View file @
a1fb08f5
...
@@ -794,6 +794,7 @@ static int bucket_alloc_from_stripe(struct btree_trans *trans,
...
@@ -794,6 +794,7 @@ static int bucket_alloc_from_stripe(struct btree_trans *trans,
unsigned
nr_replicas
,
unsigned
nr_replicas
,
unsigned
*
nr_effective
,
unsigned
*
nr_effective
,
bool
*
have_cache
,
bool
*
have_cache
,
enum
alloc_reserve
reserve
,
unsigned
flags
,
unsigned
flags
,
struct
closure
*
cl
)
struct
closure
*
cl
)
{
{
...
@@ -813,9 +814,7 @@ static int bucket_alloc_from_stripe(struct btree_trans *trans,
...
@@ -813,9 +814,7 @@ static int bucket_alloc_from_stripe(struct btree_trans *trans,
if
(
ec_open_bucket
(
c
,
ptrs
))
if
(
ec_open_bucket
(
c
,
ptrs
))
return
0
;
return
0
;
h
=
bch2_ec_stripe_head_get
(
trans
,
target
,
0
,
nr_replicas
-
1
,
h
=
bch2_ec_stripe_head_get
(
trans
,
target
,
0
,
nr_replicas
-
1
,
reserve
,
cl
);
wp
==
&
c
->
copygc_write_point
,
cl
);
if
(
IS_ERR
(
h
))
if
(
IS_ERR
(
h
))
return
PTR_ERR
(
h
);
return
PTR_ERR
(
h
);
if
(
!
h
)
if
(
!
h
)
...
@@ -926,7 +925,7 @@ static int open_bucket_add_buckets(struct btree_trans *trans,
...
@@ -926,7 +925,7 @@ static int open_bucket_add_buckets(struct btree_trans *trans,
ret
=
bucket_alloc_from_stripe
(
trans
,
ptrs
,
wp
,
&
devs
,
ret
=
bucket_alloc_from_stripe
(
trans
,
ptrs
,
wp
,
&
devs
,
target
,
erasure_code
,
target
,
erasure_code
,
nr_replicas
,
nr_effective
,
nr_replicas
,
nr_effective
,
have_cache
,
flags
,
_cl
);
have_cache
,
reserve
,
flags
,
_cl
);
if
(
bch2_err_matches
(
ret
,
BCH_ERR_transaction_restart
)
||
if
(
bch2_err_matches
(
ret
,
BCH_ERR_transaction_restart
)
||
bch2_err_matches
(
ret
,
BCH_ERR_freelist_empty
)
||
bch2_err_matches
(
ret
,
BCH_ERR_freelist_empty
)
||
bch2_err_matches
(
ret
,
BCH_ERR_open_buckets_empty
))
bch2_err_matches
(
ret
,
BCH_ERR_open_buckets_empty
))
...
...
fs/bcachefs/ec.c
View file @
a1fb08f5
...
@@ -1336,7 +1336,7 @@ static int ec_new_stripe_alloc(struct bch_fs *c, struct ec_stripe_head *h)
...
@@ -1336,7 +1336,7 @@ static int ec_new_stripe_alloc(struct bch_fs *c, struct ec_stripe_head *h)
static
struct
ec_stripe_head
*
static
struct
ec_stripe_head
*
ec_new_stripe_head_alloc
(
struct
bch_fs
*
c
,
unsigned
target
,
ec_new_stripe_head_alloc
(
struct
bch_fs
*
c
,
unsigned
target
,
unsigned
algo
,
unsigned
redundancy
,
unsigned
algo
,
unsigned
redundancy
,
bool
copygc
)
enum
alloc_reserve
reserve
)
{
{
struct
ec_stripe_head
*
h
;
struct
ec_stripe_head
*
h
;
struct
bch_dev
*
ca
;
struct
bch_dev
*
ca
;
...
@@ -1352,7 +1352,7 @@ ec_new_stripe_head_alloc(struct bch_fs *c, unsigned target,
...
@@ -1352,7 +1352,7 @@ ec_new_stripe_head_alloc(struct bch_fs *c, unsigned target,
h
->
target
=
target
;
h
->
target
=
target
;
h
->
algo
=
algo
;
h
->
algo
=
algo
;
h
->
redundancy
=
redundancy
;
h
->
redundancy
=
redundancy
;
h
->
copygc
=
copygc
;
h
->
reserve
=
reserve
;
rcu_read_lock
();
rcu_read_lock
();
h
->
devs
=
target_rw_devs
(
c
,
BCH_DATA_user
,
target
);
h
->
devs
=
target_rw_devs
(
c
,
BCH_DATA_user
,
target
);
...
@@ -1387,7 +1387,7 @@ struct ec_stripe_head *__bch2_ec_stripe_head_get(struct btree_trans *trans,
...
@@ -1387,7 +1387,7 @@ struct ec_stripe_head *__bch2_ec_stripe_head_get(struct btree_trans *trans,
unsigned
target
,
unsigned
target
,
unsigned
algo
,
unsigned
algo
,
unsigned
redundancy
,
unsigned
redundancy
,
bool
copygc
)
enum
alloc_reserve
reserve
)
{
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
bch_fs
*
c
=
trans
->
c
;
struct
ec_stripe_head
*
h
;
struct
ec_stripe_head
*
h
;
...
@@ -1404,21 +1404,21 @@ struct ec_stripe_head *__bch2_ec_stripe_head_get(struct btree_trans *trans,
...
@@ -1404,21 +1404,21 @@ struct ec_stripe_head *__bch2_ec_stripe_head_get(struct btree_trans *trans,
if
(
h
->
target
==
target
&&
if
(
h
->
target
==
target
&&
h
->
algo
==
algo
&&
h
->
algo
==
algo
&&
h
->
redundancy
==
redundancy
&&
h
->
redundancy
==
redundancy
&&
h
->
copygc
==
copygc
)
{
h
->
reserve
==
reserve
)
{
ret
=
bch2_trans_mutex_lock
(
trans
,
&
h
->
lock
);
ret
=
bch2_trans_mutex_lock
(
trans
,
&
h
->
lock
);
if
(
ret
)
if
(
ret
)
h
=
ERR_PTR
(
ret
);
h
=
ERR_PTR
(
ret
);
goto
found
;
goto
found
;
}
}
h
=
ec_new_stripe_head_alloc
(
c
,
target
,
algo
,
redundancy
,
copygc
);
h
=
ec_new_stripe_head_alloc
(
c
,
target
,
algo
,
redundancy
,
reserve
);
found:
found:
mutex_unlock
(
&
c
->
ec_stripe_head_lock
);
mutex_unlock
(
&
c
->
ec_stripe_head_lock
);
return
h
;
return
h
;
}
}
static
int
new_stripe_alloc_buckets
(
struct
btree_trans
*
trans
,
struct
ec_stripe_head
*
h
,
static
int
new_stripe_alloc_buckets
(
struct
btree_trans
*
trans
,
struct
ec_stripe_head
*
h
,
struct
closure
*
cl
)
enum
alloc_reserve
reserve
,
struct
closure
*
cl
)
{
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
bch_fs
*
c
=
trans
->
c
;
struct
bch_devs_mask
devs
=
h
->
devs
;
struct
bch_devs_mask
devs
=
h
->
devs
;
...
@@ -1428,14 +1428,12 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
...
@@ -1428,14 +1428,12 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
bool
have_cache
=
true
;
bool
have_cache
=
true
;
int
ret
=
0
;
int
ret
=
0
;
for
(
i
=
0
;
i
<
h
->
s
->
new_stripe
.
key
.
v
.
nr_blocks
;
i
++
)
{
for_each_set_bit
(
i
,
h
->
s
->
blocks_gotten
,
h
->
s
->
new_stripe
.
key
.
v
.
nr_blocks
)
{
if
(
test_bit
(
i
,
h
->
s
->
blocks_gotten
))
{
__clear_bit
(
h
->
s
->
new_stripe
.
key
.
v
.
ptrs
[
i
].
dev
,
devs
.
d
);
__clear_bit
(
h
->
s
->
new_stripe
.
key
.
v
.
ptrs
[
i
].
dev
,
devs
.
d
);
if
(
i
<
h
->
s
->
nr_data
)
if
(
i
<
h
->
s
->
nr_data
)
nr_have_data
++
;
nr_have_data
++
;
else
else
nr_have_parity
++
;
nr_have_parity
++
;
}
}
}
BUG_ON
(
nr_have_data
>
h
->
s
->
nr_data
);
BUG_ON
(
nr_have_data
>
h
->
s
->
nr_data
);
...
@@ -1449,9 +1447,7 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
...
@@ -1449,9 +1447,7 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
h
->
s
->
nr_parity
,
h
->
s
->
nr_parity
,
&
nr_have_parity
,
&
nr_have_parity
,
&
have_cache
,
&
have_cache
,
h
->
copygc
reserve
,
?
RESERVE_movinggc
:
RESERVE_none
,
0
,
0
,
cl
);
cl
);
...
@@ -1478,9 +1474,7 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
...
@@ -1478,9 +1474,7 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans, struct ec_stripe_
h
->
s
->
nr_data
,
h
->
s
->
nr_data
,
&
nr_have_data
,
&
nr_have_data
,
&
have_cache
,
&
have_cache
,
h
->
copygc
reserve
,
?
RESERVE_movinggc
:
RESERVE_none
,
0
,
0
,
cl
);
cl
);
...
@@ -1640,7 +1634,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
...
@@ -1640,7 +1634,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
unsigned
target
,
unsigned
target
,
unsigned
algo
,
unsigned
algo
,
unsigned
redundancy
,
unsigned
redundancy
,
bool
copygc
,
enum
alloc_reserve
reserve
,
struct
closure
*
cl
)
struct
closure
*
cl
)
{
{
struct
bch_fs
*
c
=
trans
->
c
;
struct
bch_fs
*
c
=
trans
->
c
;
...
@@ -1648,7 +1642,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
...
@@ -1648,7 +1642,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
int
ret
;
int
ret
;
bool
needs_stripe_new
;
bool
needs_stripe_new
;
h
=
__bch2_ec_stripe_head_get
(
trans
,
target
,
algo
,
redundancy
,
copygc
);
h
=
__bch2_ec_stripe_head_get
(
trans
,
target
,
algo
,
redundancy
,
reserve
);
if
(
!
h
)
if
(
!
h
)
bch_err
(
c
,
"no stripe head"
);
bch_err
(
c
,
"no stripe head"
);
if
(
IS_ERR_OR_NULL
(
h
))
if
(
IS_ERR_OR_NULL
(
h
))
...
@@ -1685,7 +1679,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
...
@@ -1685,7 +1679,7 @@ struct ec_stripe_head *bch2_ec_stripe_head_get(struct btree_trans *trans,
}
}
if
(
!
h
->
s
->
allocated
)
{
if
(
!
h
->
s
->
allocated
)
{
ret
=
new_stripe_alloc_buckets
(
trans
,
h
,
cl
);
ret
=
new_stripe_alloc_buckets
(
trans
,
h
,
reserve
,
cl
);
if
(
ret
)
if
(
ret
)
goto
err
;
goto
err
;
...
...
fs/bcachefs/ec.h
View file @
a1fb08f5
...
@@ -181,7 +181,7 @@ struct ec_stripe_head {
...
@@ -181,7 +181,7 @@ struct ec_stripe_head {
unsigned
target
;
unsigned
target
;
unsigned
algo
;
unsigned
algo
;
unsigned
redundancy
;
unsigned
redundancy
;
bool
copygc
;
enum
alloc_reserve
reserve
;
struct
bch_devs_mask
devs
;
struct
bch_devs_mask
devs
;
unsigned
nr_active_devs
;
unsigned
nr_active_devs
;
...
@@ -205,7 +205,8 @@ int bch2_ec_stripe_new_alloc(struct bch_fs *, struct ec_stripe_head *);
...
@@ -205,7 +205,8 @@ int bch2_ec_stripe_new_alloc(struct bch_fs *, struct ec_stripe_head *);
void
bch2_ec_stripe_head_put
(
struct
bch_fs
*
,
struct
ec_stripe_head
*
);
void
bch2_ec_stripe_head_put
(
struct
bch_fs
*
,
struct
ec_stripe_head
*
);
struct
ec_stripe_head
*
bch2_ec_stripe_head_get
(
struct
btree_trans
*
,
struct
ec_stripe_head
*
bch2_ec_stripe_head_get
(
struct
btree_trans
*
,
unsigned
,
unsigned
,
unsigned
,
bool
,
struct
closure
*
);
unsigned
,
unsigned
,
unsigned
,
enum
alloc_reserve
,
struct
closure
*
);
void
bch2_stripes_heap_update
(
struct
bch_fs
*
,
struct
stripe
*
,
size_t
);
void
bch2_stripes_heap_update
(
struct
bch_fs
*
,
struct
stripe
*
,
size_t
);
void
bch2_stripes_heap_del
(
struct
bch_fs
*
,
struct
stripe
*
,
size_t
);
void
bch2_stripes_heap_del
(
struct
bch_fs
*
,
struct
stripe
*
,
size_t
);
...
...
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