mtd/fs/jffs3 gc.c,3.3,3.4

Artem Bityuckiy dedekind at infradead.org
Fri Dec 17 07:15:59 EST 2004


Update of /home/cvs/mtd/fs/jffs3
In directory phoenix.infradead.org:/tmp/cvs-serv14703

Modified Files:
	gc.c 
Log Message:
Fix: add forgotten priority


Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs3/gc.c,v
retrieving revision 3.3
retrieving revision 3.4
diff -u -r3.3 -r3.4
--- gc.c	16 Dec 2004 16:55:01 -0000	3.3
+++ gc.c	17 Dec 2004 12:15:55 -0000	3.4
@@ -52,37 +52,37 @@
 	/* We possibly want to favour the dirtier blocks more when the
 	   number of free blocks is low. */
 	if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) {
-		DBG_GC("Picking block from bad_used_list to GC next\n");
+		DBG_GC(1, "Picking block from bad_used_list to GC next\n");
 		nextlist = &c->bad_used_list;
 	} else if (n < 50 && !list_empty(&c->erasable_list)) {
 		/* Note that most of them will have gone directly to be erased. 
 		   So don't favour the erasable_list _too_ much. */
-		DBG_GC("Picking block from erasable_list to GC next\n");
+		DBG_GC(1, "Picking block from erasable_list to GC next\n");
 		nextlist = &c->erasable_list;
 	} else if (n < 110 && !list_empty(&c->very_dirty_list)) {
 		/* Most of the time, pick one off the very_dirty list */
-		DBG_GC("Picking block from very_dirty_list to GC next\n");
+		DBG_GC(1, "Picking block from very_dirty_list to GC next\n");
 		nextlist = &c->very_dirty_list;
 	} else if (n < 126 && !list_empty(&c->dirty_list)) {
-		DBG_GC("Picking block from dirty_list to GC next\n");
+		DBG_GC(1, "Picking block from dirty_list to GC next\n");
 		nextlist = &c->dirty_list;
 	} else if (!list_empty(&c->clean_list)) {
-		DBG_GC("Picking block from clean_list to GC next\n");
+		DBG_GC(1, "Picking block from clean_list to GC next\n");
 		nextlist = &c->clean_list;
 	} else if (!list_empty(&c->dirty_list)) {
-		DBG_GC("Picking block from dirty_list to GC next (clean_list was empty)\n");
+		DBG_GC(1, "Picking block from dirty_list to GC next (clean_list was empty)\n");
 
 		nextlist = &c->dirty_list;
 	} else if (!list_empty(&c->very_dirty_list)) {
-		DBG_GC("Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n");
+		DBG_GC(1, "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n");
 		nextlist = &c->very_dirty_list;
 	} else if (!list_empty(&c->erasable_list)) {
-		DBG_GC("Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n");
+		DBG_GC(1, "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n");
 
 		nextlist = &c->erasable_list;
 	} else {
 		/* Eep. All were empty */
-		DBG_GC("No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n");
+		DBG_GC(1, "No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n");
 		return NULL;
 	}
 
