diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-09 12:22:58 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:50 -0400 |
commit | dd81a060eb0680e09d133b81db54b90442c32b5e (patch) | |
tree | eb914eacc72d4cc901b9f443353e3847612dbea9 /fs/bcachefs/ec.c | |
parent | 06ab86d596170b9f3b88ce3f8e9fea7e9c1ea0c2 (diff) | |
download | lwn-dd81a060eb0680e09d133b81db54b90442c32b5e.tar.gz lwn-dd81a060eb0680e09d133b81db54b90442c32b5e.zip |
bcachefs: ec_stripe_delete_work() now takes ref on c->writes
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/ec.c')
-rw-r--r-- | fs/bcachefs/ec.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index e320868a8b8b..f4b903f2fd22 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -672,9 +672,8 @@ void bch2_stripes_heap_update(struct bch_fs *c, heap_verify_backpointer(c, idx); - if (stripe_idx_to_delete(c) >= 0 && - !percpu_ref_is_dying(&c->writes)) - schedule_work(&c->ec_stripe_delete_work); + if (stripe_idx_to_delete(c) >= 0) + bch2_do_stripe_deletes(c); } /* stripe deletion */ @@ -707,6 +706,15 @@ static void ec_stripe_delete_work(struct work_struct *work) if (ec_stripe_delete(c, idx)) break; } + + percpu_ref_put(&c->writes); +} + +void bch2_do_stripe_deletes(struct bch_fs *c) +{ + if (percpu_ref_tryget_live(&c->writes) && + !schedule_work(&c->ec_stripe_delete_work)) + percpu_ref_put(&c->writes); } /* stripe creation: */ |