From patchwork Thu Dec 28 14:31:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13506083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24B2FC3DA6E for ; Thu, 28 Dec 2023 14:32:31 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rIrR1-0003Za-NG; Thu, 28 Dec 2023 14:32:30 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rIrQy-0003ZS-7P for linux-f2fs-devel@lists.sourceforge.net; Thu, 28 Dec 2023 14:32:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=KsSgDPeE3D2PWDe+9Cjxa1TXEgtZW4xW4czqHA4SKmM=; b=edw7VE/koXf8xyEesTO6U8Ht/L x3xziZBdrKuHCKVhzSc8ut4K+Bv4RlWYtZN9ljY6mTl6363keCQJVxeD1qONu6r/Q/BNvqc1EJ5+4 wzhr9+46ogBy70uHgRziN/bkS2EmCUMHRdZqpSxEyMYJOK07fTJRjXmWpI7xlw4XagRo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=KsSgDPeE3D2PWDe+9Cjxa1TXEgtZW4xW4czqHA4SKmM=; b=kD0KOQ/Mes+D5C4L6WLDpzxJaV QJMhaHSIZxoy1AhhVB/88pBOQgdTohdJpp/TyN/qp0sDGnL28G9Iask+MuE+hg27hHlAt3jNSkG5a 63f0ihtAMLdzTYnJ6bquxS3D3PshA9uEYArJdUJTTpCzBLAL/gyt+/BctFKpep1CEuRA=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rIrQv-0000zb-TX for linux-f2fs-devel@lists.sourceforge.net; Thu, 28 Dec 2023 14:32:26 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A1D05CE140E; Thu, 28 Dec 2023 14:32:10 +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 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> MIME-Version: 1.0 X-Headers-End: 1rIrQv-0000zb-TX Subject: [f2fs-dev] [PATCH v3 3/6] f2fs: compress: fix to check unreleased compressed cluster X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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;