Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2491221pxj; Mon, 10 May 2021 04:23:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvsSdTESFfrli9xewGxo9E/Pz/kIazWCPAIlwvmXYL1+KsTKdE+DT/RmJeokxMbeOR8t1X X-Received: by 2002:a17:907:38b:: with SMTP id ss11mr18788230ejb.104.1620645708797; Mon, 10 May 2021 04:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645708; cv=none; d=google.com; s=arc-20160816; b=uUh1ut+PXbmfUYXymW0G7+qAQ7p1rj3NfaZ+twxOaAJgv6T1ptVqHBzWaAYgS4KbOA PioVJ41UpVl+wrn9IBdCc5w/LvhjQNfLTbaNisOefsGVFHkXIKeSVvuSLdhO31TMcG4X QhNqKAThZVV0uXPVN2yEA++tsvsaVhB3Gis9YQJcikflYJ6TSZnXXwN8egAiDys66+ZC 4sRUTI3vYAhYi3xDzudSysVXz3G/chL7bkHt/jRJgcGS2mtzsyZ6Ve4SqDZpkURa9h73 Q693dS7xZfk5g5HrzTfps5efI5DPKf+f8W6pL5HposAfYYd0KKTy9itco+0t7IkZnL0p 5bqQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=S92ug/NRVgRxTDd21nqChYTrvNodej+jcy90dih87V8=; b=okDj77JwZPsJt40xq9O5Pxuwe6ak4k9i94/YuZXtDo+/h2/kZH7zCtJW1vUuZI5d4+ AbGz/gfNAo25NflHNgVZWUlS9Z4xSwREtSKMIHUEVXCoYcaLE4MJ12bs7V6gr0v8MgtH tHY/RC2rYRpllRIkI1GrAjHzjCYCqV2ken9oHAwiXOuRGmHag/DHdfyu04ypaW8UWNC8 wGUqfXdqYtFpiBUniW/2jOEAeT1xu++99RImGnnPd2LToqdhULtRdU0XD5xh/96I9zxr umfa6/I4LvokGc+TYsE9ZeHYBl1O7lTyNYj1kJ8gsesVyWwfaO1PXvmGm0Fai0Ip+p0I HTVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G3OgHO2A; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si12521529edq.473.2021.05.10.04.21.25; Mon, 10 May 2021 04:21:48 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=G3OgHO2A; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238269AbhEJLRS (ORCPT + 99 others); Mon, 10 May 2021 07:17:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:42196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233005AbhEJKxS (ORCPT ); Mon, 10 May 2021 06:53:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 80CB861285; Mon, 10 May 2021 10:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643283; bh=NtnVhsCrJlwc9ibb08GT/mVphPR7+AFmpmECtR6zvYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3OgHO2ASxZmcb9EqLZoeQZwAVcR9R2f85e4A7nFqb6sWyOA9LEvJc1fVb2lUAJZ0 fveeD5PnfrfKgsACDijB8fXTQyJ4jIZH+P3NeKA1BoXkWwnGVkQNpS7dXp6Bv5nw3+ fV1BQ5yO8AAK1Q19jHw1rYGj3jWuM3rWOkKLaIkQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hyeongseok Kim , Sungjong Seo , Namjae Jeon Subject: [PATCH 5.10 252/299] exfat: fix erroneous discard when clear cluster bit Date: Mon, 10 May 2021 12:20:49 +0200 Message-Id: <20210510102013.278838861@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hyeongseok Kim commit 77edfc6e51055b61cae2f54c8e6c3bb7c762e4fe upstream. 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") Cc: stable@vger.kernel.org # v5.7+ Signed-off-by: Hyeongseok Kim Acked-by: Sungjong Seo Signed-off-by: Namjae Jeon Signed-off-by: Greg Kroah-Hartman --- fs/exfat/balloc.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) --- a/fs/exfat/balloc.c +++ b/fs/exfat/balloc.c @@ -141,10 +141,6 @@ void exfat_free_bitmap(struct exfat_sb_i 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 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) { int i, b; @@ -186,8 +178,7 @@ void exfat_clear_bitmap(struct inode *in 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) {