Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2546403rdb; Mon, 25 Dec 2023 17:04:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzYbIM0xthAdv8f4Q9Urlx0bGGjyV8nvozLFwh12F7K3ocTxx8YBU8CarnPUWBtkMFC/YT X-Received: by 2002:a05:6358:913:b0:174:def5:f133 with SMTP id r19-20020a056358091300b00174def5f133mr725541rwi.56.1703552657257; Mon, 25 Dec 2023 17:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703552657; cv=none; d=google.com; s=arc-20160816; b=R22ZUzvJPLP1Hu04wStwMPpssfoxgmA367m22frKE1T2OS53WUuNGon0gp9qKWS46f 31cdhNwJohcrUAU8h52uiObogkCBSPW89NchclV3v7VLwZ3TVqd0kZCgQ7csaIC2vPsO 6rVJKreTLQ//76BUWGhi0EQ6PPVALSey+Vp1Qc+XB1olzxGaECnh42Lx3YNhUOIUOUsr OUOn2Q8ki//G/XXJrrLuQvStDNpSlrEBMtOZnq5LBsJvcl8lP5SVwVoqD4hb2z6+XWWa iGzNCsO78h/176fgHcZzlL6Hdma19Pwzg1hMfv3eZqctP3ihR00dJJszYCd/fO0+2tI0 9/Og== 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=Uk13JvTF7yB9wW0am5pmbBZ+RJSkpdHhHVlWrtHaRus=; fh=XjbPFQV1q33pSyHU0DJViPof6LxQPkAWDXnCrlkcrhg=; b=RKIgsYxjVWzWOKhG0h4T4zb98UFfZGxdNkwOkgVFE2fxAAkgdNcBO67S8bmohibzvM ILZxKrDFwYD+rR+cWFL9b4QoCzOVRBw/hZQrTURo4j77lJy1h1kB7Gli8BHI79j9oMJ3 g0QCatRbkPCWJ6ROnCANhAXT0PF8C1VzVbJJE+YWE2e5yVP2YAXyS8qAClLCleEBn1BE AKrCjBkS3eWzStH/iZQDYq29ahG+QNPj6eC2G+fhU3b1I6DNwqdCa9Eq9G216cwqsMWC 8Hv8djgXZ9Hf79/DgUQGdgQjT/+IA/3FH4kHUHfz57AptgeaWAWZhYqLaiqqW1nCHO4D 26Uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11305-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bs193-20020a6328ca000000b005c6045987a1si8346316pgb.7.2023.12.25.17.04.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 17:04:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-11305-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11305-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 E163E28170D for ; Tue, 26 Dec 2023 01:04:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0D5733FE; Tue, 26 Dec 2023 01:04:04 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (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 16E812919 for ; Tue, 26 Dec 2023 01:04:01 +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 szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Szc3V3yY4z1vpXh; Tue, 26 Dec 2023 09:03:50 +0800 (CST) Received: from dggpemd200001.china.huawei.com (unknown [7.185.36.224]) by mail.maildlp.com (Postfix) with ESMTPS id EA85A1A01A0; Tue, 26 Dec 2023 09:03:44 +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:29 +0800 From: ZhaoLong Wang To: , , CC: , , , , , Subject: [PATCH v6 2/5] ubi: Split io_failures into write_failure and erase_failure Date: Tue, 26 Dec 2023 09:01:10 +0800 Message-ID: <20231226010113.742079-3-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) 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 fd101ad6f12f..186306228b4d 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 f2f499feff49..8cdd25eee013 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