Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1421495rwb; Wed, 9 Nov 2022 18:05:49 -0800 (PST) X-Google-Smtp-Source: AMsMyM7mJWaZvzLf7OGcRvlTRxhqVjsXkZNjVmqg6jZ8twGRc/EBmhPwoYcwKRnf9o4WmOsH7vZ5 X-Received: by 2002:a17:90b:3011:b0:213:deb7:d47f with SMTP id hg17-20020a17090b301100b00213deb7d47fmr55128083pjb.136.1668045949126; Wed, 09 Nov 2022 18:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668045949; cv=none; d=google.com; s=arc-20160816; b=sWvYev6jTSpgTsGdiyCbVwVDdrm3khfDrbijVOuiwN0kiX1fonWnvmvi19KRVo9YkS cIE7uH/HbIpkzzfTInqsHA2pZ3UzdCHzKsPGARAzWGJiF+UCW5FBXqko73yeWy5LcdBg YJEvvrUHGmb2hx7FvJYl/h10gV+LQqcDPGVWFO2tJUYNBZlfnEqhtUaZJQlcKQUny0NY TAs27MtgGqBYwT8nCzntRoQutEEw6gSS9JloQ1QWbojMPK7FTKHKQdbhkXhYCeu5PrjF A01abMOXdOgVGtc6HPuCyQzeKNuRTPeEAbBwT2HL+rYupetz2cqRZ8vZb/YM/aplghEL 24rw== 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=qkPPqU3Emds7ezCkE/cgAIInWpSWY5MBhD/aVD5cHig=; b=Z7FSFtxtAwUeQI4L/RJ0fchgrNUL9uLJU2tgMfWQsPn1tTuMi4gI3LXgXUujwW0J2g niJZyOK5G0R6c3pri2STS1xfmBH0B1/7Jc8/iG1X3Ksavk9HY9WfRUJ3lak9sCmZt5Wz T3vma/eMYmb2hpVuOrOelbuwPNVvsmrNfJjkelD5C+tW2xaP//WnUZrFlaptAwiFRsQI h9Js47jFpudMu33TS72CplMudmi4sf3kOhDPLP/rePNZV69+OMSTHBWGYnjzeDYWJKmQ yyo1a7uX7j7OWTX4qAsjIhvNAoDlZqUq6lPGniszRt6aA67iD/gPB8S7fwJWgzYLY+Mg pP5A== 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 207-20020a6214d8000000b0056bac1881basi16418275pfu.316.2022.11.09.18.05.36; Wed, 09 Nov 2022 18:05:49 -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 S232237AbiKJCFG (ORCPT + 99 others); Wed, 9 Nov 2022 21:05:06 -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 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 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) -- 2.31.1