linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yuezhang.Mo@sony.com" <Yuezhang.Mo@sony.com>
To: "linkinjeon@kernel.org" <linkinjeon@kernel.org>,
	"sj1557.seo@samsung.com" <sj1557.seo@samsung.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"Andy.Wu@sony.com" <Andy.Wu@sony.com>,
	"Wataru.Aoyama@sony.com" <Wataru.Aoyama@sony.com>
Subject: [PATCH v1] exfat: ratelimit error msg in exfat_file_mmap()
Date: Tue, 30 Jan 2024 07:31:48 +0000	[thread overview]
Message-ID: <PUZPR04MB63169F97595D70047AF50E3B817D2@PUZPR04MB6316.apcprd04.prod.outlook.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1519 bytes --]

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 --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;
-- 
2.34.1


[-- Attachment #2: v1-0001-exfat-ratelimit-error-msg-in-exfat_file_mmap.patch --]
[-- Type: application/octet-stream, Size: 1697 bytes --]

From 5f023fcc6e632c63c1bea46379bbf031e0c4a1a5 Mon Sep 17 00:00:00 2001
From: Yuezhang Mo <Yuezhang.Mo@sony.com>
Date: Tue, 30 Jan 2024 12:46:21 +0800
Subject: [PATCH v1] exfat: ratelimit error msg in exfat_file_mmap()

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 --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;
-- 
2.34.1


                 reply	other threads:[~2024-01-30  7:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PUZPR04MB63169F97595D70047AF50E3B817D2@PUZPR04MB6316.apcprd04.prod.outlook.com \
    --to=yuezhang.mo@sony.com \
    --cc=Andy.Wu@sony.com \
    --cc=Wataru.Aoyama@sony.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).