summaryrefslogtreecommitdiffstats
path: root/fs/jffs2/xattr.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2006-05-24 03:04:45 +0200
committerDavid Woodhouse <dwmw2@infradead.org>2006-05-24 03:04:45 +0200
commit2f785402f39b96a077b6e62bf26164bfb8e0c980 (patch)
tree3f3a38b484ef2dabda1599d4d8f08b121bd03a76 /fs/jffs2/xattr.c
parentMerge branch 'master' of /home/tglx/work/kernel/git/mtd-2.6/ (diff)
downloadlinux-2f785402f39b96a077b6e62bf26164bfb8e0c980.tar.xz
linux-2f785402f39b96a077b6e62bf26164bfb8e0c980.zip
[JFFS2] Reduce visibility of raw_node_ref to upper layers of JFFS2 code.
As the first step towards eliminating the ref->next_phys member and saving memory by using an _array_ of struct jffs2_raw_node_ref per eraseblock, stop the write functions from allocating their own refs; have them just _reserve_ the appropriate number instead. Then jffs2_link_node_ref() can just fill them in. Use a linked list of pre-allocated refs in the superblock, for now. Once we switch to an array, it'll just be a case of extending that array. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to '')
-rw-r--r--fs/jffs2/xattr.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index 008f91b1c171..2255f1367bd5 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -304,8 +304,8 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
{
/* must be called under down_write(xattr_sem) */
- struct jffs2_raw_xattr rx;
struct jffs2_raw_node_ref *raw;
+ struct jffs2_raw_xattr rx;
struct kvec vecs[2];
uint32_t length;
int rc, totlen;
@@ -319,11 +319,6 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
vecs[1].iov_len = xd->name_len + 1 + xd->value_len;
totlen = vecs[0].iov_len + vecs[1].iov_len;
- raw = jffs2_alloc_raw_node_ref();
- if (!raw)
- return -ENOMEM;
- raw->flash_offset = phys_ofs;
-
/* Setup raw-xattr */
rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rx.nodetype = cpu_to_je16(JFFS2_NODETYPE_XATTR);
@@ -343,19 +338,14 @@ static int save_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x
JFFS2_WARNING("jffs2_flash_writev()=%d, req=%u, wrote=%u, at %#08x\n",
rc, totlen, length, phys_ofs);
rc = rc ? rc : -EIO;
- if (length) {
- raw->flash_offset |= REF_OBSOLETE;
- jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
- jffs2_mark_node_obsolete(c, raw);
- } else {
- jffs2_free_raw_node_ref(raw);
- }
+ if (length)
+ jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, PAD(totlen), NULL);
+
return rc;
}
/* success */
- raw->flash_offset |= REF_PRISTINE;
- jffs2_add_physical_node_ref(c, raw, PAD(totlen), NULL);
+ raw = jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(totlen), NULL);
/* FIXME */ raw->next_in_ino = (void *)xd;
if (xd->node)
@@ -563,11 +553,6 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
uint32_t phys_ofs = write_ofs(c);
int ret;
- raw = jffs2_alloc_raw_node_ref();
- if (!raw)
- return -ENOMEM;
- raw->flash_offset = phys_ofs;
-
rr.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rr.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF);
rr.totlen = cpu_to_je32(PAD(sizeof(rr)));
@@ -582,18 +567,13 @@ static int save_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref)
JFFS2_WARNING("jffs2_flash_write() returned %d, request=%u, retlen=%u, at %#08x\n",
ret, sizeof(rr), length, phys_ofs);
ret = ret ? ret : -EIO;
- if (length) {
- raw->flash_offset |= REF_OBSOLETE;
- jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
- jffs2_mark_node_obsolete(c, raw);
- } else {
- jffs2_free_raw_node_ref(raw);
- }
+ if (length)
+ jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, PAD(sizeof(rr)), NULL);
+
return ret;
}
- raw->flash_offset |= REF_PRISTINE;
- jffs2_add_physical_node_ref(c, raw, PAD(sizeof(rr)), NULL);
+ raw = jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, PAD(sizeof(rr)), NULL);
/* FIXME */ raw->next_in_ino = (void *)ref;
if (ref->node)
delete_xattr_ref_node(c, ref);