Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3982106rdb; Thu, 28 Dec 2023 06:32:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2uRQiGm3gaoeIabi8nCSfCIeu086Ums1lRuoyS4DNRI66Yhcn65BGdKLBvT4ySck3ea51 X-Received: by 2002:a05:622a:1485:b0:427:7a6c:bfe2 with SMTP id t5-20020a05622a148500b004277a6cbfe2mr14492533qtx.98.1703773971316; Thu, 28 Dec 2023 06:32:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703773971; cv=none; d=google.com; s=arc-20160816; b=pngX+ULkJkZzTZ/UQOcB//kUwCw8xZ+qCdSYBNMsZV0HcwnAZaW2hO60SsEdq0OFY+ NMnlapEqB/bAKNE7gZF19hGr653tflTToX+2ULfI8hccNztEjOW5q/R/poHxUgGfZaT1 IyK7l9KDSSor+jyMuUKvU4gmJwIokT2OYS3WT06zRrJ3h0eMKI4I8kLsRMrdz82tL+uN Z4boGQ7b8P6kcRVPy0qEmviezytf5xpKS+//JD3S5RYiDjgzGeU0EAIbzNA7xNs6RpCJ 42Ux5K46mTHauavFAJOaNCpEtX6Qxe1n8+DxM4GfE3uS6RJ5W9CZnsLbSYyDvgedCfLP DXbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=KsSgDPeE3D2PWDe+9Cjxa1TXEgtZW4xW4czqHA4SKmM=; fh=2w0/+7CnNSrmHtbae1hR3pLuwOJRubjB5ynbCr7QyGo=; b=TVDOF+JfFmS7lvrMCzBpYkxq+aTdN+x4SUrfDoS58kXaJ6aMe+lP1hRQLZbzSE5o/3 dBi8ByUS7gfyn7QDEvaFXQcG+5DuLSinGVjRBetWpcFgpRyEcDtvPvrR1aErfPpgvohd NIdaBmbxcucIxWX3EQ8ELS4zcCj7N9Mv+B8MpFSw4bJEecxG2e5Q0tiLXeuuWCqC8oxC 6Y3m77rK+6UVLXj9fgqlWkLFUvxr9XhFGiwwvy/Q7A0hV6O6pGSt8lIrADM1CqMZJjtQ 8Kys1EcOOu7kvHMKcVBfIDUqA+m6pt0QudMK11J9DgVORyIjzGDzJV/M7l03oyqLzN1W UlRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r3UmvBck; spf=pass (google.com: domain of linux-kernel+bounces-12705-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12705-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a15-20020ac85b8f000000b00427f1ffd2dcsi2819060qta.609.2023.12.28.06.32.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 06:32:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12705-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r3UmvBck; spf=pass (google.com: domain of linux-kernel+bounces-12705-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12705-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 19A9E1C21D89 for ; Thu, 28 Dec 2023 14:32:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AD8E101F7; Thu, 28 Dec 2023 14:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r3UmvBck" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2F69101DE for ; Thu, 28 Dec 2023 14:32:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90591C433C9; Thu, 28 Dec 2023 14:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703773928; bh=PlqlUk5bd+3fk4WKcXVwPKIXLZLKGpamNP0JtbEVizc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r3UmvBckldbFBMtcyi3xBTx28VUw1mf8I7YeImoXPWLb1YsrbuwkMEUL8dHxnC/QH tUu+7M+5kN1T0M4IQWEo3M7Y31SJeeLGc4v5jIjFOLbTPH0LcGSA8fbhA57yX4bn2f vaIzuIfnzXCGIZoKJiqwpLSdjxsv86uofKZ6zMVLqFa1II3ycsn+HRNzIc+LI3tY8L PuQR6tWdMqErdbCa9J1nfYVRfE9OTooB4PYZO8hoXRRvie7f3FIJxJJcBH7hR+ANRD v2/3CMDmlDZy4h6wHZhIa73FxBCl0vCtSSQV8y6ppQlUyHejH+382f2nMTCExoHAhP inT/5EXcK82aA== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Sheng Yong , Chao Yu Subject: [PATCH v3 3/6] f2fs: compress: fix to check unreleased compressed cluster Date: Thu, 28 Dec 2023 22:31:49 +0800 Message-Id: <20231228143152.1543509-3-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231228143152.1543509-1-chao@kernel.org> References: <20231228143152.1543509-1-chao@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Sheng Yong Compressed cluster may not be released due to we can fail in release_compress_blocks(), fix to handle reserved compressed cluster correctly in reserve_compress_blocks(). Fixes: 4c8ff7095bef ("f2fs: support data compression") Signed-off-by: Sheng Yong Signed-off-by: Chao Yu --- fs/f2fs/file.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 026d05a7edd8..782ae3be48f6 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3624,6 +3624,15 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) goto next; } + /* + * compressed cluster was not released due to + * it fails in release_compress_blocks(). + */ + if (blkaddr == NEW_ADDR) { + compr_blocks++; + continue; + } + if (__is_valid_data_blkaddr(blkaddr)) { compr_blocks++; continue; @@ -3633,6 +3642,9 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) } reserved = cluster_size - compr_blocks; + if (!reserved) + goto next; + ret = inc_valid_block_count(sbi, dn->inode, &reserved); if (ret) return ret; -- 2.40.1