From nobody Thu Dec 26 18:50:32 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C326FCD5BA0 for ; Tue, 19 Sep 2023 12:16:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231707AbjISMQi (ORCPT ); Tue, 19 Sep 2023 08:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231674AbjISMQT (ORCPT ); Tue, 19 Sep 2023 08:16:19 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CF6D102; Tue, 19 Sep 2023 05:16:13 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RqgcT6xHZz4f3yyV; Tue, 19 Sep 2023 20:16:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgAnOA0DkQllO8FpAw--.40065S12; Tue, 19 Sep 2023 20:16:10 +0800 (CST) From: Kemeng Shi To: tytso@mit.edu, adilger.kernel@dilger.ca, ritesh.list@gmail.com Cc: ojaswin@linux.ibm.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 10/12] ext4: add some kunit stub for mballoc kunit test Date: Wed, 20 Sep 2023 04:15:30 +0800 Message-Id: <20230919201532.310085-11-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230919201532.310085-1-shikemeng@huaweicloud.com> References: <20230919201532.310085-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: Syh0CgAnO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xVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU0TqcUUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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_context to avoid real IO to disk. Signed-off-by: Kemeng Shi Reviewed-by: Ritesh Harjani (IBM) --- fs/ext4/balloc.c | 10 ++++++++++ fs/ext4/mballoc.c | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 79b20d6ae39e..b0bf255b159f 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -22,6 +22,7 @@ #include "mballoc.h" =20 #include +#include =20 static unsigned ext4_num_base_meta_clusters(struct super_block *sb, ext4_group_t block_group); @@ -274,6 +275,9 @@ struct ext4_group_desc * ext4_get_group_desc(struct sup= er_block *sb, struct ext4_sb_info *sbi =3D EXT4_SB(sb); struct buffer_head *bh_p; =20 + KUNIT_STATIC_STUB_REDIRECT(ext4_get_group_desc, + sb, block_group, bh); + if (block_group >=3D ngroups) { ext4_error(sb, "block_group >=3D groups_count - block_group =3D %u," " groups_count =3D %u", block_group, ngroups); @@ -468,6 +472,9 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, e= xt4_group_t block_group, ext4_fsblk_t bitmap_blk; int err; =20 + KUNIT_STATIC_STUB_REDIRECT(ext4_read_block_bitmap_nowait, + sb, block_group, ignore_locked); + desc =3D ext4_get_group_desc(sb, block_group, NULL); if (!desc) return ERR_PTR(-EFSCORRUPTED); @@ -563,6 +570,9 @@ int ext4_wait_block_bitmap(struct super_block *sb, ext4= _group_t block_group, { struct ext4_group_desc *desc; =20 + KUNIT_STATIC_STUB_REDIRECT(ext4_wait_block_bitmap, + sb, block_group, bh); + if (!buffer_new(bh)) return 0; desc =3D ext4_get_group_desc(sb, block_group, NULL); diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index db0b15098a80..70dc446996a0 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -18,6 +18,7 @@ #include #include #include +#include =20 /* * MUSTDO: @@ -3967,6 +3968,10 @@ ext4_mb_mark_context(handle_t *handle, struct super_= block *sb, bool state, int err; unsigned int i, already, changed =3D len; =20 + KUNIT_STATIC_STUB_REDIRECT(ext4_mb_mark_context, + handle, sb, state, group, blkoff, len, + flags, ret_changed); + if (ret_changed) *ret_changed =3D 0; bitmap_bh =3D ext4_read_block_bitmap(sb, group); --=20 2.30.0