@@ -97,7 +97,7 @@
 	
 	/* Have we accidentally picked a clean block with wasted space ? */
 	if (ret->wasted_size) {
-		DBG_GC("Converting wasted_size %#08x to dirty_size\n", ret->wasted_size);
+		DBG_GC(1, "Converting wasted_size %#08x to dirty_size\n", ret->wasted_size);
 		ret->dirty_size += ret->wasted_size;
 		c->wasted_size -= ret->wasted_size;
 		c->dirty_size += ret->wasted_size;
@@ -152,14 +152,14 @@
 		}
 
 		if (!ic->nlink) {
-			DBG_GC("Skipping check of ino #%d with nlink zero\n", ic->ino);
+			DBG_GC(1, "Skipping check of ino #%d with nlink zero\n", ic->ino);
 			spin_unlock(&c->inocache_lock);
 			continue;
 		}
 		switch(ic->state) {
 		case INO_STATE_CHECKEDABSENT:
 		case INO_STATE_PRESENT:
-			DBG_GC("Skipping ino #%u already checked\n", ic->ino);
+			DBG_GC(1, "Skipping ino #%u already checked\n", ic->ino);
 			spin_unlock(&c->inocache_lock);
 			continue;
 
@@ -173,7 +173,7 @@
 			/* We need to wait for it to finish, lest we move on
 			   and trigger the BUG() above while we haven't yet 
 			   finished checking all its nodes */
-			DBG_GC("Waiting for ino #%u to finish reading\n", ic->ino);
+			DBG_GC(1, "Waiting for ino #%u to finish reading\n", ic->ino);
 			up(&c->alloc_sem);
 			sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
 			return 0;
@@ -187,7 +187,7 @@
 		ic->state = INO_STATE_CHECKING;
 		spin_unlock(&c->inocache_lock);
 
-		DBG_GC("Triggering inode scan of ino#%u\n", ic->ino);
+		DBG_GC(1, "Triggering inode scan of ino#%u\n", ic->ino);
 
 		ret = jffs3_do_crccheck_inode(c, ic);
 		if (ret)
@@ -205,17 +205,17 @@
 		jeb = jffs3_find_gc_block(c);
 
 	if (!jeb) {
-		DBG_GC("Couldn't find erase block to garbage collect!\n");
+		DBG_GC(1, "Couldn't find erase block to garbage collect!\n");
 		spin_unlock(&c->erase_completion_lock);
 		up(&c->alloc_sem);
 		return -EIO;
 	}
 
-	DBG_GC("GC from block %#08x, used_size %#08x, dirty_size %#08x, free_size %#08x\n",
+	DBG_GC(1, "GC from block %#08x, used_size %#08x, dirty_size %#08x, free_size %#08x\n",
 			jeb->offset, jeb->used_size, jeb->dirty_size, jeb->free_size);
 	
 	if (c->nextblock)
-		DBG_GC("Nextblock at  %#08x, used_size %#08x, dirty_size %#08x, wasted_size %#08x, free_size %#08x\n",
+		DBG_GC(1, "Nextblock at  %#08x, used_size %#08x, dirty_size %#08x, wasted_size %#08x, free_size %#08x\n",
 				c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size,
 				c->nextblock->wasted_size, c->nextblock->free_size);
 
@@ -227,7 +227,7 @@
 	raw = jeb->gc_node;
 			
 	while(ref_obsolete(raw)) {
-		DBG_GC("Node at %#08x is obsolete... skipping\n", ref_offset(raw));
+		DBG_GC(1, "Node at %#08x is obsolete... skipping\n", ref_offset(raw));
 		raw = raw->next_phys;
 		if (unlikely(!raw)) {
 			ERROR_MSG("Eep. End of raw list while still supposedly nodes to GC\n");
@@ -241,7 +241,7 @@
 	}
 	jeb->gc_node = raw;
 
-	DBG_GC("Going to garbage collect node at %#08x\n", ref_offset(raw));
+	DBG_GC(1, "Going to garbage collect node at %#08x\n", ref_offset(raw));
 
 	if (!raw->next_in_ino) {
 		/* Inode-less node. Clean marker, snapshot or something like that */
@@ -262,7 +262,7 @@
 
 	spin_unlock(&c->erase_completion_lock);
 
-	DBG_GC("Collecting from block %#08x. Node %#08x(%d), ino #%u\n",
+	DBG_GC(1, "Collecting from block %#08x. Node %#08x(%d), ino #%u\n",
 		jeb->offset, ref_offset(raw), ref_flags(raw), ic->ino);
 
 	/* Three possibilities:
@@ -283,7 +283,7 @@
 		if (ref_flags(raw) == REF_PRISTINE)
 			ic->state = INO_STATE_GC;
 		else {
-			 DBG_GC("Ino #%u is absent but node not REF_PRISTINE. Reading.\n", ic->ino);
+			DBG_GC(1, "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", ic->ino);
 		}
 		break;
 
@@ -300,7 +300,7 @@
 		   can happen.
 		*/
 		ERROR_MSG("Inode #%u already in state %d in jffs3_garbage_collect_pass()!\n",
-			       ic->ino, ic->state);
+				ic->ino, ic->state);
 		up(&c->alloc_sem);
 		spin_unlock(&c->inocache_lock);
 		BUG();
@@ -313,7 +313,7 @@
 		   drop the alloc_sem before sleeping. */
 
 		up(&c->alloc_sem);
-		DBG_GC("Waiting for ino #%u in state %d\n", ic->ino, ic->state);
+		DBG_GC(1, "Waiting for ino #%u in state %d\n", ic->ino, ic->state);
 		sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
 		/* And because we dropped the alloc_sem we must start again from the 
 		   beginning. Ponder chance of livelock here -- we're returning success
@@ -384,7 +384,7 @@
 
  eraseit:
 	if (c->gcblock && !c->gcblock->used_size) {
-		DBG_GC("Block at %#08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset);
+		DBG_GC(1, "Block at %#08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset);
 		/* We're GC'ing an empty block? */
 		list_add_tail(&c->gcblock->list, &c->erase_pending_list);
 		c->gcblock = NULL;
@@ -414,12 +414,12 @@
 
 	if (c->gcblock != jeb) {
 		spin_unlock(&c->erase_completion_lock);
-		DBG_GC("GC block is no longer gcblock. Restart\n");
+		DBG_GC(1, "GC block is no longer gcblock. Restart\n");
 		goto upnout;
 	}
 	if (ref_obsolete(raw)) {
 		spin_unlock(&c->erase_completion_lock);
-		DBG_GC("node to be GC'd was obsoleted in the meantime.\n");
+		DBG_GC(1, "node to be GC'd was obsoleted in the meantime.\n");
 		/* They'll call again */
 		goto upnout;
 	}
@@ -475,7 +475,7 @@
 	} else if (fd) {
 		ret = jffs3_garbage_collect_deletion_dirent(c, jeb, f, fd);
 	} else {
-		WARNINIG_MSG("Raw node at %#08x wasn't in node lists for ino #%u\n",
+		WARNING_MSG("Raw node at %#08x wasn't in node lists for ino #%u\n",
 			       ref_offset(raw), f->inocache->ino);
 		if (ref_obsolete(raw)) {
 			WARNING_MSG("But it's obsolete so we don't mind too much\n");
@@ -501,7 +501,7 @@
 	uint32_t crc, rawlen;
 	int retried = 0;
 
-	DBG_GC("Going to GC REF_PRISTINE node at %#08x\n", ref_offset(raw));
+	DBG_GC(1, "Going to GC REF_PRISTINE node at %#08x\n", ref_offset(raw));
 
 	rawlen = ref_totlen(c, c->gcblock, raw);
 
@@ -613,7 +613,7 @@
 
 			retried = 1;
 
-			DBG_GC("Retrying failed write of REF_PRISTINE node.\n");
+			DBG_GC(1, "Retrying failed write of REF_PRISTINE node.\n");
 			
 			jffs3_dbg_acct_sanity_check(c, jeb);
 			jffs3_dbg_acct_paranoia_check(c, jeb);
@@ -621,14 +621,14 @@
 			ret = jffs3_reserve_space_gc(c, rawlen, &phys_ofs, &dummy);
 
 			if (!ret) {
-				DBG_GC("Allocated space at %#08x to retry failed write.\n", phys_ofs);
+				DBG_GC(1, "Allocated space at %#08x to retry failed write.\n", phys_ofs);
 
 				jffs3_dbg_acct_sanity_check(c, jeb);
 				jffs3_dbg_acct_paranoia_check(c, jeb);
 
 				goto retry;
 			}
-			DBG_GC("Failed to allocate space to retry failed write: %d!\n", ret);
+			DBG_GC(1, "Failed to allocate space to retry failed write: %d!\n", ret);
 			jffs3_free_raw_node_ref(nraw);
 		}
 
@@ -650,7 +650,7 @@
 	spin_unlock(&c->erase_completion_lock);
 
 	jffs3_mark_node_obsolete(c, raw);
-	DBG_GC("WHEEE! GC REF_PRISTINE node at %#08x succeeded\n", ref_offset(raw));
+	DBG_GC(1, "WHEEE! GC REF_PRISTINE node at %#08x succeeded\n", ref_offset(raw));
 
  out_node:
 	kfree(node);
@@ -678,7 +678,7 @@
 			JFFS3_F_I_RDEV_MIN(f)));
 		mdata = (char *)&dev;
 		mdatalen = sizeof(dev);
-		DBG_GC("Writing %d bytes of kdev_t\n", mdatalen);
+		DBG_GC(1, "Writing %d bytes of kdev_t\n", mdatalen);
 	} else if (S_ISLNK(JFFS3_F_I_MODE(f))) {
 		mdatalen = fn->size;
 		mdata = kmalloc(fn->size, GFP_KERNEL);
@@ -692,7 +692,7 @@
 			kfree(mdata);
 			return ret;
 		}
-		DBG_GC("Writing %d bites of symlink target\n", mdatalen);
+		DBG_GC(1, "Writing %d bites of symlink target\n", mdatalen);
 
 	}
 	
@@ -824,7 +824,7 @@
 			    (fd->raw->flash_offset & ~(c->sector_size-1)))
 				continue;
 
-			DBG_GC("Check potential deletion dirent at %#08x\n", ref_offset(raw));
+			DBG_GC(1, "Check potential deletion dirent at %#08x\n", ref_offset(raw));
 
 			/* This is an obsolete node belonging to the same directory, and it's of the right
 			   length. We need to take a closer look...*/
@@ -860,7 +860,7 @@
 			   a new deletion dirent to replace it */
 			up(&c->erase_free_sem);
 
-			GBG_GC("Deletion dirent at %#08x still obsoletes real dirent \"%s\" at %#08x for ino #%u\n",
+			DBG_GC("Deletion dirent at %#08x still obsoletes real dirent \"%s\" at %#08x for ino #%u\n",
 				  ref_offset(fd->raw), fd->name, ref_offset(raw), je32_to_cpu(rd->ino));
 			kfree(rd);
 
@@ -898,7 +898,7 @@
 	uint32_t alloclen, phys_ofs;
 	int ret;
 
-	DBG_GC("Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n",
+	DBG_GC(1, "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n",
 		f->inocache->ino, start, end);
 	
 	memset(&ri, 0, sizeof(ri));
@@ -1034,7 +1034,7 @@
  
 	memset(&ri, 0, sizeof(ri));
 
-	DBG_GC("Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n",
+	DBG_GC(1, "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n",
 			  f->inocache->ino, start, end);
 
 	orig_end = end;
@@ -1066,14 +1066,14 @@
 			/* If the previous frag doesn't even reach the beginning, there's
 			   excessive fragmentation. Just merge. */
 			if (frag->ofs > min) {
-				DBG_GC("Expanding down to cover partial frag (0x%x-0x%x)\n",
+				DBG_GC(1, "Expanding down to cover partial frag (0x%x-0x%x)\n",
 						  frag->ofs, frag->ofs+frag->size);
 				start = frag->ofs;
 				continue;
 			}
 			/* OK. This frag holds the first byte of the page. */
 			if (!frag->node || !frag->node->raw) {
-				DBG_GC("First frag in page is hole (0x%x-0x%x). Not expanding down.\n",
+				DBG_GC(1, "First frag in page is hole (0x%x-0x%x). Not expanding down.\n",
 					  frag->ofs, frag->ofs+frag->size);
 				break;
 			} else {
@@ -1088,18 +1088,18 @@
 				jeb = &c->blocks[raw->flash_offset / c->sector_size];
 
 				if (jeb == c->gcblock) {
-					DBG_GC("Expanding down to cover frag (0x%x-0x%x) in gcblock at %#08x\n",
+					DBG_GC(1, "Expanding down to cover frag (0x%x-0x%x) in gcblock at %#08x\n",
 						  frag->ofs, frag->ofs+frag->size, ref_offset(raw));
 					start = frag->ofs;
 					break;
 				}
 				if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) {
-					DBG_GC("Not expanding down to cover frag (0x%x-0x%x) in clean block %#08x\n",
+					DBG_GC(1, "Not expanding down to cover frag (0x%x-0x%x) in clean block %#08x\n",
 						  frag->ofs, frag->ofs+frag->size, jeb->offset);
 					break;
 				}
 
-				DBG_GC("Expanding down to cover frag (0x%x-0x%x) in dirty block %#08x\n",
+				DBG_GC(1, "Expanding down to cover frag (0x%x-0x%x) in dirty block %#08x\n",
 						  frag->ofs, frag->ofs+frag->size, jeb->offset);
 				start = frag->ofs;
 				break;
@@ -1116,14 +1116,14 @@
 			/* If the previous frag doesn't even reach the beginning, there's lots
 			   of fragmentation. Just merge. */
 			if (frag->ofs+frag->size < max) {
-				DBG_GC("Expanding up to cover partial frag (0x%x-0x%x)\n",
+				DBG_GC(1, "Expanding up to cover partial frag (0x%x-0x%x)\n",
 					  frag->ofs, frag->ofs+frag->size);
 				end = frag->ofs + frag->size;
 				continue;
 			}
 
 			if (!frag->node || !frag->node->raw) {
-				DBG_GC("Last frag in page is hole (0x%x-0x%x). Not expanding up.\n",
+				DBG_GC(1, "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n",
 					  frag->ofs, frag->ofs+frag->size);
 				break;
 			} else {
@@ -1138,24 +1138,24 @@
 				jeb = &c->blocks[raw->flash_offset / c->sector_size];
 
 				if (jeb == c->gcblock) {
-					DBG_GC("Expanding up to cover frag (0x%x-0x%x) in gcblock at %#08x\n",
+					DBG_GC(1, "Expanding up to cover frag (0x%x-0x%x) in gcblock at %#08x\n",
 						  frag->ofs, frag->ofs+frag->size, ref_offset(raw));
 					end = frag->ofs + frag->size;
 					break;
 				}
 				if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) {
-					DBG_GC("Not expanding up to cover frag (0x%x-0x%x) in clean block %#08x\n",
+					DBG_GC(1, "Not expanding up to cover frag (0x%x-0x%x) in clean block %#08x\n",
 						  frag->ofs, frag->ofs+frag->size, jeb->offset);
 					break;
 				}
 
-				DBG_GC("Expanding up to cover frag (0x%x-0x%x) in dirty block %#08x\n",
+				DBG_GC(1, "Expanding up to cover frag (0x%x-0x%x) in dirty block %#08x\n",
 						  frag->ofs, frag->ofs+frag->size, jeb->offset);
 				end = frag->ofs + frag->size;
 				break;
 			}
 		}
-		DBG_GC("Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", 
+		DBG_GC(1, "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", 
 			  orig_start, orig_end, start, end);
 
 		BUG_ON(end > JFFS3_F_I_SIZE(f));





More information about the linux-mtd-cvs mailing list