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

Re: What on Earth is JFFS2 GC doing?

vipin.malik@xxxxxxx.com said:
>  What does this " jffs2_free_all_node_refs" do anyway and why can't it
> do it faster :) 

Oh yes. I'd forgotten about that, although as the comment implies I did 
realise at the time I wrote it just how bad it might be :)

I suppose we just have to increase the jffs2_raw_node_ref from 16 bytes to 
20 - unless anyone's got any better suggestions?

/* Hmmm. Maybe we should accept the extra space it takes and make
   this a standard doubly-linked list? */
static inline void jffs2_remove_node_ref_from_ino_list(struct jffs2_sb_info *sbinfo, struct jffs2_raw_node_ref *ref)
	struct jffs2_inode_cache *ic;
	struct jffs2_raw_node_ref **prev, *this;
	D2(int c=0);

	this = ref;
		 this = this->next_in_ino;

	ic = (struct jffs2_inode_cache *)this;

	D1(printk(KERN_DEBUG "Removing node at phys 0x%08x from ino #%u\n", ref->flash_offset &~3, ic->ino));

	prev = &ic->nodes;
	if (!*prev) {
		printk(KERN_WARNING "Eep. ic->nodes == NULL.\n");
	while (*prev != ref) {
		if (!(*prev)->next_in_ino) {
		        printk(KERN_WARNING "Eep. node at phys 0x%08x, mem %p. next_in_ino is NULL.\n", (*prev)->flash_offset &~3, 
		prev = &(*prev)->next_in_ino;
	*prev = ref->next_in_ino;
	this = ic->nodes;
	D2(printk(KERN_DEBUG "After remove_node_ref_from_ino_list: \n" KERN_DEBUG);
	while(this) {
		printk( "0x%08x(%d)->", this->flash_offset & ~3, this->flash_offset &3);
		if (++c == 5) {
			printk("\n" KERN_DEBUG);
		this = this->next_in_ino;
	if (ic->nodes == (void *)ic) {
		D1(printk(KERN_DEBUG "inocache for ino #%u is all gone now. Freeing\n", ic->ino));
		jffs2_del_ino_cache(sbinfo, ic);

static void jffs2_free_all_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
	struct jffs2_raw_node_ref *ref;
	D1(printk(KERN_DEBUG "Freeing all node refs for eraseblock offset 0x%08x\n", jeb->offset));
	while(jeb->first_node) {
		ref = jeb->first_node;
		jeb->first_node = ref->next_phys;
		/* Remove from the inode-list */
		if (ref->next_in_ino)
			jffs2_remove_node_ref_from_ino_list(c, ref);
		/* else it was a non-inode node so don't bother */

	jeb->last_node = NULL;


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