mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	f2fs: support printk_ratelimited() in f2fs_printk()
This patch supports using printk_ratelimited() in f2fs_printk(), and
wrap ratelimited f2fs_printk() into f2fs_{err,warn,info}_ratelimited(),
then, use these new helps to clean up codes.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
			
			
This commit is contained in:
		
							parent
							
								
									c2034ef619
								
							
						
					
					
						commit
						b1c9d3f833
					
				
					 4 changed files with 38 additions and 28 deletions
				
			
		| 
						 | 
					@ -512,8 +512,8 @@ static int lzorle_compress_pages(struct compress_ctx *cc)
 | 
				
			||||||
	ret = lzorle1x_1_compress(cc->rbuf, cc->rlen, cc->cbuf->cdata,
 | 
						ret = lzorle1x_1_compress(cc->rbuf, cc->rlen, cc->cbuf->cdata,
 | 
				
			||||||
					&cc->clen, cc->private);
 | 
										&cc->clen, cc->private);
 | 
				
			||||||
	if (ret != LZO_E_OK) {
 | 
						if (ret != LZO_E_OK) {
 | 
				
			||||||
		printk_ratelimited("%sF2FS-fs (%s): lzo-rle compress failed, ret:%d\n",
 | 
							f2fs_err_ratelimited(F2FS_I_SB(cc->inode),
 | 
				
			||||||
				KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id, ret);
 | 
									"lzo-rle compress failed, ret:%d", ret);
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -780,9 +780,9 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task)
 | 
				
			||||||
		if (provided != calculated) {
 | 
							if (provided != calculated) {
 | 
				
			||||||
			if (!is_inode_flag_set(dic->inode, FI_COMPRESS_CORRUPT)) {
 | 
								if (!is_inode_flag_set(dic->inode, FI_COMPRESS_CORRUPT)) {
 | 
				
			||||||
				set_inode_flag(dic->inode, FI_COMPRESS_CORRUPT);
 | 
									set_inode_flag(dic->inode, FI_COMPRESS_CORRUPT);
 | 
				
			||||||
				printk_ratelimited(
 | 
									f2fs_info_ratelimited(sbi,
 | 
				
			||||||
					"%sF2FS-fs (%s): checksum invalid, nid = %lu, %x vs %x",
 | 
										"checksum invalid, nid = %lu, %x vs %x",
 | 
				
			||||||
					KERN_INFO, sbi->sb->s_id, dic->inode->i_ino,
 | 
										dic->inode->i_ino,
 | 
				
			||||||
					provided, calculated);
 | 
										provided, calculated);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			set_sbi_flag(sbi, SBI_NEED_FSCK);
 | 
								set_sbi_flag(sbi, SBI_NEED_FSCK);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -995,9 +995,8 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
 | 
				
			||||||
		de = &d->dentry[bit_pos];
 | 
							de = &d->dentry[bit_pos];
 | 
				
			||||||
		if (de->name_len == 0) {
 | 
							if (de->name_len == 0) {
 | 
				
			||||||
			if (found_valid_dirent || !bit_pos) {
 | 
								if (found_valid_dirent || !bit_pos) {
 | 
				
			||||||
				printk_ratelimited(
 | 
									f2fs_warn_ratelimited(sbi,
 | 
				
			||||||
					"%sF2FS-fs (%s): invalid namelen(0), ino:%u, run fsck to fix.",
 | 
										"invalid namelen(0), ino:%u, run fsck to fix.",
 | 
				
			||||||
					KERN_WARNING, sbi->sb->s_id,
 | 
					 | 
				
			||||||
					le32_to_cpu(de->ino));
 | 
										le32_to_cpu(de->ino));
 | 
				
			||||||
				set_sbi_flag(sbi, SBI_NEED_FSCK);
 | 
									set_sbi_flag(sbi, SBI_NEED_FSCK);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1812,6 +1812,27 @@ struct f2fs_sb_info {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__printf(3, 4)
 | 
				
			||||||
 | 
					void f2fs_printk(struct f2fs_sb_info *sbi, bool limit_rate, const char *fmt, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define f2fs_err(sbi, fmt, ...)						\
 | 
				
			||||||
 | 
						f2fs_printk(sbi, false, KERN_ERR fmt, ##__VA_ARGS__)
 | 
				
			||||||
 | 
					#define f2fs_warn(sbi, fmt, ...)					\
 | 
				
			||||||
 | 
						f2fs_printk(sbi, false, KERN_WARNING fmt, ##__VA_ARGS__)
 | 
				
			||||||
 | 
					#define f2fs_notice(sbi, fmt, ...)					\
 | 
				
			||||||
 | 
						f2fs_printk(sbi, false, KERN_NOTICE fmt, ##__VA_ARGS__)
 | 
				
			||||||
 | 
					#define f2fs_info(sbi, fmt, ...)					\
 | 
				
			||||||
 | 
						f2fs_printk(sbi, false, KERN_INFO fmt, ##__VA_ARGS__)
 | 
				
			||||||
 | 
					#define f2fs_debug(sbi, fmt, ...)					\
 | 
				
			||||||
 | 
						f2fs_printk(sbi, false, KERN_DEBUG fmt, ##__VA_ARGS__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define f2fs_err_ratelimited(sbi, fmt, ...)				\
 | 
				
			||||||
 | 
						f2fs_printk(sbi, true, KERN_ERR fmt, ##__VA_ARGS__)
 | 
				
			||||||
 | 
					#define f2fs_warn_ratelimited(sbi, fmt, ...)				\
 | 
				
			||||||
 | 
						f2fs_printk(sbi, true, KERN_WARNING fmt, ##__VA_ARGS__)
 | 
				
			||||||
 | 
					#define f2fs_info_ratelimited(sbi, fmt, ...)				\
 | 
				
			||||||
 | 
						f2fs_printk(sbi, true, KERN_INFO fmt, ##__VA_ARGS__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_F2FS_FAULT_INJECTION
 | 
					#ifdef CONFIG_F2FS_FAULT_INJECTION
 | 
				
			||||||
#define time_to_inject(sbi, type) __time_to_inject(sbi, type, __func__,	\
 | 
					#define time_to_inject(sbi, type) __time_to_inject(sbi, type, __func__,	\
 | 
				
			||||||
									__builtin_return_address(0))
 | 
														__builtin_return_address(0))
 | 
				
			||||||
| 
						 | 
					@ -1829,9 +1850,8 @@ static inline bool __time_to_inject(struct f2fs_sb_info *sbi, int type,
 | 
				
			||||||
	atomic_inc(&ffi->inject_ops);
 | 
						atomic_inc(&ffi->inject_ops);
 | 
				
			||||||
	if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
 | 
						if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
 | 
				
			||||||
		atomic_set(&ffi->inject_ops, 0);
 | 
							atomic_set(&ffi->inject_ops, 0);
 | 
				
			||||||
		printk_ratelimited("%sF2FS-fs (%s) : inject %s in %s of %pS\n",
 | 
							f2fs_info_ratelimited(sbi, "inject %s in %s of %pS",
 | 
				
			||||||
			KERN_INFO, sbi->sb->s_id, f2fs_fault_name[type],
 | 
									f2fs_fault_name[type], func, parent_func);
 | 
				
			||||||
			func, parent_func);
 | 
					 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
| 
						 | 
					@ -2325,20 +2345,6 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
 | 
				
			||||||
	return -ENOSPC;
 | 
						return -ENOSPC;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__printf(2, 3)
 | 
					 | 
				
			||||||
void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define f2fs_err(sbi, fmt, ...)						\
 | 
					 | 
				
			||||||
	f2fs_printk(sbi, KERN_ERR fmt, ##__VA_ARGS__)
 | 
					 | 
				
			||||||
#define f2fs_warn(sbi, fmt, ...)					\
 | 
					 | 
				
			||||||
	f2fs_printk(sbi, KERN_WARNING fmt, ##__VA_ARGS__)
 | 
					 | 
				
			||||||
#define f2fs_notice(sbi, fmt, ...)					\
 | 
					 | 
				
			||||||
	f2fs_printk(sbi, KERN_NOTICE fmt, ##__VA_ARGS__)
 | 
					 | 
				
			||||||
#define f2fs_info(sbi, fmt, ...)					\
 | 
					 | 
				
			||||||
	f2fs_printk(sbi, KERN_INFO fmt, ##__VA_ARGS__)
 | 
					 | 
				
			||||||
#define f2fs_debug(sbi, fmt, ...)					\
 | 
					 | 
				
			||||||
	f2fs_printk(sbi, KERN_DEBUG fmt, ##__VA_ARGS__)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define PAGE_PRIVATE_GET_FUNC(name, flagname) \
 | 
					#define PAGE_PRIVATE_GET_FUNC(name, flagname) \
 | 
				
			||||||
static inline bool page_private_##name(struct page *page) \
 | 
					static inline bool page_private_##name(struct page *page) \
 | 
				
			||||||
{ \
 | 
					{ \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -264,7 +264,8 @@ static match_table_t f2fs_tokens = {
 | 
				
			||||||
	{Opt_err, NULL},
 | 
						{Opt_err, NULL},
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...)
 | 
					void f2fs_printk(struct f2fs_sb_info *sbi, bool limit_rate,
 | 
				
			||||||
 | 
											const char *fmt, ...)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct va_format vaf;
 | 
						struct va_format vaf;
 | 
				
			||||||
	va_list args;
 | 
						va_list args;
 | 
				
			||||||
| 
						 | 
					@ -275,8 +276,12 @@ void f2fs_printk(struct f2fs_sb_info *sbi, const char *fmt, ...)
 | 
				
			||||||
	level = printk_get_level(fmt);
 | 
						level = printk_get_level(fmt);
 | 
				
			||||||
	vaf.fmt = printk_skip_level(fmt);
 | 
						vaf.fmt = printk_skip_level(fmt);
 | 
				
			||||||
	vaf.va = &args;
 | 
						vaf.va = &args;
 | 
				
			||||||
	printk("%c%cF2FS-fs (%s): %pV\n",
 | 
						if (limit_rate)
 | 
				
			||||||
	       KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf);
 | 
							printk_ratelimited("%c%cF2FS-fs (%s): %pV\n",
 | 
				
			||||||
 | 
								KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							printk("%c%cF2FS-fs (%s): %pV\n",
 | 
				
			||||||
 | 
								KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	va_end(args);
 | 
						va_end(args);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue