linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel@collabora.com>
To: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	Richard Weinberger <richard@nod.at>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Ezequiel Garcia <ezequiel@collabora.com>
Subject: [PATCH 3/3] mtdblock: Warn if the added for a NAND device
Date: Sun,  1 Aug 2021 20:45:09 -0300	[thread overview]
Message-ID: <20210801234509.18774-8-ezequiel@collabora.com> (raw)
In-Reply-To: <20210801234509.18774-1-ezequiel@collabora.com>

There is a surprisingly large number of tutorials
that suggest using mtdblock to mount SquashFS filesystems
on flash devices, including NAND devices.

This approach is suboptimal than using UBI. If the flash device
is NAND, this is specially true, due to wear leveling, bit-flips and
badblocks. In this case UBI is strongly preferred, so be nice to users
and print a warning suggesting to consider UBI block, if mtdblock
is added for a NAND device.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>

Untracked files not listed
---
 drivers/mtd/mtdblock.c    | 4 ++++
 drivers/mtd/mtdblock_ro.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index b2d5ed1cbc94..7c02643f862f 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -332,6 +332,10 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 	if (!(mtd->flags & MTD_WRITEABLE))
 		dev->mbd.readonly = 1;
 
+	if (mtd_type_is_nand(mtd))
+		pr_warn("%s: MTD device '%s' is NAND, please consider using UBI block devices instead.\n",
+			tr->name, mtd->name);
+
 	if (add_mtd_blktrans_dev(&dev->mbd))
 		kfree(dev);
 }
diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c
index fb5dc89369de..a438e2f6089c 100644
--- a/drivers/mtd/mtdblock_ro.c
+++ b/drivers/mtd/mtdblock_ro.c
@@ -60,6 +60,10 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 	dev->tr = tr;
 	dev->readonly = 1;
 
+	if (mtd_type_is_nand(mtd))
+		pr_warn("%s: MTD device '%s' is NAND, please consider using UBI block devices instead.\n",
+			tr->name, mtd->name);
+
 	if (add_mtd_blktrans_dev(dev))
 		kfree(dev);
 }
-- 
2.32.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  parent reply	other threads:[~2021-08-01 23:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-01 23:45 [PATCH 0/3] mtdblock: Advertise about UBI and UBI block Ezequiel Garcia
2021-08-01 23:45 ` [PATCH 1/3] mtdblock: Update old JFFS2 mention in Kconfig Ezequiel Garcia
2021-08-01 23:45 ` [PATCH 2/3] mtdblock: Add comment about UBI block devices Ezequiel Garcia
2021-08-01 23:45 ` [PATCH 3/3] mtdblock: Warn if the added for a NAND device Ezequiel Garcia
2021-08-01 23:45 ` [PATCH 0/3] mtdblock: Advertise about UBI and UBI block Ezequiel Garcia
2021-08-01 23:45 ` [PATCH 1/3] mtdblock: Update old JFFS2 mention in Kconfig Ezequiel Garcia
2021-08-06 20:05   ` Miquel Raynal
2021-08-01 23:45 ` [PATCH 2/3] mtdblock: Add comment about UBI block devices Ezequiel Garcia
2021-08-06 20:05   ` Miquel Raynal
2021-08-01 23:45 ` Ezequiel Garcia [this message]
2021-08-06 20:05   ` [PATCH 3/3] mtdblock: Warn if the added for a NAND device Miquel Raynal
2021-08-17 16:27     ` Ezequiel Garcia
2021-08-17 16:49       ` Miquel Raynal
2021-10-26 15:03 ` [PATCH 0/3] mtdblock: Advertise about UBI and UBI block Trevor Woerner
2021-10-26 19:01   ` Richard Weinberger
2021-10-28 13:31     ` Trevor Woerner
2021-11-09 10:55       ` Miquel Raynal
2021-11-09 11:45       ` Daniel Golle
2021-11-12 13:54   ` Ezequiel Garcia
2022-01-20  9:39     ` Miquel Raynal
2022-01-20 10:26       ` Ezequiel Garcia
2022-01-20 11:22         ` Miquel Raynal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210801234509.18774-8-ezequiel@collabora.com \
    --to=ezequiel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).