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

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