From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7081CC5DF8B for ; Thu, 20 Aug 2026 10:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LbJ2R6kw/nF1tU9lYymlzF4SYkka7Pix2TjQJ7+oGMU=; b=d6gT0A5UZsbENs 5KAOLFORwvMVJjVKsPvTzKcH8jYqH0YbHuzdGwI/dtADOWI7+eJ6DSJ7H3VEDpQwJjxChLos3jZVg tMYhw2PiiZlCrKzjUxARP5ehiNBc8B64pHUNKnOMjHEtRZOOhOYksbnk33a7uzb/N2haSzRbKzKZ7 pq1DO/PMadHLCtrpfBeGorwP7FF4XgOF6bHYA6Bdf9bmFwaoXhsMD9LmGB7CRoTNS/yvgvqnxOPP4 kEm2TtdD9hneBld4hsX/6laSVV5HePnUUsDgIU7aUEm3vk9Qky1zfnXkVe89Hw+cznN7jvZrp7hW2 miw3nKvRZJhmlnw/m9pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wx0SL-0000000BOb9-1SXP; Thu, 20 Aug 2026 10:57:09 +0000 Received: from canpmsgout03.his.huawei.com ([113.46.200.218]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wx0SH-0000000BOYI-3ihB for linux-mtd@lists.infradead.org; Thu, 20 Aug 2026 10:57:08 +0000 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=/TR7Ya244Vuybsce9gxyOWbUCBZRN+8PiB8fEOS0TpA=; b=OCmxK7oK1lKSypL7S2R3CRyhSzYLf6NKFdvk0RBtIlmmppUlvH6DjZNaXOgSgIibsUwMSWfQ1 Gzc5iPZy0BKX/L0IX7MAN8OcE3pa+Radhgr63up+ETDpC3z+1E1mo3e/1ycML37LOJMTpyKWegp HLbFl+94PULGVNjr5kSiluQ= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4hQg8V5WhlzpT1J; Thu, 20 Aug 2026 18:46:02 +0800 (CST) Received: from dggpemr100018.china.huawei.com (unknown [7.185.36.64]) by mail.maildlp.com (Postfix) with ESMTPS id A628D40537; Thu, 20 Aug 2026 18:57:00 +0800 (CST) Received: from huawei.com (10.50.85.155) by dggpemr100018.china.huawei.com (7.185.36.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Thu, 20 Aug 2026 18:57:00 +0800 From: zhouminqiang To: , CC: , , , , Subject: [PATCH 6/6] jffs2: add runtime toggle for write verification Date: Thu, 20 Aug 2026 18:50:02 +0800 Message-ID: <20260820105003.2525647-7-zhouminqiang2@huawei.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260820105003.2525647-1-zhouminqiang2@huawei.com> References: <20260820105003.2525647-1-zhouminqiang2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.85.155] X-ClientProxiedBy: kwepems200002.china.huawei.com (7.221.188.68) To dggpemr100018.china.huawei.com (7.185.36.64) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260820_035706_600960_9B276A0B X-CRM114-Status: GOOD ( 12.87 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org Write verification is a diagnostic facility that adds read-back overhead to every write. In production, this overhead is undesirable unless fault isolation is required. Add a module parameter jffs2.write_verify (bool, 0644) that defaults to off when CONFIG_JFFS2_FS_WRITE_VERIFY is enabled. The verification entry checks READ_ONCE(jffs2_write_verify) and returns immediately when disabled, avoiding any overhead. The parameter can be toggled at runtime via /sys/module/jffs2/parameters/write_verify or set at boot/modprobe time. Signed-off-by: zhouminqiang --- fs/jffs2/Kconfig | 8 ++++++++ fs/jffs2/writev.c | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/fs/jffs2/Kconfig b/fs/jffs2/Kconfig index 556025a5d438..03dadbd003cd 100644 --- a/fs/jffs2/Kconfig +++ b/fs/jffs2/Kconfig @@ -61,6 +61,14 @@ config JFFS2_FS_WRITE_VERIFY tell transport/program-time corruption from post-commit media damage. + Verification defaults to off when this option is selected and can + be enabled at runtime via sysfs: + + /sys/module/jffs2/parameters/write_verify + + Write 0 to disable, 1 to enable. Boot/modprobe parameter + jffs2.write_verify=0|1 is also supported. + If unsure, say 'N'. config JFFS2_SUMMARY diff --git a/fs/jffs2/writev.c b/fs/jffs2/writev.c index fc1eae60c476..b32eb07747f4 100644 --- a/fs/jffs2/writev.c +++ b/fs/jffs2/writev.c @@ -9,12 +9,32 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include +#include #include #include #include "nodelist.h" #ifdef CONFIG_JFFS2_FS_WRITE_VERIFY +/* + * Optional read-back after writes. + * + * Catch cases where data is corrupted after node CRCs are calculated but + * before it is correctly programmed -- e.g. in RAM or during DMA/bus + * transfer to the flash controller -- so mtd_write() succeeds while the + * medium does not match the in-memory image. + * + * Runtime toggle: /sys/module/jffs2/parameters/write_verify + * (also boot/modprobe: jffs2.write_verify=0|1) + */ +static bool jffs2_write_verify; +module_param_named(write_verify, jffs2_write_verify, bool, 0644); +MODULE_PARM_DESC(write_verify, + "Verify flash writes by reading back (default: N)"); + + int jffs2_verify_write(struct jffs2_sb_info *c, const unsigned char *buf, uint32_t ofs, size_t len) { @@ -23,6 +43,9 @@ int jffs2_verify_write(struct jffs2_sb_info *c, const unsigned char *buf, char *eccstr; void *verify_buf; + if (!READ_ONCE(jffs2_write_verify)) + return 0; + verify_buf = __vmalloc(len, GFP_NOFS); if (!verify_buf) { pr_warn("%s(): verify buffer allocation failed, skipping verification\n", -- 2.52.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (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 36521389111 for ; Thu, 20 Aug 2026 10:57:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787223431; cv=none; b=DEs+Cxzqzm8VaXp1TCC63lbq/FqP++GpYevtcQ4YYvGhYHJZIukusvtfPH1UZzfk6BCw7y9KVXRt6tQuCRlemQSiptwdNVqTRJiLOwaB5eenURfxS7Zz7yWFTvFCkaKem7wrr9uwvLvkO+++FG9ybj2dOY6qOdhwX5UhOGKtZkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787223431; c=relaxed/simple; bh=Nttx8T1xym36MBGXKOwvnJ3Uz/oMRm+BKEOkbjf8XU4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RojN438kT1JYMp+KfMvaVuNXWt3HavDnzaZ7obch5LRFf0KcvCSn6erfmAUVTB0gADjn29fXlTWMcqW5iw+HeGz6ZJcn1Y17YSdyDHCjiXcYbovoZNZOySfmahb2uJkZ2oQrTagmNKsIi4AqDvqRchhM2ShJphmslKY9sy8ZbUE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=OCmxK7oK; arc=none smtp.client-ip=113.46.200.218 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="OCmxK7oK" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=/TR7Ya244Vuybsce9gxyOWbUCBZRN+8PiB8fEOS0TpA=; b=OCmxK7oK1lKSypL7S2R3CRyhSzYLf6NKFdvk0RBtIlmmppUlvH6DjZNaXOgSgIibsUwMSWfQ1 Gzc5iPZy0BKX/L0IX7MAN8OcE3pa+Radhgr63up+ETDpC3z+1E1mo3e/1ycML37LOJMTpyKWegp HLbFl+94PULGVNjr5kSiluQ= Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4hQg8V5WhlzpT1J; Thu, 20 Aug 2026 18:46:02 +0800 (CST) Received: from dggpemr100018.china.huawei.com (unknown [7.185.36.64]) by mail.maildlp.com (Postfix) with ESMTPS id A628D40537; Thu, 20 Aug 2026 18:57:00 +0800 (CST) Received: from huawei.com (10.50.85.155) by dggpemr100018.china.huawei.com (7.185.36.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Thu, 20 Aug 2026 18:57:00 +0800 From: zhouminqiang To: , CC: , , , , Subject: [PATCH 6/6] jffs2: add runtime toggle for write verification Date: Thu, 20 Aug 2026 18:50:02 +0800 Message-ID: <20260820105003.2525647-7-zhouminqiang2@huawei.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260820105003.2525647-1-zhouminqiang2@huawei.com> References: <20260820105003.2525647-1-zhouminqiang2@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: kwepems200002.china.huawei.com (7.221.188.68) To dggpemr100018.china.huawei.com (7.185.36.64) Write verification is a diagnostic facility that adds read-back overhead to every write. In production, this overhead is undesirable unless fault isolation is required. Add a module parameter jffs2.write_verify (bool, 0644) that defaults to off when CONFIG_JFFS2_FS_WRITE_VERIFY is enabled. The verification entry checks READ_ONCE(jffs2_write_verify) and returns immediately when disabled, avoiding any overhead. The parameter can be toggled at runtime via /sys/module/jffs2/parameters/write_verify or set at boot/modprobe time. Signed-off-by: zhouminqiang --- fs/jffs2/Kconfig | 8 ++++++++ fs/jffs2/writev.c | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/fs/jffs2/Kconfig b/fs/jffs2/Kconfig index 556025a5d438..03dadbd003cd 100644 --- a/fs/jffs2/Kconfig +++ b/fs/jffs2/Kconfig @@ -61,6 +61,14 @@ config JFFS2_FS_WRITE_VERIFY tell transport/program-time corruption from post-commit media damage. + Verification defaults to off when this option is selected and can + be enabled at runtime via sysfs: + + /sys/module/jffs2/parameters/write_verify + + Write 0 to disable, 1 to enable. Boot/modprobe parameter + jffs2.write_verify=0|1 is also supported. + If unsure, say 'N'. config JFFS2_SUMMARY diff --git a/fs/jffs2/writev.c b/fs/jffs2/writev.c index fc1eae60c476..b32eb07747f4 100644 --- a/fs/jffs2/writev.c +++ b/fs/jffs2/writev.c @@ -9,12 +9,32 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include +#include #include #include #include "nodelist.h" #ifdef CONFIG_JFFS2_FS_WRITE_VERIFY +/* + * Optional read-back after writes. + * + * Catch cases where data is corrupted after node CRCs are calculated but + * before it is correctly programmed -- e.g. in RAM or during DMA/bus + * transfer to the flash controller -- so mtd_write() succeeds while the + * medium does not match the in-memory image. + * + * Runtime toggle: /sys/module/jffs2/parameters/write_verify + * (also boot/modprobe: jffs2.write_verify=0|1) + */ +static bool jffs2_write_verify; +module_param_named(write_verify, jffs2_write_verify, bool, 0644); +MODULE_PARM_DESC(write_verify, + "Verify flash writes by reading back (default: N)"); + + int jffs2_verify_write(struct jffs2_sb_info *c, const unsigned char *buf, uint32_t ofs, size_t len) { @@ -23,6 +43,9 @@ int jffs2_verify_write(struct jffs2_sb_info *c, const unsigned char *buf, char *eccstr; void *verify_buf; + if (!READ_ONCE(jffs2_write_verify)) + return 0; + verify_buf = __vmalloc(len, GFP_NOFS); if (!verify_buf) { pr_warn("%s(): verify buffer allocation failed, skipping verification\n", -- 2.52.0