diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-01 23:08:40 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-08 23:29:24 +0200 |
commit | f4301b635a2ee6588d61d03fe261a2bba9225eb7 (patch) | |
tree | c3ddebebbcd945bbaad817f833a94ab38c3efc5c /fs | |
parent | bcachefs: kill bch2_dev_bkey_exists() in check_alloc_info() (diff) | |
download | linux-f4301b635a2ee6588d61d03fe261a2bba9225eb7.tar.xz linux-f4301b635a2ee6588d61d03fe261a2bba9225eb7.zip |
bcachefs: kill bch2_dev_bkey_exists() in discard_one_bucket_fast()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/alloc_background.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index ef1d17fbd750..71b727f5d432 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1903,9 +1903,12 @@ static void bch2_do_discards_fast_work(struct work_struct *work) static void bch2_discard_one_bucket_fast(struct bch_fs *c, struct bpos bucket) { - struct bch_dev *ca = bch2_dev_bkey_exists(c, bucket.inode); + rcu_read_lock(); + struct bch_dev *ca = bch2_dev_rcu(c, bucket.inode); + bool dead = !ca || percpu_ref_is_dying(&ca->io_ref); + rcu_read_unlock(); - if (!percpu_ref_is_dying(&ca->io_ref) && + if (!dead && !discard_in_flight_add(c, bucket) && bch2_write_ref_tryget(c, BCH_WRITE_REF_discard_fast) && !queue_work(c->write_ref_wq, &c->discard_fast_work)) |