From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.9]) (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 998D0397ACA for ; Thu, 15 Jan 2026 12:49:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768481380; cv=none; b=XEWyTDK4I8049rwVLRfhc7e5OT8OJdR0eyrDpxtM4cwU57iDnWY9yTmcC8XQGHXjaBYl3VCJ9ZyxmwAq0OPzRujtsQJLTi53274RasfxHQDz5h1z3jVsTKSpCUybRlyzUcqqGlFxOpezy2jfOo3vtv0dpRLhRhoZqxL0H1POyQg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768481380; c=relaxed/simple; bh=NgMEStvlc0j3fDI/dtaww6uS/Cc0mEVPc7NDVFflBfI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FRAX6AjH6fkd1c3rBcBmVkBscoraz7I72xVeIV1ZVXWvppf3F3u5i0XljGL+Yv/nEeN64jOMTx39K11q+WbczfS75xRu5IoFTQQan/96AArpMI4/uPqFoqXrFTmm4Q8rBy+A96kIhh0JHnMlPvZhRT288/JVvqmgQ+A/se3FLSY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com; spf=pass smtp.mailfrom=126.com; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b=VALYQ5KZ; arc=none smtp.client-ip=220.197.31.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=126.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=126.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=126.com header.i=@126.com header.b="VALYQ5KZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:To:From: Content-Type; bh=5eCVinJm+L7ouQItCXmIzH+u40QbG89UJd41OTXBx9A=; b=VALYQ5KZHkUTQ8R6Wf7LC7HCBFPT6Ah3QlChd36Tf2xnkRxMGajS6iUmpjVyJX 75gXbrt1wgpMoBeV3HcEGOx3nK5LWAOlqYOBtlOdfW3749Igqa8Tgl9Ta5Gy5Ne3 xFqn1tq2ukqQsKVeGWlafiNX0qigPY4jvyBBjdf0uIuBc= Received: from [IPV6:2409:8a20:4df2:4050:39de:fd86:6396:5263] (unknown []) by gzga-smtp-mtada-g0-3 (Coremail) with SMTP id _____wDnb0c34mhpoW_QBg--.14999S2; Thu, 15 Jan 2026 20:48:56 +0800 (CST) Message-ID: <5e888451-228e-41e5-ada7-a22a61cb84dd@126.com> Date: Thu, 15 Jan 2026 20:48:54 +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] f2fs: avoid f2fs_map_blocks() for consecutive holes in readpages To: Chao Yu Cc: jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20260112013320.8028-1-chao@kernel.org> Content-Language: en-US From: Nanzhe Zhao In-Reply-To: <20260112013320.8028-1-chao@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID:_____wDnb0c34mhpoW_QBg--.14999S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxAF15Wr1fZw17AryxtFW3Awb_yoWrJFy3pF yUtFy3uF45GryIvFsag3WDZF1S934Utayj9wsag343Jwn8tr1SvF92ga43u3W5KF48Zr1U XF45Ja48Wa1YyFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UG9aPUUUUU= X-CM-SenderInfo: xq22xtbr6rjloofrz/xtbBsBk7C2lo4jnULwAA34 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? Thanks,