* UBI: PATCH: -EINTR do not causes ubi to switch to read-only mode.
@ 2007-07-17 11:52 Vinit Agnihotri
2007-07-17 12:18 ` Artem Bityutskiy
0 siblings, 1 reply; 2+ messages in thread
From: Vinit Agnihotri @ 2007-07-17 11:52 UTC (permalink / raw)
To: linux-mtd, dedekind
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@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;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: UBI: PATCH: -EINTR do not causes ubi to switch to read-only mode.
2007-07-17 11:52 UBI: PATCH: -EINTR do not causes ubi to switch to read-only mode Vinit Agnihotri
@ 2007-07-17 12:18 ` Artem Bityutskiy
0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2007-07-17 12:18 UTC (permalink / raw)
To: Vinit Agnihotri; +Cc: linux-mtd
Vinit,
your patch again does not apply. Please, try to save your own mail and
apply it with git-am.
Also few notes below.
On Tue, 2007-07-17 at 17:22 +0530, Vinit Agnihotri wrote:
> 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:
It is better to include the commit message you would like to see in the
commit instead.
> Signed-off-by: Vinit Agnihotri <vinit.agnihotri@gmail.com>
> ================================================================
This line is unneeded.
> 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;
There is already return statement below. Also it would be nice to add
-ENOMEM check here as well.
> 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) {
No need to retry if user wants to interrupt. Just put, unlock and return
-EINTR up.
> + ubi_ro_mode(ubi);
> + leb_write_unlock(ubi, vol_id, lnum);
> + ubi_free_vid_hdr(ubi, vid_hdr);
> + return err;
> + }
> + err = -EINTR;
> + }
> + else
} 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;
> + }
Similar.
> + 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;
> + }
Please, amend comments as well otherwise they do not match the code.
> ubi_ro_mode(ubi);
> return err;
> }
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-17 12:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-17 11:52 UBI: PATCH: -EINTR do not causes ubi to switch to read-only mode Vinit Agnihotri
2007-07-17 12:18 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox