mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Joern Engel <joern@lazybastard.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Pali Rohár" <pali.rohar@gmail.com>
Subject: [PATCH 5/5] ubi: Allow to use read-only UBI volume with not enough PEBs
Date: Fri,  2 Jun 2017 17:43:42 +0200	[thread overview]
Message-ID: <1496418222-23483-6-git-send-email-pali.rohar@gmail.com> (raw)
In-Reply-To: <1496418222-23483-1-git-send-email-pali.rohar@gmail.com>

In read-only mode is skipped auto-resize. For pre-build images ready for
auto-resize there can be reserved more PEBs as whole size of pre-build
image. In read-only we do not do any write operation therefore this would
allow to use read-only UBI volume which is not auto-resized yet.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 drivers/mtd/ubi/vtbl.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 263743e..1d708c5 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -240,8 +240,10 @@ static int vtbl_check(const struct ubi_device *ubi,
 		if (reserved_pebs > ubi->good_peb_count) {
 			ubi_err(ubi, "too large reserved_pebs %d, good PEBs %d",
 				reserved_pebs, ubi->good_peb_count);
-			err = 9;
-			goto bad;
+			if (!ubi->ro_mode) {
+				err = 9;
+				goto bad;
+			}
 		}
 
 		if (name_len > UBI_VOL_NAME_MAX) {
@@ -652,10 +654,12 @@ static int init_volumes(struct ubi_device *ubi,
 		if (ubi->corr_peb_count)
 			ubi_err(ubi, "%d PEBs are corrupted and not used",
 				ubi->corr_peb_count);
-		return -ENOSPC;
+		if (!ubi->ro_mode)
+			return -ENOSPC;
+	} else {
+		ubi->rsvd_pebs += reserved_pebs;
+		ubi->avail_pebs -= reserved_pebs;
 	}
-	ubi->rsvd_pebs += reserved_pebs;
-	ubi->avail_pebs -= reserved_pebs;
 
 	return 0;
 }
-- 
1.7.9.5

  parent reply	other threads:[~2017-06-02 15:44 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 15:43 [PATCH 0/5] Extends block2mtd and ubi drivers Pali Rohár
2017-06-02 15:43 ` [PATCH 1/5] mtd: block2mtd: Check for valid user supplied erase size Pali Rohár
2017-07-21 19:45   ` Richard Weinberger
2017-06-02 15:43 ` [PATCH 2/5] mtd: block2mtd: Add support for specifying MTD write size and subpage shift Pali Rohár
2017-06-02 16:13   ` Richard Weinberger
2017-06-05 11:21     ` Pali Rohár
2017-06-05 11:23       ` Richard Weinberger
2017-06-05 11:25         ` Pali Rohár
2017-06-05 11:27           ` Richard Weinberger
2017-06-07  8:46             ` Pali Rohár
2017-06-18 10:06             ` Pavel Machek
2017-06-18 10:11               ` Richard Weinberger
2017-07-17 12:34                 ` Pali Rohár
2017-06-02 15:43 ` [PATCH 3/5] mtd: block2mtd: Fallback to read-only mode Pali Rohár
2017-07-21 19:53   ` Richard Weinberger
2017-07-25 14:28     ` Pali Rohár
2017-06-02 15:43 ` [PATCH 4/5] mtd: block2mtd: Add support for deleting block2mtd mapping Pali Rohár
2017-07-21 19:56   ` Richard Weinberger
2017-07-25 14:24     ` Pali Rohár
2017-08-06  9:39       ` Richard Weinberger
2017-06-02 15:43 ` Pali Rohár [this message]
2017-07-21 20:12   ` [PATCH 5/5] ubi: Allow to use read-only UBI volume with not enough PEBs Richard Weinberger
2017-07-25 14:27     ` Pali Rohár
2017-08-06  9:43       ` Richard Weinberger
2017-08-06 10:30         ` Pali Rohár
2017-06-02 16:17 ` [PATCH 0/5] Extends block2mtd and ubi drivers Richard Weinberger
2017-06-05 11:18   ` Pali Rohár

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=1496418222-23483-6-git-send-email-pali.rohar@gmail.com \
    --to=pali.rohar@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=joern@lazybastard.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    /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

all inboxes | Powered by JetHome®