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
627a2312
Commit
627a2312
authored
Feb 18, 2023
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Switch ec_stripes_heap_lock to a mutex
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
5e2d8be8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
26 deletions
+25
-26
fs/bcachefs/bcachefs.h
fs/bcachefs/bcachefs.h
+1
-1
fs/bcachefs/buckets.c
fs/bcachefs/buckets.c
+7
-7
fs/bcachefs/ec.c
fs/bcachefs/ec.c
+16
-17
fs/bcachefs/super.c
fs/bcachefs/super.c
+1
-1
No files found.
fs/bcachefs/bcachefs.h
View file @
627a2312
...
...
@@ -941,7 +941,7 @@ struct bch_fs {
GENRADIX
(
struct
gc_stripe
)
gc_stripes
;
ec_stripes_heap
ec_stripes_heap
;
s
pinlock_t
ec_stripes_heap_lock
;
s
truct
mutex
ec_stripes_heap_lock
;
/* ERASURE CODING */
struct
list_head
ec_stripe_head_list
;
...
...
fs/bcachefs/buckets.c
View file @
627a2312
...
...
@@ -907,10 +907,10 @@ static int bch2_mark_stripe_ptr(struct btree_trans *trans,
return
-
ENOMEM
;
}
spin
_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_lock
(
&
c
->
ec_stripes_heap_lock
);
if
(
!
m
||
!
m
->
alive
)
{
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
bch_err_ratelimited
(
c
,
"pointer to nonexistent stripe %llu"
,
(
u64
)
p
.
idx
);
bch2_inconsistent_error
(
c
);
...
...
@@ -920,7 +920,7 @@ static int bch2_mark_stripe_ptr(struct btree_trans *trans,
m
->
block_sectors
[
p
.
block
]
+=
sectors
;
r
=
m
->
r
;
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
r
.
e
.
data_type
=
data_type
;
update_replicas
(
c
,
k
,
&
r
.
e
,
sectors
,
trans
->
journal_res
.
seq
,
true
);
...
...
@@ -1047,9 +1047,9 @@ int bch2_mark_stripe(struct btree_trans *trans,
}
if
(
!
new_s
)
{
spin
_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_lock
(
&
c
->
ec_stripes_heap_lock
);
bch2_stripes_heap_del
(
c
,
m
,
idx
);
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
memset
(
m
,
0
,
sizeof
(
*
m
));
}
else
{
...
...
@@ -1063,9 +1063,9 @@ int bch2_mark_stripe(struct btree_trans *trans,
for
(
i
=
0
;
i
<
new_s
->
nr_blocks
;
i
++
)
m
->
blocks_nonempty
+=
!!
stripe_blockcount_get
(
new_s
,
i
);
spin
_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_lock
(
&
c
->
ec_stripes_heap_lock
);
bch2_stripes_heap_update
(
c
,
m
,
idx
);
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
}
}
else
{
struct
gc_stripe
*
m
=
...
...
fs/bcachefs/ec.c
View file @
627a2312
...
...
@@ -549,13 +549,13 @@ static int __ec_stripe_mem_alloc(struct bch_fs *c, size_t idx, gfp_t gfp)
if
(
!
init_heap
(
&
n
,
max
(
1024UL
,
roundup_pow_of_two
(
idx
+
1
)),
gfp
))
return
-
ENOMEM
;
spin
_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_lock
(
&
c
->
ec_stripes_heap_lock
);
if
(
n
.
size
>
h
->
size
)
{
memcpy
(
n
.
data
,
h
->
data
,
h
->
used
*
sizeof
(
h
->
data
[
0
]));
n
.
used
=
h
->
used
;
swap
(
*
h
,
n
);
}
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
free_heap
(
&
n
);
}
...
...
@@ -695,15 +695,15 @@ static void ec_stripe_delete_work(struct work_struct *work)
ssize_t
idx
;
while
(
1
)
{
spin
_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_lock
(
&
c
->
ec_stripes_heap_lock
);
idx
=
stripe_idx_to_delete
(
c
);
if
(
idx
<
0
)
{
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
break
;
}
bch2_stripes_heap_del
(
c
,
genradix_ptr
(
&
c
->
stripes
,
idx
),
idx
);
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
if
(
ec_stripe_delete
(
c
,
idx
))
break
;
...
...
@@ -1013,12 +1013,13 @@ static void ec_stripe_create(struct ec_stripe_new *s)
bch_err
(
c
,
"error creating stripe: error updating pointers: %s"
,
bch2_err_str
(
ret
));
spin_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex_lock
(
&
c
->
ec_stripes_heap_lock
);
m
=
genradix_ptr
(
&
c
->
stripes
,
s
->
new_stripe
.
key
.
k
.
p
.
offset
);
BUG_ON
(
m
->
on_heap
);
bch2_stripes_heap_insert
(
c
,
m
,
s
->
new_stripe
.
key
.
k
.
p
.
offset
);
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
err_put_writes:
bch2_write_ref_put
(
c
,
BCH_WRITE_REF_stripe_create
);
err:
...
...
@@ -1398,7 +1399,7 @@ static s64 get_existing_stripe(struct bch_fs *c,
if
(
may_create_new_stripe
(
c
))
return
-
1
;
spin
_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_lock
(
&
c
->
ec_stripes_heap_lock
);
for
(
heap_idx
=
0
;
heap_idx
<
h
->
used
;
heap_idx
++
)
{
/* No blocks worth reusing, stripe will just be deleted: */
if
(
!
h
->
data
[
heap_idx
].
blocks_nonempty
)
...
...
@@ -1416,12 +1417,11 @@ static s64 get_existing_stripe(struct bch_fs *c,
break
;
}
}
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
return
ret
;
}
static
int
__bch2_ec_stripe_head_reuse
(
struct
bch_fs
*
c
,
struct
ec_stripe_head
*
h
)
static
int
__bch2_ec_stripe_head_reuse
(
struct
bch_fs
*
c
,
struct
ec_stripe_head
*
h
)
{
unsigned
i
;
s64
idx
;
...
...
@@ -1464,8 +1464,7 @@ static int __bch2_ec_stripe_head_reuse(struct bch_fs *c,
return
0
;
}
static
int
__bch2_ec_stripe_head_reserve
(
struct
bch_fs
*
c
,
struct
ec_stripe_head
*
h
)
static
int
__bch2_ec_stripe_head_reserve
(
struct
bch_fs
*
c
,
struct
ec_stripe_head
*
h
)
{
return
bch2_disk_reservation_get
(
c
,
&
h
->
s
->
res
,
h
->
blocksize
,
...
...
@@ -1606,9 +1605,9 @@ int bch2_stripes_read(struct bch_fs *c)
for
(
i
=
0
;
i
<
s
->
nr_blocks
;
i
++
)
m
->
blocks_nonempty
+=
!!
stripe_blockcount_get
(
s
,
i
);
spin
_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_lock
(
&
c
->
ec_stripes_heap_lock
);
bch2_stripes_heap_update
(
c
,
m
,
k
.
k
->
p
.
offset
);
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
}
bch2_trans_iter_exit
(
&
trans
,
&
iter
);
...
...
@@ -1626,7 +1625,7 @@ void bch2_stripes_heap_to_text(struct printbuf *out, struct bch_fs *c)
struct
stripe
*
m
;
size_t
i
;
spin
_lock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_lock
(
&
c
->
ec_stripes_heap_lock
);
for
(
i
=
0
;
i
<
min_t
(
size_t
,
h
->
used
,
20
);
i
++
)
{
m
=
genradix_ptr
(
&
c
->
stripes
,
h
->
data
[
i
].
idx
);
...
...
@@ -1635,7 +1634,7 @@ void bch2_stripes_heap_to_text(struct printbuf *out, struct bch_fs *c)
m
->
nr_blocks
-
m
->
nr_redundant
,
m
->
nr_redundant
);
}
spin
_unlock
(
&
c
->
ec_stripes_heap_lock
);
mutex
_unlock
(
&
c
->
ec_stripes_heap_lock
);
}
void
bch2_new_stripes_to_text
(
struct
printbuf
*
out
,
struct
bch_fs
*
c
)
...
...
fs/bcachefs/super.c
View file @
627a2312
...
...
@@ -706,7 +706,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
INIT_LIST_HEAD
(
&
c
->
data_progress_list
);
mutex_init
(
&
c
->
data_progress_lock
);
spin_lock
_init
(
&
c
->
ec_stripes_heap_lock
);
mutex
_init
(
&
c
->
ec_stripes_heap_lock
);
seqcount_init
(
&
c
->
gc_pos_lock
);
...
...
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