diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-02 00:06:35 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-08 23:29:23 +0200 |
commit | 222eacabc17f360ede4efddda50534f828228ed0 (patch) | |
tree | 92bea657f9337430754c2060311c9f79ef680dc4 /fs/bcachefs/data_update.c | |
parent | bcachefs: kill bch2_dev_bkey_exists() in bkey_pick_read_device() (diff) | |
download | linux-222eacabc17f360ede4efddda50534f828228ed0.tar.xz linux-222eacabc17f360ede4efddda50534f828228ed0.zip |
bcachefs: kill bch2_dev_bkey_exists() in data_update_init()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/data_update.c')
-rw-r--r-- | fs/bcachefs/data_update.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index 7aad6085ef53..1dee93eee7ad 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -544,8 +544,16 @@ int bch2_data_update_init(struct btree_trans *trans, m->op.compression_opt = background_compression(io_opts); m->op.watermark = m->data_opts.btree_insert_flags & BCH_WATERMARK_MASK; - bkey_for_each_ptr(ptrs, ptr) - bch2_dev_get(bch2_dev_bkey_exists(c, ptr->dev)); + bkey_for_each_ptr(ptrs, ptr) { + if (!bch2_dev_tryget(c, ptr->dev)) { + bkey_for_each_ptr(ptrs, ptr2) { + if (ptr2 == ptr) + break; + bch2_dev_put(bch2_dev_have_ref(c, ptr2->dev)); + } + return -BCH_ERR_data_update_done; + } + } unsigned durability_have = 0, durability_removing = 0; |