From patchwork Thu Nov 10 02:25:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Yi X-Patchwork-Id: 1701946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=gandalf.ozlabs.org; envelope-from=srs0=pd67=3k=vger.kernel.org=linux-ext4-owner@ozlabs.org; receiver=) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N74sx1ln8z23lW for ; Thu, 10 Nov 2022 13:05:09 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4N74sx0pMyz4xGR for ; Thu, 10 Nov 2022 13:05:09 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4N74sx0l2Fz4xGT; Thu, 10 Nov 2022 13:05:09 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4N74sx0RDLz4xGR for ; Thu, 10 Nov 2022 13:05:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232529AbiKJCFH (ORCPT ); Wed, 9 Nov 2022 21:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbiKJCEg (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 39C4DD125 for ; Wed, 9 Nov 2022 18:04:35 -0800 (PST) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N74rz3Zs1zmVnx; Thu, 10 Nov 2022 10:04:19 +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:33 +0800 From: Zhang Yi To: CC: , , , , Subject: [PATCH v2 05/12] ext4: add inode I/O fault injection Date: Thu, 10 Nov 2022 10:25:51 +0800 Message-ID: <20221110022558.7844-6-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 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 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 b177263592ff..68b2c02bb266 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)