Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3605523rwb; Tue, 8 Nov 2022 06:29:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM6YTfuP4eAIGp3aEep5CHBo7EX67x5+zyVe55mlVTXL0s4koT8qejoEuvwQpI4IeUEjR1Xb X-Received: by 2002:a05:6a00:24d0:b0:56c:fa97:a91c with SMTP id d16-20020a056a0024d000b0056cfa97a91cmr56558000pfv.23.1667917780354; Tue, 08 Nov 2022 06:29:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667917780; cv=none; d=google.com; s=arc-20160816; b=pF6m3bmLEZ1lZ2NTPB+c0oS+Hw+4CPDCMHt8iVAJBYEXph444Hhy/07GfoFbKwNpKZ OZ6dATJBsBpaAu6vckAxi1dTxVO/icUnX/8vBQtvgaiJOPYIuEhbLa6Qpe7yqfAjduO5 J2/u3KUAtlloKXmHZYirQgn/zQ9Rqug3iZH8pc/dI1WIObCqPyFsaVIXuiI1FWZuceSe jwoiaLDpdGrlK1CFXYy/uXx3bYIf8tg4suwTc0/VjnHIhi6qqwAmZBoQNjpbITzXzxTE fO+W8oR7LblgBwxHECl/9n5Si78X73IDtjcxKcW5NC2wi+asNf+ls2GLmWqAkmn2ngsZ 7mPg== 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=Z9dVO9Fw3wC4NEJdr19LmRLexOiugoj88GVrSlqrojQ=; b=A9OrNdb/cpC/6s0sEPSE9k4kvbuesqbJ+dYq2ENUPlQsWx3lIXJCb2Dzu6jr8HCuQl a/AvSeu6MVHKfe/ayOba1oKrIfpAiy7D0USYIBiwtAoSIZn9NXaBrgd31JrBGP1y6GQJ ccfFRcR8HMz1+DAu0xneLUMcMQ1sO8kgeabj/oij7tMBnRWYWMICUlvjBLPYAwXIi512 h7XvJ4Ivo7mf404ty9hwyH94vknio0u0ndHBHZTh1qaAU1AjJJxTtHKJmmmOnd113C2A 6H7tt/IZaBOgeVccTA1O3Vkqn30xaCKxybSlnPhsPRX8/YdN8S8lAqcwePbBvifptc83 yVug== 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 x2-20020a634842000000b0047008f7c2dcsi14997032pgk.61.2022.11.08.06.29.25; Tue, 08 Nov 2022 06:29:40 -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 S233753AbiKHO1D (ORCPT + 99 others); Tue, 8 Nov 2022 09:27:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234121AbiKHO0N (ORCPT ); Tue, 8 Nov 2022 09:26:13 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1C7F5B862 for ; Tue, 8 Nov 2022 06:24:54 -0800 (PST) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N69ND6GYszRp5v; Tue, 8 Nov 2022 22:24:44 +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:52 +0800 From: Zhang Yi To: CC: , , , , Subject: [PATCH 10/12] ext4: add symlink block I/O fault injection Date: Tue, 8 Nov 2022 22:46:15 +0800 Message-ID: <20221108144617.4159381-11-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 symlink block, user could specify which inode to inject error. It will return -EIO immediately instead of submitting I/O. Signed-off-by: Zhang Yi --- fs/ext4/ext4.h | 2 ++ fs/ext4/symlink.c | 4 ++++ fs/ext4/sysfs.c | 1 + 3 files changed, 7 insertions(+) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 94894daef595..813127cfd3c0 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1525,6 +1525,7 @@ enum ext4_fault_bits { EXT4_FAULT_EXTENT_EIO, /* extent block */ EXT4_FAULT_DIRBLOCK_EIO, /* directory block */ EXT4_FAULT_XATTR_EIO, /* xattr block */ + EXT4_FAULT_SYMLINK_EIO, /* symlink block */ EXT4_FAULT_MAX }; @@ -1630,6 +1631,7 @@ EXT4_FAULT_INODE_FN(INODE_EIO, inode_io, -EIO) EXT4_FAULT_INODE_PBLOCK_FN(EXTENT_EIO, extent_io, -EIO) EXT4_FAULT_INODE_LBLOCK_FN(DIRBLOCK_EIO, dirblock_io, -EIO) EXT4_FAULT_INODE_FN(XATTR_EIO, xattr_io, -EIO) +EXT4_FAULT_INODE_FN(SYMLINK_EIO, symlink_io, -EIO) /* * fourth extended-fs super-block data in memory diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c index 3d3ed3c38f56..5392e707418e 100644 --- a/fs/ext4/symlink.c +++ b/fs/ext4/symlink.c @@ -39,6 +39,8 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry, caddr = EXT4_I(inode)->i_data; max_size = sizeof(EXT4_I(inode)->i_data); } else { + if (ext4_fault_symlink_io(inode->i_sb, inode->i_ino)) + return ERR_PTR(-EIO); bh = ext4_bread(NULL, inode, 0, 0); if (IS_ERR(bh)) return ERR_CAST(bh); @@ -97,6 +99,8 @@ static const char *ext4_get_link(struct dentry *dentry, struct inode *inode, if (!bh || !ext4_buffer_uptodate(bh)) return ERR_PTR(-ECHILD); } else { + if (ext4_fault_symlink_io(inode->i_sb, inode->i_ino)) + return ERR_PTR(-EIO); bh = ext4_bread(NULL, inode, 0, 0); if (IS_ERR(bh)) return ERR_CAST(bh); diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index f7f8882037a5..aca91ab5b506 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c @@ -584,6 +584,7 @@ char *ext4_fault_names[EXT4_FAULT_MAX] = { "extent_block_eio", /* EXT4_FAULT_EXTENT_EIO */ "dir_block_eio", /* EXT4_FAULT_DIRBLOCK_EIO */ "xattr_block_eio", /* EXT4_FAULT_XATTR_EIO */ + "symlink_block_eio", /* EXT4_FAULT_SYMLINK_EIO */ }; static int ext4_fault_available_show(struct seq_file *m, void *v) -- 2.31.1