Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp302626rdb; Thu, 24 Aug 2023 06:44:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPmINmrnn2UVGhAMukWhbJ8YlM5EDICayEEJZur8Yw46jH7l2hVfu/vQQGkvaLSsD6F3QU X-Received: by 2002:a17:906:1f17:b0:992:b3a3:81f9 with SMTP id w23-20020a1709061f1700b00992b3a381f9mr11756156ejj.71.1692884657431; Thu, 24 Aug 2023 06:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692884657; cv=none; d=google.com; s=arc-20160816; b=PeuSYjVsls2yLwfCpYnNfpt++4jLztQJkj7H0WusCKW2gediKppT0dIGzIyuzMXYAZ Rz11M8YrVjOuxVr75fnr9Iak45pdevZjeiUTBIhw29adZ3YaTqiniamsrxb+7HePcLmW pVY0OIzoTNtW+0yBgImQL9p+thsxWAAk7Y4PM+SRiFlUH6DmunqPqaIhr1gL9s5eurUN 7Hbz7UkZgrhlZLgU7OOhYMDi180wYOYL1HoVsEPlhCKYUStfGCQ7jzQoU3Uncu5FpGEc ZRQQ39rtCY9Bv5czGauGdy+RP1NbN0eRwQE9ObPiIKFOdm9GaUjho8UEqBSC4TPg7hEJ EnZA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GGDVNhXRgZvdr3ZrIfWdk5pVueKL/BLL4wY8d+HSWZA=; fh=kuRpQQorcKDqUwyIih6K7H1bgjOqULBSCDKVMHeTjvs=; b=yCeibvtBd/xpzJW7KuHiS0YAlSdNdY1Eoi+a3vOvwdRW1pGNZVJ6o45n/QVGy27mKw xv89Z93fuoCKzi9AaOGRShznWWUnf3J0DvUR+IUafAJG5pbZXNq9YQqsGEeF3GA50rNI PkZ4UwPIrfZVdE4v7lC8jF5gHe6yXMjKbHgx/GU4Nb/lAI6h3m2fFv+o+jjYjmhKioFr Ih5iAxrcp/YEp+gxk5zhvi5B3PEFlPuaCPagc+Dt4HNrmJVQKbVEwKeF6wAGH6RlXYpV l+1iIaRSGhiXGCgiElqHJ3Zi7LoPJoWgDiTbIsd8bno0M64VDPDlxfIj69siElVluyp0 rZoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n23-20020a170906841700b00992e22a640csi9889240ejx.547.2023.08.24.06.43.49; Thu, 24 Aug 2023 06:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240331AbjHXJbA (ORCPT + 99 others); Thu, 24 Aug 2023 05:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240784AbjHXJas (ORCPT ); Thu, 24 Aug 2023 05:30:48 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0364519A0 for ; Thu, 24 Aug 2023 02:30:45 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4RWd9W68pXz4f3lK3 for ; Thu, 24 Aug 2023 17:30:39 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAHl6kzI+dkL1rbBQ--.46575S11; Thu, 24 Aug 2023 17:30:43 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [RFC PATCH 07/16] ext4: count inode's total delalloc data blocks into ext4_es_tree Date: Thu, 24 Aug 2023 17:26:10 +0800 Message-Id: <20230824092619.1327976-8-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824092619.1327976-1-yi.zhang@huaweicloud.com> References: <20230824092619.1327976-1-yi.zhang@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAHl6kzI+dkL1rbBQ--.46575S11 X-Coremail-Antispam: 1UD129KBjvJXoWxXrWDWrW7JrWkGr1rKw47twb_yoW5Gw13pa s3A3WUGr4fXw1kWayxXr4UZr1fta48Gay7GrWftr1IkFyUAryftF10yFWjvFyYqrW8Jw45 XF48tw1UGa13KaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j6r xdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI7VAKI48JMx C20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAF wI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20x vE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04k26cxK x2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI 0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQSdkUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,MAY_BE_FORGED, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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-ext4@vger.kernel.org From: Zhang Yi Add a parameter in struct ext4_es_tree to count per-inode's total delalloc data blocks number, it will be used to calculate reserved meta blocks when creating a new delalloc extent entry, or mapping a delalloc entry to a real one or releasing a delalloc entry. Signed-off-by: Zhang Yi --- fs/ext4/extents_status.c | 19 +++++++++++++++++++ fs/ext4/extents_status.h | 1 + 2 files changed, 20 insertions(+) diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 34164c2827f2..b098c3316189 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c @@ -178,6 +178,7 @@ void ext4_es_init_tree(struct ext4_es_tree *tree) { tree->root = RB_ROOT; tree->cache_es = NULL; + tree->da_es_len = 0; } #ifdef ES_DEBUG__ @@ -787,6 +788,20 @@ static inline void ext4_es_insert_extent_check(struct inode *inode, } #endif +/* + * Update total delay allocated extent length. + */ +static inline void ext4_es_update_da_block(struct inode *inode, long es_len) +{ + struct ext4_es_tree *tree = &EXT4_I(inode)->i_es_tree; + + if (!es_len) + return; + + tree->da_es_len += es_len; + es_debug("update da blocks %ld, to %u\n", es_len, tree->da_es_len); +} + static int __es_insert_extent(struct inode *inode, struct extent_status *newes, struct extent_status *prealloc) { @@ -915,6 +930,7 @@ void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, __es_free_extent(es1); es1 = NULL; } + ext4_es_update_da_block(inode, -rinfo.ndelonly_blk); err2 = __es_insert_extent(inode, &newes, es2); if (err2 == -ENOMEM && !ext4_es_must_keep(&newes)) @@ -1571,6 +1587,7 @@ void ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk, __es_free_extent(es); es = NULL; } + ext4_es_update_da_block(inode, -rinfo.ndelonly_blk); write_unlock(&EXT4_I(inode)->i_es_lock); if (err) goto retry; @@ -2161,6 +2178,8 @@ void ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk, pr = NULL; } } + + ext4_es_update_da_block(inode, newes.es_len); error: write_unlock(&EXT4_I(inode)->i_es_lock); if (err1 || err2 || err3 < 0) diff --git a/fs/ext4/extents_status.h b/fs/ext4/extents_status.h index 7344667eb2cd..ee873b305210 100644 --- a/fs/ext4/extents_status.h +++ b/fs/ext4/extents_status.h @@ -66,6 +66,7 @@ struct extent_status { struct ext4_es_tree { struct rb_root root; struct extent_status *cache_es; /* recently accessed extent */ + ext4_lblk_t da_es_len; /* total delalloc len */ }; struct ext4_es_stats { -- 2.39.2