diff mbox series

[v1] exfat: ratelimit error msg in exfat_file_mmap()

Message ID PUZPR04MB63169F97595D70047AF50E3B817D2@PUZPR04MB6316.apcprd04.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series [v1] exfat: ratelimit error msg in exfat_file_mmap() | expand

Commit Message

Yuezhang.Mo@sony.com Jan. 30, 2024, 7:31 a.m. UTC
Ratelimit the error message of zeroing out data between the valid
size and the file size in exfat_file_mmap() to not flood dmesg.

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
---
 fs/exfat/exfat_fs.h | 5 +++++
 fs/exfat/file.c     | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index 9474cd50da6d..46f2760d9846 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -542,6 +542,11 @@  void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
 /* expand to pr_*() with prefix */
 #define exfat_err(sb, fmt, ...)						\
 	pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
+#define exfat_err_ratelimit(sb, fmt, args...) \
+	do { \
+		if (__ratelimit(&EXFAT_SB(sb)->ratelimit)) \
+			exfat_err(sb, fmt, ## args); \
+	} while (0)
 #define exfat_warn(sb, fmt, ...)					\
 	pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
 #define exfat_info(sb, fmt, ...)					\
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 473c1641d50d..68405ae06772 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -619,7 +619,7 @@  static int exfat_file_mmap(struct file *file, struct vm_area_struct *vma)
 		ret = exfat_file_zeroed_range(file, ei->valid_size, end);
 		inode_unlock(inode);
 		if (ret < 0) {
-			exfat_err(inode->i_sb,
+			exfat_err_ratelimit(inode->i_sb,
 				  "mmap: fail to zero from %llu to %llu(%d)",
 				  start, end, ret);
 			return ret;