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 66BB030EF9A for ; Tue, 6 Jan 2026 09:19:09 +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=1767691150; cv=none; b=SF2CC/J1US15LWMJ8CCYJvc1UaGyr6Wjd/4dZ0+RHgj/1gtj5uGXVHIDrPBARU7/rG4r+aGTq5NoCtXgI8PPX5Z+0dgzf94ycTwDF+Ss6Qy7PLDbZyn/cpmk4ZhIi8H6tHDkPqfYWwCJqH0g/KroFTMHGZPPMDkBfI6OXWVUDPc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767691150; c=relaxed/simple; bh=HM7bO4kGE61iGCmc+DywYU7RkkXgKI7ZuQwEXodrOqk=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=PSEJ2HUFz5gGCmZKel3E6xt7O5KWXAXSznqXHmT+rFZU14s8WZQIqkgwp6mnZgWPYhQBapr6kMJpdhAsKQKs2sGwFxD/ws7dYm6sCrdFVIpHdEkZp+sL8JwF1QxPJP37VxrQESR+vKXMUfuA5/XFTXyglSSks8iicd81rYceVqU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pclQmq9d; 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="pclQmq9d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1792C116C6; Tue, 6 Jan 2026 09:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1767691149; bh=HM7bO4kGE61iGCmc+DywYU7RkkXgKI7ZuQwEXodrOqk=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=pclQmq9d9pAdkLxYlolSQoK+5cNcFgY/EVKwrbZ7SNWkezoewCWmR6EomVXPkiKB6 ksxv+lemSzPr+DrBbUFJX8hQ56A99sEQfSsksSgFM+LjcVqgWBvHIeXfFj2kI3sr+m C3fFTbWe1T2JGlnto0QmoT3l9ZqbUV+nZP6WV8gRm/FWz/xl5FBtzhckCH/j2gWRgl IMzfWUTlqpYgXQiRAnB0s/8xyWknT79Pqcvi4ovuSPWvhaalMCoAOG3sZVfbe7R2I1 2+YidKDs9T3QYqKnF5GOSNYSCRSuBLQiqdYTBHazaL6rMac2RrFy4mI3C/iHJJFj74 lfyJjDDobgCnA== Message-ID: <9b4f9818-f8fd-4af2-8f5e-bab768bac8c9@kernel.org> Date: Tue, 6 Jan 2026 17:19:14 +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, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 3/5] f2fs: add f2fs_block_needs_zeroing() to handle hole blocks To: Nanzhe Zhao , Kim Jaegeuk References: <20260105153101.152892-1-nzzhao@126.com> <20260105153101.152892-4-nzzhao@126.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20260105153101.152892-4-nzzhao@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/5/2026 11:30 PM, Nanzhe Zhao wrote: > f2fs_read_data_large_folio() relies on f2fs_map_blocks() to decide whether > a subpage should be zero-filled or queued to a read bio. > > However, f2fs_map_blocks() can set F2FS_MAP_MAPPED for NULL_ADDR and > NEW_ADDR in the non-DIO, no-create path. The large folio read code then Nanzhe, IIUC, f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_DEFAULT) won't map hole space, or am I missing something? Thanks, > treats such hole blocks as mapped blocks, and may account them > in read_pages_pending and attempt to build bios for them, which can > leave tasks stuck in readahead for heavily fragmented files. > > Add a helper, f2fs_block_needs_zeroing(), which detects NULL_ADDR and > NEW_ADDR from struct f2fs_map_blocks. Use it to prioritize the zeroing > path by checking f2fs_block_needs_zeroing() before > (map.m_flags & F2FS_MAP_MAPPED) under got_it: label. > > Signed-off-by: Nanzhe Zhao > --- > fs/f2fs/data.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 4bef04560924..66ab7a43a56f 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -2413,6 +2413,11 @@ static void ffs_detach_free(struct folio *folio) > kmem_cache_free(ffs_entry_slab, ffs); > } > > +static inline bool f2fs_block_needs_zeroing(const struct f2fs_map_blocks *map) > +{ > + return map->m_pblk == NULL_ADDR || map->m_pblk == NEW_ADDR; > +} > + > static int f2fs_read_data_large_folio(struct inode *inode, > struct readahead_control *rac, struct folio *folio) > { > @@ -2468,14 +2473,7 @@ static int f2fs_read_data_large_folio(struct inode *inode, > if (ret) > goto err_out; > got_it: > - if ((map.m_flags & F2FS_MAP_MAPPED)) { > - block_nr = map.m_pblk + index - map.m_lblk; > - if (!f2fs_is_valid_blkaddr(F2FS_I_SB(inode), block_nr, > - DATA_GENERIC_ENHANCE_READ)) { > - ret = -EFSCORRUPTED; > - goto err_out; > - } > - } else { > + if ((f2fs_block_needs_zeroing(&map))) { > folio_zero_range(folio, offset << PAGE_SHIFT, PAGE_SIZE); > if (f2fs_need_verity(inode, index) && > !fsverity_verify_page(folio_file_page(folio, > @@ -2484,6 +2482,13 @@ static int f2fs_read_data_large_folio(struct inode *inode, > goto err_out; > } > continue; > + } else if((map.m_flags & F2FS_MAP_MAPPED)) { > + block_nr = map.m_pblk + index - map.m_lblk; > + if (!f2fs_is_valid_blkaddr(F2FS_I_SB(inode), block_nr, > + DATA_GENERIC_ENHANCE_READ)) { > + ret = -EFSCORRUPTED; > + goto err_out; > + } > } > > /* We must increment read_pages_pending before possible BIOs submitting > -- > 2.34.1 >