Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1207861pxy; Sun, 1 Aug 2021 16:49:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymr+9NYP0gZKF4fVZOGFYSijcT6rbF1FyWwWFXw15/B32JbdvOP00W3DaUW5Y3Q0eCi505 X-Received: by 2002:a05:6402:60b:: with SMTP id n11mr16653399edv.235.1627861745066; Sun, 01 Aug 2021 16:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627861745; cv=none; d=google.com; s=arc-20160816; b=CuFbi+gwW6f+fWu/4X4a7OasIDmmHabTSlMmGn4ndtCBK+F7ITtUYYeuUVODor9/RE aX76TiIjI+cYlWjgjibh0QFZiJIP/ad9QIyL4k6kt7tR7UY8IvhV3vx/u9vxcpYhjq0K e3dSBeA6eUZz10hn9Cu+VeRxP+RR9R5FTJXo7lMJlAeGKk1GjYZlG24y7ab0K/kirJFR XFAIzjE8HmHUtIehxS7N9urUinY2m8JfvlI1jgV63meTKPzUW6bkOuzAu/z7z1R1x0oB FsZVwKDX1rPqS/FB0vCDTX2M73H+NcOubHcYEQZekj5HycX8jAx6fnq2agwGAQvHv0y5 53bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gVHEHlseyDZHvboi7M7oJcrbSupQYM6dYT3x56GRfmE=; b=gwrmEB1J2x5bo4mRvor9Xrb6yp8am0aLKESQ2hKvR0SbR0dPGPDvgHcl8aF2fxAOwl T7xL6H+GVziuhqURNn2tktnhGjRMGGxRoJgZpSNpiLL4SP3HSn9MO36Nu/1I9UGnunTd mKf8b9xQFjWWuW67EaPmLX8C56y5KCPzc6i9wvhUCaC+kGJSQyxW6wyY4yXY6ZFa8obX tqZD+LvbL73mTXlQQsAe3Eod22kSMIcpE1RkccFJPEJILNtJhXCjoX4Z66fJjzT5ee6t wUk5yhCaTRa1TaYFMpxbaO44tm3lPvDZDW71ra2JMsq+UI+sKwqnORyeQMP5d4jSGO8c GvYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r26si8751366edt.275.2021.08.01.16.48.42; Sun, 01 Aug 2021 16:49:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231818AbhHAXp4 (ORCPT + 99 others); Sun, 1 Aug 2021 19:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231958AbhHAXpw (ORCPT ); Sun, 1 Aug 2021 19:45:52 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A36BC06175F for ; Sun, 1 Aug 2021 16:45:44 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 9A6121F424D4 From: Ezequiel Garcia To: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Richard Weinberger Cc: Miquel Raynal , Vignesh Raghavendra , Ezequiel Garcia Subject: [PATCH 3/3] mtdblock: Warn if the added for a NAND device Date: Sun, 1 Aug 2021 20:45:09 -0300 Message-Id: <20210801234509.18774-8-ezequiel@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210801234509.18774-1-ezequiel@collabora.com> References: <20210801234509.18774-1-ezequiel@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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