[PATCH] jffs2: Do not assume erase will fail

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Thu Oct 7 12:29:46 EDT 2010


Test if it did and then abort.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund at transmode.se>
---
 fs/jffs2/nodemgmt.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
index 694aa5b..49ee5de 100644
--- a/fs/jffs2/nodemgmt.c
+++ b/fs/jffs2/nodemgmt.c
@@ -260,9 +260,9 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c)
 		spin_lock(&c->erase_completion_lock);
 
 		/* An erase may have failed, decreasing the
-		   amount of free space available. So we must
-		   restart from the beginning */
-		return -EAGAIN;
+		   amount of free space available. */
+		if (list_empty(&c->free_list))
+			return -EAGAIN; /* restart from the beginning */
 	}
 
 	next = c->free_list.next;
-- 
1.7.2.2




More information about the linux-mtd mailing list