]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: split btrfs_fs_closing() and change return type to bool
authorDavid Sterba <dsterba@suse.com>
Tue, 6 Jan 2026 12:30:28 +0000 (13:30 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Feb 2026 06:51:42 +0000 (07:51 +0100)
There are two tests in btrfs_fs_closing() but checking the
BTRFS_FS_CLOSING_DONE bit is done only in one place
load_extent_tree_free(). As this is an inline we can reduce size of the
generated code. The types can be also changed to bool as this becomes a
simple condition.

   text    data     bss     dec     hex filename
1674006  146704   15560 1836270  1c04ee pre/btrfs.ko
1673772  146704   15560 1836036  1c0404 post/btrfs.ko

DELTA: -234

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/fs.h

index e417aba4c4c7a0a58684d35132ef90891932f891..a1119f06b6d10680f9562c027cff1d645ab62d6c 100644 (file)
@@ -761,7 +761,7 @@ next:
        nritems = btrfs_header_nritems(leaf);
 
        while (1) {
-               if (btrfs_fs_closing(fs_info) > 1) {
+               if (btrfs_fs_closing_done(fs_info)) {
                        last = (u64)-1;
                        break;
                }
index 428b2b2391897dc4158c80676b83d794d2104895..e3e5e52e97a2a2e74e5a3e0d67fd8b9673e3c471 100644 (file)
@@ -1118,15 +1118,17 @@ void __btrfs_clear_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag,
 #define btrfs_test_opt(fs_info, opt)   ((fs_info)->mount_opt & \
                                         BTRFS_MOUNT_##opt)
 
-static inline int btrfs_fs_closing(const struct btrfs_fs_info *fs_info)
+static inline bool btrfs_fs_closing(const struct btrfs_fs_info *fs_info)
 {
-       /* Do it this way so we only ever do one test_bit in the normal case. */
-       if (test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags)) {
-               if (test_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags))
-                       return 2;
-               return 1;
-       }
-       return 0;
+       return unlikely(test_bit(BTRFS_FS_CLOSING_START, &fs_info->flags));
+}
+
+static inline bool btrfs_fs_closing_done(const struct btrfs_fs_info *fs_info)
+{
+       if (btrfs_fs_closing(fs_info) && test_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags))
+               return true;
+
+       return false;
 }
 
 /*