Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2187540rdb; Sun, 24 Dec 2023 23:14:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOZ6aJh5KjegGzNKIFEk+97+mxnsnzj46DOQcS02eLa+uKQdAnmQBwPvau6x7yfxXf0S6u X-Received: by 2002:a05:6a20:12c7:b0:18f:97c:8a19 with SMTP id v7-20020a056a2012c700b0018f097c8a19mr7686914pzg.68.1703488480404; Sun, 24 Dec 2023 23:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703488480; cv=none; d=google.com; s=arc-20160816; b=TnJnKpI6+iBmm/zbsfmXRpr0+M9tWhyuLGQjYaH/hJU4Dg0n6fKhqOdOtkOIunVbcw Qbp1GgsomubKOJv90ZIkyGX1zlSjDtGxtLsuvBR7G5CdgkcQfvFQYETz/VBq4UEOi8pd 1YAHgQX3JtLfDxC2Dqd07ZNa1JVQqSPhw0nXipx13LtfUPsnpZH/w3IDeAs2KbqpFynT xinafyAjEI+VTt6fwmOXWr3zj2vGhhaX+K7npkz/u0uf9/vLzoggptjtjoYGqbDppK1I 36hw4kFM4NevVZL9mZPmUJTSOTBrx1XBYr0n4E75onFT8eROOTDs/szR95tG8lx1bP/K wHnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Kht8TqPImchJE85TY86IRwGnCFknzRaMH6WneOJkbSA=; fh=XjbPFQV1q33pSyHU0DJViPof6LxQPkAWDXnCrlkcrhg=; b=EtrSaQvSRNryb3vd0OXS5Uj2ZE5AnrU7/mkTqZxmwhYukkKlP2fskdwHgJ+25FNTnF CNtSm5zhsf2y9DDsbSYLNnNZxh4UeNxcCp3meldfsmJrMFtpU/byNo998pjSTIdJCWRe /87PgJvw7fhxa5S1PWp6YX0rdZ9BSDPOb1mk/OzBPZhlHgk6qv6PARxK5WI00zC5VFqO 7E0SMHIF+7Ddh2EAmzMWGMKk8ljUvJGZgDAzu95C1yia8U2S3EQQWNAr3g2dPLxR1mte LkeCj83YExmVIWQ6LWVhzDeSXnXOBHeiEwAQUDQTr5GrLNAx+Wi3Er3bhCho5eXlYuRl LRxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10926-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cb3-20020a056a02070300b005cda1f22178si4361653pgb.297.2023.12.24.23.14.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 23:14:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10926-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10926-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10926-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 56D8F280D14 for ; Mon, 25 Dec 2023 07:14:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6D9C10967; Mon, 25 Dec 2023 07:13:29 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA8ACEAD5 for ; Mon, 25 Dec 2023 07:13:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Sz8J43wwGzZdsC; Mon, 25 Dec 2023 15:13:08 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id E06D11800BB; Mon, 25 Dec 2023 15:13:17 +0800 (CST) Received: from huawei.com (10.175.104.67) by dggpemd200001.china.huawei.com (7.185.36.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Mon, 25 Dec 2023 15:13:17 +0800 From: ZhaoLong Wang To: , , CC: , , , , , Subject: [PATCH v5 5/5] mtd: Add several functions to the fail_function list Date: Mon, 25 Dec 2023 15:10:55 +0800 Message-ID: <20231225071055.1721000-6-wangzhaolong1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231225071055.1721000-1-wangzhaolong1@huawei.com> References: <20231225071055.1721000-1-wangzhaolong1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemd200001.china.huawei.com (7.185.36.224) add mtd_read(), mtd_write(), mtd_erase(), mtd_block_markbad() to fail_function list for testing purpose - Specify the function to inject the fault echo mtd_read > /sys/kernel/debug/fail_function/inject - Specifies the return value of the function to inject the fault printf %#x -12 > /sys/kernel/debug/fail_function/mtd_read/retval - Specify other fault injection configuration parameters. echo -1 > /sys/kernel/debug/fail_function/times echo 100 > /sys/kernel/debug/fail_function/probability echo 15 > /sys/kernel/debug/fail_function/space Signed-off-by: ZhaoLong Wang Reviewed-by: Zhihao Cheng --- drivers/mtd/mtdcore.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index bb0759ca12f1..e451b28840d5 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -1412,6 +1413,7 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) return ret; } EXPORT_SYMBOL_GPL(mtd_erase); +ALLOW_ERROR_INJECTION(mtd_erase, ERRNO); /* * This stuff for eXecute-In-Place. phys is optional and may be set to NULL. @@ -1511,6 +1513,7 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, return ret; } EXPORT_SYMBOL_GPL(mtd_read); +ALLOW_ERROR_INJECTION(mtd_read, ERRNO); int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) @@ -1527,6 +1530,7 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, return ret; } EXPORT_SYMBOL_GPL(mtd_write); +ALLOW_ERROR_INJECTION(mtd_write, ERRNO); /* * In blackbox flight recorder like scenarios we want to make successful writes @@ -2347,6 +2351,7 @@ int mtd_block_markbad(struct mtd_info *mtd, loff_t ofs) return 0; } EXPORT_SYMBOL_GPL(mtd_block_markbad); +ALLOW_ERROR_INJECTION(mtd_block_markbad, ERRNO); /* * default_mtd_writev - the default writev method -- 2.39.2