[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What on Earth is JFFS2 GC doing?




dwmw2@xxxxxxx.org said:
>  I didn't expect the jitter to go away.
> You're still garbage-collecting a whole 256KiB block in the timeslice
> of the unlucky write, rather than doing a little bit each time.
> That's a separate problem. 

We really ought to sort out the reserved space properly, some time soon.
In the meantime, this may help.

Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodemgmt.c,v
retrieving revision 1.39
diff -u -r1.39 nodemgmt.c
--- nodemgmt.c	2001/04/11 22:20:26	1.39
+++ nodemgmt.c	2001/06/23 23:17:49
@@ -42,6 +42,35 @@
 #include <linux/interrupt.h>
 #include "nodelist.h"
 
+/* Bias the free block calculations to reduce jitter. If we've already
+   GC'd enough of the current gc_block that we can fit the remainder
+   into the end of the block we're filling, require one fewer free
+   block than we otherwise would.
+*/
+static inline int jffs2_reserve_bias(struct jffs2_sb_info *c)
+{
+	__u32 gc_ofs;
+
+	if (!c->gcblock)
+		return 0;
+
+	D1(if (!c->gcblock->gc_node) BUG());
+
+	if (!c->nextblock)
+		return 0;
+
+	gc_ofs = c->gcblock->gc_node->flash_offset & ~(c->sector_size - 1);
+
+	if (gc_ofs > c->nextblock->free_size) {
+		/* We're already far enough through the GC to fit the
+		   remainder of gc_block into nextblock */
+		D1(printk(KERN_DEBUG "jffs2_reserve_bias returns 1. gc_ofs 0x%08x, nextblock->free_size 0x%08x\n",
+			  gc_ofs, c->nextblock->free_size));
+		return 1;
+	}
+	return 0;
+}
+
 /**
  *	jffs2_reserve_space - request physical space to write nodes to flash
  *	@c: superblock info
@@ -83,7 +112,7 @@
 
 	/* this needs a little more thought */
 	while(ret == -EAGAIN) {
-		while(c->nr_free_blocks + c->nr_erasing_blocks < blocksneeded) {
+		while(c->nr_free_blocks + c->nr_erasing_blocks < blocksneeded - jffs2_reserve_bias(c)) {
 			int ret;
 
 			up(&c->alloc_sem);


--
dwmw2



To unsubscribe from this list: send the line "unsubscribe jffs-dev" in
the body of a message to majordomo@xxxxxxx.com