fat: add fat_msg_ratelimit.
PATCH 1/2 fat: add fat_msg_ratelimit.
I tried to add fat_msg_ratelimit to limit many message at once.
--- fs/fat/fat.h | 9 +++++++-- fs/fat/misc.c | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-)
fs/fat/fat.h +7 -2
@@ -333,8 +333,13 @@ void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...); __fat_fs_error(sb, 1, fmt , ## args) #define fat_fs_error_ratelimit(sb, fmt, args...) \ __fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args) -__printf(3, 4) __cold -void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...); +__printf(4, 5) __cold +void __fat_msg(struct super_block *sb, int report, const char *level, + const char *fmt, ...); +#define fat_msg(sb, level, fmt, args...) \ + __fat_msg(sb, 1, level, fmt, ## args) +#define fat_msg_ratelimit(sb, level, fmt, args...) \ + __fat_msg(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), level, fmt, ## args) extern int fat_clusters_flush(struct super_block *sb); extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
fs/fat/misc.c +10 -8
@@ -45,19 +45,21 @@ void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...)EXPORT_SYMBOL_GPL (__fat_fs_error);/** -* fat_msg() - print preformated FAT specific messages. Every thing what is +* __fat_msg() - print preformated FAT specific messages. Every thing what is * not fat_fs_error() should be fat_msg(). */ -void fat_msg (struct super_block *sb,const char *level,const char *fmt, ...) +void __fat_msg (struct super_block *sb,int report,const char *level, +const char *fmt, ...) {struct va_format vaf;va_list args; - -va_start (args, fmt); - vaf.fmt = fmt; - vaf.va = &args; -printk ("%sFAT-fs (%s): %pV\n" , level, sb->s_id, &vaf); -va_end (args); +if (report) { +va_start (args, fmt); + vaf.fmt = fmt; + vaf.va = &args; +printk ("%sFAT-fs (%s): %pV\n" , level, sb->s_id, &vaf); +va_end (args); + } }/* Flushes the number of free clusters on FAT32 */
Signature · 1 line
1.7.5.4
Quoted 4 lines · Namjae Jeon
I tried to add
fat_msg_ratelimitto limit many message at once.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Amit Sahrawat <[email protected]>
Looks fine.
Thanks.
Quoted 59 lines
--- fs/fat/fat.h | 9 +++++++-- fs/fat/misc.c | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-)fs/fat/fat.h +7
-2@@ -333,8 +333,13 @@ void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...); __fat_fs_error(sb, 1, fmt , ## args) #define fat_fs_error_ratelimit(sb, fmt, args...) \ __fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args) -__printf(3, 4) __cold -void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...); +__printf(4, 5) __cold +void __fat_msg(struct super_block *sb, int report, const char *level, + const char *fmt, ...); +#define fat_msg(sb, level, fmt, args...) \ + __fat_msg(sb, 1, level, fmt, ## args) +#define fat_msg_ratelimit(sb, level, fmt, args...) \ + __fat_msg(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), level, fmt, ## args) extern int fat_clusters_flush(struct super_block *sb); extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,fs/fat/misc.c +10
-8@@ -45,19 +45,21 @@ void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...)EXPORT_SYMBOL_GPL (__fat_fs_error);/** -* fat_msg() - print preformated FAT specific messages. Every thing what is +* __fat_msg() - print preformated FAT specific messages. Every thing what is * not fat_fs_error() should be fat_msg(). */ -void fat_msg (struct super_block *sb,const char *level,const char *fmt, ...) +void __fat_msg (struct super_block *sb,int report,const char *level, +const char *fmt, ...) {struct va_format vaf;va_list args; - -va_start (args, fmt); - vaf.fmt = fmt; - vaf.va = &args; -printk ("%sFAT-fs (%s): %pV\n" , level, sb->s_id, &vaf); -va_end (args); +if (report) { +va_start (args, fmt); + vaf.fmt = fmt; + vaf.va = &args; +printk ("%sFAT-fs (%s): %pV\n" , level, sb->s_id, &vaf); +va_end (args); + } }/* Flushes the number of free clusters on FAT32 */
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Quoted 16 lines · Namjae Jeon
I tried to add
fat_msg_ratelimitto limit many message at once.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Amit Sahrawat <[email protected]>--- fs/fat/fat.h | 9 +++++++-- fs/fat/misc.c | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-)fs/fat/fat.h +0
-0@@ -333,8 +333,13 @@ void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...); __fat_fs_error(sb, 1, fmt , ## args) #define fat_fs_error_ratelimit(sb, fmt, args...) \
fs/fat/fat.h void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...); · line 342
Quoted 10 lines
fs/fat/fat.h +7
-2__fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args) -__printf(3, 4) __cold -void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...); +__printf(4, 5) __cold +void __fat_msg(struct super_block *sb, int report, const char *level, + const char *fmt, ...); +#define fat_msg(sb, level, fmt, args...) \ + __fat_msg(sb, 1, level, fmt, ## args) +#define fat_msg_ratelimit(sb, level, fmt, args...) \ + __fat_msg(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), level, fmt, ## args)
I think it better to move the test above the call
and not change the fat_msg function at all.
#define fat_msg_ratelimit(sb, level, fmt, args...) \
do { \
if (! __ratelimit(&MSDOS_SB(sb)->ratelimit)) \
fsg_msg(sb, level, fmt, ##args); \
} while (0)OGAWA Hirofumi
maintainerQuoted 31 lines · Joe Perches
Quoted 16 lines · Namjae Jeon
I tried to add
fat_msg_ratelimitto limit many message at once.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Amit Sahrawat <[email protected]>--- fs/fat/fat.h | 9 +++++++-- fs/fat/misc.c | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-)fs/fat/fat.h +0
-0@@ -333,8 +333,13 @@ void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...); __fat_fs_error(sb, 1, fmt , ## args) #define fat_fs_error_ratelimit(sb, fmt, args...) \fs/fat/fat.h void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...); · line 342
Quoted 10 lines
fs/fat/fat.h +7
-2__fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args) -__printf(3, 4) __cold -void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...); +__printf(4, 5) __cold +void __fat_msg(struct super_block *sb, int report, const char *level, + const char *fmt, ...); +#define fat_msg(sb, level, fmt, args...) \ + __fat_msg(sb, 1, level, fmt, ## args) +#define fat_msg_ratelimit(sb, level, fmt, args...) \ + __fat_msg(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), level, fmt, ## args)I think it better to move the test above the call
and not change thefat_msgfunction at all.
Quoted 5 lines
#define
fat_msg_ratelimit(sb, level, fmt, args...)\do { \ if (! __ratelimit(&MSDOS_SB(sb)->ratelimit)) \ fsg_msg(sb, level, fmt, ##args); \ } while (0)
Looks sane. I myself don't care either "fat_fs_error vs yours" style.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Quoted 3 lines · OGAWA Hirofumi
Quoted 2 lines · Joe Perches
Quoted 1 line · Namjae Jeon
I tried to add
fat_msg_ratelimitto limit many message at once.
[]
Quoted 3 lines
Quoted 3 lines
#define
fat_msg_ratelimit(sb, level, fmt, args...)\do { \ if (! __ratelimit(&MSDOS_SB(sb)->ratelimit)) \
This should be
if (__ratelimit(etc..))