Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2546805rdb; Mon, 25 Dec 2023 17:05:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0r1Q/GDebXYLGFHBosLvg8Idt4nt1g/FSD0IsIIqQ7mp5Mj+V2Mk5Uaqtk0j/WTTSmi4W X-Received: by 2002:a17:902:bb10:b0:1d3:bc1e:27d0 with SMTP id im16-20020a170902bb1000b001d3bc1e27d0mr6734714plb.45.1703552731132; Mon, 25 Dec 2023 17:05:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703552731; cv=none; d=google.com; s=arc-20160816; b=iONccrdgFTOrNZ05KLDxn5xVb/pbmX4EuHH00K7+PkrlGD//slEfR8kK66aXrO8u9G MXO37EidKc8SC79fkm/N6KGhxVcL3aqld78al6h2jqO5GUlAFoHC6PVujtCJl5GyCPsh A87hgdKBeJkLBnob4xa3wRBo4RfyQqkEDZpdqAlO2hUGNoCUHJQ0mlDRpk43+cyBeKEr i/97//GJWsLG62bpJrAtYidQa+S0U032ZNIh4p2j8AKN2baq2Kw8hzblPTKabW/VIHG0 pIxi29boLIVNCDGnSVnrAq/TRFJpMUCCD7e8ZIFfq4VKLBE7AmXRYGH1DhsooElBT+1L 8Xcg== 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=IrwtR/c14jm0UMQxEWOY90xEWrUAfMAt1fWt5a6qT6MBgbF7kzqKOWFZNQsvsF0J/v 8JlfG8sBRpFywTLUvyqmy98qEpnYt0MgU4A//vqWOMcrwJuThHU358oz8DVCEqopUrex iHIHPWe4Lr8UlTEp7z8rvQ/41ca7a35aBNPS6PvQ7LwwIt03vpfUMC16Te2/KlNTi35p 7m8d3b3eITLnhtbQS6AX69QWfR7KTRsqjUTvY9epfKA+gZC5gIIguQjppu1Q2WmYZKan q37dqbSlngYNBwr42bTgiHaBTfR3V6TCr4UEDKBRrZTU/Tkjbk/piK8OG4A/oTJHEWbG vviw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11308-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11308-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id jb5-20020a170903258500b001d336801025si8538507plb.255.2023.12.25.17.05.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 17:05:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11308-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11308-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11308-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8F11FB21293 for ; Tue, 26 Dec 2023 01:05:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88BC8C152; Tue, 26 Dec 2023 01:05:09 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 3A73A9446 for ; Tue, 26 Dec 2023 01:05:07 +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.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Szc3251Prz1g04x; Tue, 26 Dec 2023 09:03:26 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id 0359A1A0199; Tue, 26 Dec 2023 09:04:30 +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; Tue, 26 Dec 2023 09:03:31 +0800 From: ZhaoLong Wang To: , , CC: , , , , , Subject: [PATCH v6 5/5] mtd: Add several functions to the fail_function list Date: Tue, 26 Dec 2023 09:01:13 +0800 Message-ID: <20231226010113.742079-6-wangzhaolong1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231226010113.742079-1-wangzhaolong1@huawei.com> References: <20231226010113.742079-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