Commit b64335f2 authored by David Woodhouse's avatar David Woodhouse

[JFFS2] Add length argument to jffs2_add_physical_node_ref()

If __totlen is going away, we need to pass the length in separately.
Also stop callers from needlessly setting ref->next_phys to NULL,
since that's done for them... and since that'll also be going away soon.
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 49f11d40
...@@ -627,8 +627,6 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -627,8 +627,6 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
/* OK, all the CRCs are good; this node can just be copied as-is. */ /* OK, all the CRCs are good; this node can just be copied as-is. */
retry: retry:
nraw->flash_offset = phys_ofs; nraw->flash_offset = phys_ofs;
nraw->__totlen = rawlen;
nraw->next_phys = NULL;
ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node);
...@@ -640,7 +638,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -640,7 +638,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
nraw->next_in_ino = NULL; nraw->next_in_ino = NULL;
nraw->flash_offset |= REF_OBSOLETE; nraw->flash_offset |= REF_OBSOLETE;
jffs2_add_physical_node_ref(c, nraw); jffs2_add_physical_node_ref(c, nraw, rawlen);
jffs2_mark_node_obsolete(c, nraw); jffs2_mark_node_obsolete(c, nraw);
} else { } else {
printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset); printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", nraw->flash_offset);
...@@ -680,7 +678,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, ...@@ -680,7 +678,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
goto out_node; goto out_node;
} }
nraw->flash_offset |= REF_PRISTINE; nraw->flash_offset |= REF_PRISTINE;
jffs2_add_physical_node_ref(c, nraw); jffs2_add_physical_node_ref(c, nraw, rawlen);
if (ic) { if (ic) {
/* Link into per-inode list. This is safe because of the ic /* Link into per-inode list. This is safe because of the ic
......
...@@ -362,7 +362,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs ...@@ -362,7 +362,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs
uint32_t *len, int prio, uint32_t sumsize); uint32_t *len, int prio, uint32_t sumsize);
int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs,
uint32_t *len, uint32_t sumsize); uint32_t *len, uint32_t sumsize);
int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new); int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len);
void jffs2_complete_reservation(struct jffs2_sb_info *c); 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); void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw);
......
...@@ -374,7 +374,6 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin ...@@ -374,7 +374,6 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
* @c: superblock info * @c: superblock info
* @new: new node reference to add * @new: new node reference to add
* @len: length of this physical node * @len: length of this physical node
* @dirty: dirty flag for new node
* *
* Should only be used to report nodes for which space has been allocated * Should only be used to report nodes for which space has been allocated
* by jffs2_reserve_space. * by jffs2_reserve_space.
...@@ -382,13 +381,12 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin ...@@ -382,13 +381,12 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uin
* Must be called with the alloc_sem held. * 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) int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len)
{ {
struct jffs2_eraseblock *jeb; struct jffs2_eraseblock *jeb;
uint32_t len;
jeb = &c->blocks[new->flash_offset / c->sector_size]; jeb = &c->blocks[new->flash_offset / c->sector_size];
len = ref_totlen(c, jeb, new); new->__totlen = len;
D1(printk(KERN_DEBUG "jffs2_add_physical_node_ref(): Node at 0x%x(%d), size 0x%x\n", ref_offset(new), ref_flags(new), len)); D1(printk(KERN_DEBUG "jffs2_add_physical_node_ref(): Node at 0x%x(%d), size 0x%x\n", ref_offset(new), ref_flags(new), len));
#if 1 #if 1
......
...@@ -312,11 +312,9 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) ...@@ -312,11 +312,9 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c)
return; return;
raw2->flash_offset = ofs | REF_OBSOLETE; raw2->flash_offset = ofs | REF_OBSOLETE;
raw2->__totlen = ref_totlen(c, jeb, *first_raw);
raw2->next_phys = NULL;
raw2->next_in_ino = NULL; raw2->next_in_ino = NULL;
jffs2_add_physical_node_ref(c, raw2); jffs2_add_physical_node_ref(c, raw2, ref_totlen(c, jeb, *first_raw));
} }
return; return;
} }
......
...@@ -103,8 +103,6 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 ...@@ -103,8 +103,6 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
fn->raw = raw; fn->raw = raw;
raw->flash_offset = flash_ofs; raw->flash_offset = flash_ofs;
raw->__totlen = PAD(sizeof(*ri)+datalen);
raw->next_phys = NULL;
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) {
BUG_ON(!retried); BUG_ON(!retried);
...@@ -133,7 +131,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 ...@@ -133,7 +131,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
any node we write before the original intended end of any node we write before the original intended end of
this node */ this node */
raw->flash_offset |= REF_OBSOLETE; raw->flash_offset |= REF_OBSOLETE;
jffs2_add_physical_node_ref(c, raw); jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen));
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
} else { } else {
printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset); printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
...@@ -191,7 +189,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 ...@@ -191,7 +189,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
} else { } else {
raw->flash_offset |= REF_NORMAL; raw->flash_offset |= REF_NORMAL;
} }
jffs2_add_physical_node_ref(c, raw); jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*ri)+datalen));
/* Link into per-inode list */ /* Link into per-inode list */
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
...@@ -259,8 +257,6 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -259,8 +257,6 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
fd->raw = raw; fd->raw = raw;
raw->flash_offset = flash_ofs; raw->flash_offset = flash_ofs;
raw->__totlen = PAD(sizeof(*rd)+namelen);
raw->next_phys = NULL;
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) {
BUG_ON(!retried); BUG_ON(!retried);
...@@ -281,7 +277,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -281,7 +277,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
if (retlen) { if (retlen) {
raw->next_in_ino = NULL; raw->next_in_ino = NULL;
raw->flash_offset |= REF_OBSOLETE; raw->flash_offset |= REF_OBSOLETE;
jffs2_add_physical_node_ref(c, raw); jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen));
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
} else { } else {
printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset); printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", raw->flash_offset);
...@@ -327,7 +323,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff ...@@ -327,7 +323,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
} }
/* Mark the space used */ /* Mark the space used */
raw->flash_offset |= REF_PRISTINE; raw->flash_offset |= REF_PRISTINE;
jffs2_add_physical_node_ref(c, raw); jffs2_add_physical_node_ref(c, raw, PAD(sizeof(*rd)+namelen));
spin_lock(&c->erase_completion_lock); spin_lock(&c->erase_completion_lock);
raw->next_in_ino = f->inocache->nodes; raw->next_in_ino = f->inocache->nodes;
......
...@@ -322,8 +322,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x ...@@ -322,8 +322,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
if (!raw) if (!raw)
return -ENOMEM; return -ENOMEM;
raw->flash_offset = phys_ofs; raw->flash_offset = phys_ofs;
raw->__totlen = PAD(totlen);
raw->next_phys = NULL;
raw->next_in_ino = (void *)xd; raw->next_in_ino = (void *)xd;
/* Setup raw-xattr */ /* Setup raw-xattr */
...@@ -348,17 +346,17 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x ...@@ -348,17 +346,17 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
if (length) { if (length) {
raw->flash_offset |= REF_OBSOLETE; raw->flash_offset |= REF_OBSOLETE;
raw->next_in_ino = NULL; raw->next_in_ino = NULL;
jffs2_add_physical_node_ref(c, raw); jffs2_add_physical_node_ref(c, raw, PAD(totlen));
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
} else { } else {
jffs2_free_raw_node_ref(raw); jffs2_free_raw_node_ref(raw);
} }
return rc; return rc;
} }
BUG_ON(raw->__totlen < sizeof(struct jffs2_raw_xattr));
/* success */ /* success */
raw->flash_offset |= REF_PRISTINE; raw->flash_offset |= REF_PRISTINE;
jffs2_add_physical_node_ref(c, raw); jffs2_add_physical_node_ref(c, raw, PAD(totlen));
if (xd->node) if (xd->node)
delete_xattr_datum_node(c, xd); delete_xattr_datum_node(c, xd);
xd->node = raw; xd->node = raw;
...@@ -568,8 +566,6 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, ...@@ -568,8 +566,6 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
if (!raw) if (!raw)
return -ENOMEM; return -ENOMEM;
raw->flash_offset = phys_ofs; raw->flash_offset = phys_ofs;
raw->__totlen = PAD(sizeof(rr));
raw->next_phys = NULL;
raw->next_in_ino = (void *)ref; raw->next_in_ino = (void *)ref;
rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
...@@ -589,7 +585,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, ...@@ -589,7 +585,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
if (length) { if (length) {
raw->flash_offset |= REF_OBSOLETE; raw->flash_offset |= REF_OBSOLETE;
raw->next_in_ino = NULL; raw->next_in_ino = NULL;
jffs2_add_physical_node_ref(c, raw); jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)));
jffs2_mark_node_obsolete(c, raw); jffs2_mark_node_obsolete(c, raw);
} else { } else {
jffs2_free_raw_node_ref(raw); jffs2_free_raw_node_ref(raw);
...@@ -598,7 +594,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref, ...@@ -598,7 +594,7 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
} }
raw->flash_offset |= REF_PRISTINE; raw->flash_offset |= REF_PRISTINE;
jffs2_add_physical_node_ref(c, raw); jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)));
if (ref->node) if (ref->node)
delete_xattr_ref_node(c, ref); delete_xattr_ref_node(c, ref);
ref->node = raw; ref->node = raw;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment