Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3605289rwb; Tue, 8 Nov 2022 06:29:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM68CaBDa55P8Aj1ed3VxLqvjl2CEGxPVOCPd0VVP5Dnf6LsC8BbYtFIs6miRDUlcJww4M+E X-Received: by 2002:a17:90a:2b42:b0:213:82b3:212b with SMTP id y2-20020a17090a2b4200b0021382b3212bmr58283541pjc.106.1667917772585; Tue, 08 Nov 2022 06:29:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667917772; cv=none; d=google.com; s=arc-20160816; b=CT/M2Bjkvhq12LyM5LWDEtHzq6/pqZu4Ezno7jL5+Pu5Bxq4c8Yk5wEaaazYvgSWUr wfqmn8M3wgqnTKhKUCFekVdCZr/seskLPYk9jqQ1yVcfSsgmtU7vpZo8qzK2Nha7Iypa 7fpdjT8Qchk48CmxY9lhxcGEvCycxEEcXsp6wTdKZ7saX6gfoSy/WQFSMDkVLXgCJmP5 4btznncUOnOK8Cyo4eIluIYqVEknOSZyk14nQNx8KEGgHv0VP8wrPVWOf1rpQgxff+af knfu/0Z6WJLmK+jPgkiS6eSf8ZyDWSXQeqtLauWtWvcHh7ZQLUuA7tQdwSOm+F8Jjg8T QNkg== 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=DGpescpEb0eafUp0MnpwAyLvWYiu+1nRLI+5t9bXDUU=; b=iF6y7G6EwJPUk3aKFO1g/5usnb+6UYyNdzoPCbANlkKJTjCsnbeq22dn0BtUZhVjbI RC4iX1Az8V4ExWGO+fp7VsQbipxkhxMjkr/T3ZJDqPRHw/iiekCi4dKNl4VQT6g7nZys Ei33l6lqbRmpW/yEiAzUb3EGg7DvxPyq6xHHmxBbC2cOVpiS+OIhIoTKG8srywQw2KPZ uGWsnPmWyN2o9ABSY67zx2wndIMGeFUuZCVmU09t9U4GGPZq4hEI7+9HXcLHdsCz0Jz2 Jn5rUqNs4esIzSQaYVFME6wwnPYB4p52RBbYtQ5ElcwQbfHfwnUmBZXg79yMEWaATXpL zdQw== 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 w34-20020a634762000000b0046f58089605si14893140pgk.272.2022.11.08.06.29.18; Tue, 08 Nov 2022 06:29:32 -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 S233214AbiKHO0t (ORCPT + 99 others); Tue, 8 Nov 2022 09:26:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbiKHO0L (ORCPT ); Tue, 8 Nov 2022 09:26:11 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9201F5C767 for ; Tue, 8 Nov 2022 06:24:52 -0800 (PST) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N69NB42dFzRp5p; Tue, 8 Nov 2022 22:24:42 +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; Tue, 8 Nov 2022 22:24:50 +0800 From: Zhang Yi To: CC: , , , , Subject: [PATCH 05/12] ext4: add inode I/O fault injection Date: Tue, 8 Nov 2022 22:46:10 +0800 Message-ID: <20221108144617.4159381-6-yi.zhang@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221108144617.4159381-1-yi.zhang@huawei.com> References: <20221108144617.4159381-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: dggems705-chm.china.huawei.com (10.3.19.182) 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 I/O fault injection when reading raw inode from disk, we can specify the inode to inject, __ext4_get_inode_loc() will return -EIO immediately instead of submitting I/O, note that it doesn't handle the readhead case. Signed-off-by: Zhang Yi --- fs/ext4/ext4.h | 2 ++ fs/ext4/inode.c | 18 ++++++++++++------ fs/ext4/sysfs.c | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 589d901e8946..29a819a186f7 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1521,6 +1521,7 @@ enum ext4_fault_bits { /* inject metadata IO error*/ EXT4_FAULT_IBITMAP_EIO, /* inode bitmap block */ EXT4_FAULT_BBITMAP_EIO, /* block bitmap block */ + EXT4_FAULT_INODE_EIO, /* inode */ EXT4_FAULT_MAX }; @@ -1622,6 +1623,7 @@ 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) +EXT4_FAULT_INODE_FN(INODE_EIO, inode_io, -EIO) /* * fourth extended-fs super-block data in memory diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 8bfbc8d100b4..8c611ad6dac1 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4570,19 +4570,25 @@ static int __ext4_get_inode_loc(struct super_block *sb, unsigned long ino, * Read the block from disk. */ trace_ext4_load_inode(sb, ino); + if (ext4_fault_inode_io(sb, ino)) { + unlock_buffer(bh); + blk_finish_plug(&plug); + goto err; + } ext4_read_bh_nowait(bh, REQ_META | REQ_PRIO, NULL); blk_finish_plug(&plug); wait_on_buffer(bh); ext4_simulate_fail_bh(sb, bh, EXT4_SIM_INODE_EIO); - if (!buffer_uptodate(bh)) { - if (ret_block) - *ret_block = block; - brelse(bh); - return -EIO; - } + if (!buffer_uptodate(bh)) + goto err; has_buffer: iloc->bh = bh; return 0; +err: + if (ret_block) + *ret_block = block; + brelse(bh); + return -EIO; } static int __ext4_get_inode_loc_noinmem(struct inode *inode, diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index 638892046dc8..9c6d9a212d47 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -580,6 +580,7 @@ char *ext4_fault_names[EXT4_FAULT_MAX] = { "xattr_block_checksum", /* EXT4_FAULT_XATTR_CSUM */ "inode_bitmap_eio", /* EXT4_FAULT_IBITMAP_EIO */ "block_bitmap_eio", /* EXT4_FAULT_BBITMAP_EIO */ + "inode_eio", /* EXT4_FAULT_INODE_EIO */ }; static int ext4_fault_available_show(struct seq_file *m, void *v) -- 2.31.1