From mboxrd@z Thu Jan 1 00:00:00 1970 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 20DA8D4A613 for ; Fri, 16 Jan 2026 08:52:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Type:Content-Transfer-Encoding:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:In-Reply-To:References:To:MIME-Version:Date: Message-ID:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=x1xB2k2pevKfMrY2tjZBKs2uQTRS++59K49d5HN+uAg=; b=ZMENL816ADKNG6Uk3Cj5bwlkpu 906jT3XVZMfztenpwZ3CTN+9dHKqbo5pzChJpd6mR8Q+0uOIdApncp5dhcOy/sGj9/QQn+oLWUNNt Ql79a1hDahlgEv/M6Um2BBrJ22lDS8siCJX00r93CbPNKjafeg9wge3AitLk8JVG+Q4g=; 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 1vgfYx-0000tG-Sy; Fri, 16 Jan 2026 08:52:12 +0000 Received: from [172.30.29.66] (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 1vgfYw-0000t3-Iy for linux-f2fs-devel@lists.sourceforge.net; Fri, 16 Jan 2026 08:52:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: From:References:To:Subject:Cc:MIME-Version:Date:Message-ID:Sender:Reply-To: 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=n+OOERGBuU/eEjCp1ha38wJ5HyY6ce/nMwEGAWhOWb0=; b=RUG8DupDJU7QkKmIwLSU+6woUH 2di1jiVNqAMtxfwE2Sa43FUEqnHeBhIU3qf3gkZha+fXcBs2ma2cx18yIDE3ucwfOEL+hlDjPDs0n RKFNaInr6Pq7mqrh6oJmP2+YfLdyuwaMH/sYlIsUjcHc5suLjC83qKU88N2uxZxEHttQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:To: Subject:Cc:MIME-Version:Date:Message-ID:Sender:Reply-To: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=n+OOERGBuU/eEjCp1ha38wJ5HyY6ce/nMwEGAWhOWb0=; b=CJlf6Gf0lMG0Gj5yW3LDksMmlS YDl8Rk7LlBlZvHl7oLaTicUlZjvp3LfdgYBm4VPz12rl7iIafdP2IKsM63MTtlXkJVENABUbWlwlE Xgz2R9HaX5rKYVE38gQasa/60icG8qSau1BubVxuXcZ4JJV5j+VwNmpraS2/fPBVr0Sw=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vgfYw-0000xf-Nn for linux-f2fs-devel@lists.sourceforge.net; Fri, 16 Jan 2026 08:52:11 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id EE65260160; Fri, 16 Jan 2026 08:51:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BDA4C116C6; Fri, 16 Jan 2026 08:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768553519; bh=/zsgcs8Fw8H+LfE4CH7aLQ1FuP0loEYnkIsVJQ3YFXs=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=Zq0POuEmVGPeVnRtjlMlWshSSqVLIjvo7GDAixjP5KdefO2VKvjJjlRNilgt5qTXO IhMkMbq41Xwnn88UvhLve8/IQqaIElBumKuVJws5j8QI7TVjHLgJz8OoYQEo669Lbn qqhCIKI53GiOKG3mdXgPnJh9snkLpWygX4VswCMM6Z9W7BwGscMaeZ2QAkiB1cZx+N 4TgMXA7alSGmmm54jMyg6svPDQtgDMWWcBirZwKD/VUrxbAUB+7EqN5+7gJHrtzAv/ VH1psjgTphtju+P4J7KNj2tsYOUiZsfs1EXM5t4ni2D5sLe05OM/ehG/xA9RTv2e29 8DGwC2DlZWvPg== Message-ID: <32fa7311-0393-4e71-a927-3c502e40efd8@kernel.org> Date: Fri, 16 Jan 2026 16:52:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Nanzhe Zhao References: <20260112013320.8028-1-chao@kernel.org> <5e888451-228e-41e5-ada7-a22a61cb84dd@126.com> Content-Language: en-US In-Reply-To: <5e888451-228e-41e5-ada7-a22a61cb84dd@126.com> X-Headers-End: 1vgfYw-0000xf-Nn Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid f2fs_map_blocks() for consecutive holes in readpages 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: , From: Chao Yu via Linux-f2fs-devel Reply-To: Chao Yu Cc: jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 1/15/2026 8:48 PM, Nanzhe Zhao wrote: > Hi Chao: > > On 2026/1/12 09:33, Chao Yu via Linux-f2fs-devel wrote: >> For consecutive large hole mapping across {d,id,did}nodes , we don't >> need to call f2fs_map_blocks() to check one hole block per one time, >> instead, we can use map.m_next_pgofs as a hint of next potential valid >> block, so that we can skip calling f2fs_map_blocks the range of >> [cur_pgofs + 1, .m_next_pgofs). >> >> 1) regular case >> >> touch /mnt/f2fs/file >> truncate -s $((1024*1024*1024)) /mnt/f2fs/file >> time dd if=/mnt/f2fs/file of=/dev/null bs=1M count=1024 >> >> Before: >> real 0m0.706s >> user 0m0.000s >> sys 0m0.706s >> >> After: >> real 0m0.620s >> user 0m0.008s >> sys 0m0.611s >> >> 2) large folio case >> >> touch /mnt/f2fs/file >> truncate -s $((1024*1024*1024)) /mnt/f2fs/file >> f2fs_io setflags immutable /mnt/f2fs/file >> sync >> echo 3 > /proc/sys/vm/drop_caches >> time dd if=/mnt/f2fs/file of=/dev/null bs=1M count=1024 >> >> Before: >> real 0m0.438s >> user 0m0.004s >> sys 0m0.433s >> >> After: >> real 0m0.368s >> user 0m0.004s >> sys 0m0.364s >> >> Signed-off-by: Chao Yu >> --- >> fs/f2fs/data.c | 21 +++++++++++++++------ >> 1 file changed, 15 insertions(+), 6 deletions(-) >> >> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >> index a2c4769d0ae1..5b0642cd27ff 100644 >> --- a/fs/f2fs/data.c >> +++ b/fs/f2fs/data.c >> @@ -2176,10 +2176,13 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio, >> /* >> * Map blocks using the previous result first. >> */ >> - if ((map->m_flags & F2FS_MAP_MAPPED) && >> - block_in_file > map->m_lblk && >> + if (map->m_flags & F2FS_MAP_MAPPED) { >> + if (block_in_file > map->m_lblk && >> block_in_file < (map->m_lblk + map->m_len)) >> + goto got_it; >> + } else if (block_in_file < *map->m_next_pgofs) { >> goto got_it; >> + } >> >> /* >> * Then do more f2fs_map_blocks() calls until we are >> @@ -2454,7 +2457,7 @@ static int f2fs_read_data_large_folio(struct inode *inode, >> struct bio *bio = NULL; >> sector_t last_block_in_bio = 0; >> struct f2fs_map_blocks map = {0, }; >> - pgoff_t index, offset; >> + pgoff_t index, offset, next_pgofs = 0; >> unsigned max_nr_pages = rac ? readahead_count(rac) : >> folio_nr_pages(folio); >> unsigned nrpages; >> @@ -2487,16 +2490,21 @@ static int f2fs_read_data_large_folio(struct inode *inode, >> /* >> * Map blocks using the previous result first. >> */ >> - if ((map.m_flags & F2FS_MAP_MAPPED) && >> - index > map.m_lblk && >> + if (map.m_flags & F2FS_MAP_MAPPED) { >> + if (index > map.m_lblk && >> index < (map.m_lblk + map.m_len)) >> + goto got_it; >> + } else if (index < next_pgofs) { >> + /* hole case */ >> goto got_it; >> + } >> >> /* >> * Then do more f2fs_map_blocks() calls until we are >> * done with this page. >> */ >> memset(&map, 0, sizeof(map)); >> + map.m_next_pgofs = &next_pgofs; >> map.m_seg_type = NO_CHECK_TYPE; >> map.m_lblk = index; >> map.m_len = max_nr_pages; >> @@ -2617,6 +2625,7 @@ static int f2fs_mpage_readpages(struct inode *inode, >> pgoff_t nc_cluster_idx = NULL_CLUSTER; >> pgoff_t index; >> #endif >> + pgoff_t next_pgofs = 0; >> unsigned nr_pages = rac ? readahead_count(rac) : 1; >> struct address_space *mapping = rac ? rac->mapping : folio->mapping; >> unsigned max_nr_pages = nr_pages; >> @@ -2637,7 +2646,7 @@ static int f2fs_mpage_readpages(struct inode *inode, >> map.m_lblk = 0; >> map.m_len = 0; >> map.m_flags = 0; >> - map.m_next_pgofs = NULL; >> + map.m_next_pgofs = &next_pgofs; >> map.m_next_extent = NULL; >> map.m_seg_type = NO_CHECK_TYPE; >> map.m_may_create = false; > > Do we have plans to also support reducing f2fs_map_blocks() calls for > consectives holes in logical file postion with dnode have already been > allocated in buffered large folio read? > Such as consective NULL_ADDR or NEW_ADDR? Nanzhe, We have supported that for large folio read w/ this patch? Thanks, > > Thanks, > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel 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 42C6825F994 for ; Fri, 16 Jan 2026 08:51:59 +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=1768553520; cv=none; b=p6i3z7d98MWPUYJXmAF5a66aXiebIGS3ls1xsf8+gPXvfb9LtS3GJ5q+cpGTA3ALNr6FWEK6DQveJdhgPukuIykjjEb+m5BLKPvWPprQ8iVKifeX7aTTavCwGeekQ4drlm1D2KzfIovU3/MWqizUnSYTThUcOyUG7NgXIPBBtrI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768553520; c=relaxed/simple; bh=/zsgcs8Fw8H+LfE4CH7aLQ1FuP0loEYnkIsVJQ3YFXs=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=Wn0IZ/0sVHgo8+m4Xls+Y40reFIuk5xyUNZUqKVbZ8UEBcTrdWbOJzW/lMzHvMEu7LXZHwDaN4r6nJhPPlqJjVURfqRdzk+gCRkftJSxj8lc8pIrrLTl82bOhM1/4MFi/31RAdvvbRm7/jutWJojAD4iW+jL3s4JEDgrA3eTnHs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zq0POuEm; 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="Zq0POuEm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BDA4C116C6; Fri, 16 Jan 2026 08:51:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768553519; bh=/zsgcs8Fw8H+LfE4CH7aLQ1FuP0loEYnkIsVJQ3YFXs=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=Zq0POuEmVGPeVnRtjlMlWshSSqVLIjvo7GDAixjP5KdefO2VKvjJjlRNilgt5qTXO IhMkMbq41Xwnn88UvhLve8/IQqaIElBumKuVJws5j8QI7TVjHLgJz8OoYQEo669Lbn qqhCIKI53GiOKG3mdXgPnJh9snkLpWygX4VswCMM6Z9W7BwGscMaeZ2QAkiB1cZx+N 4TgMXA7alSGmmm54jMyg6svPDQtgDMWWcBirZwKD/VUrxbAUB+7EqN5+7gJHrtzAv/ VH1psjgTphtju+P4J7KNj2tsYOUiZsfs1EXM5t4ni2D5sLe05OM/ehG/xA9RTv2e29 8DGwC2DlZWvPg== Message-ID: <32fa7311-0393-4e71-a927-3c502e40efd8@kernel.org> Date: Fri, 16 Jan 2026 16:52:02 +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, jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid f2fs_map_blocks() for consecutive holes in readpages To: Nanzhe Zhao References: <20260112013320.8028-1-chao@kernel.org> <5e888451-228e-41e5-ada7-a22a61cb84dd@126.com> Content-Language: en-US From: Chao Yu In-Reply-To: <5e888451-228e-41e5-ada7-a22a61cb84dd@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/15/2026 8:48 PM, Nanzhe Zhao wrote: > Hi Chao: > > On 2026/1/12 09:33, Chao Yu via Linux-f2fs-devel wrote: >> For consecutive large hole mapping across {d,id,did}nodes , we don't >> need to call f2fs_map_blocks() to check one hole block per one time, >> instead, we can use map.m_next_pgofs as a hint of next potential valid >> block, so that we can skip calling f2fs_map_blocks the range of >> [cur_pgofs + 1, .m_next_pgofs). >> >> 1) regular case >> >> touch /mnt/f2fs/file >> truncate -s $((1024*1024*1024)) /mnt/f2fs/file >> time dd if=/mnt/f2fs/file of=/dev/null bs=1M count=1024 >> >> Before: >> real 0m0.706s >> user 0m0.000s >> sys 0m0.706s >> >> After: >> real 0m0.620s >> user 0m0.008s >> sys 0m0.611s >> >> 2) large folio case >> >> touch /mnt/f2fs/file >> truncate -s $((1024*1024*1024)) /mnt/f2fs/file >> f2fs_io setflags immutable /mnt/f2fs/file >> sync >> echo 3 > /proc/sys/vm/drop_caches >> time dd if=/mnt/f2fs/file of=/dev/null bs=1M count=1024 >> >> Before: >> real 0m0.438s >> user 0m0.004s >> sys 0m0.433s >> >> After: >> real 0m0.368s >> user 0m0.004s >> sys 0m0.364s >> >> Signed-off-by: Chao Yu >> --- >> fs/f2fs/data.c | 21 +++++++++++++++------ >> 1 file changed, 15 insertions(+), 6 deletions(-) >> >> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >> index a2c4769d0ae1..5b0642cd27ff 100644 >> --- a/fs/f2fs/data.c >> +++ b/fs/f2fs/data.c >> @@ -2176,10 +2176,13 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio, >> /* >> * Map blocks using the previous result first. >> */ >> - if ((map->m_flags & F2FS_MAP_MAPPED) && >> - block_in_file > map->m_lblk && >> + if (map->m_flags & F2FS_MAP_MAPPED) { >> + if (block_in_file > map->m_lblk && >> block_in_file < (map->m_lblk + map->m_len)) >> + goto got_it; >> + } else if (block_in_file < *map->m_next_pgofs) { >> goto got_it; >> + } >> >> /* >> * Then do more f2fs_map_blocks() calls until we are >> @@ -2454,7 +2457,7 @@ static int f2fs_read_data_large_folio(struct inode *inode, >> struct bio *bio = NULL; >> sector_t last_block_in_bio = 0; >> struct f2fs_map_blocks map = {0, }; >> - pgoff_t index, offset; >> + pgoff_t index, offset, next_pgofs = 0; >> unsigned max_nr_pages = rac ? readahead_count(rac) : >> folio_nr_pages(folio); >> unsigned nrpages; >> @@ -2487,16 +2490,21 @@ static int f2fs_read_data_large_folio(struct inode *inode, >> /* >> * Map blocks using the previous result first. >> */ >> - if ((map.m_flags & F2FS_MAP_MAPPED) && >> - index > map.m_lblk && >> + if (map.m_flags & F2FS_MAP_MAPPED) { >> + if (index > map.m_lblk && >> index < (map.m_lblk + map.m_len)) >> + goto got_it; >> + } else if (index < next_pgofs) { >> + /* hole case */ >> goto got_it; >> + } >> >> /* >> * Then do more f2fs_map_blocks() calls until we are >> * done with this page. >> */ >> memset(&map, 0, sizeof(map)); >> + map.m_next_pgofs = &next_pgofs; >> map.m_seg_type = NO_CHECK_TYPE; >> map.m_lblk = index; >> map.m_len = max_nr_pages; >> @@ -2617,6 +2625,7 @@ static int f2fs_mpage_readpages(struct inode *inode, >> pgoff_t nc_cluster_idx = NULL_CLUSTER; >> pgoff_t index; >> #endif >> + pgoff_t next_pgofs = 0; >> unsigned nr_pages = rac ? readahead_count(rac) : 1; >> struct address_space *mapping = rac ? rac->mapping : folio->mapping; >> unsigned max_nr_pages = nr_pages; >> @@ -2637,7 +2646,7 @@ static int f2fs_mpage_readpages(struct inode *inode, >> map.m_lblk = 0; >> map.m_len = 0; >> map.m_flags = 0; >> - map.m_next_pgofs = NULL; >> + map.m_next_pgofs = &next_pgofs; >> map.m_next_extent = NULL; >> map.m_seg_type = NO_CHECK_TYPE; >> map.m_may_create = false; > > Do we have plans to also support reducing f2fs_map_blocks() calls for > consectives holes in logical file postion with dnode have already been > allocated in buffered large folio read? > Such as consective NULL_ADDR or NEW_ADDR? Nanzhe, We have supported that for large folio read w/ this patch? Thanks, > > Thanks, >