Updates in message printers and formatters
David Sterba
maintainerHi,
this was inspired by recent Anand's post to change the printing format of the btrfs_err etc. helpers to include UUID. We do not use the helpers everywhere, so I've introduced all the missing variants that require eg printing the rcu_string (device name), are ratelimited or are both ratelimited and using rcu_string.
First part introduces macros and switches existing users, the patch 7/7 converts some printks to the helpers (avoiding mostly debugging messages).
In the end we should route all user-visile messages through some common formatter, this is preparatory work. The mount-time messages are still printk-based.
Please consider for the 4.4 dev cycle. Thanks.
----------------------------------------------------------------
The following changes since commit 9ffecb10283508260936b96022d4ee43a7798b4c:
Linux 4.3-rc3 (2015-09-27 07:50:08 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git cleanup/messages
for you to fetch changes up to f14d104dbdb5044dac9acd0e983ffb60f706c746:
btrfs: switch more printks to our helpers (2015-10-08 13:08:03 +0200)
----------------------------------------------------------------
David Sterba (7):
btrfs: introduce _in_rcu variants of message printing functions
btrfs: switch message printers to _in_rcu variants
btrfs: introduce ratelimited _in_rcu variants of message printing functions
btrfs: switch message printers to ratelimited _in_rcu variants
btrfs: introduce ratelimited variants of message printing functions
btrfs: switch message printers to ratelimited variants
btrfs: switch more printks to our helpers
fs/btrfs/check-integrity.c | 4 +-- fs/btrfs/ctree.h | 88 +++++++++++++++++++++++++++++++++++++++++++++ fs/btrfs/dev-replace.c | 16 ++++----- fs/btrfs/disk-io.c | 37 ++++++++++--------- fs/btrfs/extent-tree.c | 14 ++++---- fs/btrfs/extent_io.c | 26 +++++++------- fs/btrfs/free-space-cache.c | 10 +++--- fs/btrfs/inode.c | 7 ++-- fs/btrfs/ioctl.c | 8 ++--- fs/btrfs/root-tree.c | 5 +-- fs/btrfs/scrub.c | 42 +++++++++++----------- fs/btrfs/send.c | 2 +- fs/btrfs/volumes.c | 25 ++++++------- 13 files changed, 187 insertions(+), 97 deletions(-)
David Sterba
maintainerPATCH 1/7 btrfs: introduce _in_rcu variants of message printing functions
Due to the missing variants there are messages that lack the information printed by btrfs_info etc helpers.
--- fs/btrfs/ctree.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
fs/btrfs/ctree.h +29 -0
@@ -4039,14 +4039,43 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) #define btrfs_info(fs_info, fmt, args...) \ btrfs_printk(fs_info, KERN_INFO fmt, ##args) +/* +* Wrappers that use printk_in_rcu +*/ +#define btrfs_emerg_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_in_rcu(fs_info, KERN_EMERG fmt, ##args) +#define btrfs_alert_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_in_rcu(fs_info, KERN_ALERT fmt, ##args) +#define btrfs_crit_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_in_rcu(fs_info, KERN_CRIT fmt, ##args) +#define btrfs_err_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_in_rcu(fs_info, KERN_ERR fmt, ##args) +#define btrfs_warn_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_in_rcu(fs_info, KERN_WARNING fmt, ##args) +#define btrfs_notice_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_in_rcu(fs_info, KERN_NOTICE fmt, ##args) +#define btrfs_info_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args) +#ifdef DEBUG #define btrfs_debug(fs_info, fmt, args...) \ btrfs_printk(fs_info, KERN_DEBUG fmt, ##args) +#define btrfs_debug_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args)#else #define btrfs_debug(fs_info, fmt, args...) \ no_printk(KERN_DEBUG fmt, ##args) +#define btrfs_debug_in_rcu(fs_info, fmt, args...) \ + no_printk(KERN_DEBUG fmt, ##args)#endif +#define btrfs_printk_in_rcu(fs_info, fmt, args...) \ +do { \ + rcu_read_lock(); \ + btrfs_printk(fs_info, fmt, ##args); \ + rcu_read_unlock(); \ +} while (0) +#ifdef CONFIG_BTRFS_ASSERT __cold
Signature · 1 line
2.1.3
David Sterba
maintainerPATCH 2/7 btrfs: switch message printers to _in_rcu variants
In reply to David Sterba--- fs/btrfs/check-integrity.c | 4 ++-- fs/btrfs/dev-replace.c | 16 ++++++++-------- fs/btrfs/ioctl.c | 2 +- fs/btrfs/scrub.c | 14 +++++++------- fs/btrfs/volumes.c | 18 +++++++++--------- 5 files changed, 27 insertions(+), 27 deletions(-)
fs/btrfs/check-integrity.c +2 -2
@@ -845,8 +845,8 @@ static int btrfsic_process_superblock_dev_mirror( superblock_tmp->never_written =0 ; superblock_tmp->mirror_num =1 + superblock_mirror_num;if (state->print_mask &BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE ) - printk_in_rcu(KERN_INFO "New initial S-block (bdev %p, %s)" - " @%llu (%s/%llu/%d)\n", + btrfs_info_in_rcu(device->dev_root->fs_info, + "new initial S-block (bdev %p, %s) @%llu (%s/%llu/%d)", superblock_bdev, rcu_str_deref(device->name), dev_bytenr, dev_state->name, dev_bytenr,
fs/btrfs/dev-replace.c +8 -8
@@ -379,8 +379,8 @@ int btrfs_dev_replace_start(struct btrfs_root *root,if (ret)btrfs_err (root->fs_info,"kobj add dev failed %d\n" , ret); - printk_in_rcu(KERN_INFO - "BTRFS: dev_replace from %s (devid %llu) to %s started\n", + btrfs_info_in_rcu(root->fs_info, + "dev_replace from %s (devid %llu) to %s started", src_device->missing ? "<missing disk>" : rcu_str_deref(src_device->name), src_device->devid,
@@ -523,8 +523,8 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, src_device, tgt_device); }else { - printk_in_rcu(KERN_ERR - "BTRFS: btrfs_scrub_dev(%s, %llu, %s) failed %d\n", + btrfs_err_in_rcu(root->fs_info, + "btrfs_scrub_dev(%s, %llu, %s) failed %d", src_device->missing ? "<missing disk>" : rcu_str_deref(src_device->name), src_device->devid,
@@ -540,8 +540,8 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,return scrub_ret; } - printk_in_rcu(KERN_INFO - "BTRFS: dev_replace from %s (devid %llu) to %s finished\n", + btrfs_info_in_rcu(root->fs_info, + "dev_replace from %s (devid %llu) to %s finished", src_device->missing ? "<missing disk>" : rcu_str_deref(src_device->name), src_device->devid,
@@ -809,8 +809,8 @@ static int btrfs_dev_replace_kthread(void *data) progress = status_args->status.progress_1000;kfree (status_args); progress =div_u64 (progress,10 ); - printk_in_rcu(KERN_INFO - "BTRFS: continuing dev_replace from %s (devid %llu) to %s @%u%%\n", + btrfs_info_in_rcu(fs_info, + "continuing dev_replace from %s (devid %llu) to %s @%u%%", dev_replace->srcdev->missing ? "<missing disk>" : rcu_str_deref(dev_replace->srcdev->name), dev_replace->srcdev->devid,
fs/btrfs/ioctl.c +1 -1
@@ -1579,7 +1579,7 @@ static noinline int btrfs_ioctl_resize(struct file *file, new_size =div_u64 (new_size, root->sectorsize); new_size *= root->sectorsize; -printk_in_rcu (KERN_INFO "BTRFS: new size for %s is %llu\n" , +btrfs_info_in_rcu (root->fs_info,"new size for %s is %llu" ,rcu_str_deref (device->name), new_size);if (new_size > old_size) {
fs/btrfs/scrub.c +7 -7
@@ -580,9 +580,9 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,* hold all of the paths here */ for (i =0 ; i < ipath->fspath->elem_cnt; ++i) - printk_in_rcu(KERN_WARNING "BTRFS: %s at logical %llu on dev " + btrfs_warn_in_rcu(fs_info, "%s at logical %llu on dev " "%s, sector %llu, root %llu, inode %llu, offset %llu, " - "length %llu, links %u (path: %s)\n", swarn->errstr, + "length %llu, links %u (path: %s)", swarn->errstr, swarn->logical, rcu_str_deref(swarn->dev->name), (unsigned long long)swarn->sector, root, inum, offset, min(isize - offset, (u64)PAGE_SIZE), nlink,
@@ -592,9 +592,9 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,return 0 ; err: -printk_in_rcu (KERN_WARNING "BTRFS: %s at logical %llu on dev " +btrfs_warn_in_rcu (fs_info,"%s at logical %llu on dev " "%s, sector %llu, root %llu, inode %llu, offset %llu: path " -"resolving failed with ret=%d\n" , swarn->errstr, +"resolving failed with ret=%d" , swarn->errstr, swarn->logical,rcu_str_deref (swarn->dev->name), (unsigned long long )swarn->sector, root, inum, offset, ret);
@@ -649,10 +649,10 @@ static void scrub_print_warning(const char *errstr, struct scrub_block *sblock) ret =tree_backref_for_extent (&ptr, eb, &found_key, ei, item_size, &ref_root, &ref_level); - printk_in_rcu(KERN_WARNING - "BTRFS: %s at logical %llu on dev %s, " + btrfs_warn_in_rcu(fs_info, + "%s at logical %llu on dev %s, " "sector %llu: metadata %s (level %d) in tree " - "%llu\n", errstr, swarn.logical, + "%llu", errstr, swarn.logical, rcu_str_deref(dev->name), (unsigned long long)swarn.sector, ref_level ? "node" : "leaf",
fs/btrfs/volumes.c +9 -9
@@ -6594,8 +6594,8 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans,BUG_ON (!path); ret =btrfs_search_slot (trans, dev_root, &key, path,-1 ,1 );if (ret <0 ) { -printk_in_rcu (KERN_WARNING "BTRFS: " -"error %d while searching for dev_stats item for device %s!\n" , +btrfs_warn_in_rcu (dev_root->fs_info, +"error %d while searching for dev_stats item for device %s" , ret,rcu_str_deref (device->name)); goto out; }
@@ -6605,8 +6605,8 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans,/* need to delete old one and insert a new one */ ret =btrfs_del_item (trans, dev_root, path);if (ret !=0 ) { -printk_in_rcu (KERN_WARNING "BTRFS: " -"delete too small dev_stats item for device %s failed %d!\n" , +btrfs_warn_in_rcu (dev_root->fs_info, +"delete too small dev_stats item for device %s failed %d" ,rcu_str_deref (device->name), ret); goto out; }
@@ -6619,9 +6619,9 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans, ret =btrfs_insert_empty_item (trans, dev_root, path, &key,sizeof (*ptr));if (ret <0 ) { -printk_in_rcu (KERN_WARNING "BTRFS: " -"insert dev_stats item for device %s failed %d!\n" , -rcu_str_deref (device->name), ret); +btrfs_warn_in_rcu (dev_root->fs_info, +"insert dev_stats item for device %s failed %d" , +rcu_str_deref (device->name), ret); goto out; } }
@@ -6695,8 +6695,8 @@ static void btrfs_dev_stat_print_on_load(struct btrfs_device *dev)if (i ==BTRFS_DEV_STAT_VALUES_MAX )return ;/* all values == 0, suppress message */ - printk_in_rcu(KERN_INFO "BTRFS: " - "bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u\n", + btrfs_info_in_rcu(dev->dev_root->fs_info, + "bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u", rcu_str_deref(dev->name), btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS), btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_READ_ERRS),
Signature · 1 line
2.1.3
David Sterba
maintainerPATCH 3/7 btrfs: introduce ratelimited _in_rcu variants of message printing functions
In reply to David Sterba--- fs/btrfs/ctree.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
fs/btrfs/ctree.h +38 -0
@@ -4057,16 +4057,38 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) #define btrfs_info_in_rcu(fs_info, fmt, args...) \ btrfs_printk_in_rcu(fs_info, KERN_INFO fmt, ##args) +/* +* Wrappers that use a ratelimited printk_in_rcu +*/ +#define btrfs_emerg_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_EMERG fmt, ##args) +#define btrfs_alert_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_ALERT fmt, ##args) +#define btrfs_crit_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_CRIT fmt, ##args) +#define btrfs_err_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_ERR fmt, ##args) +#define btrfs_warn_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_WARNING fmt, ##args) +#define btrfs_notice_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_NOTICE fmt, ##args) +#define btrfs_info_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args) +#ifdef DEBUG #define btrfs_debug(fs_info, fmt, args...) \ btrfs_printk(fs_info, KERN_DEBUG fmt, ##args) #define btrfs_debug_in_rcu(fs_info, fmt, args...) \ btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args) +#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args)#else #define btrfs_debug(fs_info, fmt, args...) \ no_printk(KERN_DEBUG fmt, ##args) #define btrfs_debug_in_rcu(fs_info, fmt, args...) \ no_printk(KERN_DEBUG fmt, ##args) +#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \ + no_printk(KERN_DEBUG fmt, ##args)#endif #define btrfs_printk_in_rcu(fs_info, fmt, args...) \
@@ -4076,6 +4098,22 @@ do { \rcu_read_unlock (); \ }while (0 ) +#define btrfs_printk_ratelimited(fs_info, fmt, args...) \ +do { \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ +if (__ratelimit (&_rs)) \ + btrfs_printk(fs_info, fmt, ##args); \ +} while (0) + +#define btrfs_printk_rl_in_rcu(fs_info, fmt, args...) \ +do { \ + rcu_read_lock(); \ + btrfs_printk_ratelimited(fs_info, fmt, ##args); \ + rcu_read_unlock(); \ +} while (0) +#ifdef CONFIG_BTRFS_ASSERT __cold
Signature · 1 line
2.1.3
David Sterba
maintainerPATCH 4/7 btrfs: switch message printers to ratelimited _in_rcu variants
In reply to David Sterba--- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/scrub.c | 20 ++++++++++---------- fs/btrfs/volumes.c | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-)
fs/btrfs/disk-io.c +2 -2
@@ -3175,8 +3175,8 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)struct btrfs_device *device = (struct btrfs_device *) bh->b_private; -printk_ratelimited_in_rcu (KERN_WARNING "BTRFS: lost page write due to " -"I/O error on %s\n" , +btrfs_warn_rl_in_rcu (device->dev_root->fs_info, +"lost page write due to IO error on %s" ,rcu_str_deref (device->name));/* note, we dont' set_buffer_write_io_error because we have * our own ways of dealing with the IO errors
fs/btrfs/extent_io.c +2 -2
@@ -2078,8 +2078,8 @@ int repair_io_failure(struct inode *inode, u64 start, u64 length, u64 logical,return -EIO ; } -printk_ratelimited_in_rcu (KERN_INFO -"BTRFS: read error corrected: ino %llu off %llu (dev %s sector %llu)\n" , +btrfs_info_rl_in_rcu (fs_info, +"read error corrected: ino %llu off %llu (dev %s sector %llu)" ,btrfs_ino (inode), start,rcu_str_deref (dev->name), sector);bio_put (bio);
fs/btrfs/scrub.c +10 -10
@@ -850,8 +850,8 @@ static void scrub_fixup_nodatasum(struct btrfs_work *work)btrfs_dev_replace_stats_inc ( &sctx->dev_root->fs_info->dev_replace. num_uncorrectable_read_errors); -printk_ratelimited_in_rcu (KERN_ERR "BTRFS: " -"unable to fixup (nodatasum) error at logical %llu on dev %s\n" , +btrfs_err_rl_in_rcu (sctx->dev_root->fs_info, +"unable to fixup (nodatasum) error at logical %llu on dev %s" , fixup->logical,rcu_str_deref (fixup->dev->name)); }
@@ -1230,8 +1230,8 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check) sctx->stat.corrected_errors++; sblock_to_check->data_corrected =1 ;spin_unlock (&sctx->stat_lock); -printk_ratelimited_in_rcu (KERN_ERR -"BTRFS: fixed up error at logical %llu on dev %s\n" , +btrfs_err_rl_in_rcu (fs_info, +"fixed up error at logical %llu on dev %s" , logical,rcu_str_deref (dev->name)); } }else {
@@ -1239,8 +1239,8 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)spin_lock (&sctx->stat_lock); sctx->stat.uncorrectable_errors++;spin_unlock (&sctx->stat_lock); -printk_ratelimited_in_rcu (KERN_ERR -"BTRFS: unable to fixup (regular) error at logical %llu on dev %s\n" , +btrfs_err_rl_in_rcu (fs_info, +"unable to fixup (regular) error at logical %llu on dev %s" , logical,rcu_str_deref (dev->name)); }
@@ -2201,15 +2201,15 @@ static void scrub_missing_raid56_worker(struct btrfs_work *work)spin_lock (&sctx->stat_lock); sctx->stat.read_errors++;spin_unlock (&sctx->stat_lock); -printk_ratelimited_in_rcu (KERN_ERR -"BTRFS: I/O error rebulding logical %llu for dev %s\n" , +btrfs_err_rl_in_rcu (fs_info, +"IO error rebuilding logical %llu for dev %s" , logical,rcu_str_deref (dev->name)); }else if (sblock->header_error || sblock->checksum_error) {spin_lock (&sctx->stat_lock); sctx->stat.uncorrectable_errors++;spin_unlock (&sctx->stat_lock); -printk_ratelimited_in_rcu (KERN_ERR -"BTRFS: failed to rebuild valid logical %llu for dev %s\n" , +btrfs_err_rl_in_rcu (fs_info, +"failed to rebuild valid logical %llu for dev %s" , logical,rcu_str_deref (dev->name)); }else {scrub_write_block_to_dev_replace (sblock);
fs/btrfs/volumes.c +2 -2
@@ -6675,8 +6675,8 @@ static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev) {if (!dev->dev_stats_valid)return ; - printk_ratelimited_in_rcu(KERN_ERR "BTRFS: " - "bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u\n", + btrfs_err_rl_in_rcu(dev->dev_root->fs_info, + "bdev %s errs: wr %u, rd %u, flush %u, corrupt %u, gen %u", rcu_str_deref(dev->name), btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS), btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_READ_ERRS),
Signature · 1 line
2.1.3
David Sterba
maintainerPATCH 5/7 btrfs: introduce ratelimited variants of message printing functions
In reply to David Sterba--- fs/btrfs/ctree.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
fs/btrfs/ctree.h +21 -0
@@ -4075,6 +4075,23 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) #define btrfs_info_rl_in_rcu(fs_info, fmt, args...) \ btrfs_printk_rl_in_rcu(fs_info, KERN_INFO fmt, ##args) +/* +* Wrappers that use a ratelimited printk +*/ +#define btrfs_emerg_rl(fs_info, fmt, args...) \ + btrfs_printk_ratelimited(fs_info, KERN_EMERG fmt, ##args) +#define btrfs_alert_rl(fs_info, fmt, args...) \ + btrfs_printk_ratelimited(fs_info, KERN_ALERT fmt, ##args) +#define btrfs_crit_rl(fs_info, fmt, args...) \ + btrfs_printk_ratelimited(fs_info, KERN_CRIT fmt, ##args) +#define btrfs_err_rl(fs_info, fmt, args...) \ + btrfs_printk_ratelimited(fs_info, KERN_ERR fmt, ##args) +#define btrfs_warn_rl(fs_info, fmt, args...) \ + btrfs_printk_ratelimited(fs_info, KERN_WARNING fmt, ##args) +#define btrfs_notice_rl(fs_info, fmt, args...) \ + btrfs_printk_ratelimited(fs_info, KERN_NOTICE fmt, ##args) +#define btrfs_info_rl(fs_info, fmt, args...) \ + btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args)#ifdef DEBUG #define btrfs_debug(fs_info, fmt, args...) \ btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
@@ -4082,6 +4099,8 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args) #define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \ btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, ##args) +#define btrfs_debug_rl(fs_info, fmt, args...) \ + btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt, ##args)#else #define btrfs_debug(fs_info, fmt, args...) \ no_printk(KERN_DEBUG fmt, ##args)
@@ -4089,6 +4108,8 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) no_printk(KERN_DEBUG fmt, ##args) #define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \ no_printk(KERN_DEBUG fmt, ##args) +#define btrfs_debug_rl(fs_info, fmt, args...) \ + no_printk(KERN_DEBUG fmt, ##args)#endif #define btrfs_printk_in_rcu(fs_info, fmt, args...) \
Signature · 1 line
2.1.3
David Sterba
maintainerPATCH 6/7 btrfs: switch message printers to ratelimited variants
In reply to David Sterba--- fs/btrfs/disk-io.c | 21 ++++++++++----------- fs/btrfs/extent-tree.c | 14 ++++++++------ fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/free-space-cache.c | 10 +++++----- fs/btrfs/inode.c | 7 ++----- fs/btrfs/scrub.c | 8 ++++---- 6 files changed, 31 insertions(+), 33 deletions(-)
fs/btrfs/disk-io.c +10 -11
@@ -319,9 +319,9 @@ static int csum_tree_block(struct btrfs_fs_info *fs_info,memcpy (&found, result, csum_size);read_extent_buffer (buf, &val,0 , csum_size); -printk_ratelimited (KERN_WARNING -"BTRFS: %s checksum verify failed on %llu wanted %X found %X " -"level %d\n" , +btrfs_warn_rl (fs_info, +"%s checksum verify failed on %llu wanted %X found %X " +"level %d" , fs_info->sb->s_id, buf->start, val, found,btrfs_header_level (buf));if (result != (char *)&inline_result)
@@ -368,9 +368,9 @@ static int verify_parent_transid(struct extent_io_tree *io_tree, ret =0 ; goto out; } -printk_ratelimited (KERN_ERR -"BTRFS (device %s): parent transid verify failed on %llu wanted %llu found %llu\n" , - eb->fs_info->sb->s_id, eb->start, +btrfs_err_rl (eb->fs_info, +"parent transid verify failed on %llu wanted %llu found %llu" , + eb->start, parent_transid,btrfs_header_generation (eb)); ret =1 ;
@@ -629,15 +629,14 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, found_start =btrfs_header_bytenr (eb);if (found_start != eb->start) { -printk_ratelimited (KERN_ERR "BTRFS (device %s): bad tree block start " -"%llu %llu\n" , - eb->fs_info->sb->s_id, found_start, eb->start); +btrfs_err_rl (eb->fs_info,"bad tree block start %llu %llu" , + found_start, eb->start); ret = -EIO ; goto err; }if (check_tree_block_fsid (root->fs_info, eb)) { -printk_ratelimited (KERN_ERR "BTRFS (device %s): bad fsid on block %llu\n" , - eb->fs_info->sb->s_id, eb->start); +btrfs_err_rl (eb->fs_info,"bad fsid on block %llu" , + eb->start); ret = -EIO ; goto err; }
fs/btrfs/extent-tree.c +8 -6
@@ -8271,10 +8271,11 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, ret =account_shared_subtree (trans, root, next, generation, level -1 );if (ret) { -printk_ratelimited (KERN_ERR "BTRFS: %s Error " +btrfs_err_rl (root->fs_info, +"Error " "%d accounting shared subtree. Quota " -"is out of sync, rescan required.\n" , - root->fs_info->sb->s_id, ret); +"is out of sync, rescan required." , + ret); } } ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent,
@@ -8363,10 +8364,11 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,BUG_ON (ret);/* -ENOMEM */ ret =account_leaf_items (trans, root, eb);if (ret) { -printk_ratelimited (KERN_ERR "BTRFS: %s Error " +btrfs_err_rl (root->fs_info, +"error " "%d accounting leaf items. Quota " -"is out of sync, rescan required.\n" , - root->fs_info->sb->s_id, ret); +"is out of sync, rescan required." , + ret); } }/* make block locked assertion in clean_tree_block happy */
fs/btrfs/extent_io.c +2 -2
@@ -96,8 +96,8 @@ static inline void __btrfs_debug_check_extent_io_range(const char *caller, inode = tree->mapping->host; isize =i_size_read (inode);if (end >=PAGE_SIZE && (end %2 ) ==0 && end != isize -1 ) { -printk_ratelimited (KERN_DEBUG -"BTRFS: %s: ino %llu isize %llu odd range [%llu,%llu]\n" , +btrfs_debug_rl (BTRFS_I (inode)->root->fs_info, +"%s: ino %llu isize %llu odd range [%llu,%llu]" , caller,btrfs_ino (inode), isize, start, end); } }
fs/btrfs/free-space-cache.c +5 -5
@@ -450,9 +450,9 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation) gen = io_ctl->cur;if (le64_to_cpu (*gen) != generation) { -printk_ratelimited (KERN_ERR "BTRFS: space cache generation " -"(%Lu) does not match inode (%Lu)\n" , *gen, - generation); +btrfs_err_rl (io_ctl->root->fs_info, +"space cache generation (%llu) does not match inode (%llu)" , + *gen, generation);io_ctl_unmap_page (io_ctl);return -EIO ; }
@@ -506,8 +506,8 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index) PAGE_CACHE_SIZE - offset);btrfs_csum_final (crc, (char *)&crc);if (val != crc) { -printk_ratelimited (KERN_ERR "BTRFS: csum mismatch on free " -"space cache\n" ); +btrfs_err_rl (io_ctl->root->fs_info, +"csum mismatch on free space cache" );io_ctl_unmap_page (io_ctl);return -EIO ; }
fs/btrfs/inode.c +2 -5
@@ -3018,8 +3018,6 @@ static int __readpage_endio_check(struct inode *inode,char *kaddr;u32 csum_expected;u32 csum = ~(u32 )0 ; - static DEFINE_RATELIMIT_STATE(_rs, DEFAULT_RATELIMIT_INTERVAL, - DEFAULT_RATELIMIT_BURST); csum_expected = *(((u32 *)io_bio->csum) + icsum);
@@ -3032,9 +3030,8 @@ static int __readpage_endio_check(struct inode *inode,kunmap_atomic (kaddr);return 0 ; zeroit: -if (__ratelimit (&_rs)) -btrfs_warn (BTRFS_I (inode)->root->fs_info, -"csum failed ino %llu off %llu csum %u expected csum %u" , +btrfs_warn_rl (BTRFS_I (inode)->root->fs_info, +"csum failed ino %llu off %llu csum %u expected csum %u" ,btrfs_ino (inode), start, csum, csum_expected);memset (kaddr + pgoff,1 , len);flush_dcache_page (page);
fs/btrfs/scrub.c +4 -4
@@ -1626,9 +1626,9 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,int ret;if (!page_bad->dev->bdev) { -printk_ratelimited (KERN_WARNING "BTRFS: " +btrfs_warn_rl (sblock_bad->sctx->dev_root->fs_info,"scrub_repair_page_from_good_copy(bdev == NULL) " -"is unexpected!\n" ); +"is unexpected" );return -EIO ; }
@@ -4375,8 +4375,8 @@ static int write_page_nocow(struct scrub_ctx *sctx,if (!dev)return -EIO ;if (!dev->bdev) { -printk_ratelimited (KERN_WARNING -"BTRFS: scrub write_page_nocow(bdev == NULL) is unexpected!\n" ); +btrfs_warn_rl (dev->dev_root->fs_info, +"scrub write_page_nocow(bdev == NULL) is unexpected" );return -EIO ; } bio =btrfs_io_bio_alloc (GFP_NOFS ,1 );
Signature · 1 line
2.1.3
David Sterba
maintainerPATCH 7/7 btrfs: switch more printks to our helpers
In reply to David SterbaConvert the simple cases, not all functions provide a way to reach the fs_info. Also skipped debugging messages (print-tree, integrity checker and pr_debug) and messages that are printed from possibly unfinished mount.
--- fs/btrfs/disk-io.c | 12 ++++++------ fs/btrfs/extent_io.c | 18 ++++++++++-------- fs/btrfs/ioctl.c | 6 +++--- fs/btrfs/root-tree.c | 5 +++-- fs/btrfs/send.c | 2 +- fs/btrfs/volumes.c | 3 ++- 6 files changed, 25 insertions(+), 21 deletions(-)
fs/btrfs/disk-io.c +6 -6
@@ -2347,8 +2347,7 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,u64 bytenr =btrfs_super_log_root (disk_super);if (fs_devices->rw_devices ==0 ) { -printk (KERN_WARNING "BTRFS: log replay required " -"on RO media\n" ); +btrfs_warn (fs_info,"log replay required on RO media" );return -EIO ; }
@@ -2363,12 +2362,12 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info, log_tree_root->node =read_tree_block (tree_root, bytenr, fs_info->generation +1 );if (IS_ERR (log_tree_root->node)) { -printk (KERN_ERR "BTRFS: failed to read log tree\n" ); +btrfs_warn (fs_info,"failed to read log tree" ); ret =PTR_ERR (log_tree_root->node);kfree (log_tree_root);return ret; }else if (!extent_buffer_uptodate (log_tree_root->node)) { -printk (KERN_ERR "BTRFS: failed to read log tree\n" ); +btrfs_err (fs_info,"failed to read log tree" );free_extent_buffer (log_tree_root->node);kfree (log_tree_root);return -EIO ;
@@ -3294,8 +3293,9 @@ static int write_dev_supers(struct btrfs_device *device, bh =__getblk (device->bdev, bytenr /4096 ,BTRFS_SUPER_INFO_SIZE );if (!bh) { -printk (KERN_ERR "BTRFS: couldn't get super " -"buffer head for bytenr %Lu\n" , bytenr); +btrfs_err (device->dev_root->fs_info, +"couldn't get super buffer head for bytenr %llu" , + bytenr); errors++;continue ; }
fs/btrfs/extent_io.c +10 -8
@@ -5563,13 +5563,15 @@ void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,unsigned long src_i;if (src_offset + len > dst->len) { -printk (KERN_ERR "BTRFS: memmove bogus src_offset %lu move " -"len %lu dst len %lu\n" , src_offset, len, dst->len); +btrfs_err (dst->fs_info, +"memmove bogus src_offset %lu move " +"len %lu dst len %lu" , src_offset, len, dst->len);BUG_ON (1 ); }if (dst_offset + len > dst->len) { -printk (KERN_ERR "BTRFS: memmove bogus dst_offset %lu move " -"len %lu dst len %lu\n" , dst_offset, len, dst->len); +btrfs_err (dst->fs_info, +"memmove bogus dst_offset %lu move " +"len %lu dst len %lu" , dst_offset, len, dst->len);BUG_ON (1 ); }
@@ -5609,13 +5611,13 @@ void memmove_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,unsigned long src_i;if (src_offset + len > dst->len) { -printk (KERN_ERR "BTRFS: memmove bogus src_offset %lu move " -"len %lu len %lu\n" , src_offset, len, dst->len); +btrfs_err (dst->fs_info,"memmove bogus src_offset %lu move " +"len %lu len %lu" , src_offset, len, dst->len);BUG_ON (1 ); }if (dst_offset + len > dst->len) { -printk (KERN_ERR "BTRFS: memmove bogus dst_offset %lu move " -"len %lu len %lu\n" , dst_offset, len, dst->len); +btrfs_err (dst->fs_info,"memmove bogus dst_offset %lu move " +"len %lu len %lu" , dst_offset, len, dst->len);BUG_ON (1 ); }if (dst_offset < src_offset) {
fs/btrfs/ioctl.c +3 -3
@@ -1342,7 +1342,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,break ;if (btrfs_defrag_cancelled (root->fs_info)) { -printk (KERN_DEBUG "BTRFS: defrag_file cancelled\n" ); +btrfs_debug (root->fs_info,"defrag_file cancelled" ); ret = -EAGAIN ;break ; }
@@ -2081,7 +2081,7 @@ static noinline int search_ioctl(struct inode *inode, key.offset = (u64)-1 ; root =btrfs_read_fs_root_no_name (info, &key);if (IS_ERR (root)) { -printk (KERN_ERR "BTRFS: could not find root %llu\n" , +btrfs_err (info,"could not find root %llu" , sk->tree_id);btrfs_free_path (path);return -ENOENT ;
@@ -2221,7 +2221,7 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info, key.offset = (u64)-1 ; root =btrfs_read_fs_root_no_name (info, &key);if (IS_ERR (root)) { -printk (KERN_ERR "BTRFS: could not find root %llu\n" , tree_id); +btrfs_err (info,"could not find root %llu" , tree_id); ret = -ENOENT ; goto out; }
fs/btrfs/root-tree.c +3 -2
@@ -45,12 +45,13 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot,if (!need_reset &&btrfs_root_generation (item) !=btrfs_root_generation_v2 (item)) {if (btrfs_root_generation_v2 (item) !=0 ) { -printk (KERN_WARNING "BTRFS: mismatching " +btrfs_warn (eb->fs_info, +"mismatching " "generation and generation_v2 " "found in root item. This root " "was probably mounted with an " "older kernel. Resetting all " -"new fields.\n" ); +"new fields." ); } need_reset =1 ; }
fs/btrfs/send.c +1 -1
@@ -2562,7 +2562,7 @@ verbose_printk("btrfs: send_create_inode %llu\n", ino); }else if (S_ISSOCK (mode)) { cmd =BTRFS_SEND_C_MKSOCK ; }else { -printk (KERN_WARNING "btrfs: unexpected inode type %o" , +btrfs_warn (sctx->send_root->fs_info,"unexpected inode type %o" , (int )(mode &S_IFMT )); ret = -ENOTSUPP ; goto out;
fs/btrfs/volumes.c +2 -1
@@ -2352,7 +2352,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) root->fs_info->fsid);if (kobject_rename (&root->fs_info->fs_devices->super_kobj, fsid_buf)) -pr_warn ("BTRFS: sysfs: failed to create fsid for sprout\n" ); +btrfs_warn (root->fs_info, +"sysfs: failed to create fsid for sprout" ); } root->fs_info->num_tolerated_disk_barrier_failures =
Signature · 1 line
2.1.3