From patchwork Wed Jun 13 21:23:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 929097 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kibUrvij"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415fwz6jPsz9s01 for ; Thu, 14 Jun 2018 07:27:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hbnoZjV3UNK0enzv3qJsHDRsUHPHUwzfw0R7w3JlTJ0=; b=kibUrvijuPHwXlnkf6l5aSHQ/X DM0UhoTkOGS0DLTkYgA/5soc0MzjfbXhzX19RH8EcpRkki4yyno6vfe+tDP8eWRSLf9dPloYxAqu4 j1iBkGoHocR7iTHV6jp9Opui1KguNUkg6936zruowdGvI9/g7THiM4ikGk3TIjITLtreQUuNDauyM Ws5bAXFqBKTNbnQiS5bimE9bP7NUaPUnSXBTkMd9zTo3XK9RmFKh7pTHvJN+TWVUa6DU/nFtMiZSt DnmddjdSD5yzh4NPVtTRqzU9yGIPCdi98SP3hrrCF0oq5WS1GO5eo14mRFadRoUU4YuYd5xtgwuTd d92jsFlg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTDIk-00087p-Jq; Wed, 13 Jun 2018 21:27:34 +0000 Received: from lilium.sigma-star.at ([109.75.188.150]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTDFi-0004ui-Nx for linux-mtd@lists.infradead.org; Wed, 13 Jun 2018 21:24:41 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 286E918198DC2; Wed, 13 Jun 2018 23:24:07 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH 11/14] ubi: Add module parameter to force a full scan Date: Wed, 13 Jun 2018 23:23:41 +0200 Message-Id: <20180613212344.11608-12-richard@nod.at> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180613212344.11608-1-richard@nod.at> References: <20180613212344.11608-1-richard@nod.at> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180613_142426_982419_6CFF1A83 X-CRM114-Status: GOOD ( 15.12 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Using this parameter one can force UBI do to a full scan instead of using a fastmap. Signed-off-by: Richard Weinberger --- drivers/mtd/ubi/attach.c | 13 +++++++++---- drivers/mtd/ubi/build.c | 5 ++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c index 9a8072cf458c..134b15f093c3 100644 --- a/drivers/mtd/ubi/attach.c +++ b/drivers/mtd/ubi/attach.c @@ -925,7 +925,7 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr, return err; } -static bool vol_ignored(int vol_id) +static bool vol_ignored(struct ubi_attach_info *ai, int vol_id) { switch (vol_id) { case UBI_LAYOUT_VOLUME_ID: @@ -933,6 +933,9 @@ static bool vol_ignored(int vol_id) } #ifdef CONFIG_MTD_UBI_FASTMAP + if (ai->force_full_scan) + return false; + return ubi_is_fm_vol(vol_id); #else return false; @@ -1143,7 +1146,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, } vol_id = be32_to_cpu(vidh->vol_id); - if (vol_id > UBI_MAX_VOLUMES && !vol_ignored(vol_id)) { + if (vol_id > UBI_MAX_VOLUMES && !vol_ignored(ai, vol_id)) { int lnum = be32_to_cpu(vidh->lnum); /* Unsupported internal volume */ @@ -1581,9 +1584,11 @@ int ubi_attach(struct ubi_device *ubi, int force_scan) force_scan = 1; } - if (force_scan) + if (force_scan) { + ubi_msg(ubi, "full scan forced"); + ai->force_full_scan = 1; err = scan_all(ubi, ai, 0); - else { + } else { err = scan_fast(ubi, &ai); if (err > 0 || mtd_is_eccerr(err)) { if (err != UBI_NO_FASTMAP) { diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index d2a726654ff1..1e3f75ede985 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -83,6 +83,7 @@ static struct mtd_dev_param mtd_dev_param[UBI_MAX_DEVICES]; static bool fm_autoconvert; static bool fm_debug; #endif +static bool force_scan; /* Slab cache for wear-leveling entries */ struct kmem_cache *ubi_wl_entry_slab; @@ -956,7 +957,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, if (!ubi->fm_buf) goto out_free; #endif - err = ubi_attach(ubi, 0); + err = ubi_attach(ubi, force_scan); if (err) { ubi_err(ubi, "failed to attach mtd%d, error %d", mtd->index, err); @@ -1458,6 +1459,8 @@ module_param(fm_autoconvert, bool, 0644); MODULE_PARM_DESC(fm_autoconvert, "Set this parameter to enable fastmap automatically on images without a fastmap."); module_param(fm_debug, bool, 0); MODULE_PARM_DESC(fm_debug, "Set this parameter to enable fastmap debugging by default. Warning, this will make fastmap slow!"); +module_param(force_scan, bool, 0644); +MODULE_PARM_DESC(force_scan, "Always do a full scan of the MTD and drop possible fastmap structures from the MTD."); #endif MODULE_VERSION(__stringify(UBI_VERSION)); MODULE_DESCRIPTION("UBI - Unsorted Block Images");