mtd/drivers/mtd inftlcore.c,1.12,1.13

David Woodhouse dwmw2 at infradead.org
Thu Jun 26 03:42:57 EDT 2003


Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv22953

Modified Files:
	inftlcore.c 
Log Message:
Compiled and tested fix for NFTL_trydeletechain()


Index: inftlcore.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/inftlcore.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- inftlcore.c	25 Jun 2003 21:33:14 -0000	1.12
+++ inftlcore.c	26 Jun 2003 07:42:54 -0000	1.13
@@ -573,7 +573,7 @@
 {
 	unsigned char BlockUsed[MAX_SECTORS_PER_UNIT];
 	unsigned char BlockDeleted[MAX_SECTORS_PER_UNIT];
-	unsigned int thisEUN, prevEUN, status;
+	unsigned int thisEUN, status;
 	int block, silly;
 	struct inftl_bci bci;
 	size_t retlen;
@@ -645,23 +645,25 @@
 	DEBUG(MTD_DEBUG_LEVEL1, "INFTL: deleting empty VUC %d\n", thisVUC);
 
 	for (;;) {
-		/* Find oldest unit in chain. */
-		thisEUN = inftl->VUtable[thisVUC];
-		prevEUN = BLOCK_NIL;
+		u16 *prevEUN = &inftl->VUtable[thisVUC];
+		thisEUN = *prevEUN;
 
-		if (thisEUN == BLOCK_FREE) {
+		/* If the chain is all gone already, we're done */
+		if (thisEUN == BLOCK_NIL) {
 			DEBUG(MTD_DEBUG_LEVEL2, "INFTL: Empty VUC %d for deletion was already absent\n", thisEUN);
 			return;
 		}
 
+		/* Find oldest unit in chain. */
 		while (inftl->PUtable[thisEUN] != BLOCK_NIL) {
-			prevEUN = thisEUN;
-			thisEUN = inftl->PUtable[thisEUN];
-
 			BUG_ON(thisEUN >= inftl->nb_blocks);
+
+			prevEUN = &inftl->PUtable[thisEUN];
+			thisEUN = *prevEUN;
 		}
-		if (thisEUN == BLOCK_NIL || thisEUN == BLOCK_FREE)
-			return;
+
+		DEBUG(MTD_DEBUG_LEVEL3, "Deleting EUN %d from VUC %d\n",
+		      thisEUN, thisVUC);
 
                 if (INFTL_formatblock(inftl, thisEUN) < 0) {
 			/*
@@ -676,14 +678,8 @@
 		}
 
 		/* Now sort out whatever was pointing to it... */
-		if (prevEUN == BLOCK_NIL) {
-			/* We just deleted the last EUN in thie chain */
-			inftl->VUtable[thisVUC] = BLOCK_NIL;
-			return;
-		} else {
-			/* The previous block is now the last */
-			inftl->PUtable[prevEUN] = BLOCK_NIL;
-		}
+		*prevEUN = BLOCK_NIL;
+
 		/* Ideally we'd actually be responsive to new
 		   requests while we're doing this -- if there's
 		   free space why should others be made to wait? */




More information about the linux-mtd-cvs mailing list