Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2548584pxj; Mon, 10 May 2021 05:41:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwh7YHn80ZUrHrunXg3MxhJWSNmGKcyH87PTeb2nHZ/dNfsMPZRFg7LyIiFX01sRTGp9rB X-Received: by 2002:a05:6402:3cc:: with SMTP id t12mr29315941edw.64.1620650500786; Mon, 10 May 2021 05:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620650500; cv=none; d=google.com; s=arc-20160816; b=Qa4SPwoRl6YpWTq92LYOVqA+kzTXNw9ykNzEdUoynPU4ncR/dj/ZocdhCAvW2/3QtD wCu08xc/mdHqtuywD3XmKOgCBIIuH0FPfqiMAR+w4vNiB7ij3AsfU9N3kOpejuANy3pZ Kxo7q9O3C89Vbkmn/bRDOWUKhPUNgRUX68ogaBLL0cBcXuT8vLQvtb87H4fm2RltXZMP dYjyYm55YAYa1AZDqRfh4YHzdZL79K+T+vdWPCR2kck0LhgXBVG3Myr77/UswBHvkXuf sMeGoXMn7xoDGSj5cvWF7wLGXbcvuehelO8weiSNDANcPTtS7qEUt8EEyQQ3O+pkgqZl +pRQ== 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=CnLvSVBur1GSNzPKpa4jmHE4Mtm8+UhUPMX+fDLPgTg=; b=J3oqT9BKw9AR1X7H69TEGJb+Q0LPV8UoVu9LlxrZzfmscYbImC81cxjLxxhh0hF5ZS HONUJODtxlCwDPwZ7teFupM0d1w8KYicF+5mLxublTSaYzU4168jVA9s4HBbsBWbdXBD KqiWPCco2/fgHivQi9X3CCqbCiFtUjM/NS5c9lABzXJoZJu31gv+UPYcx/uB8/65n4Sv XnhRUWMwiX4XKt5RACWkYEZn2dVz6cJ4hURGUDU58S808RVaPNN5r+u5VwvDf7KNf052 jdjj9K7NYfzDW3rOffqpm8fvH30cd7zWZzbuiru7foDckegF9dRKWhFhkLcGdTDZ+3gX gY5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ok9M41Hc; 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 ia10si13564037ejc.582.2021.05.10.05.41.17; Mon, 10 May 2021 05:41:40 -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=ok9M41Hc; 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 S1344725AbhEJMgI (ORCPT + 99 others); Mon, 10 May 2021 08:36:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:49986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236441AbhEJLNv (ORCPT ); Mon, 10 May 2021 07:13:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC768613CA; Mon, 10 May 2021 11:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620645029; bh=yFpD5J1x5PKko8O8S5fPjp0aRGWDYZyzJrGiEVBA+v4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ok9M41Hc7+sSj9t1qdkxIPDKs3lwNuB3SLb/juM9/rncPl2BkMWzoEHSyasBRSCIJ 2FJQa7FkQVHSpGlDYHO81FOrp6aI8b5NV+lC2OPfqLgLmhvqq41QrUp201sllX8N2h uP9qBeqB8CUmPnF5B9x8QoWoCX9828dmMFvwFOtE= 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.12 322/384] exfat: fix erroneous discard when clear cluster bit Date: Mon, 10 May 2021 12:21:51 +0200 Message-Id: <20210510102025.415318793@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@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, bool sync) { 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) {