Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3186884rwd; Sat, 3 Jun 2023 00:03:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72ajxW3KvRgUoSmg4ckH1rtqiB6fE3pDs1v2+trSGtqETBAtw5gqiaSv8dAG9uMSfqgcTV X-Received: by 2002:a17:90a:1996:b0:255:c061:9e5b with SMTP id 22-20020a17090a199600b00255c0619e5bmr2031212pji.37.1685775803499; Sat, 03 Jun 2023 00:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685775803; cv=none; d=google.com; s=arc-20160816; b=A6Ik8tAasweL4DYIE/p+KOtwqHmJTaMltVWSSNNzmqYM0QBp0JQZQF+q6EWdHOQAjL XRAH/4kiqmmZFbtmOstBzQcVeVpE7/p6WR9HFOCm20ZnVkXLYALf1QqO6IEW9cUqGXql GoKNfR0SYkV1DoBjVS1//7KyMNZ47UedR971wNsGKYg/TqVBAD5Etder7sz3OBtoaLxl nJg3LOmz+3LcuzPVcMEAvJACLthPaP4ZYMc2Ni0AcLsm1K/Qz8mH2NkCvM9EV7zu7kMN 3vltvIp3Dcd7svNQrJWwruW5LxYOWzABYRb2bw6eYFLEjUzHb2WFgmMzCt827b/a/NQG +twQ== 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=+ax4RqThsq0WQr4zoJO5GnpCTurplSGI4fySmlXZGUU=; b=acI2M+eS3MHXaOvNjwpUn/6HxExnxjEqKYgg5zEHe7xPRYlVC1Awv8aj8nNQ1JljIV CobaW/4y+qrAygWm9+fGvqMPZz0Zvkytgb/fU1PUquD2IDC63Ff/WxYgfY44KzUiaKfK PHtvQnvlTJ0OLe8MCp71/lcR6eHbPGCLPEem9ZXmaIWuSRAN94RXTXXx58fuRaGvZFtK WVfzopPU3Lx+qGgxECYFwdJOzHlFAZr12N3A54BKHsJiDo5wtH+Dd/tsVTc1AnWcQbj8 FK1IdPIjLcvd3DcYT5Mk9buD7YcL9XnsuRk+kR9X9qjCjelrPjTGVFaX1BB80q7jcOre dK5w== 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 i13-20020a17090a64cd00b002472cd8ded6si4006094pjm.103.2023.06.03.00.03.09; Sat, 03 Jun 2023 00:03:23 -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 S234360AbjFCHCh (ORCPT + 99 others); Sat, 3 Jun 2023 03:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233058AbjFCHCO (ORCPT ); Sat, 3 Jun 2023 03:02:14 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 268DB1B7; Sat, 3 Jun 2023 00:02:13 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4QY9lx2KC8z4f3pCg; Sat, 3 Jun 2023 15:02:05 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgCHOKxk5Xpk+MxPKw--.30174S20; Sat, 03 Jun 2023 15:02:06 +0800 (CST) From: Kemeng Shi To: tytso@mit.edu, adilger.kernel@dilger.ca, ojaswin@linux.ibm.com Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com Subject: [PATCH v4 18/19] ext4: add some kunit stub for mballoc kunit test Date: Sat, 3 Jun 2023 23:03:26 +0800 Message-Id: <20230603150327.3596033-19-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230603150327.3596033-1-shikemeng@huaweicloud.com> References: <20230603150327.3596033-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgCHOKxk5Xpk+MxPKw--.30174S20 X-Coremail-Antispam: 1UD129KBjvJXoWxWFW8XFW5Xr15tF15ur1xKrg_yoW5XF43pa n0yF1DGr43uw1DuF4Ik34Fg3WfGw1vgr1UJry3ur13uFy7JrnrZFWkJFnYya1YvFZxZFsr XFy5Zry3Cr1fW3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRv JPtUUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Multiblocks allocation will read and write block bitmap and group descriptor which reside on disk. Add kunit stub to function ext4_get_group_desc, ext4_read_block_bitmap_nowait, ext4_wait_block_bitmap and ext4_mb_mark_group_bb to avoid real IO to disk. Signed-off-by: Kemeng Shi --- fs/ext4/balloc.c | 16 ++++++++++++++++ fs/ext4/mballoc.c | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index c1edde817be8..49411b21a190 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -22,6 +22,7 @@ #include "mballoc.h" #include +#include static unsigned ext4_num_base_meta_clusters(struct super_block *sb, ext4_group_t block_group); @@ -274,6 +275,11 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb, struct ext4_sb_info *sbi = EXT4_SB(sb); struct buffer_head *bh_p; +#ifdef CONFIG_EXT4_KUNIT_TESTS + KUNIT_STATIC_STUB_REDIRECT(ext4_get_group_desc, + sb, block_group, bh); +#endif + if (block_group >= ngroups) { ext4_error(sb, "block_group >= groups_count - block_group = %u," " groups_count = %u", block_group, ngroups); @@ -470,6 +476,11 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group, ext4_fsblk_t bitmap_blk; int err; +#ifdef CONFIG_EXT4_KUNIT_TESTS + KUNIT_STATIC_STUB_REDIRECT(ext4_read_block_bitmap_nowait, + sb, block_group, ignore_locked); +#endif + desc = ext4_get_group_desc(sb, block_group, NULL); if (!desc) return ERR_PTR(-EFSCORRUPTED); @@ -565,6 +576,11 @@ int ext4_wait_block_bitmap(struct super_block *sb, ext4_group_t block_group, { struct ext4_group_desc *desc; +#ifdef CONFIG_EXT4_KUNIT_TESTS + KUNIT_STATIC_STUB_REDIRECT(ext4_wait_block_bitmap, + sb, block_group, bh); +#endif + if (!buffer_new(bh)) return 0; desc = ext4_get_group_desc(sb, block_group, NULL); diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 18713b671e46..c9b7fc0de49e 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -17,6 +17,7 @@ #include #include #include +#include /* * MUSTDO: @@ -3791,6 +3792,11 @@ ext4_mb_mark_group_bb(struct ext4_mark_context *mc, ext4_group_t group, int err; unsigned int i, already, changed = len; +#ifdef CONFIG_EXT4_KUNIT_TESTS + KUNIT_STATIC_STUB_REDIRECT(ext4_mb_mark_group_bb, + mc, group, blkoff, len, flags); +#endif + mc->changed = 0; bitmap_bh = ext4_read_block_bitmap(sb, group); if (IS_ERR(bitmap_bh)) -- 2.30.0