Skip to content

Commit 266d244

Browse files
committed
btrfs: simplify debug print helpers without enabled printk
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>
1 parent 9328875 commit 266d244

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

fs/btrfs/backref.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,7 +2201,6 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
22012201
int ret;
22022202
u64 flags;
22032203
u64 size = 0;
2204-
u32 item_size;
22052204
const struct extent_buffer *eb;
22062205
struct btrfs_extent_item *ei;
22072206
struct btrfs_key key;
@@ -2244,15 +2243,14 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
22442243
}
22452244

22462245
eb = path->nodes[0];
2247-
item_size = btrfs_item_size(eb, path->slots[0]);
22482246

22492247
ei = btrfs_item_ptr(eb, path->slots[0], struct btrfs_extent_item);
22502248
flags = btrfs_extent_flags(eb, ei);
22512249

22522250
btrfs_debug(fs_info,
22532251
"logical %llu is at position %llu within the extent (%llu EXTENT_ITEM %llu) flags %#llx size %u",
22542252
logical, logical - found_key->objectid, found_key->objectid,
2255-
found_key->offset, flags, item_size);
2253+
found_key->offset, flags, btrfs_item_size(eb, path->slots[0]));
22562254

22572255
WARN_ON(!flags_ret);
22582256
if (flags_ret) {

fs/btrfs/messages.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...);
7474
#define btrfs_debug_rl(fs_info, fmt, args...) \
7575
btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
7676
#else
77-
#define btrfs_debug(fs_info, fmt, args...) \
78-
btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
79-
#define btrfs_debug_rl(fs_info, fmt, args...) \
80-
btrfs_no_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)
77+
/* When printk() is no_printk(), expand to no-op. */
78+
#define btrfs_debug(fs_info, fmt, args...) do { (void)(fs_info); } while(0)
79+
#define btrfs_debug_rl(fs_info, fmt, args...) do { (void)(fs_info); } while(0)
8180
#endif
8281

8382
#define btrfs_printk_in_rcu(fs_info, fmt, args...) \
@@ -87,13 +86,6 @@ do { \
8786
rcu_read_unlock(); \
8887
} while (0)
8988

90-
#define btrfs_no_printk_in_rcu(fs_info, fmt, args...) \
91-
do { \
92-
rcu_read_lock(); \
93-
btrfs_no_printk(fs_info, fmt, ##args); \
94-
rcu_read_unlock(); \
95-
} while (0)
96-
9789
#define btrfs_printk_ratelimited(fs_info, fmt, args...) \
9890
do { \
9991
static DEFINE_RATELIMIT_STATE(_rs, \

0 commit comments

Comments
 (0)