Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2009261rdd; Thu, 11 Jan 2024 17:06:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGy/EhCH2jvW3UKzIi7ZAhnZZFsr2lL885fBuzkweQt56T5DQcHeaoCiaqF8vaVbK7Omm05 X-Received: by 2002:a05:6214:268a:b0:67f:3991:ef38 with SMTP id gm10-20020a056214268a00b0067f3991ef38mr116900qvb.122.1705021611191; Thu, 11 Jan 2024 17:06:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705021611; cv=none; d=google.com; s=arc-20160816; b=PWSuI75ocmwrxmTAF+mhsKQ/Ujhoxc6Otl4dnUMSwmHl8v2L65YqqQ0wAnhU1I8gFe m/uiN7s5rdDNfi2by87BFoiWTrda8h5FmeeEQzjmKqCsH7/oZGWnMGo1XGnejs4PXq0i QqloFz8iFF4Hu6DBBLXrGPhGe6hsgaJ4kpsV2e2NoGwpQsghLthMxIzueYCLyHNqQRB7 2Gk0bsApwNXweG/keDuughIv3La8u6jCPQzwAWmqmWAYaGeeM+xu/u3iGrJyzPdwDmPl OLndMmJqgBlZ6ET2BmMMdbBE+o+6lQ5Q4bvQP1oXt4fNqJZNEGb6ygbtO1bgwlcf9igh 2MEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=KSMIIbujOvvOTOkarcGkflDrabqHHxoC410CeAGIN4s=; fh=CVABXt/2+I/w5TIrpoqOngQihKkOOcSQFZlYGDqF0qk=; b=bvA2aobcSoMR1riSWQtynWvUDis2MN0F5qWYm7I7i6v1zPHY7iqkqlLjvH4p43dnR6 AljNnQBjGdb7mR0EV8nC8pdoCb9AXlB1rjx/0gxG50I2YuZW0w7phmmCifDIPJItedM2 VVzrjXjNmB+qdMlC+cBRb3+u4aMsiyNwNy4Dp/1yYptYu1NOTjgIG4FJDz2qxRmmigKr NS8u+P9U21ZoueO7UQ+arKsnkF6v92qxAH93rkN77j+B31YLYJpKIUiCYUdNxkBuj4YC XHGcmEl2w1uR0QAiP4gJtFuMwp0BKPfb3nvpm2RM+ZTLoMXDd32tu6OqUIM+VB0nNkeU quCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gVc5HDk+; spf=pass (google.com: domain of linux-kernel+bounces-24198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24198-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 n16-20020a0ce490000000b00680b16ddd2asi1946178qvl.495.2024.01.11.17.06.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 17:06:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24198-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=gVc5HDk+; spf=pass (google.com: domain of linux-kernel+bounces-24198-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24198-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 E000E1C241A8 for ; Fri, 12 Jan 2024 01:06:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C36F5EC5; Fri, 12 Jan 2024 01:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gVc5HDk+" 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 E463D81C for ; Fri, 12 Jan 2024 01:06:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88EB7C433F1; Fri, 12 Jan 2024 01:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705021601; bh=hVgQfaTNbu8e8u2PuXBunuk/KB2v9c8tBDHRJ1yrMBY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=gVc5HDk+8JyrndEwP6so6gn1fSvC35oo6TbS2MvWsd5x0QaWgcx4HXwwHfOoCGdHu P3qOgI+3LgX9KOVKu6IfLSmuoz+YM56OtZeZG7I4/PblmsrATdO4j9JnXit0UL2Uxz hzGzUY5C4jXi0q0B1+bKUT9ZMjbdjrXANT73AJ5I6rmQCY3xHvfgnOdPQ+d3ckJbds C0TXuUUHto2MYqguGC+vdmFNriUJXJ8F2DhmmGybVWfmG93bYTIKrqlPVD7BxQqmAf e/ET8wCG01xC8ZNRhOZF6HVB33XzVARyMQI4oajxKjg+l6N0JtmAJfAjQf53y50Jtl gUiU1BLBDLM2A== Message-ID: Date: Fri, 12 Jan 2024 09:06:39 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [f2fs-dev] [PATCH v3 3/6] f2fs: compress: fix to check unreleased compressed cluster To: Daeho Jeong Cc: jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20231228143152.1543509-1-chao@kernel.org> <20231228143152.1543509-3-chao@kernel.org> Content-Language: en-US From: Chao Yu Autocrypt: addr=chao@kernel.org; keydata= xsFNBFYs6bUBEADJuxYGZRMvAEySns+DKVtVQRKDYcHlmj+s9is35mtlhrLyjm35FWJY099R 6DL9bp8tAzLJOMBn9RuTsu7hbRDErCCTiyXWAsFsPkpt5jgTOy90OQVyTon1i/fDz4sgGOrL 1tUfcx4m5i5EICpdSuXm0dLsC5lFB2KffLNw/ZfRuS+nNlzUm9lomLXxOgAsOpuEVps7RdYy UEC81IYCAnweojFbbK8U6u4Xuu5DNlFqRFe/MBkpOwz4Nb+caCx4GICBjybG1qLl2vcGFNkh eV2i8XEdUS8CJP2rnp0D8DM0+Js+QmAi/kNHP8jzr7CdG5tje1WIVGH6ec8g8oo7kIuFFadO kwy6FSG1kRzkt4Ui2d0z3MF5SYgA1EWQfSqhCPzrTl4rJuZ72ZVirVxQi49Ei2BI+PQhraJ+ pVXd8SnIKpn8L2A/kFMCklYUaLT8kl6Bm+HhKP9xYMtDhgZatqOiyVV6HFewfb58HyUjxpza 1C35+tplQ9klsejuJA4Fw9y4lhdiFk8y2MppskaqKg950oHiqbJcDMEOfdo3NY6/tXHFaeN1 etzLc1N3Y0pG8qS/mehcIXa3Qs2fcurIuLBa+mFiFWrdfgUkvicSYqOimsrE/Ezw9hYhAHq4 KoW4LQoKyLbrdOBJFW0bn5FWBI4Jir1kIFHNgg3POH8EZZDWbQARAQABzRlDaGFvIFl1IDxj aGFvQGtlcm5lbC5vcmc+wsF3BBMBCgAhBQJWLOm1AhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4B AheAAAoJEKTPgB1/p52Gm2MP/0zawCU6QN7TZuJ8R1yfdhYr0cholc8ZuPoGim69ud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 8bit On 2024/1/12 1:15, Daeho Jeong wrote: > On Wed, Jan 10, 2024 at 5:33 PM Chao Yu wrote: >> >> On 2024/1/11 9:18, Daeho Jeong wrote: >>> On Thu, Dec 28, 2023 at 6:33 AM Chao Yu wrote: >>>> >>>> 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; >>> >>> How about merging two conditions like "blkaddr == NEW_ADDR || >>> __is_valid_data_blkaddr(blkaddr)"? >> >> Oh, sure. >> >>> >>>> @@ -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; >>>> + >>> >>> How can the reserved variable be zero? >> >> I guess it can happen if a cluster was not released during >> release_compress_blocks(), then all blocks in the cluster should >> has been reserved, so, in this round of reserving, it needs to skip >> reserve blocks, right? > > Let's assume cluster_size is 4. How can compr_blocks be 4? > > if (i == 0) { > if (blkaddr == COMPRESS_ADDR) > continue; > dn->ofs_in_node += cluster_size; > goto next; > } > > We skip the block having COMPRESS_ADDR when counting compr_blocks. > So, the maximum value of compr_blocks should be 3, right? Ah, got it, and I think you're right. Should fix the condition as below? /* for the case all blocks in cluster were reserved */ if (reserved == 1) goto next; Thanks, > >> >> Thanks, >> >>> >>>> ret = inc_valid_block_count(sbi, dn->inode, &reserved); >>>> if (ret) >>>> return ret; >>>> -- >>>> 2.40.1 >>>> >>>> >>>> >>>> _______________________________________________ >>>> Linux-f2fs-devel mailing list >>>> Linux-f2fs-devel@lists.sourceforge.net >>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel