Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1421259rwb; Wed, 9 Nov 2022 18:05:36 -0800 (PST) X-Google-Smtp-Source: AMsMyM4M6ZKvugsPD4AaLHV1I5sCrv3cCWvT03DBR6xpn0Y1tdtLpvyVmEaB6Dc6R6+IEqbvZFmt X-Received: by 2002:a05:6a00:24cb:b0:56c:7815:bc7d with SMTP id d11-20020a056a0024cb00b0056c7815bc7dmr63774401pfv.44.1668045936088; Wed, 09 Nov 2022 18:05:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045936; cv=none; d=google.com; s=arc-20160816; b=ZGbqprgqeQoUhbRL9SpmxaHf541WG/Rxovg/7i9HmKZ8ulGTmgdNhMHt2gvh0eZmb9 j69EanQ0HP9x3uNw73aA+hsanvoDzO54cOUmyYwUr9A3OLraj+t3DI3Hw9dPZJPImpva PAUUZr+pf2mbL7/5/anlIK3kGNGdSv9d/FIBXtM2FsVIxzDZZcMjn7d0uFSUhomstx3E S3yAAstYlwKjxjtPaGAMfsG04E/rnEWJh9bgBJZgBDTqDzMch3wWRZ3nFHqeqbGm7r95 QCvLUdhZJL0e6R+YWBIUAgQBOJWrbflG2Q1ZkXdFhYtEjyLTAMGMCO1rc7x7oxAm1WfC 3j+A== 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=z9EuCr1zapgthUUD9NSVvi+BnCqlyeWNh6BpvjKwMb4=; b=wf/V4O8PCvSAe9YG/Ei7tGKpEOh34FirrFG/reqRS9XmguZqz7QK5aK2QQY/T24FEH wTZCD2KCcfOWgPuVZ7XwaEE9oJCl0O4cA5F1SORE7m7ZtQlMBOjVzTsSYOSvpnOROVax hrKMr9xSkoz9yWnY4iihNs2SI2E7/W/HBDurcZ3Cyr7UzQBwZ7/1qWYvI4iMplZh0eol blcAwEyg++cvNBLgk483au4T7e2qdFvKTiMIXCdqgWZ3F2tAe1AEdVogIs4gvnDx9ZnN PMg52HDCF0yBkRo2Wq+vF63s1IYS5kKhY0QllcJARmkQxTLY7im4ZfxhbN1ckz87Ia2/ p8bw== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 22-20020a631756000000b0047059dd37b0si16290059pgx.652.2022.11.09.18.05.23; Wed, 09 Nov 2022 18:05:36 -0800 (PST) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232392AbiKJCFE (ORCPT + 99 others); Wed, 9 Nov 2022 21:05:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232237AbiKJCEg (ORCPT ); Wed, 9 Nov 2022 21:04:36 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2E8AC765 for ; Wed, 9 Nov 2022 18:04:34 -0800 (PST) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N74n006MtzpWLp; Thu, 10 Nov 2022 10:00:52 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 10 Nov 2022 10:04:32 +0800 From: Zhang Yi To: CC: , , , , Subject: [PATCH v2 04/12] ext4: add bitmaps I/O fault injection Date: Thu, 10 Nov 2022 10:25:50 +0800 Message-ID: <20221110022558.7844-5-yi.zhang@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221110022558.7844-1-yi.zhang@huawei.com> References: <20221110022558.7844-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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-ext4@vger.kernel.org Add inode and block bitmap reading I/O fault injections, we can specify the group to inject, the reading function will return -EIO immediately instead of submitting I/O. Signed-off-by: Zhang Yi --- fs/ext4/balloc.c | 10 ++++++++++ fs/ext4/ext4.h | 6 ++++++ fs/ext4/ialloc.c | 20 +++++++++++++------- fs/ext4/sysfs.c | 2 ++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 8ff4b9192a9f..ff5c90f4386d 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -501,6 +501,16 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group, */ set_buffer_new(bh); trace_ext4_read_block_bitmap_load(sb, block_group, ignore_locked); + err = ext4_fault_block_bitmap_io(sb, block_group); + if (err) { + unlock_buffer(bh); + ext4_error_err(sb, -err, "Cannot read block bitmap - " + "block_group = %u, block_bitmap = %llu", + block_group, bitmap_blk); + ext4_mark_group_bitmap_corrupted(sb, block_group, + EXT4_GROUP_INFO_BBITMAP_CORRUPT); + goto out; + } ext4_read_bh_nowait(bh, REQ_META | REQ_PRIO | (ignore_locked ? REQ_RAHEAD : 0), ext4_end_bitmap_read); diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 4c85cf977bea..589d901e8946 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1518,6 +1518,9 @@ enum ext4_fault_bits { EXT4_FAULT_DIRBLOCK_CSUM, /* directory block */ EXT4_FAULT_DIRIDX_CSUM, /* directory index block */ EXT4_FAULT_XATTR_CSUM, /* xattr block */ + /* inject metadata IO error*/ + EXT4_FAULT_IBITMAP_EIO, /* inode bitmap block */ + EXT4_FAULT_BBITMAP_EIO, /* block bitmap block */ EXT4_FAULT_MAX }; @@ -1617,6 +1620,9 @@ EXT4_FAULT_INODE_FN(DIRBLOCK_CSUM, dirblock_csum, 1) EXT4_FAULT_INODE_FN(DIRIDX_CSUM, dirindex_csum, 1) EXT4_FAULT_INODE_FN(XATTR_CSUM, xattr_csum, 1) +EXT4_FAULT_GRP_FN(IBITMAP_EIO, inode_bitmap_io, -EIO) +EXT4_FAULT_GRP_FN(BBITMAP_EIO, block_bitmap_io, -EIO) + /* * fourth extended-fs super-block data in memory */ diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index e9bc46684106..e299aa80a718 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -194,16 +194,16 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) * submit the buffer_head for reading */ trace_ext4_load_inode_bitmap(sb, block_group); + err = ext4_fault_inode_bitmap_io(sb, block_group); + if (err) { + unlock_buffer(bh); + goto read_err; + } ext4_read_bh(bh, REQ_META | REQ_PRIO, ext4_end_bitmap_read); ext4_simulate_fail_bh(sb, bh, EXT4_SIM_IBITMAP_EIO); if (!buffer_uptodate(bh)) { - put_bh(bh); - ext4_error_err(sb, EIO, "Cannot read inode bitmap - " - "block_group = %u, inode_bitmap = %llu", - block_group, bitmap_blk); - ext4_mark_group_bitmap_corrupted(sb, block_group, - EXT4_GROUP_INFO_IBITMAP_CORRUPT); - return ERR_PTR(-EIO); + err = -EIO; + goto read_err; } verify: @@ -211,6 +211,12 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) if (err) goto out; return bh; +read_err: + ext4_error_err(sb, -err, "Cannot read inode bitmap - " + "block_group = %u, inode_bitmap = %llu", + block_group, bitmap_blk); + ext4_mark_group_bitmap_corrupted(sb, block_group, + EXT4_GROUP_INFO_IBITMAP_CORRUPT); out: put_bh(bh); return ERR_PTR(err); diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index 7773c5504174..b177263592ff 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -578,6 +578,8 @@ char *ext4_fault_names[EXT4_FAULT_MAX] = { "dir_block_checksum", /* EXT4_FAULT_DIRBLOCK_CSUM */ "dir_index_block_checksum", /* EXT4_FAULT_DIRIDX_CSUM */ "xattr_block_checksum", /* EXT4_FAULT_XATTR_CSUM */ + "inode_bitmap_eio", /* EXT4_FAULT_IBITMAP_EIO */ + "block_bitmap_eio", /* EXT4_FAULT_BBITMAP_EIO */ }; static int ext4_fault_available_show(struct seq_file *m, void *v) -- 2.31.1