UBI: Do not try to autoresize in readonly mode
Subsystems (2)
PATCH 1/1 UBI: Do not try to autoresize in readonly mode
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.
drivers/mtd/ubi/build.c +0 -0
@@ -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?
Signature · 2 lines
Pali Rohár [email protected]
Quoted 3 lines · Pali Rohár
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 <[email protected]>
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.
--- drivers/mtd/ubi/build.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mtd/ubi/build.c +5 -0
@@ -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
Signature · 1 line
1.7.10.4
Quoted 2 lines
BTW, is there userspace tool for unpacking data from ubifs image without need to simulate nand device in kernel?
Unfortunately no.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 8 lines · On Friday 24 August 2012 18:29:31 Artem Bityutskiy wrote:
Quoted 3 lines · Pali Rohár
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.
Quoted 4 lines
Quoted 2 lines
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.
Signature · 2 lines
Pali Rohár [email protected]
Quoted 5 lines · Pali Rohár
Quoted 4 lines
Quoted 2 lines
BTW, is there userspace tool for unpacking data from ubifs image without need to simulate nand device in kernel?
Unfortunately no.
Quoted 7 lines
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?
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 15 lines · On Friday 24 August 2012 18:57:01 Artem Bityutskiy wrote:
Quoted 6 lines · Pali Rohár
Quoted 5 lines
Quoted 3 lines
BTW, is there userspace tool for unpacking data from ubifs
image without need to simulate nand device in kernel?Unfortunately no.
Quoted 7 lines
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.
Quoted 3 lines
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...
Signature · 2 lines
Pali Rohár [email protected]
Quoted 6 lines · Pali Rohár
Quoted 3 lines
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.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 8 lines · On Friday 24 August 2012 18:09:16 Artem Bityutskiy wrote:
Quoted 6 lines · Pali Rohár
Quoted 3 lines
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...
Quoted 7 lines
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.
Signature · 2 lines
Pali Rohár [email protected]