Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2187390rdb; Sun, 24 Dec 2023 23:14:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFRphJNehGZfsBJUpgObdG60pRcqwx8b/5xWe9+SFNYAWtsCrkrn5O31LkT/M99RN//iozc X-Received: by 2002:a17:906:1456:b0:a23:32bd:d166 with SMTP id q22-20020a170906145600b00a2332bdd166mr2363078ejc.48.1703488451171; Sun, 24 Dec 2023 23:14:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703488451; cv=none; d=google.com; s=arc-20160816; b=MIQjNS4oqSPG/hBvyyK+uY86/NsJ9HMhySfunvTWF+907GET7g4YiONPibMyGbLhZ/ wpOXKlg282yFgDyKv+DwLw184RpomIcE689NEYnZC1mG1x4OXzsp7afz5ug8nkBYDuEk wR1ACKXE4Slus9sRoe1YCv+EdyQrYE0fWasiUvHOgm2laDUsNOwhTO6lnsbZ+m1APH1D wqxOcCQEyPgPp+oEZDD+CIPu4lhFoyP8FICZeUMZNnghU70ZcNx4ro0taXsGwIaAsBTq H4kHsRrfiNC7tzFniLQUCX15b9GcEaDdEsRVx0XJB+u38ZQEPr3SLRkfFCOy6oIM9o+b 4zmg== 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=1gK9hLKxGIMkbaQde8ACMJ5KKbljfn9b1qI/nUOfKhM=; fh=XjbPFQV1q33pSyHU0DJViPof6LxQPkAWDXnCrlkcrhg=; b=PYlNU8Y5wlOw0kCZzN8kchAfbiQLNEkMTGSQKVcQAzxOfLJzmJsBIacWIKCHFPL5fL Vk8wxVPyrPdjmPaNx4kFFc8XKciC4U0bmyfQwPzhAz1pDhsVrh8EhtOeeCGp+USNxMBO ojFpvQqjYuGftkBJ2u2VomMUVY4o/3ffQqKB2HTSbWOiWhgDRecLEvKJs3ZpdHT35Aj/ gTMO7Fj7mSUVUAEOdecKfTdO/9Zarl45aSfAYhLMTrq1gZF1xoeV/u2Efu3+Z/3L3oeB 72PCBzjavjT9VDQ0Z4VZTbvSBVTSeSfcQ2gTUsFXqNa7zyWujQob2aeVvKYK0zXZCQ75 cYjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10924-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h15-20020a17090791cf00b00a26f0f9b88bsi663210ejz.200.2023.12.24.23.14.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 23:14:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10924-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E66941F2130A for ; Mon, 25 Dec 2023 07:14:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCCD4EAEE; Mon, 25 Dec 2023 07:13:26 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 963AED297 for ; Mon, 25 Dec 2023 07:13:23 +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.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Sz8Gk1cS8z1R60X; Mon, 25 Dec 2023 15:11:58 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id 62BFB140258; Mon, 25 Dec 2023 15:13:16 +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:15 +0800 From: ZhaoLong Wang To: , , CC: , , , , , Subject: [PATCH v5 2/5] ubi: Split io_failures into write_failure and erase_failure Date: Mon, 25 Dec 2023 15:10:52 +0800 Message-ID: <20231225071055.1721000-3-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) The emulate_io_failures debugfs entry controls both write failure and erase failure. This patch split io_failures to write_failure and erase_failure. Signed-off-by: ZhaoLong Wang Reviewed-by: Zhihao Cheng --- drivers/mtd/ubi/debug.c | 13 +++++++++---- drivers/mtd/ubi/debug.h | 14 ++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c index 81682bd72eb9..3ce5265e3a16 100644 --- a/drivers/mtd/ubi/debug.c +++ b/drivers/mtd/ubi/debug.c @@ -14,7 +14,8 @@ #ifdef CONFIG_MTD_UBI_FAULT_INJECTION static DECLARE_FAULT_ATTR(fault_bitflips_attr); -static DECLARE_FAULT_ATTR(fault_io_failures_attr); +static DECLARE_FAULT_ATTR(fault_write_failure_attr); +static DECLARE_FAULT_ATTR(fault_erase_failure_attr); static DECLARE_FAULT_ATTR(fault_power_cut_attr); #define FAIL_ACTION(name, fault_attr) \ @@ -24,7 +25,8 @@ bool should_fail_##name(void) \ } FAIL_ACTION(bitflips, fault_bitflips_attr) -FAIL_ACTION(io_failures, fault_io_failures_attr) +FAIL_ACTION(write_failure, fault_write_failure_attr) +FAIL_ACTION(erase_failure, fault_erase_failure_attr) FAIL_ACTION(power_cut, fault_power_cut_attr) #endif @@ -245,8 +247,11 @@ static void dfs_create_fault_entry(struct dentry *parent) fault_create_debugfs_attr("emulate_bitflips", dir, &fault_bitflips_attr); - fault_create_debugfs_attr("emulate_io_failures", dir, - &fault_io_failures_attr); + fault_create_debugfs_attr("emulate_write_failure", dir, + &fault_write_failure_attr); + + fault_create_debugfs_attr("emulate_erase_failure", dir, + &fault_erase_failure_attr); fault_create_debugfs_attr("emulate_power_cut", dir, &fault_power_cut_attr); diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h index 92553299c685..2d7004ec78d3 100644 --- a/drivers/mtd/ubi/debug.h +++ b/drivers/mtd/ubi/debug.h @@ -92,10 +92,12 @@ static inline int ubi_dbg_erase_failure(const struct ubi_device *ubi) /* Emulate bit-flips */ #define MASK_BITFLIPS (1 << 2) /* Emulates -EIO during write/erase */ -#define MASK_IO_FAILURE (1 << 3) +#define MASK_WRITE_FAILURE (1 << 3) +#define MASK_ERASE_FAILURE (1 << 4) extern bool should_fail_bitflips(void); -extern bool should_fail_io_failures(void); +extern bool should_fail_write_failure(void); +extern bool should_fail_erase_failure(void); extern bool should_fail_power_cut(void); static inline bool ubi_dbg_fail_bitflip(const struct ubi_device *ubi) @@ -107,15 +109,15 @@ static inline bool ubi_dbg_fail_bitflip(const struct ubi_device *ubi) static inline bool ubi_dbg_fail_write(const struct ubi_device *ubi) { - if (ubi->dbg.emulate_failures & MASK_IO_FAILURE) - return should_fail_io_failures(); + if (ubi->dbg.emulate_failures & MASK_WRITE_FAILURE) + return should_fail_write_failure(); return false; } static inline bool ubi_dbg_fail_erase(const struct ubi_device *ubi) { - if (ubi->dbg.emulate_failures & MASK_IO_FAILURE) - return should_fail_io_failures(); + if (ubi->dbg.emulate_failures & MASK_ERASE_FAILURE) + return should_fail_erase_failure(); return false; } -- 2.39.2