Skip to content

Commit 222eaca

Browse files
author
Kent Overstreet
committed
bcachefs: kill bch2_dev_bkey_exists() in data_update_init()
Signed-off-by: Kent Overstreet <[email protected]>
1 parent a9422fd commit 222eaca

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fs/bcachefs/data_update.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,16 @@ int bch2_data_update_init(struct btree_trans *trans,
544544
m->op.compression_opt = background_compression(io_opts);
545545
m->op.watermark = m->data_opts.btree_insert_flags & BCH_WATERMARK_MASK;
546546

547-
bkey_for_each_ptr(ptrs, ptr)
548-
bch2_dev_get(bch2_dev_bkey_exists(c, ptr->dev));
547+
bkey_for_each_ptr(ptrs, ptr) {
548+
if (!bch2_dev_tryget(c, ptr->dev)) {
549+
bkey_for_each_ptr(ptrs, ptr2) {
550+
if (ptr2 == ptr)
551+
break;
552+
bch2_dev_put(bch2_dev_have_ref(c, ptr2->dev));
553+
}
554+
return -BCH_ERR_data_update_done;
555+
}
556+
}
549557

550558
unsigned durability_have = 0, durability_removing = 0;
551559

0 commit comments

Comments
 (0)