Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2260081rdb; Tue, 3 Oct 2023 15:52:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELx1NsxxePIWzH4MIyf136sktWVvqQjGUKahXhIdCxRemvyfflXLZjhQFK0Amsu9rGKc0H X-Received: by 2002:a05:6870:64a7:b0:1d1:40a6:e82d with SMTP id cz39-20020a05687064a700b001d140a6e82dmr919413oab.59.1696373543075; Tue, 03 Oct 2023 15:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696373543; cv=none; d=google.com; s=arc-20160816; b=zthdTdkz/S5Oi/utQPy08DWGNWTVJEPJ37dx9zubjxTgwfpwpJ48OTcHrpN5kYy9hv 8AxdO9vZTdAJh6PiGI5jtAxCzp2o5zezcmUVKsNd2gHJcqiP1ydZSVUo4bRQvU3wWSei Zv6vz5XNCgfa/KtR+O++aziU4eJAIkTiZh10fqRbpeeYOUPZCkxoyAkR/YdXgeqsW1h7 p1WjadW/a7NNgJih34nuJTSvHymnlCXezsfMi6NVpkQqgXBu6lJGyprdeq7ylUpqD2QQ OYHGEyT21GRBXBaDTGTWUJe6eNS/1M8w+w6YxWJBJR5GtM7mjgIIgm+fNYpxXbDE4FIX Bm7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QFJHG4MApC2VrGBRfY0KV3r+q1koqCRwIvJ+1iywOvQ=; fh=rqHW7NazYv3wAmgqDKAbZUXWTmf0VaM5epB9R4zfTUE=; b=hxMXt3D+4Bu1jaRKSU88bqi9rti6Bcm8u9BZUBsTh1SdNJTeeBrbZ/HZDXJsxaTvSB em9+TXxAMDslPqUqx80S9ZPFYysgl44P/8JC3DINskAek38cO6/1okQbcGYHleULus4M q3aqJP60s0+MEs5tBmmhzvBHcOXv+QdlYa6EpPBe7MXi7awMWAbPnWH4rGKrFpTotYnK Dmn4dAZ9eGLGXseq34p8BG+l0jAPPmVKG3UEbg0uUbbM9la1svCZXzgHfinh10aa1p5a BIJRZEEsE75c4JvSl/yC1BD8YVYfeLw/us9NBD4cW5R8e/UPg167ausP7500w7lDy4Gv yqlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HF6nIf/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id w12-20020a056a0014cc00b0068a6f573f6asi2603057pfu.213.2023.10.03.15.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 15:52:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HF6nIf/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 995AC81B93D5; Tue, 3 Oct 2023 15:52:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231600AbjJCWwW (ORCPT + 99 others); Tue, 3 Oct 2023 18:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjJCWwV (ORCPT ); Tue, 3 Oct 2023 18:52:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98EA09E for ; Tue, 3 Oct 2023 15:52:18 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21A47C433C7; Tue, 3 Oct 2023 22:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696373538; bh=DAv2AfX6INF2/9pEZJP+mKh8rXKAu51RSvWoW5djUnA=; h=From:To:Cc:Subject:Date:From; b=HF6nIf/t1kA+ZxoD3boKZynlbN/56xiURDRVeBwjZ9dyZGcm1B9CC0JAGfJiMZgc0 8IPSPTEjMiSyXBHMkxRgkl2OEUlGrBfPJlHmxsDsODzuY5hF8A4E0C2z9Jeg8Aes4n DoGuxmHQPMvTDDdQroZu8T6cjxZCb6V29OvDZX5WG9hwikidufm62yGJJqGWqMt0hA rys+7LO8OG4/pmXsgwrS8C2ZzT1+zUkjz/f+m17zxQk86+3I8slTWIhrES9yR+TceW dJgwPjTPMkJ+Z7u4CKVvHHCX5WM5sbIscSmsiTUHJTFxlclvxjLpVibOWO3WXtFXrt XXk/0v+avs9XQ== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH] f2fs: stop iterating f2fs_map_block if hole exists Date: Tue, 3 Oct 2023 15:52:08 -0700 Message-ID: <20231003225208.1936359-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 15:52:21 -0700 (PDT) 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 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) return err; map.m_lblk = m_next_extent; -- 2.42.0.582.g8ccd20d70d-goog