bcachefs: bch2_evacuate_bucket() -> bch2_dev_tryget()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2024-04-30 15:46:45 -04:00
parent 07d7c4da7b
commit cb4d340a10

View File

@ -690,6 +690,10 @@ int bch2_evacuate_bucket(struct moving_context *ctxt,
struct bpos bp_pos = POS_MIN;
int ret = 0;
struct bch_dev *ca = bch2_dev_tryget(c, bucket.inode);
if (!ca)
return 0;
trace_bucket_evacuate(c, &bucket);
bch2_bkey_buf_init(&sk);
@ -711,7 +715,7 @@ int bch2_evacuate_bucket(struct moving_context *ctxt,
a = bch2_alloc_to_v4(k, &a_convert);
dirty_sectors = bch2_bucket_sectors_dirty(*a);
bucket_size = bch2_dev_bkey_exists(c, bucket.inode)->mi.bucket_size;
bucket_size = ca->mi.bucket_size;
fragmentation = a->fragmentation_lru;
ret = bch2_btree_write_buffer_tryflush(trans);
@ -823,6 +827,7 @@ int bch2_evacuate_bucket(struct moving_context *ctxt,
trace_evacuate_bucket(c, &bucket, dirty_sectors, bucket_size, fragmentation, ret);
err:
bch2_dev_put(ca);
bch2_bkey_buf_exit(&sk, c);
return ret;
}