Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcb75787 authored by David Woodhouse's avatar David Woodhouse
Browse files

[JFFS2] Extend jffs2_link_node_ref() to link into per-inode list too.



Let's avoid the potential for forgetting to set ref->next_in_ino, by doing
it within jffs2_link_node_ref() instead.

This highlights the ugliness of what we're currently doing with
xattr_datum and xattr_ref structures -- we should find a nicer way of
dealing with that.

Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent a1b563d6
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -410,10 +410,9 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
		/* Everything else got zeroed before the erase */
		jeb->free_size = c->sector_size;

		marker_ref->next_in_ino = NULL;
		marker_ref->flash_offset = jeb->offset | REF_NORMAL;

		jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size);
		jffs2_link_node_ref(c, jeb, marker_ref, c->cleanmarker_size, NULL);
	}

	spin_lock(&c->erase_completion_lock);
+2 −15
Original line number Diff line number Diff line
@@ -634,11 +634,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
		printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n",
                       rawlen, phys_ofs, ret, retlen);
		if (retlen) {
                        /* Doesn't belong to any inode */
			nraw->next_in_ino = NULL;

			nraw->flash_offset |= REF_OBSOLETE;
			jffs2_add_physical_node_ref(c, nraw, rawlen);
			jffs2_add_physical_node_ref(c, nraw, rawlen, NULL);
			jffs2_mark_node_obsolete(c, nraw);
		} else {
			printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset);
@@ -678,18 +675,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
		goto out_node;
	}
	nraw->flash_offset |= REF_PRISTINE;
	jffs2_add_physical_node_ref(c, nraw, rawlen);
	jffs2_add_physical_node_ref(c, nraw, rawlen, ic);

	if (ic) {
		/* Link into per-inode list. This is safe because of the ic
		   state being INO_STATE_GC. Note that if we're doing this
		   for an inode which is in-core, the 'nraw' pointer is then
		   going to be fetched from ic->nodes by our caller. */
		spin_lock(&c->erase_completion_lock);
		nraw->next_in_ino = ic->nodes;
		ic->nodes = nraw;
		spin_unlock(&c->erase_completion_lock);
	}
	jffs2_mark_node_obsolete(c, raw);
	D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw)));

+10 −3
Original line number Diff line number Diff line
@@ -1048,7 +1048,8 @@ void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
}

void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
			 struct jffs2_raw_node_ref *ref, uint32_t len)
			 struct jffs2_raw_node_ref *ref, uint32_t len,
			 struct jffs2_inode_cache *ic)
{
	if (!jeb->first_node)
		jeb->first_node = ref;
@@ -1065,6 +1066,13 @@ void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
	}
	jeb->last_node = ref;

	if (ic) {
		ref->next_in_ino = ic->nodes;
		ic->nodes = ref;
	} else {
		ref->next_in_ino = NULL;
	}

	switch(ref_flags(ref)) {
	case REF_UNCHECKED:
		c->unchecked_size += len;
@@ -1120,12 +1128,11 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb

		ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
		ref->flash_offset |= REF_OBSOLETE;
		ref->next_in_ino = 0;
#ifdef TEST_TOTLEN
		ref->__totlen = size;
#endif

		jffs2_link_node_ref(c, jeb, ref, size);
		jffs2_link_node_ref(c, jeb, ref, size, NULL);
	}

	return 0;
+6 −2
Original line number Diff line number Diff line
@@ -307,7 +307,8 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size);
int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn);
void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb,
			 struct jffs2_raw_node_ref *ref, uint32_t len);
			 struct jffs2_raw_node_ref *ref, uint32_t len,
			 struct jffs2_inode_cache *ic);
extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c,
				   struct jffs2_eraseblock *jeb,
				   struct jffs2_raw_node_ref *ref);
@@ -318,7 +319,10 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs
			uint32_t *len, int prio, uint32_t sumsize);
int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs,
			uint32_t *len, uint32_t sumsize);
int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len);
int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, 
				struct jffs2_raw_node_ref *new,
				uint32_t len,
				struct jffs2_inode_cache *ic);
void jffs2_complete_reservation(struct jffs2_sb_info *c);
void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw);

+3 −2
Original line number Diff line number Diff line
@@ -381,7 +381,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
 *	Must be called with the alloc_sem held.
 */

int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len)
int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new,
				uint32_t len, struct jffs2_inode_cache *ic)
{
	struct jffs2_eraseblock *jeb;

@@ -403,7 +404,7 @@ int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_r
#endif
	spin_lock(&c->erase_completion_lock);

	jffs2_link_node_ref(c, jeb, new, len);
	jffs2_link_node_ref(c, jeb, new, len, ic);

	if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) {
		/* If it lives on the dirty_list, jffs2_reserve_space will put it there */
Loading