Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1232882

[PATCH 3/5] UBI: switch the UBI device in read-only mode when mtd returns -EROFS

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH 3/5] UBI: switch the UBI device in read-only mode when mtd returns -EROFS
Date 2015-09-25 17:20 +0200
Message-ID <qcCX0-58P-21@gated-at.bofh.it> (permalink)
References <qcCWZ-58P-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The NAND layer is now able to forward power-cut emulation errors from
a NAND driver to the MTD user.
Check for this kind of errors in UBI and switch the UBI device in read-only
mode if such an error occurs.
The error will also be forwarded to the UBI user requesting the operation
if any, thus allowing UBIFS to act accordingly.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/mtd/ubi/io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 5bbd1f0..c5ebef7 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -303,6 +303,8 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
 		len = ubi->peb_size - offset;
 		if (len)
 			err = ubi_self_check_all_ff(ubi, pnum, offset, len);
+	} else if (err == -EROFS) {
+		ubi_ro_mode(ubi);
 	}
 
 	return err;
@@ -355,7 +357,7 @@ retry:
 
 	err = mtd_erase(ubi->mtd, &ei);
 	if (err) {
-		if (retries++ < UBI_IO_RETRIES) {
+		if (err != -EROFS && retries++ < UBI_IO_RETRIES) {
 			ubi_warn(ubi, "error %d while erasing PEB %d, retry",
 				 err, pnum);
 			yield();
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] mtd: nand/UBI: add power-cut emulation Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-09-25 17:20 +0200
  [PATCH 3/5] UBI: switch the UBI device in read-only mode when mtd returns -EROFS Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-09-25 17:20 +0200
    Re: [PATCH 3/5] UBI: switch the UBI device in read-only mode when mtd  returns -EROFS Richard Weinberger <richard@nod.at> - 2015-09-25 19:40 +0200
      Re: [PATCH 3/5] UBI: switch the UBI device in read-only mode when  mtd returns -EROFS Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-09-26 10:50 +0200
  [PATCH 2/5] mtd: nand: return -EROFS in case of power-cut emulation Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-09-25 17:20 +0200

csiph-web