/* 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);
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);
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)));
}
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;
}
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;
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;
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);
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);
* 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;
#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 */
xd->node = raw;
raw->flash_offset = ofs | REF_PRISTINE;
- raw->next_in_ino = (void *)xd;
- jffs2_link_node_ref(c, jeb, raw, totlen);
+ jffs2_link_node_ref(c, jeb, raw, totlen, NULL);
+ /* FIXME */ raw->next_in_ino = (void *)xd;
if (jffs2_sum_active())
jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset);
c->xref_temp = ref;
raw->flash_offset = ofs | REF_PRISTINE;
- raw->next_in_ino = (void *)ref;
- jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen)));
+ jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rr->totlen)), NULL);
+ /* FIXME */ raw->next_in_ino = (void *)ref;
if (jffs2_sum_active())
jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset);
printk(KERN_NOTICE "Failed to allocate node ref for clean marker\n");
return -ENOMEM;
}
- marker_ref->next_in_ino = NULL;
marker_ref->flash_offset = ofs | 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);
ofs += PAD(c->cleanmarker_size);
}
if (!ref)
return -ENOMEM;
ref->flash_offset = ofs | REF_PRISTINE;
- ref->next_in_ino = 0;
- jffs2_link_node_ref(c, jeb, ref, PAD(je32_to_cpu(node->totlen)));
+ jffs2_link_node_ref(c, jeb, ref, PAD(je32_to_cpu(node->totlen)), NULL);
/* We can't summarise nodes we don't grok */
jffs2_sum_disable_collecting(s);
raw->flash_offset = ofs | REF_UNCHECKED;
- raw->next_in_ino = ic->nodes;
- ic->nodes = raw;
-
- jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen)));
+ jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(ri->totlen)), ic);
D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n",
je32_to_cpu(ri->ino), je32_to_cpu(ri->version),
}
raw->flash_offset = ofs | REF_PRISTINE;
- raw->next_in_ino = ic->nodes;
- ic->nodes = raw;
-
- jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen)));
+ jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(rd->totlen)), ic);
fd->raw = raw;
fd->next = NULL;
raw->flash_offset |= REF_UNCHECKED;
- raw->next_in_ino = ic->nodes;
- ic->nodes = raw;
-
- jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)));
+ jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spi->totlen)), ic);
*pseudo_random += je32_to_cpu(spi->version);
}
raw->flash_offset |= REF_PRISTINE;
- raw->next_in_ino = ic->nodes;
- ic->nodes = raw;
-
- jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)));
+ jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spd->totlen)), ic);
fd->raw = raw;
fd->next = NULL;
xd->node = raw;
raw->flash_offset |= REF_UNCHECKED;
- raw->next_in_ino = (void *)xd;
- jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen)));
+ jffs2_link_node_ref(c, jeb, raw, PAD(je32_to_cpu(spx->totlen)), NULL);
+ /* FIXME */ raw->next_in_ino = (void *)xd;
*pseudo_random += je32_to_cpu(spx->xid);
sp += JFFS2_SUMMARY_XATTR_SIZE;
c->xref_temp = ref;
raw->flash_offset |= REF_UNCHECKED;
- raw->next_in_ino = (void *)ref;
- jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref)));
+ jffs2_link_node_ref(c, jeb, raw, PAD(sizeof(struct jffs2_raw_xref)), NULL);
+ /* FIXME */ raw->next_in_ino = (void *)ref;
*pseudo_random += raw->flash_offset;
sp += JFFS2_SUMMARY_XREF_SIZE;
}
marker_ref->flash_offset = jeb->offset | REF_NORMAL;
- marker_ref->next_in_ino = NULL;
- jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr));
+ jffs2_link_node_ref(c, jeb, marker_ref, je32_to_cpu(summary->cln_mkr), NULL);
}
}
return -ENOMEM;
}
- cache_ref->next_in_ino = NULL;
cache_ref->flash_offset |= REF_NORMAL;
- jffs2_link_node_ref(c, jeb, cache_ref, sumsize);
+ jffs2_link_node_ref(c, jeb, cache_ref, sumsize, NULL);
if (unlikely(jeb->free_size)) {
JFFS2_WARNING("Free size 0x%x bytes in eraseblock @0x%08x with summary?\n",
ref->flash_offset = jeb->offset + c->sector_size - jeb->free_size;
ref->flash_offset |= REF_OBSOLETE;
- ref->next_in_ino = 0;
- jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size);
+ jffs2_link_node_ref(c, jeb, ref, c->sector_size - jeb->free_size, NULL);
}
c->summary->sum_size = JFFS2_SUMMARY_NOSUM_SIZE;
return -ENOMEM;
}
- summary_ref->next_in_ino = NULL;
summary_ref->flash_offset = (jeb->offset + c->sector_size - jeb->free_size) | REF_NORMAL;
spin_lock(&c->erase_completion_lock);
- jffs2_link_node_ref(c, jeb, summary_ref, infosize);
+ jffs2_link_node_ref(c, jeb, summary_ref, infosize, NULL);
return 0;
}
return;
raw2->flash_offset = ofs | REF_OBSOLETE;
- raw2->next_in_ino = NULL;
- jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw));
+ jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw), NULL);
}
return;
}
return -ENOMEM;
ref->flash_offset = c->wbuf_ofs + c->wbuf_len;
ref->flash_offset |= REF_OBSOLETE;
- ref->next_in_ino = NULL;
spin_lock(&c->erase_completion_lock);
- jffs2_link_node_ref(c, jeb, ref, waste);
+ jffs2_link_node_ref(c, jeb, ref, waste, NULL);
/* FIXME: that made it count as dirty. Convert to wasted */
jeb->dirty_size -= waste;
c->dirty_size -= waste;
/* Mark the space as dirtied */
if (retlen) {
- /* Doesn't belong to any inode */
- raw->next_in_ino = NULL;
-
/* Don't change raw->size to match retlen. We may have
written the node header already, and only the data will
seem corrupted, in which case the scan would skip over
any node we write before the original intended end of
this node */
raw->flash_offset |= REF_OBSOLETE;
- jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen));
+ jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen), NULL);
jffs2_mark_node_obsolete(c, raw);
} else {
printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
} else {
raw->flash_offset |= REF_NORMAL;
}
- jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen));
-
- /* Link into per-inode list */
- spin_lock(&c->erase_completion_lock);
- raw->next_in_ino = f->inocache->nodes;
- f->inocache->nodes = raw;
- spin_unlock(&c->erase_completion_lock);
+ jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen), f->inocache);
D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n",
flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize),
sizeof(*rd)+namelen, flash_ofs, ret, retlen);
/* Mark the space as dirtied */
if (retlen) {
- raw->next_in_ino = NULL;
raw->flash_offset |= REF_OBSOLETE;
- jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen));
+ jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen), NULL);
jffs2_mark_node_obsolete(c, raw);
} else {
printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
}
/* Mark the space used */
raw->flash_offset |= REF_PRISTINE;
- jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen));
-
- spin_lock(&c->erase_completion_lock);
- raw->next_in_ino = f->inocache->nodes;
- f->inocache->nodes = raw;
- spin_unlock(&c->erase_completion_lock);
+ jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen), f->inocache);
if (retried) {
jffs2_dbg_acct_sanity_check(c,NULL);
if (!raw)
return -ENOMEM;
raw->flash_offset = phys_ofs;
- raw->next_in_ino = (void *)xd;
/* Setup raw-xattr */
rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rc = rc ? rc : -EIO;
if (length) {
raw->flash_offset |= REF_OBSOLETE;
- raw->next_in_ino = NULL;
- jffs2_add_physical_node_ref(c, raw, PAD(totlen));
+ jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
jffs2_mark_node_obsolete(c, raw);
} else {
jffs2_free_raw_node_ref(raw);
/* success */
raw->flash_offset |= REF_PRISTINE;
- jffs2_add_physical_node_ref(c, raw, PAD(totlen));
+ jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
+ /* FIXME */ raw->next_in_ino = (void *)xd;
+
if (xd->node)
delete_xattr_datum_node(c, xd);
xd->node = raw;
if (!raw)
return -ENOMEM;
raw->flash_offset = phys_ofs;
- raw->next_in_ino = (void *)ref;
rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF);
ret = ret ? ret : -EIO;
if (length) {
raw->flash_offset |= REF_OBSOLETE;
- raw->next_in_ino = NULL;
- jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)));
+ jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
jffs2_mark_node_obsolete(c, raw);
} else {
jffs2_free_raw_node_ref(raw);
}
raw->flash_offset |= REF_PRISTINE;
- jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)));
+ jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
+ /* FIXME */ raw->next_in_ino = (void *)ref;
if (ref->node)
delete_xattr_ref_node(c, ref);
ref->node = raw;