From patchwork Fri Jan 12 19:41:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13518811 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 C6B0DC47258 for ; Sat, 13 Jan 2024 03:57:40 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rOV9P-0003sR-3o; Sat, 13 Jan 2024 03:57:39 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rOV9M-0003s9-Q4 for linux-f2fs-devel@lists.sourceforge.net; Sat, 13 Jan 2024 03:57:36 +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=HUUR43amUC8jwyxGEGINJMRoyp5HU6PI866HjxWnqtE=; b=lEuksIXAfJHsQj8Yipx541rOOZ gHiWEXJikwGkTS1AR3rcLIkfgEAuEudKqmOwqovH7FYo3xuqjJtyQtu4aeOoq4hONX30TkLiB8Lt/ RRXk0CLr7LdBdC9Am1MEST/ChtJPJ26DvITvyFVTlA4zUzQFzw+mt3INq+JsMWAnprAk=; 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=HUUR43amUC8jwyxGEGINJMRoyp5HU6PI866HjxWnqtE=; b=TNar+WTL7XBpJxkYgBSngbJh5v FepZOUdMYqLnSFVhcGbve4vdWVa/rXrCnKZG7+muuXKpjSYEJ+zSJ9pWML0c/Ed5mt0llOEybR766 S2xHhg/NTyvPrOB9Jshvlf7vDDha0TtZSTmgD191q7DVX0Qd3Fbgk7wnLtW3773aAjpk=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rOV9L-0003oa-JK for linux-f2fs-devel@lists.sourceforge.net; Sat, 13 Jan 2024 03:57:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B45B161ED0; Sat, 13 Jan 2024 03:57:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78372C43330; Sat, 13 Jan 2024 03:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705118245; bh=RQ/5bYxkS3MyNG96Qf/wOP3mhXKTcQQqJW6nVAGR5yE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=syf/atgsKYI3WxMH06ywnV/Te/ggAxXMNSL4DKHuokLI71CB4OwWpBcIULcF+qcU2 fe28JdWhS0wGi29VFqMPcUzHiCDGofP9ZlpJXuZ3japDp8q3LYxzfEBK7FJBQUfkoP 9SzmGPqL9uyjV3Sa+gY1NAMoNGxfugggb5ubfC7rVxEDAedZP3dvjjj0IdiLzrOmFk HOxJnBIkX+PAloeuTF9rtEBs7BBCGY9VnUUoH8KBtE4oqTzfmAQ3ulQCvLdMou6hYE hL8fIb/Yc39UIsnzqjNcHj114X1NpTDJq1vNLvFFQyIUF0AhiIcS0x+XA5HesD/Klb 2PZr3VULR85Pw== From: Chao Yu To: jaegeuk@kernel.org Date: Sat, 13 Jan 2024 03:41:29 +0800 Message-Id: <20240112194132.25637-3-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240112194132.25637-1-chao@kernel.org> References: <20240112194132.25637-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1rOV9L-0003oa-JK Subject: [f2fs-dev] [PATCH v5 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 --- v5: - fix wrong condition pointed out by Daeho. fs/f2fs/file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 026d05a7edd8..4aef2310395f 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3624,7 +3624,13 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) goto next; } - if (__is_valid_data_blkaddr(blkaddr)) { + /* + * compressed cluster was not released due to it + * fails in release_compress_blocks(), so NEW_ADDR + * is a possible case. + */ + if (blkaddr == NEW_ADDR || + __is_valid_data_blkaddr(blkaddr)) { compr_blocks++; continue; } @@ -3633,6 +3639,11 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count) } reserved = cluster_size - compr_blocks; + + /* for the case all blocks in cluster were reserved */ + if (reserved == 1) + goto next; + ret = inc_valid_block_count(sbi, dn->inode, &reserved); if (ret) return ret;