From 011d644b769609ecf6ceef71a1411c4a9e008a5b Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 19 May 2025 09:12:49 -0400 Subject: [PATCH] bcachefs: subvol_inum_eq() Signed-off-by: Kent Overstreet --- fs/bcachefs/bcachefs.h | 3 --- fs/bcachefs/fs.c | 5 ----- fs/bcachefs/inode.h | 8 ++++++++ fs/bcachefs/namei.c | 6 ++---- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 3077f15439cd..7824da2af9d0 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -736,9 +736,6 @@ struct btree_trans_buf { struct btree_trans *trans; }; -#define BCACHEFS_ROOT_SUBVOL_INUM \ - ((subvol_inum) { BCACHEFS_ROOT_SUBVOL, BCACHEFS_ROOT_INO }) - #define BCH_WRITE_REFS() \ x(journal) \ x(trans) \ diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 9916bd38a599..ddfe89d84966 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -191,11 +191,6 @@ int bch2_fs_quota_transfer(struct bch_fs *c, return ret; } -static bool subvol_inum_eq(subvol_inum a, subvol_inum b) -{ - return a.subvol == b.subvol && a.inum == b.inum; -} - static u32 bch2_vfs_inode_hash_fn(const void *data, u32 len, u32 seed) { const subvol_inum *inum = data; diff --git a/fs/bcachefs/inode.h b/fs/bcachefs/inode.h index bb81b7c269bb..bf6624aadc56 100644 --- a/fs/bcachefs/inode.h +++ b/fs/bcachefs/inode.h @@ -309,6 +309,14 @@ bch2_inode_rebalance_opts_get(struct bch_fs *c, struct bch_inode_unpacked *inode return io_opts_to_rebalance_opts(c, &io_opts); } +#define BCACHEFS_ROOT_SUBVOL_INUM \ + ((subvol_inum) { BCACHEFS_ROOT_SUBVOL, BCACHEFS_ROOT_INO }) + +static inline bool subvol_inum_eq(subvol_inum a, subvol_inum b) +{ + return a.subvol == b.subvol && a.inum == b.inum; +} + int bch2_inode_rm_snapshot(struct btree_trans *, u64, u32); int bch2_delete_dead_inodes(struct bch_fs *); diff --git a/fs/bcachefs/namei.c b/fs/bcachefs/namei.c index 9136a9097789..ce2d34698e64 100644 --- a/fs/bcachefs/namei.c +++ b/fs/bcachefs/namei.c @@ -404,8 +404,7 @@ int bch2_rename_trans(struct btree_trans *trans, src_hash = bch2_hash_info_init(c, src_dir_u); - if (dst_dir.inum != src_dir.inum || - dst_dir.subvol != src_dir.subvol) { + if (!subvol_inum_eq(dst_dir, src_dir)) { ret = bch2_inode_peek(trans, &dst_dir_iter, dst_dir_u, dst_dir, BTREE_ITER_intent); if (ret) @@ -599,8 +598,7 @@ int bch2_inum_to_path(struct btree_trans *trans, subvol_inum inum, struct printb unsigned orig_pos = path->pos; int ret = 0; - while (!(inum.subvol == BCACHEFS_ROOT_SUBVOL && - inum.inum == BCACHEFS_ROOT_INO)) { + while (!subvol_inum_eq(inum, BCACHEFS_ROOT_SUBVOL_INUM)) { struct bch_inode_unpacked inode; ret = bch2_inode_find_by_inum_trans(trans, inum, &inode); if (ret) -- 2.25.1