Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp938792pxb; Wed, 3 Mar 2021 21:49:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJys6sOwCo8xHJPSToYXfD5IX88so+mqGnFv4h2N2C/yfvMkEFwG+jn0d4obM3Jg8nYAiMAj X-Received: by 2002:a17:906:d1d5:: with SMTP id bs21mr2491332ejb.242.1614836944049; Wed, 03 Mar 2021 21:49:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614836944; cv=none; d=google.com; s=arc-20160816; b=Rg/hx14dyH2Hz9Cl+mKJEZpXFys0pSxIHzI8dGd68OIiZo//7ivE+czSEoSGVRtOnN yNMoFTNJtlnOTQe2sYtdi3AzAE7kFF42rh2NhUlwyGuEgiV1Je54iT+lfFEqGbgie2N+ c2ExxsVT/9nv0gYFlEHE/yuzFlvP1i4wDtlT4c6NLCZgmHYODJiP77LMXw4U9mWsDEHP aFQoeG2qZKug157SaAV+IfoIjtu+CPjN/sc5tR2e34qlgfgLjxeAzBAH1IOjbrpxKU6p n3aiuO/7rKVWZJOOmJph/q+S5RnsRKnIwmeAu41JrNTBBBQM99oUYSjdRpnSBHdFI9UE vvPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=KsTquK6HBVR6gWCGt6Eda/Orp7nGuXw2ak/HYVfr530=; b=xtgzudgY1EU1Taz0iVrYM5D+U41ZEmglvIU3ocRJevp6T41Kh0JXdZBe1lU30B9PoA jM7SzIo13UxGPoJlYuG757BqWssDXZjMzyxu7AlPKtXQPCv3/0JBYGt//6ThZN77ewtI uOiLsctkddriawThRQV1ILdeUNh1o4p/N+4gfP5Q0reNVqRG2C/qcUNMiQDA+pWWgw9G 9VOgV/7cYm9aPtLU3baVhpu2aGw5t80AaGjKqY+fYb3FoQLsJfdHog57cFBcLu3fzy9B drbUoUgVZzUsKXQv4aBJIghssjsRGwk6BpFmGPNdxb2iNKeRpkUD2fCi3GtAM7tXzHj4 DtOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mLlFmfHe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s21si16426119ejj.271.2021.03.03.21.48.41; Wed, 03 Mar 2021 21:49:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mLlFmfHe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345478AbhCBG4N (ORCPT + 99 others); Tue, 2 Mar 2021 01:56:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381338AbhCBFVN (ORCPT ); Tue, 2 Mar 2021 00:21:13 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AFC2C06178A; Mon, 1 Mar 2021 21:20:32 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id b21so13109765pgk.7; Mon, 01 Mar 2021 21:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KsTquK6HBVR6gWCGt6Eda/Orp7nGuXw2ak/HYVfr530=; b=mLlFmfHeXvQ/VkA/Wfw2tspq7RS/aGONP8mHoC22l1G0FNA+Si3IPaUoQ1AdtVnXfP XBulWzzgQmGRAJ/+5IcRN16LHpZy4sZQlFwL+/kgjVvJxSQY/drXOMJDwHKjwxb1GLJF a7AgHDM7FOBvZNHGJ5gMZ1Jyom0V31mwvSlxBIjxillR/aS17zTkW6EUoaLUXkQrnpx9 HtJpPa3Dijh/Lclb8Sz6JtZNRsGppymd+r/vhxHOEP+y6fRFuRETfLcyzsQgu0XkbXmp abGSD+IqFG7DNonD16cUcKW0hECL4lJ9TvE70wqjsbS5f7zZk8odUgNDjL1/RPHZAm6M iGag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KsTquK6HBVR6gWCGt6Eda/Orp7nGuXw2ak/HYVfr530=; b=Vq+xYtf0JQTVKYQ3sHeJ8TjZoBHktX2od5UAFiB0WeckyoS7XMy/SljWFYRWrdwWvi mskrHhs4SDx7O00FSRZUfBL+t9/nbtoUkv5c4VC4Yxi6NLP7EUc8JbdusTqGkvILH3CP OTHQO1nCZgMg2HZfP6qDNTCGXveUCGKpBjsZZyGipwaUtIN5O05yd8feRkmKQXcup3/0 pwA1eHU8zLkVdC4LZI2HW4vQjoYRmuN4oIGpC79IH7LPEFZXRvO6GdtyrMfGF8nA32yR V1V3DViR9olYBWPu58oHPyQYQY40G2CMpdmVgZ4BqJQttp8uOrOWAqEbvLrcM7cqnPDj ofTw== X-Gm-Message-State: AOAM530ctiMO7eT9nnU6I0/jfj87QuhIj4p3OwabHy6tamWVVfyxLumS kg7d6HTFqcfSn3qe2w6UmclHKxTiuASG6Y0K X-Received: by 2002:a62:800d:0:b029:1ee:2fc7:b9ee with SMTP id j13-20020a62800d0000b02901ee2fc7b9eemr1808233pfd.34.1614662431914; Mon, 01 Mar 2021 21:20:31 -0800 (PST) Received: from localhost.localdomain ([27.122.242.75]) by smtp.gmail.com with ESMTPSA id i13sm18784100pfe.46.2021.03.01.21.20.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Mar 2021 21:20:31 -0800 (PST) From: Hyeongseok Kim To: namjae.jeon@samsung.com, sj1557.seo@samsung.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Hyeongseok Kim Subject: [PATCH v2] exfat: fix erroneous discard when clear cluster bit Date: Tue, 2 Mar 2021 14:20:20 +0900 Message-Id: <20210302052020.63598-1-hyeongseok@gmail.com> X-Mailer: git-send-email 2.27.0.83.g0313f36 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If mounted with discard option, exFAT issues discard command when clear cluster bit to remove file. But the input parameter of cluster-to-sector calculation is abnormally added by reserved cluster size which is 2, leading to discard unrelated sectors included in target+2 cluster. With fixing this, remove the wrong comments in set/clear/find bitmap functions. Fixes: 1e49a94cf707 ("exfat: add bitmap operations") Signed-off-by: Hyeongseok Kim Acked-by: Sungjong Seo --- fs/exfat/balloc.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/fs/exfat/balloc.c b/fs/exfat/balloc.c index 761c79c3a4ba..54f1bcbddb26 100644 --- a/fs/exfat/balloc.c +++ b/fs/exfat/balloc.c @@ -141,10 +141,6 @@ void exfat_free_bitmap(struct exfat_sb_info *sbi) kfree(sbi->vol_amap); } -/* - * If the value of "clu" is 0, it means cluster 2 which is the first cluster of - * the cluster heap. - */ int exfat_set_bitmap(struct inode *inode, unsigned int clu) { int i, b; @@ -162,10 +158,6 @@ int exfat_set_bitmap(struct inode *inode, unsigned int clu) return 0; } -/* - * If the value of "clu" is 0, it means cluster 2 which is the first cluster of - * the cluster heap. - */ void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync) { int i, b; @@ -186,8 +178,7 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync) int ret_discard; ret_discard = sb_issue_discard(sb, - exfat_cluster_to_sector(sbi, clu + - EXFAT_RESERVED_CLUSTERS), + exfat_cluster_to_sector(sbi, clu), (1 << sbi->sect_per_clus_bits), GFP_NOFS, 0); if (ret_discard == -EOPNOTSUPP) { @@ -197,10 +188,6 @@ void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync) } } -/* - * If the value of "clu" is 0, it means cluster 2 which is the first cluster of - * the cluster heap. - */ unsigned int exfat_find_free_bitmap(struct super_block *sb, unsigned int clu) { unsigned int i, map_i, map_b, ent_idx; -- 2.27.0.83.g0313f36