Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2054729rdb; Mon, 9 Oct 2023 10:56:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHE/Rwmjb2JGTySdkXvK5N/LVU/wGZpRzBejEQJp2HK++sYb/A5Bz4pxfTbvolCjLwqmfAV X-Received: by 2002:a17:902:d490:b0:1c6:de7:add9 with SMTP id c16-20020a170902d49000b001c60de7add9mr22162640plg.19.1696874219337; Mon, 09 Oct 2023 10:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696874219; cv=none; d=google.com; s=arc-20160816; b=I3XVN/p9ATWE2287luCt1+yK/EKbduiIQIfxzCqUrdejWAwkEZMwfgc5G2wTohhLSh NrjlvEwNWbWg2iwyfxlGrJ9CedEwxitm8Xa2CWtQV/fvJ/XUopSCkwPCdyCZ9e5p0sGW RPcQ8ZmomVI000UH8GKjJXs4RUd+av7pNcia8nmzX+I1voKR5CW/ZraBMIUD8kYdrGSV K7jZ4hnB+u2ElFCA1zh89KtifYUwaq2Ir08Y4oiAi6xXOFhI3nFKrFPMgxcuW/h1LEo1 9bgNOBbY6oMfQsSs5kldll5HJg37uuiA5rj7mvlBLtW3gTxfZ/jG+3a2PnEAhPKxWtpV m11A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZRt/+3mgSIEWQipS3FEkc0c87GqDD6cp+NOxAG0+0wQ=; fh=KuS+1UlV5gqHbJ37XPD8MCZ1v8KBm0nhjTGQI/haxiI=; b=Un9W5/UBEQMrvVt49+Nba9iIaZgocA1QAAVR2PX/GiclLMCiidMJBISbIovJXNKRtm AvXJBYI6T5gN1hYpV3Uo+z5YmA3UhhsDWY+ErpsWlrBC0sToAnVxa0yovIrhX4TfN3uR orYBXa1eq10jhg59n/Xr/RsJETefdMj3WaF8pqF5AhdDbIkNicZ1caK6XtoBDPevi4/v DCHnrigmD1BL3xwQbe48e5rfHiDVsna4Mgqb9YIy58grLCkPihUAji3g+xCkmkH7zI0V +6XrR54Judzg9SlbkQlcMqIqWa51pJ/0XpG0+WAcrgkDxTQdCzackx7LTwsUUr/j8NCO KXVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V2sw+VQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j10-20020a170902da8a00b001b8ba81d04dsi10991415plx.395.2023.10.09.10.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 10:56:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V2sw+VQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0A42380B120B; Mon, 9 Oct 2023 10:56:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377071AbjJIR4q (ORCPT + 99 others); Mon, 9 Oct 2023 13:56:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376891AbjJIR4p (ORCPT ); Mon, 9 Oct 2023 13:56:45 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB87E94 for ; Mon, 9 Oct 2023 10:56:43 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DC9EC433C7; Mon, 9 Oct 2023 17:56:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696874203; bh=4MAFR8eRn/jRjp4WwCXLLtnADd0TxOn+fdtPOWOfo7M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V2sw+VQv8f0ozr2rncMF7mI6tyJRl5QaqR2TC6GSo7A46dLZWJfthNAfmMJPf2pzs LnkTwKxODVo0wJPr9zWjy/9DzNSr1GdbFBxM49MC9kbCTGnS2gVAUmxNTrKwwCFjez 5Wzcx/ZFFu6UD1dBBwH9OLFFgSOvBazQLPUZodcV2Y1XAnrdh5i61qGvluVxkrAgvb Gh3392etim9H6xDIBoo83BngdlVLuBPzwR3kXPM40jG2XyuXtJ8Y9hyjnY/8Kl7cIm ELuUvZRTewhsRPf95y1sFBxzaD6Ez73MZGX5BugS6xiEXOoBKvUlk5ttjEjv7mAHPh YQXwK1lGvVZEA== Date: Mon, 9 Oct 2023 10:56:41 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH] f2fs: stop iterating f2fs_map_block if hole exists Message-ID: References: <20231003225208.1936359-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 10:56:56 -0700 (PDT) X-Spam-Level: ** On 10/07, Chao Yu wrote: > On 2023/10/4 6:52, Jaegeuk Kim wrote: > > Let's avoid unnecessary f2fs_map_block calls to load extents. > > > > # f2fs_io fadvise willneed 0 4096 /data/local/tmp/test > > > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 386, start blkaddr = 0x34ac00, len = 0x1400, flags = 2, > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 5506, start blkaddr = 0x34c200, len = 0x1000, flags = 2, > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 9602, start blkaddr = 0x34d600, len = 0x1200, flags = 2, > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 14210, start blkaddr = 0x34ec00, len = 0x400, flags = 2, > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 15235, start blkaddr = 0x34f401, len = 0xbff, flags = 2, > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 18306, start blkaddr = 0x350200, len = 0x1200, flags = 2 > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 22915, start blkaddr = 0x351601, len = 0xa7d, flags = 2 > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 25600, start blkaddr = 0x351601, len = 0x0, flags = 0 > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 25601, start blkaddr = 0x351601, len = 0x0, flags = 0 > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 25602, start blkaddr = 0x351601, len = 0x0, flags = 0 > > ... > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 1037188, start blkaddr = 0x351601, len = 0x0, flags = 0 > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 1038206, start blkaddr = 0x351601, len = 0x0, flags = 0 > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 1039224, start blkaddr = 0x351601, len = 0x0, flags = 0 > > f2fs_map_blocks: dev = (254,51), ino = 85845, file offset = 2075548, start blkaddr = 0x351601, len = 0x0, flags = 0 > > Jaegeuk, > > Not sure, but it looks it's due to f2fs_precache_extents() will traverse file > w/ range [0, max_file_blocks), since data which exceeds EOF will always be zero, > so it's not necessary to precache its mapping info, so we'd better adjust upper > boundary to i_size rather than max_file_blocks(). > > > > > Signed-off-by: Jaegeuk Kim > > --- > > fs/f2fs/file.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > index 161826c6e200..2403fd1de5a0 100644 > > --- a/fs/f2fs/file.c > > +++ b/fs/f2fs/file.c > > @@ -3270,7 +3270,7 @@ int f2fs_precache_extents(struct inode *inode) > > f2fs_down_write(&fi->i_gc_rwsem[WRITE]); > > err = f2fs_map_blocks(inode, &map, F2FS_GET_BLOCK_PRECACHE); > > f2fs_up_write(&fi->i_gc_rwsem[WRITE]); > > - if (err) > > + if (err || !map.m_len) > Well, if there is a hole in the head of file, it may break here rather > than precaching following valid map info. > > What about passing parameter offset|len from f2fs_file_fadvise() to > f2fs_precache_extents(), and then precaching mapping info on demand. I'd rather stop reading metadata if it meets a hole within i_size, since this gives benefits when reading the entire non-hole case, FWIW. Rather than that, I think generic readahead flow can hide the metadata loading. > > Thanks, > > > return err; > > map.m_lblk = m_next_extent;