Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2579081rdd; Fri, 12 Jan 2024 14:19:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJzG6tnbv1okcgs+JJo4rEL7vu2FA6iSYTA8oJcw1bftmvp8ei7oaP8RTttZsaHGr3p77g X-Received: by 2002:a17:90a:a403:b0:28e:96e:694b with SMTP id y3-20020a17090aa40300b0028e096e694bmr1148393pjp.56.1705097994308; Fri, 12 Jan 2024 14:19:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705097994; cv=none; d=google.com; s=arc-20160816; b=WQsYqSsBL4dVqH7rtYyu8iLzyFcQvWs+AeZS8Br8KelhQwCnb9+9/wjPfxq5v4WVgk WHbmWr6WLN0cXsnQe1vz765Q+XyYeDwqmb5POAaw6OT5829glOCbu0zC9rqD8CdEqObQ M3iN5WTo9E7DKTzKjm9n4M5SpgSXcyVWw4GoPuU93vWziZg/2MJjtCEoBO4Cz1l4nLub QaNr2V2tQMt5CmXi8uZgM9/o+a7Fx6QBMLubnUiTIA8+JaPgAlAuo9gok7YwHJ82mK/2 v9IjMMGH1Rbzjd1Jq8+oxAS+bupfpDl4C3rTH/ud/QMFj/qzkbeKVtaVa6vdU4jEtUHB citQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=7e/2OkUvS339Il58Bmr0PaHeMM9UBP4jRux2aDWKwj0=; fh=HSbZBoqfPPu29USLL22LZlK5/916a1HOg8gfajXborE=; b=BDro1Hjcu4UZxh3kAW9asEAqQADb6baibvREZ7iiBsfGVK4eVuucmr1EC+t6AYfiVB DRLtzUv8SD186VIovzT00YtwiN6XlAEHQmyOLzLPYgpbmMa5tvdZWK3o3JvqiJqqU8hP NRnfdJDjU2C5vKwNjpdK2frH7D9WzCxHIMLAClV+XGbew/p7L7ct9xiqvyWUq7ueBp3v RTbHjSipAc8yv+hWZSgqCMhSnEv/DrF2yZfe3Gw3mEYMGAjB8y35TRnFbPq7FN7lxspz LnmtyJ8x4K0Lu8j0TdjzGpZMv6M/S/jmXjr//UibkP12sEwZOGMZaZTj4aa5iolVLq+R 2f2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lOpkDo2p; spf=pass (google.com: domain of linux-kernel+bounces-25063-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o16-20020a63e350000000b005ce097ce679si4171550pgj.741.2024.01.12.14.19.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 14:19:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25063-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lOpkDo2p; spf=pass (google.com: domain of linux-kernel+bounces-25063-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EC622283850 for ; Fri, 12 Jan 2024 22:19:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E230C17732; Fri, 12 Jan 2024 22:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lOpkDo2p" Received: from mail-ua1-f44.google.com (mail-ua1-f44.google.com [209.85.222.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9BA617727 for ; Fri, 12 Jan 2024 22:19:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ua1-f44.google.com with SMTP id a1e0cc1a2514c-7cd03e3f8a3so2000387241.3 for ; Fri, 12 Jan 2024 14:19:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705097985; x=1705702785; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7e/2OkUvS339Il58Bmr0PaHeMM9UBP4jRux2aDWKwj0=; b=lOpkDo2pdGaeYDqU4ZUqz6eEKM+3hfmNJR0+LEPyCd8zvQbHEmJOUXb1K2JeKZRoaL IpZY6FyYmWFLMZK4icFFFlNR9pikus/yThbgoM/Hf/YtjGjVFnMFwHP/fLtYVAGoLG5T jBDcINmTDA38sGu6f3ipvM+Y5h5wpNI4wDqi9O1Uo+mnpsCotcrYOeL7UCvtKERsIQIj WopnqkI8vlMPSq5CTcnoRlU8z9XDZ8mWv7npyGI8ZbHsGnjgMhhH67RdpGfkci9CS3fb Z7lJumJJ7MNlkrPspOAm3oIn8TP0gj4pKT+Tv2YH/pT5RgEJ/ij+UTjH2kSK+dPWp/By 9HiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705097985; x=1705702785; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7e/2OkUvS339Il58Bmr0PaHeMM9UBP4jRux2aDWKwj0=; b=XtfeztOnPV2co+FCUjSF7tuziAifrd8/XeVcqDouJpzrywuVia+WOC+SHbBSUtydga U7A0P+++oP4cxFubRxrMKcMlsfyLJHJwvi3ILb4KZ3PnwcqJ9j1J8PYFKNSwNxB9cOqe 4Dg52htD2UErknkH73+ruCJRd4C1xU0SdPG1tfwf6SCAqub4MdAbISIs4uQmprxhmCGC JdWHQjhz1DfH+zI1roBHQSia2UV6pdJBUhILn/94iz8mLEsEJda4UvEE5fp/CfKNsmPN qax0Bn2yK+oXRJX+H/LgZvQxWNOODTWzz2xDtm+KzZg35wFFEWSjgt2YM4xQN/fJECOt jHCw== X-Gm-Message-State: AOJu0YxPrz0IQ5WDcvoA+RJFtpfwdmze5SGHvac3HsH6EaRx0r54vvIB Ko7OvebQB6W+U8SDAHqTUcU+kioKmhGM29npiok= X-Received: by 2002:a05:6122:2191:b0:4b6:d4c8:9caa with SMTP id j17-20020a056122219100b004b6d4c89caamr2254783vkd.21.1705097985517; Fri, 12 Jan 2024 14:19:45 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231228143152.1543509-1-chao@kernel.org> <20231228143152.1543509-3-chao@kernel.org> In-Reply-To: From: Daeho Jeong Date: Fri, 12 Jan 2024 14:19:34 -0800 Message-ID: Subject: Re: [f2fs-dev] [PATCH v3 3/6] f2fs: compress: fix to check unreleased compressed cluster To: Chao Yu Cc: jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 11, 2024 at 5:06=E2=80=AFPM Chao Yu wrote: > > On 2024/1/12 1:15, Daeho Jeong wrote: > > On Wed, Jan 10, 2024 at 5:33=E2=80=AFPM Chao Yu wrote= : > >> > >> On 2024/1/11 9:18, Daeho Jeong wrote: > >>> On Thu, Dec 28, 2023 at 6:33=E2=80=AFAM Chao Yu wro= te: > >>>> > >>>> 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 dno= de_of_data *dn, pgoff_t count) > >>>> goto next; > >>>> } > >>>> > >>>> + /* > >>>> + * compressed cluster was not released due t= o > >>>> + * it fails in release_compress_blocks(). > >>>> + */ > >>>> + if (blkaddr =3D=3D NEW_ADDR) { > >>>> + compr_blocks++; > >>>> + continue; > >>>> + } > >>>> + > >>>> if (__is_valid_data_blkaddr(blkaddr)) { > >>>> compr_blocks++; > >>>> continue; > >>> > >>> How about merging two conditions like "blkaddr =3D=3D NEW_ADDR || > >>> __is_valid_data_blkaddr(blkaddr)"? > >> > >> Oh, sure. > >> > >>> > >>>> @@ -3633,6 +3642,9 @@ static int reserve_compress_blocks(struct dnod= e_of_data *dn, pgoff_t count) > >>>> } > >>>> > >>>> reserved =3D 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 =3D=3D 0) { > > if (blkaddr =3D=3D COMPRESS_ADDR) > > continue; > > dn->ofs_in_node +=3D 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 =3D=3D 1) > goto next; It looks good to me. > > Thanks, > > > > >> > >> Thanks, > >> > >>> > >>>> ret =3D inc_valid_block_count(sbi, dn->inode, &res= erved); > >>>> 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