From mboxrd@z Thu Jan 1 00:00:00 1970 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 612DD3C2F for ; Wed, 7 Jan 2026 01:16:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767748606; cv=none; b=Jw8xDI9/k7u+y/yFXXXzsfcDpyixKsAGp/lceFUiT9qNbwPzZRpROmbHfnQ+pGramJ1XB4mu0bhhbI828Cg3kbXmzrxfVPZYnzZO9pZmlk2oTzRYnjVDfwphEE8OSKNMKa3vpzk+I7Wh8EvGSQkrVT0Z8mLHX4GoZeIMXmtmCtQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767748606; c=relaxed/simple; bh=xKtV6AOaYVPWBBxqvPFR38c99Xn4erhfv9E/aQPjHoA=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=SMMm797GQo9imT1oSMRlK65gonUEQRo12XJ9LoL/7QFgEt6/CZe66DQ8CQIGfRl2o3HhYGzl0b1Wr9WVfZD93oFvwEk/6ehwJ1L6IOTex40w+JsfmDddn6fzJctZFjqktquNTES0acTQ+fwNZTij/XH/NqFSepGiWR+WsKzub8A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ff3gEjVq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ff3gEjVq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10DC5C116C6; Wed, 7 Jan 2026 01:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767748606; bh=xKtV6AOaYVPWBBxqvPFR38c99Xn4erhfv9E/aQPjHoA=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=Ff3gEjVqn2FeA+tVN0uBp1kAY0JBEo55Jc3TiRFvKGoweIGk0EDuP8Pe7XIcDJjyI LhLPpASYqlifTUcDFetU1d8ccUiKaXZphx4QrhcFZrQ+YpD0knbHCkkpl0cWN8dZxH 64xcVB++tJyExZAJQlMSCb1QU+TV4tx6b1I10wPHT/KEMdBN0NW1gcA5lCMWkof65M wGgrg1tmlrj+ob4ImdoEu/RWfqULiOt5Fz7Jie8uxENVIeo78HThvkBac/uPMUaISj sRluATBjt2GlGe46JJhS92jn6SvX0lyUX68Y8Dl3hzKWUmeTcKMpDbTgPyp7fLh5nU 15iDEvl2/51UQ== Message-ID: Date: Wed, 7 Jan 2026 09:16:50 +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 Cc: chao@kernel.org, Kim Jaegeuk , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 4/5] f2fs: add 'folio_in_bio' to handle readahead folios with no BIO submission To: Nanzhe Zhao References: <20260105153101.152892-1-nzzhao@126.com> <20260105153101.152892-5-nzzhao@126.com> <5ca2ef6a-ce46-4d80-b2e0-ff35c628e0ba@kernel.org> <6a3d4e52.402.19b95df7350.Coremail.nzzhao@126.com> Content-Language: en-US From: Chao Yu In-Reply-To: <6a3d4e52.402.19b95df7350.Coremail.nzzhao@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/7/2026 8:33 AM, Nanzhe Zhao wrote: > Hi Chao yu: > At 2026-01-06 17:31:20, "Chao Yu" wrote: >>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>>> index 66ab7a43a56f..ac569a396914 100644 >>>> --- a/fs/f2fs/data.c >>>> +++ b/fs/f2fs/data.c >>>> @@ -2430,6 +2430,7 @@ static int f2fs_read_data_large_folio(struct inode *inode, >>>> unsigned nrpages; >>>> struct f2fs_folio_state *ffs; >>>> int ret = 0; >>>> + bool folio_in_bio = false; >>> >>> No need to initialize folio_in_bio? > > Agreed. It's redundant since we reset it to false for each new folio before processing. > >>>> @@ -2539,6 +2542,11 @@ static int f2fs_read_data_large_folio(struct inode *inode, >>>> } >>>> trace_f2fs_read_folio(folio, DATA); >>>> if (rac) { >>>> + if (!folio_in_bio) { >>>> + if (!ret) >>>> + folio_mark_uptodate(folio); >>>> + folio_unlock(folio); >>>> + } >>> >>> err_out: >>> /* Nothing was submitted. */ >>> if (!bio) { >>> if (!ret) >>> folio_mark_uptodate(folio); >>> folio_unlock(folio); >>> >>> ^^^^^^^^^^^^ >>> >>> If all folios in rac have not been mapped (hole case), will we unlock the folio twice? > > Are you worried the folio could be unlocked once in the if (rac) { ... } block and then > unlocked again at err_out:? If so, I think that won't happen. > > In such a case, every non-NULL folio will be unlocked exactly once by: > > if (!folio_in_bio) { > if (!ret) > folio_mark_uptodate(folio); > folio_unlock(folio); > } > Specifically, after the last folio runs through the block above, the next call: > > folio = readahead_folio(rac); > will return NULL. Then we go to next_folio:, and will directly hit: > > if (!folio) > goto out; > This jumps straight to the out: label, skipping err_out: entirely. > Therefore, when ret is not an error code, the err_out: label will never be reached. > > If ret becomes an error code, then the current folio will immediately goto err_out; > and be unlocked there once. > > If rac is NULL (meaning we only read the single large folio passed in as the function argument), > we won't enter the if (rac) { ... goto next_folio; } path at all, so we also won't go to next_folio > and then potentially goto out;. In that case, it will naturally be unlocked once at err_out:. > Or am I missing some edge case here? Nanzhe, Oh, yes, I think so, thanks for the explanation. Thanks, > > Thanks, > Nanzhe