UBI: PATCH: -EINTR do not causes ubi to switch to read-only mode.
Vinit Agnihotri
vinit.agnihotri at gmail.com
Tue Jul 17 07:52:03 EDT 2007
With reference to previous mails, I am posting patch to handle -EINTR
separately.
Now ubi wont switch to read-only mode on receiving -EINTR signal while
writing or erasing.
patch is here:
Signed-off-by: Vinit Agnihotri <vinit.agnihotri at gmail.com>
================================================================
diff -ruN linux-2.6.18.3-vanila/drivers/mtd/ubi/eba.c
linux-2.6.18.3-mod/drivers/mtd/ubi/eba.c
--- linux-2.6.18.3-vanila/drivers/mtd/ubi/eba.c 2007-07-09
14:28:28.000000000 +0530
+++ linux-2.6.18.3-mod/drivers/mtd/ubi/eba.c 2007-07-17 16:59:28.000000000 +0530
@@ -616,6 +616,10 @@
ubi_warn("failed to write data to PEB %d", pnum);
if (err == -EIO && ubi->bad_allowed)
err = recover_peb(ubi, pnum, vol_id, lnum, buf, offset, len);
+ if (err == -EINTR) {
+ leb_write_unlock(ubi, vol_id, lnum);
+ return err;
+ }
if (err)
ubi_ro_mode(ubi);
}
@@ -673,7 +677,18 @@
write_error:
if (err != -EIO || !ubi->bad_allowed) {
- ubi_ro_mode(ubi);
+ if (err == -EINTR) {
+ err = ubi_wl_put_peb(ubi, pnum, 1);
+ if (err || ++tries > UBI_IO_RETRIES) {
+ ubi_ro_mode(ubi);
+ leb_write_unlock(ubi, vol_id, lnum);
+ ubi_free_vid_hdr(ubi, vid_hdr);
+ return err;
+ }
+ err = -EINTR;
+ }
+ else
+ ubi_ro_mode(ubi);
leb_write_unlock(ubi, vol_id, lnum);
ubi_free_vid_hdr(ubi, vid_hdr);
return err;
@@ -799,7 +814,17 @@
* something nasty and unexpected happened. Switch to read-only
* mode just in case.
*/
- ubi_ro_mode(ubi);
+ if (err == -EINTR) {
+ err = ubi_wl_put_peb(ubi, pnum, 1);
+ if (err || ++tries > UBI_IO_RETRIES) {
+ ubi_ro_mode(ubi);
+ leb_write_unlock(ubi, vol_id, lnum);
+ ubi_free_vid_hdr(ubi, vid_hdr);
+ return err;
+ }
+ err = -EINTR;
+ } else
+ ubi_ro_mode(ubi);
leb_write_unlock(ubi, vol_id, lnum);
ubi_free_vid_hdr(ubi, vid_hdr);
return err;
diff -ruN linux-2.6.18.3-vanila/drivers/mtd/ubi/wl.c
linux-2.6.18.3-mod/drivers/mtd/ubi/wl.c
--- linux-2.6.18.3-vanila/drivers/mtd/ubi/wl.c 2007-07-09
14:28:28.000000000 +0530
+++ linux-2.6.18.3-mod/drivers/mtd/ubi/wl.c 2007-07-17 16:37:44.000000000 +0530
@@ -1103,6 +1103,10 @@
* this physical eraseblock for erasure again would cause
* errors again and again. Well, lets switch to RO mode.
*/
+ if (err == -EINTR) {
+ err = schedule_erase(ubi, e, 0);
+ return -EINTR;
+ }
ubi_ro_mode(ubi);
return err;
}
More information about the linux-mtd
mailing list