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/dirent.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/dirent.c')
-rw-r--r-- | fs/bcachefs/dirent.c | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index 8653a106809d..c7344ac87fcd 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -191,34 +191,15 @@ int __bch2_dirent_read_target(struct btree_trans *trans, if (likely(d.v->d_type != DT_SUBVOL)) { *inum = le64_to_cpu(d.v->d_inum); } else { - struct btree_iter iter; - struct bkey_s_c k; - struct bkey_s_c_subvolume s; + struct bch_subvolume s; int ret; *subvol = le64_to_cpu(d.v->d_inum); - bch2_trans_iter_init(trans, &iter, BTREE_ID_subvolumes, - POS(0, *subvol), - BTREE_ITER_CACHED); - k = bch2_btree_iter_peek_slot(&iter); - ret = bkey_err(k); - if (ret) - goto err; - - if (k.k->type != KEY_TYPE_subvolume) { - ret = -ENOENT; - goto err; - } - s = bkey_s_c_to_subvolume(k); - *snapshot = le32_to_cpu(s.v->snapshot); - *inum = le64_to_cpu(s.v->inode); -err: - if (ret == -ENOENT && !is_fsck) - bch2_fs_inconsistent(trans->c, "pointer to missing subvolume %u", - *subvol); + ret = bch2_subvolume_get(trans, *subvol, !is_fsck, BTREE_ITER_CACHED, &s); - bch2_trans_iter_exit(trans, &iter); + *snapshot = le32_to_cpu(s.snapshot); + *inum = le64_to_cpu(s.inode); } return ret; |