diff mbox series

[v2,07/16] btrfs: convert incompat and compat flag test helpers to defines

Message ID b0865d613f9bf886670806b3d2487d149b770745.1666033501.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs: split out larger chunks of ctree.h | expand

Commit Message

Josef Bacik Oct. 17, 2022, 7:09 p.m. UTC
These helpers use functions not defined in fs.h, they're simply
accessors of the super block in fs_info, convert them to define's so
that we don't have a weird dependency between fs.h and accessor.h.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/fs.h | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

Comments

David Sterba Oct. 18, 2022, 2:43 p.m. UTC | #1
On Mon, Oct 17, 2022 at 03:09:04PM -0400, Josef Bacik wrote:
> These helpers use functions not defined in fs.h, they're simply
> accessors of the super block in fs_info, convert them to define's so
> that we don't have a weird dependency between fs.h and accessor.h.

Right, we can switch inlines to macros to avoid that, though with
inlines there's type checking but we'd notice if there's a wrong type
that wouldn't have ->super_copy.
diff mbox series

Patch

diff --git a/fs/btrfs/fs.h b/fs/btrfs/fs.h
index c4786e838ee0..857caa07fd77 100644
--- a/fs/btrfs/fs.h
+++ b/fs/btrfs/fs.h
@@ -44,6 +44,12 @@  void __btrfs_set_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
 void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
 				const char *name);
 
+#define __btrfs_fs_incompat(__fs_info, flags)		\
+	(!!(btrfs_super_incompat_flags((__fs_info)->super_copy) & flags))
+
+#define __btrfs_fs_compat_ro(__fs_info, flags)		\
+	(!!(btrfs_super_compat_ro_flags((__fs_info)->super_copy) & flags))
+
 #define btrfs_set_fs_incompat(__fs_info, opt) \
 	__btrfs_set_fs_incompat((__fs_info), BTRFS_FEATURE_INCOMPAT_##opt, \
 				#opt)
@@ -66,20 +72,6 @@  void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
 #define btrfs_fs_compat_ro(fs_info, opt) \
 	__btrfs_fs_compat_ro((fs_info), BTRFS_FEATURE_COMPAT_RO_##opt)
 
-static inline bool __btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag)
-{
-	struct btrfs_super_block *disk_super;
-	disk_super = fs_info->super_copy;
-	return !!(btrfs_super_incompat_flags(disk_super) & flag);
-}
-
-static inline int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)
-{
-	struct btrfs_super_block *disk_super;
-	disk_super = fs_info->super_copy;
-	return !!(btrfs_super_compat_ro_flags(disk_super) & flag);
-}
-
 static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info)
 {
 	/*