mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
bcachefs: bch2_trans_update() is now __must_check
With snapshots, bch2_trans_update() has to check if we need a whitout, which can cause a transaction restart, so this is important now. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
1d81313f22
commit
94a3e1a6c1
@ -73,8 +73,8 @@ int bch2_btree_node_update_key(struct btree_trans *, struct btree_iter *,
|
||||
int bch2_btree_node_update_key_get_iter(struct btree_trans *,
|
||||
struct btree *, struct bkey_i *, bool);
|
||||
|
||||
int bch2_trans_update(struct btree_trans *, struct btree_iter *,
|
||||
struct bkey_i *, enum btree_update_flags);
|
||||
int __must_check bch2_trans_update(struct btree_trans *, struct btree_iter *,
|
||||
struct bkey_i *, enum btree_update_flags);
|
||||
void bch2_trans_commit_hook(struct btree_trans *,
|
||||
struct btree_trans_commit_hook *);
|
||||
int __bch2_trans_commit(struct btree_trans *);
|
||||
|
@ -1312,8 +1312,8 @@ static int need_whiteout_for_snapshot(struct btree_trans *trans,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bch2_trans_update(struct btree_trans *trans, struct btree_iter *iter,
|
||||
struct bkey_i *k, enum btree_update_flags flags)
|
||||
int __must_check bch2_trans_update(struct btree_trans *trans, struct btree_iter *iter,
|
||||
struct bkey_i *k, enum btree_update_flags flags)
|
||||
{
|
||||
struct btree_insert_entry *i, n;
|
||||
|
||||
|
@ -1549,7 +1549,9 @@ static int bch2_trans_mark_pointer(struct btree_trans *trans,
|
||||
goto out;
|
||||
|
||||
bch2_alloc_pack(c, a, u);
|
||||
bch2_trans_update(trans, &iter, &a->k, 0);
|
||||
ret = bch2_trans_update(trans, &iter, &a->k, 0);
|
||||
if (ret)
|
||||
goto out;
|
||||
out:
|
||||
bch2_trans_iter_exit(trans, &iter);
|
||||
return ret;
|
||||
@ -1600,7 +1602,9 @@ static int bch2_trans_mark_stripe_ptr(struct btree_trans *trans,
|
||||
stripe_blockcount_set(&s->v, p.ec.block,
|
||||
stripe_blockcount_get(&s->v, p.ec.block) +
|
||||
sectors);
|
||||
bch2_trans_update(trans, &iter, &s->k_i, 0);
|
||||
ret = bch2_trans_update(trans, &iter, &s->k_i, 0);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
bch2_bkey_to_replicas(&r.e, bkey_i_to_s_c(&s->k_i));
|
||||
r.e.data_type = data_type;
|
||||
@ -1738,7 +1742,9 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans,
|
||||
u.data_type = !deleting ? data_type : 0;
|
||||
|
||||
bch2_alloc_pack(c, a, u);
|
||||
bch2_trans_update(trans, &iter, &a->k, 0);
|
||||
ret = bch2_trans_update(trans, &iter, &a->k, 0);
|
||||
if (ret)
|
||||
goto err;
|
||||
err:
|
||||
bch2_trans_iter_exit(trans, &iter);
|
||||
return ret;
|
||||
@ -2017,7 +2023,9 @@ static int __bch2_trans_mark_metadata_bucket(struct btree_trans *trans,
|
||||
u.dirty_sectors = sectors;
|
||||
|
||||
bch2_alloc_pack(c, a, u);
|
||||
bch2_trans_update(trans, &iter, &a->k, 0);
|
||||
ret = bch2_trans_update(trans, &iter, &a->k, 0);
|
||||
if (ret)
|
||||
goto out;
|
||||
out:
|
||||
bch2_trans_iter_exit(trans, &iter);
|
||||
return ret;
|
||||
|
@ -367,7 +367,9 @@ int bch2_dirent_rename(struct btree_trans *trans,
|
||||
}
|
||||
}
|
||||
|
||||
bch2_trans_update(trans, &dst_iter, &new_dst->k_i, 0);
|
||||
ret = bch2_trans_update(trans, &dst_iter, &new_dst->k_i, 0);
|
||||
if (ret)
|
||||
goto out;
|
||||
out_set_src:
|
||||
|
||||
/*
|
||||
@ -384,7 +386,9 @@ out_set_src:
|
||||
src_update_flags |= BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE;
|
||||
}
|
||||
|
||||
bch2_trans_update(trans, &src_iter, &new_src->k_i, src_update_flags);
|
||||
ret = bch2_trans_update(trans, &src_iter, &new_src->k_i, src_update_flags);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (mode == BCH_RENAME_EXCHANGE)
|
||||
*src_offset = new_src->k.p.offset;
|
||||
|
@ -488,7 +488,7 @@ static int bch2_snapshot_node_create(struct btree_trans *trans, u32 parent,
|
||||
n = bch2_trans_kmalloc(trans, sizeof(*n));
|
||||
ret = PTR_ERR_OR_ZERO(n);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto err;
|
||||
|
||||
bkey_snapshot_init(&n->k_i);
|
||||
n->k.p = iter.pos;
|
||||
@ -498,11 +498,10 @@ static int bch2_snapshot_node_create(struct btree_trans *trans, u32 parent,
|
||||
n->v.pad = 0;
|
||||
SET_BCH_SNAPSHOT_SUBVOL(&n->v, true);
|
||||
|
||||
bch2_trans_update(trans, &iter, &n->k_i, 0);
|
||||
|
||||
ret = bch2_mark_snapshot(trans, bkey_s_c_null, bkey_i_to_s_c(&n->k_i), 0);
|
||||
ret = bch2_trans_update(trans, &iter, &n->k_i, 0) ?:
|
||||
bch2_mark_snapshot(trans, bkey_s_c_null, bkey_i_to_s_c(&n->k_i), 0);
|
||||
if (ret)
|
||||
break;
|
||||
goto err;
|
||||
|
||||
new_snapids[i] = iter.pos.offset;
|
||||
}
|
||||
@ -536,7 +535,9 @@ static int bch2_snapshot_node_create(struct btree_trans *trans, u32 parent,
|
||||
n->v.children[0] = cpu_to_le32(new_snapids[0]);
|
||||
n->v.children[1] = cpu_to_le32(new_snapids[1]);
|
||||
SET_BCH_SNAPSHOT_SUBVOL(&n->v, false);
|
||||
bch2_trans_update(trans, &iter, &n->k_i, 0);
|
||||
ret = bch2_trans_update(trans, &iter, &n->k_i, 0);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
err:
|
||||
bch2_trans_iter_exit(trans, &iter);
|
||||
@ -1049,7 +1050,9 @@ found_slot:
|
||||
|
||||
if (src_subvolid) {
|
||||
src_subvol->v.snapshot = cpu_to_le32(new_nodes[1]);
|
||||
bch2_trans_update(trans, &src_iter, &src_subvol->k_i, 0);
|
||||
ret = bch2_trans_update(trans, &src_iter, &src_subvol->k_i, 0);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
new_subvol = bch2_trans_kmalloc(trans, sizeof(*new_subvol));
|
||||
@ -1064,7 +1067,9 @@ found_slot:
|
||||
SET_BCH_SUBVOLUME_RO(&new_subvol->v, ro);
|
||||
SET_BCH_SUBVOLUME_SNAP(&new_subvol->v, src_subvolid != 0);
|
||||
new_subvol->k.p = dst_iter.pos;
|
||||
bch2_trans_update(trans, &dst_iter, &new_subvol->k_i, 0);
|
||||
ret = bch2_trans_update(trans, &dst_iter, &new_subvol->k_i, 0);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
*new_subvolid = new_subvol->k.p.offset;
|
||||
*new_snapshotid = new_nodes[0];
|
||||
|
@ -584,10 +584,10 @@ static int rand_mixed_trans(struct btree_trans *trans,
|
||||
if (!(i & 3) && k.k) {
|
||||
bkey_cookie_init(&cookie->k_i);
|
||||
cookie->k.p = iter->pos;
|
||||
bch2_trans_update(trans, iter, &cookie->k_i, 0);
|
||||
ret = bch2_trans_update(trans, iter, &cookie->k_i, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rand_mixed(struct bch_fs *c, u64 nr)
|
||||
|
Loading…
Reference in New Issue
Block a user