diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-09-30 19:46:23 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:13 -0400 |
commit | 97996ddfdb9b0b4df22913d04ce01a069a944430 (patch) | |
tree | b70b6c6d388f1f3bdf4728e7a32e484074c5fde4 /fs/bcachefs/fs-common.c | |
parent | 69294246b7a441a112d1a550ffc8e4e1e45142a4 (diff) | |
download | linux-97996ddfdb9b0b4df22913d04ce01a069a944430.tar.gz linux-97996ddfdb9b0b4df22913d04ce01a069a944430.tar.bz2 linux-97996ddfdb9b0b4df22913d04ce01a069a944430.zip |
bcachefs: bch2_subvolume_get()
Factor out a little helper.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/fs-common.c')
-rw-r--r-- | fs/bcachefs/fs-common.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/fs/bcachefs/fs-common.c b/fs/bcachefs/fs-common.c index 3e8e3c5bf870..00c7ba17f6c8 100644 --- a/fs/bcachefs/fs-common.c +++ b/fs/bcachefs/fs-common.c @@ -67,26 +67,14 @@ int bch2_create_trans(struct btree_trans *trans, if (!snapshot_src.inum) { /* Inode wasn't specified, just snapshot: */ - struct btree_iter subvol_iter; - struct bkey_s_c k; - - bch2_trans_iter_init(trans, &subvol_iter, BTREE_ID_subvolumes, - POS(0, snapshot_src.subvol), 0); - k = bch2_btree_iter_peek_slot(&subvol_iter); - - ret = bkey_err(k); - if (!ret && k.k->type != KEY_TYPE_subvolume) { - bch_err(c, "subvolume %u not found", - snapshot_src.subvol); - ret = -ENOENT; - } - - if (!ret) - snapshot_src.inum = le64_to_cpu(bkey_s_c_to_subvolume(k).v->inode); - bch2_trans_iter_exit(trans, &subvol_iter); + struct bch_subvolume s; + ret = bch2_subvolume_get(trans, snapshot_src.subvol, true, + BTREE_ITER_CACHED, &s); if (ret) goto err; + + snapshot_src.inum = le64_to_cpu(s.inode); } ret = bch2_inode_peek(trans, &inode_iter, new_inode, snapshot_src, |