mtd/drivers/mtd inftlcore.c,1.11,1.12
David Woodhouse
dwmw2 at infradead.org
Wed Jun 25 17:33:17 EDT 2003
Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv14427
Modified Files:
inftlcore.c
Log Message:
Untested and uncompiled attempt to fix NFTL_trydeletechain.
Index: inftlcore.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/inftlcore.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- inftlcore.c 23 Jun 2003 12:00:08 -0000 1.11
+++ inftlcore.c 25 Jun 2003 21:33:14 -0000 1.12
@@ -648,23 +648,46 @@
/* Find oldest unit in chain. */
thisEUN = inftl->VUtable[thisVUC];
prevEUN = BLOCK_NIL;
+
+ if (thisEUN == BLOCK_FREE) {
+ DEBUG(MTD_DEBUG_LEVEL2, "INFTL: Empty VUC %d for deletion was already absent\n", thisEUN);
+ return;
+ }
+
while (inftl->PUtable[thisEUN] != BLOCK_NIL) {
prevEUN = thisEUN;
thisEUN = inftl->PUtable[thisEUN];
+
+ BUG_ON(thisEUN >= inftl->nb_blocks);
}
+ if (thisEUN == BLOCK_NIL || thisEUN == BLOCK_FREE)
+ return;
if (INFTL_formatblock(inftl, thisEUN) < 0) {
/*
* Could not erase : mark block as reserved.
- * FixMe: Update Bad Unit Table on disk.
+ * FixMe: Update Bad Unit Table on medium.
*/
inftl->PUtable[thisEUN] = BLOCK_RESERVED;
} else {
/* Correctly erased : mark it as free */
inftl->PUtable[thisEUN] = BLOCK_FREE;
- inftl->PUtable[prevEUN] = BLOCK_NIL;
inftl->numfreeEUNs++;
- }
+ }
+
+ /* 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;
+ }
+ /* 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? */
+ cond_resched();
}
inftl->VUtable[thisVUC] = BLOCK_NIL;
More information about the linux-mtd-cvs
mailing list