* [PATCH] UBI: Do not try to autoresize in readonly mode
@ 2012-08-18 12:11 Pali Rohár
2012-08-24 15:29 ` Artem Bityutskiy
0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2012-08-18 12:11 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]
Hello,
when I'm tried to mount ubifs image from readonly mtd device (e.g
virtual, only for unpacking data) it failed because image has
autoresize flag on ubi block. ubi build.c code trying to
autoresize ubi image if has autoresize flag and if autoresize
failed, attaching ubi failed. So it is not possible to mount
ubifs image if ubi has autoresize flag in read only mode (because
resizing is not possible on read only device).
I'm sending small patch which skip autoresizing ubi in readonly
mode. I think it is really not good idea to try resize in ro
mode.
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 738772c..ad911ab 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -927,7 +927,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd,
int ubi_num, int vid_hdr_offset)
goto out_debugging;
}
- if (ubi->autoresize_vol_id != -1) {
+ if (!ubi->ro_mode && ubi->autoresize_vol_id != -1) {
err = autoresize(ubi, ubi->autoresize_vol_id);
if (err)
goto out_detach;
With this patch I'm able to mount & unpack data from ubifs image
on read only (virtual/simulated) nand device with autoresize
flag. Consider including this patch to ubi-2.6 git tree.
BTW, is there userspace tool for unpacking data from ubifs image
without need to simulate nand device in kernel?
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] UBI: Do not try to autoresize in readonly mode
2012-08-18 12:11 [PATCH] UBI: Do not try to autoresize in readonly mode Pali Rohár
@ 2012-08-24 15:29 ` Artem Bityutskiy
2012-08-24 15:48 ` Pali Rohár
0 siblings, 1 reply; 7+ messages in thread
From: Artem Bityutskiy @ 2012-08-24 15:29 UTC (permalink / raw)
To: Pali Rohár; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 1664 bytes --]
On Sat, 2012-08-18 at 14:11 +0200, Pali Rohár wrote:
> I'm sending small patch which skip autoresizing ubi in readonly
> mode. I think it is really not good idea to try resize in ro
> mode.
Hi, I've just pushed a similar patch to linux-ubi.git, is this fine with
you? I've also CCed -stable.
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date: Sat, 18 Aug 2012 14:11:42 +0200
Subject: [PATCH] UBI: fix autoresize handling in R/O mode
Currently UBI fails in autoresize when it is in R/O mode (e.g., because the
underlying MTD device is R/O). This patch fixes the issue - we just skip
autoresize and print a warning.
Reported-by: Pali Rohár <pali.rohar@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
drivers/mtd/ubi/build.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 355756b..8966088 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -799,6 +799,11 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
struct ubi_volume *vol = ubi->volumes[vol_id];
int err, old_reserved_pebs = vol->reserved_pebs;
+ if (ubi->ro_mode) {
+ ubi_warn("skip auto-resize because of R/O mode");
+ return 0;
+ }
+
/*
* Clear the auto-resize flag in the volume in-memory copy of the
* volume table, and 'ubi_resize_volume()' will propagate this change
--
1.7.10.4
> BTW, is there userspace tool for unpacking data from ubifs image
> without need to simulate nand device in kernel?
Unfortunately no.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] UBI: Do not try to autoresize in readonly mode
2012-08-24 15:29 ` Artem Bityutskiy
@ 2012-08-24 15:48 ` Pali Rohár
2012-08-24 15:57 ` Artem Bityutskiy
0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2012-08-24 15:48 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]
On Friday 24 August 2012 18:29:31 Artem Bityutskiy wrote:
> On Sat, 2012-08-18 at 14:11 +0200, Pali Rohár wrote:
> > I'm sending small patch which skip autoresizing ubi in
> > readonly mode. I think it is really not good idea to try
> > resize in ro mode.
>
> Hi, I've just pushed a similar patch to linux-ubi.git, is this
> fine with you? I've also CCed -stable.
>
Hi, patch is OK. I tested it and working for me fine.
> > BTW, is there userspace tool for unpacking data from ubifs
> > image without need to simulate nand device in kernel?
>
> Unfortunately no.
Ok. I have patch for block2mtd.ko which allows me to mount ubifs
image in way: losetup --> block2mtd --> ubiattach --> mount
without nandsim. I needed to patch block2mtd, because ubi code
needs correct erase size, write size nand subpage shift and full
image size. So I added params for these properties in block2mtd
code - and it working. But I do not know if this is correct way,
but I can send my patch.
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] UBI: Do not try to autoresize in readonly mode
2012-08-24 15:48 ` Pali Rohár
@ 2012-08-24 15:57 ` Artem Bityutskiy
2012-08-24 15:59 ` Pali Rohár
0 siblings, 1 reply; 7+ messages in thread
From: Artem Bityutskiy @ 2012-08-24 15:57 UTC (permalink / raw)
To: Pali Rohár; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
On Fri, 2012-08-24 at 17:48 +0200, Pali Rohár wrote:
> > > BTW, is there userspace tool for unpacking data from ubifs
> > > image without need to simulate nand device in kernel?
> >
> > Unfortunately no.
>
> Ok. I have patch for block2mtd.ko which allows me to mount ubifs
> image in way: losetup --> block2mtd --> ubiattach --> mount
> without nandsim. I needed to patch block2mtd, because ubi code
> needs correct erase size, write size nand subpage shift and full
> image size. So I added params for these properties in block2mtd
> code - and it working. But I do not know if this is correct way,
> but I can send my patch.
Why do you need to use block2mtd? If you have an image for NOR flash,
use mtdram, if it is for NAND - use nandsim. What prevents you from
using mtdram or nandsim?
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] UBI: Do not try to autoresize in readonly mode
2012-08-24 15:57 ` Artem Bityutskiy
@ 2012-08-24 15:59 ` Pali Rohár
2012-08-24 16:09 ` Artem Bityutskiy
0 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2012-08-24 15:59 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]
On Friday 24 August 2012 18:57:01 Artem Bityutskiy wrote:
> On Fri, 2012-08-24 at 17:48 +0200, Pali Rohár wrote:
> > > > BTW, is there userspace tool for unpacking data from
> > > > ubifs
> > > > image without need to simulate nand device in kernel?
> > >
> > > Unfortunately no.
> >
> > Ok. I have patch for block2mtd.ko which allows me to mount
> > ubifs image in way: losetup --> block2mtd --> ubiattach -->
> > mount without nandsim. I needed to patch block2mtd, because
> > ubi code needs correct erase size, write size nand subpage
> > shift and full image size. So I added params for these
> > properties in block2mtd code - and it working. But I do not
> > know if this is correct way, but I can send my patch.
>
> Why do you need to use block2mtd? If you have an image for NOR
> flash, use mtdram, if it is for NAND - use nandsim. What
> prevents you from using mtdram or nandsim?
I do not know why, but copying 256 MB image to nandsim takes more
time than losetup & block2mtd & mount...
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] UBI: Do not try to autoresize in readonly mode
2012-08-24 15:59 ` Pali Rohár
@ 2012-08-24 16:09 ` Artem Bityutskiy
2017-06-02 15:39 ` Pali Rohár
0 siblings, 1 reply; 7+ messages in thread
From: Artem Bityutskiy @ 2012-08-24 16:09 UTC (permalink / raw)
To: Pali Rohár; +Cc: linux-mtd
[-- Attachment #1: Type: text/plain, Size: 735 bytes --]
On Fri, 2012-08-24 at 17:59 +0200, Pali Rohár wrote:
> > Why do you need to use block2mtd? If you have an image for NOR
> > flash, use mtdram, if it is for NAND - use nandsim. What
> > prevents you from using mtdram or nandsim?
>
> I do not know why, but copying 256 MB image to nandsim takes more
> time than losetup & block2mtd & mount...
May be, how much more? Is that a show-stopper for you? If you copy with
'dd', try 'bs=2048' if you are simulating a device with a 2048 bytes
NAND page size.
But I guess you can patch block2mtd, I do not have objections (although
it'll report about itself as NOR flash?), but I never used it and I am
not sure how many bugs there are.
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] UBI: Do not try to autoresize in readonly mode
2012-08-24 16:09 ` Artem Bityutskiy
@ 2017-06-02 15:39 ` Pali Rohár
0 siblings, 0 replies; 7+ messages in thread
From: Pali Rohár @ 2017-06-02 15:39 UTC (permalink / raw)
To: dedekind1; +Cc: linux-mtd
[-- Attachment #1: Type: Text/Plain, Size: 1072 bytes --]
On Friday 24 August 2012 18:09:16 Artem Bityutskiy wrote:
> On Fri, 2012-08-24 at 17:59 +0200, Pali Rohár wrote:
> > > Why do you need to use block2mtd? If you have an image for NOR
> > > flash, use mtdram, if it is for NAND - use nandsim. What
> > > prevents you from using mtdram or nandsim?
> >
> > I do not know why, but copying 256 MB image to nandsim takes more
> > time than losetup & block2mtd & mount...
>
> May be, how much more? Is that a show-stopper for you? If you copy
> with 'dd', try 'bs=2048' if you are simulating a device with a 2048
> bytes NAND page size.
>
> But I guess you can patch block2mtd, I do not have objections
> (although it'll report about itself as NOR flash?), but I never used
> it and I am not sure how many bugs there are.
Hi! Years ago I wrote patches for block2mtd to allow specify write size
and nand subpage shift. But I forgot to send them. I think they could be
useful for other people, so rebased them on mainline kernel I will send
them in few minutes.
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-06-02 15:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-18 12:11 [PATCH] UBI: Do not try to autoresize in readonly mode Pali Rohár
2012-08-24 15:29 ` Artem Bityutskiy
2012-08-24 15:48 ` Pali Rohár
2012-08-24 15:57 ` Artem Bityutskiy
2012-08-24 15:59 ` Pali Rohár
2012-08-24 16:09 ` Artem Bityutskiy
2017-06-02 15:39 ` Pali Rohár
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).