UBI: handle zero-length case

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Feb 3 06:59:02 EST 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=60c031531a85b3580f66c2530f9b2802adcad4df
Commit:     60c031531a85b3580f66c2530f9b2802adcad4df
Parent:     1b68d0eea5daddc762c54bf02154f4ad607d9ce8
Author:     Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
AuthorDate: Thu Jan 24 17:56:14 2008 +0200
Committer:  Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
CommitDate: Fri Jan 25 16:41:25 2008 +0200

    UBI: handle zero-length case
    
    ubi_eba_atomic_leb_change() has to just map the LEB to a free PEB
    if data length is zero.
    
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
---
 drivers/mtd/ubi/eba.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 1f7375e..7ce91ca 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -862,6 +862,17 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
 	if (ubi->ro_mode)
 		return -EROFS;
 
+	if (len == 0) {
+		/*
+		 * Special case when data length is zero. In this case the LEB
+		 * has to be unmapped and mapped somewhere else.
+		 */
+		err = ubi_eba_unmap_leb(ubi, vol, lnum);
+		if (err)
+			return err;
+		return ubi_eba_write_leb(ubi, vol, lnum, NULL, 0, 0, dtype);
+	}
+
 	vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
 	if (!vid_hdr)
 		return -ENOMEM;



More information about the linux-mtd-cvs mailing list