Blame SOURCES/0070-exfat-fix-erroneous-discard-when-clear-cluster-bit.patch

Kmods SIG 9e3ffb
From 77edfc6e51055b61cae2f54c8e6c3bb7c762e4fe Mon Sep 17 00:00:00 2001
Kmods SIG 9e3ffb
From: Hyeongseok Kim <hyeongseok@gmail.com>
Kmods SIG 9e3ffb
Date: Thu, 4 Mar 2021 09:15:34 +0900
Kmods SIG 9e3ffb
Subject: [Backport 77edfc6e5105] exfat: fix erroneous discard when clear
Kmods SIG 9e3ffb
 cluster bit
Kmods SIG 9e3ffb
Kmods SIG 9e3ffb
If mounted with discard option, exFAT issues discard command when clear
Kmods SIG 9e3ffb
cluster bit to remove file. But the input parameter of cluster-to-sector
Kmods SIG 9e3ffb
calculation is abnormally added by reserved cluster size which is 2,
Kmods SIG 9e3ffb
leading to discard unrelated sectors included in target+2 cluster.
Kmods SIG 9e3ffb
With fixing this, remove the wrong comments in set/clear/find bitmap
Kmods SIG 9e3ffb
functions.
Kmods SIG 9e3ffb
Kmods SIG 9e3ffb
Fixes: 1e49a94cf707 ("exfat: add bitmap operations")
Kmods SIG 9e3ffb
Cc: stable@vger.kernel.org # v5.7+
Kmods SIG 9e3ffb
Signed-off-by: Hyeongseok Kim <hyeongseok@gmail.com>
Kmods SIG 9e3ffb
Acked-by: Sungjong Seo <sj1557.seo@samsung.com>
Kmods SIG 9e3ffb
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Kmods SIG 9e3ffb
---
Kmods SIG 9e3ffb
 src/balloc.c | 11 +----------
Kmods SIG 9e3ffb
 1 file changed, 1 insertion(+), 10 deletions(-)
Kmods SIG 9e3ffb
Kmods SIG 9e3ffb
diff --git a/src/balloc.c b/src/balloc.c
Kmods SIG 9e3ffb
index 761c79c3a4ba262870686608f3619c98312f65cb..411fb0a8da10d40be5610f55f72280d44eb03ee7 100644
Kmods SIG 9e3ffb
--- a/src/balloc.c
Kmods SIG 9e3ffb
+++ b/src/balloc.c
Kmods SIG 9e3ffb
@@ -141,10 +141,6 @@ void exfat_free_bitmap(struct exfat_sb_info *sbi)
Kmods SIG 9e3ffb
 	kfree(sbi->vol_amap);
Kmods SIG 9e3ffb
 }
Kmods SIG 9e3ffb
 
Kmods SIG 9e3ffb
-/*
Kmods SIG 9e3ffb
- * If the value of "clu" is 0, it means cluster 2 which is the first cluster of
Kmods SIG 9e3ffb
- * the cluster heap.
Kmods SIG 9e3ffb
- */
Kmods SIG 9e3ffb
 int exfat_set_bitmap(struct inode *inode, unsigned int clu)
Kmods SIG 9e3ffb
 {
Kmods SIG 9e3ffb
 	int i, b;
Kmods SIG 9e3ffb
@@ -162,10 +158,6 @@ int exfat_set_bitmap(struct inode *inode, unsigned int clu)
Kmods SIG 9e3ffb
 	return 0;
Kmods SIG 9e3ffb
 }
Kmods SIG 9e3ffb
 
Kmods SIG 9e3ffb
-/*
Kmods SIG 9e3ffb
- * If the value of "clu" is 0, it means cluster 2 which is the first cluster of
Kmods SIG 9e3ffb
- * the cluster heap.
Kmods SIG 9e3ffb
- */
Kmods SIG 9e3ffb
 void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync)
Kmods SIG 9e3ffb
 {
Kmods SIG 9e3ffb
 	int i, b;
Kmods SIG 9e3ffb
@@ -186,8 +178,7 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync)
Kmods SIG 9e3ffb
 		int ret_discard;
Kmods SIG 9e3ffb
 
Kmods SIG 9e3ffb
 		ret_discard = sb_issue_discard(sb,
Kmods SIG 9e3ffb
-			exfat_cluster_to_sector(sbi, clu +
Kmods SIG 9e3ffb
-						EXFAT_RESERVED_CLUSTERS),
Kmods SIG 9e3ffb
+			exfat_cluster_to_sector(sbi, clu),
Kmods SIG 9e3ffb
 			(1 << sbi->sect_per_clus_bits), GFP_NOFS, 0);
Kmods SIG 9e3ffb
 
Kmods SIG 9e3ffb
 		if (ret_discard == -EOPNOTSUPP) {
Kmods SIG 9e3ffb
-- 
Kmods SIG 9e3ffb
2.31.1
Kmods SIG 9e3ffb