Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp310638rdh; Thu, 23 Nov 2023 04:52:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZL7AIzlgrUfY/KiaQPSbtuFRj6Sf+jDzFTe+eSDAAMrfAv8Z1QnXH7ZROGA7Ld36HxF68 X-Received: by 2002:a05:6358:1082:b0:16d:bb7b:c0a6 with SMTP id j2-20020a056358108200b0016dbb7bc0a6mr5931090rwi.10.1700743959339; Thu, 23 Nov 2023 04:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700743959; cv=none; d=google.com; s=arc-20160816; b=W0R0Pbx72WUHHYR1TrWx85zp1RZd6AGT7Q4w537Vt116qzKLp5B9Q/8bjv2o2mG48R qb7pIafettzXXvWXbXoW+GdPkZ2oM9xNxA+99YPdkBAClTVm2V9sAi+gYMCfV7pGg5jL aZAIYiG67c/x2h3zeqgJw2t+NdBl262BHi1DKHD997NDSJSQTtJH+HP4T4gAeHEurDnb Q14Ijttj23I7Gbotk/HoVRq+5IO8xWQ2k5puBSYe7NnethFyXewPdWBNTeeW5HJ69GMf eXdcQuVi5YwihJ7VCTBTkzUZkZ/FsB5Y7mhCI2m+elSXhpHmCckAyYC735txRM6ksrNv 4ugw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=m6aHdjmGBWOIlHM3CJTKwBPQ7oYlHWALHe02acJoTYM=; fh=oXgJbFeK1mY0T4jBbK/Fs3Mi9F4SdMRqpoziDljuAF4=; b=RW4VwU31xgVFO9g86N/8QdwgFWVjjbJHEzyh7OnghXkr94UF+E5D4z9fEUNDPbcBgW FKvszqHBAzP2JV9jxm7xGIlCQ5AhCGY5R6tmtQ8I18pTmReihXhGW1/kGwnMFhom8XQ5 Zm17VIYF+DsjGbuiAxwJ0Fts+e6NOpumoyBaMUMnCtVVrgN3DOrTKDOhYTSQaBAkFyTR EatM0EWJsmZZwQDriXAsfTyQAi+6xEasuA4dw92oMkNI//mIHzrwcDfY5//j7G1Z/L7W 8VL8A3fg1DsdWfAYaukqfn17dUC3UxX5rDzj6O5QX4XZkcfhETbKGLauaKCFEXYHrSfD 3iCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-110-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w2-20020a0cf702000000b00678029eeb9asi1080573qvn.231.2023.11.23.04.52.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 04:52:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-110-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-110-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0DDE61C2103D for ; Thu, 23 Nov 2023 12:52:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D70E725565; Thu, 23 Nov 2023 12:52:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC90AD41; Thu, 23 Nov 2023 04:52:03 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SbdKl62qrz4f3m6f; Thu, 23 Nov 2023 20:51:55 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id F34F81A0479; Thu, 23 Nov 2023 20:51:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDn6xHdSl9lSfnfBg--.20473S6; Thu, 23 Nov 2023 20:51:59 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [RFC PATCH 02/18] ext4: make ext4_es_lookup_extent() return the next extent if not found Date: Thu, 23 Nov 2023 20:51:04 +0800 Message-Id: <20231123125121.4064694-3-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123125121.4064694-1-yi.zhang@huaweicloud.com> References: <20231123125121.4064694-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgDn6xHdSl9lSfnfBg--.20473S6 X-Coremail-Antispam: 1UD129KBjvJXoW7Wryxuw1rtw15CFW7XrW8JFb_yoW8GFWfp3 sxZ34UKrW8uw10ka1xKr1UXr1Yg3W8KFWxGry3Kr1fG3Z3J34SkF1YyFy2va4kWrW8Gw4Y qay8KrZrGayjvrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUHbyAUUUUU = X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Make ext4_es_lookup_extent() return the next extent entry if we can't find the extent that lblk belongs to, it's useful to estimate and limit the length of a potential hole in ext4_map_blocks(). Signed-off-by: Zhang Yi --- fs/ext4/extents_status.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 1b1b1a8848a8..19a0cc904cd8 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c @@ -1012,19 +1012,9 @@ int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, goto out; } - node = tree->root.rb_node; - while (node) { - es1 = rb_entry(node, struct extent_status, rb_node); - if (lblk < es1->es_lblk) - node = node->rb_left; - else if (lblk > ext4_es_end(es1)) - node = node->rb_right; - else { - found = 1; - break; - } - } - + es1 = __es_tree_search(&tree->root, lblk); + if (es1 && in_range(lblk, es1->es_lblk, es1->es_len)) + found = 1; out: stats = &EXT4_SB(inode->i_sb)->s_es_stats; if (found) { @@ -1045,6 +1035,11 @@ int ext4_es_lookup_extent(struct inode *inode, ext4_lblk_t lblk, *next_lblk = 0; } } else { + if (es1) { + es->es_lblk = es1->es_lblk; + es->es_len = es1->es_len; + es->es_pblk = es1->es_pblk; + } percpu_counter_inc(&stats->es_stats_cache_misses); } -- 2.39.2