]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: simplify debug print helpers without enabled printk
authorDavid Sterba <dsterba@suse.com>
Mon, 9 Jun 2025 17:09:30 +0000 (19:09 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:56:39 +0000 (23:56 +0200)
The btrfs_debug() helpers depend on various config options. In case of
"no_printk" we don't need to define a special helper that in the end
does nothing but validates the parameters. As the default build config
is to validate the parameters we can simplify it to let the debug
helpers expand to nothing and remove btrfs_no_printk_in_rcu().

To avoid warnings use fs_info and inline one variable in
extent_from_logical().

Reviewed-by: Daniel Vacek <neelx@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/backref.c
fs/btrfs/messages.h

index bebef4bd0c65929ff3c849ad9cea4d0842fe4466..2e0d959092f5b1d660997b52940ddc0ca9e4395e 100644 (file)
@@ -2201,7 +2201,6 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
        int ret;
        u64 flags;
        u64 size = 0;
-       u32 item_size;
        const struct extent_buffer *eb;
        struct btrfs_extent_item *ei;
        struct btrfs_key key;
@@ -2244,7 +2243,6 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
        }
 
        eb = path->nodes[0];
-       item_size = btrfs_item_size(eb, path->slots[0]);
 
        ei = btrfs_item_ptr(eb, path->slots[0], struct btrfs_extent_item);
        flags = btrfs_extent_flags(eb, ei);
@@ -2252,7 +2250,7 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
        btrfs_debug(fs_info,
                "logical %llu is at position %llu within the extent (%llu EXTENT_ITEM %llu) flags %#llx size %u",
                 logical, logical - found_key->objectid, found_key->objectid,
-                found_key->offset, flags, item_size);
+                found_key->offset, flags, btrfs_item_size(eb, path->slots[0]));
 
        WARN_ON(!flags_ret);
        if (flags_ret) {
index 9b78600efe0eb1afaccf5456d75f813833ced5c8..483524fccdc02595079d87ed280b76464c14d03c 100644 (file)
@@ -74,10 +74,9 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
 #define btrfs_debug_rl(fs_info, fmt, args...) \
        btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
 #else
-#define btrfs_debug(fs_info, fmt, args...) \
-       btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
-#define btrfs_debug_rl(fs_info, fmt, args...) \
-       btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
+/* When printk() is no_printk(), expand to no-op. */
+#define btrfs_debug(fs_info, fmt, args...)     do { (void)(fs_info); } while(0)
+#define btrfs_debug_rl(fs_info, fmt, args...)  do { (void)(fs_info); } while(0)
 #endif
 
 #define btrfs_printk_in_rcu(fs_info, fmt, args...)     \
@@ -87,13 +86,6 @@ do {                                                 \
        rcu_read_unlock();                              \
 } while (0)
 
-#define btrfs_no_printk_in_rcu(fs_info, fmt, args...)  \
-do {                                                   \
-       rcu_read_lock();                                \
-       btrfs_no_printk(fs_info, fmt, ##args);          \
-       rcu_read_unlock();                              \
-} while (0)
-
 #define btrfs_printk_ratelimited(fs_info, fmt, args...)                \
 do {                                                           \
        static DEFINE_RATELIMIT_STATE(_rs,                      \