diff mbox series

[v2,2/3] exfat: don't print error log in normal case

Message ID PUZPR04MB6316B9A83221D5AB769AB8CA81AC9@PUZPR04MB6316.apcprd04.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series exfat: fix and refine exfat_alloc_cluster() | expand

Commit Message

Yuezhang.Mo@sony.com Feb. 28, 2023, 6:07 a.m. UTC
When allocating a new cluster, exFAT first allocates from the
next cluster of the last cluster of the file. If the last cluster
of the file is the last cluster of the volume, allocate from the
first cluster. This is a normal case, but the following error log
will be printed. It makes users confused, so this commit removes
the error log.

[1960905.181545] exFAT-fs (sdb1): hint_cluster is invalid (262130)

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Andy Wu <Andy.Wu@sony.com>
---
 fs/exfat/fatent.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c
index 65a8c9fb072c..c75c5a2cad42 100644
--- a/fs/exfat/fatent.c
+++ b/fs/exfat/fatent.c
@@ -344,8 +344,9 @@  int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
 
 	/* check cluster validation */
 	if (!is_valid_cluster(sbi, hint_clu)) {
-		exfat_err(sb, "hint_cluster is invalid (%u)",
-			hint_clu);
+		if (hint_clu != sbi->num_clusters)
+			exfat_err(sb, "hint_cluster is invalid (%u), rewind to the first cluster",
+					hint_clu);
 		hint_clu = EXFAT_FIRST_CLUSTER;
 		p_chain->flags = ALLOC_FAT_CHAIN;
 	}