mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 12:52:30 +00:00
[JFFS2][XATTR] using 'delete marker' for xdatum/xref deletion
- When xdatum is removed, a new xdatum with 'delete marker' is written. (version==0xffffffff means 'delete marker') - When xref is removed, a new xref with 'delete marker' is written. (odd-numbered xseqno means 'delete marker') - delete_xattr_(datum/xref)_delay() are new deletion functions are added. We can only use them if we can detect the target obsolete xdatum/xref as a orphan or errir one. (e.g when inode deletion, or detecting crc error) [1/3] jffs2-xattr-v6-01-delete_marker.patch Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
This commit is contained in:
parent
6d4f8224d4
commit
c9f700f840
@ -230,7 +230,6 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
|
|||||||
at the end of the linked list. Stash it and continue
|
at the end of the linked list. Stash it and continue
|
||||||
from the beginning of the list */
|
from the beginning of the list */
|
||||||
ic = (struct jffs2_inode_cache *)(*prev);
|
ic = (struct jffs2_inode_cache *)(*prev);
|
||||||
BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE);
|
|
||||||
prev = &ic->nodes;
|
prev = &ic->nodes;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -254,7 +253,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
|
|||||||
|
|
||||||
/* PARANOIA */
|
/* PARANOIA */
|
||||||
if (!ic) {
|
if (!ic) {
|
||||||
printk(KERN_WARNING "inode_cache not found in remove_node_refs()!!\n");
|
JFFS2_WARNING("inode_cache/xattr_datum/xattr_ref"
|
||||||
|
" not found in remove_node_refs()!!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,8 +279,19 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
|
|||||||
printk("\n");
|
printk("\n");
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ic->nodes == (void *)ic && ic->nlink == 0)
|
switch (ic->class) {
|
||||||
jffs2_del_ino_cache(c, ic);
|
#ifdef CONFIG_JFFS2_FS_XATTR
|
||||||
|
case RAWNODE_CLASS_XATTR_DATUM:
|
||||||
|
jffs2_release_xattr_datum(c, (struct jffs2_xattr_datum *)ic);
|
||||||
|
break;
|
||||||
|
case RAWNODE_CLASS_XATTR_REF:
|
||||||
|
jffs2_release_xattr_ref(c, (struct jffs2_xattr_ref *)ic);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
if (ic->nodes == (void *)ic && ic->nlink == 0)
|
||||||
|
jffs2_del_ino_cache(c, ic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
|
void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
|
||||||
|
@ -275,13 +275,12 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
|
|||||||
* We can decide whether this node is inode or xattr by ic->class. */
|
* We can decide whether this node is inode or xattr by ic->class. */
|
||||||
if (ic->class == RAWNODE_CLASS_XATTR_DATUM
|
if (ic->class == RAWNODE_CLASS_XATTR_DATUM
|
||||||
|| ic->class == RAWNODE_CLASS_XATTR_REF) {
|
|| ic->class == RAWNODE_CLASS_XATTR_REF) {
|
||||||
BUG_ON(raw->next_in_ino != (void *)ic);
|
|
||||||
spin_unlock(&c->erase_completion_lock);
|
spin_unlock(&c->erase_completion_lock);
|
||||||
|
|
||||||
if (ic->class == RAWNODE_CLASS_XATTR_DATUM) {
|
if (ic->class == RAWNODE_CLASS_XATTR_DATUM) {
|
||||||
ret = jffs2_garbage_collect_xattr_datum(c, (struct jffs2_xattr_datum *)ic);
|
ret = jffs2_garbage_collect_xattr_datum(c, (struct jffs2_xattr_datum *)ic, raw);
|
||||||
} else {
|
} else {
|
||||||
ret = jffs2_garbage_collect_xattr_ref(c, (struct jffs2_xattr_ref *)ic);
|
ret = jffs2_garbage_collect_xattr_ref(c, (struct jffs2_xattr_ref *)ic, raw);
|
||||||
}
|
}
|
||||||
goto release_sem;
|
goto release_sem;
|
||||||
}
|
}
|
||||||
|
@ -119,8 +119,11 @@ struct jffs2_sb_info {
|
|||||||
#ifdef CONFIG_JFFS2_FS_XATTR
|
#ifdef CONFIG_JFFS2_FS_XATTR
|
||||||
#define XATTRINDEX_HASHSIZE (57)
|
#define XATTRINDEX_HASHSIZE (57)
|
||||||
uint32_t highest_xid;
|
uint32_t highest_xid;
|
||||||
|
uint32_t highest_xseqno;
|
||||||
struct list_head xattrindex[XATTRINDEX_HASHSIZE];
|
struct list_head xattrindex[XATTRINDEX_HASHSIZE];
|
||||||
struct list_head xattr_unchecked;
|
struct list_head xattr_unchecked;
|
||||||
|
struct list_head xattr_dead_list;
|
||||||
|
struct jffs2_xattr_ref *xref_dead_list;
|
||||||
struct jffs2_xattr_ref *xref_temp;
|
struct jffs2_xattr_ref *xref_temp;
|
||||||
struct rw_semaphore xattr_sem;
|
struct rw_semaphore xattr_sem;
|
||||||
uint32_t xdatum_mem_usage;
|
uint32_t xdatum_mem_usage;
|
||||||
|
@ -291,6 +291,7 @@ struct jffs2_xattr_datum *jffs2_alloc_xattr_datum(void)
|
|||||||
|
|
||||||
memset(xd, 0, sizeof(struct jffs2_xattr_datum));
|
memset(xd, 0, sizeof(struct jffs2_xattr_datum));
|
||||||
xd->class = RAWNODE_CLASS_XATTR_DATUM;
|
xd->class = RAWNODE_CLASS_XATTR_DATUM;
|
||||||
|
xd->node = (void *)xd;
|
||||||
INIT_LIST_HEAD(&xd->xindex);
|
INIT_LIST_HEAD(&xd->xindex);
|
||||||
return xd;
|
return xd;
|
||||||
}
|
}
|
||||||
@ -309,6 +310,7 @@ struct jffs2_xattr_ref *jffs2_alloc_xattr_ref(void)
|
|||||||
|
|
||||||
memset(ref, 0, sizeof(struct jffs2_xattr_ref));
|
memset(ref, 0, sizeof(struct jffs2_xattr_ref));
|
||||||
ref->class = RAWNODE_CLASS_XATTR_REF;
|
ref->class = RAWNODE_CLASS_XATTR_REF;
|
||||||
|
ref->node = (void *)ref;
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,19 +684,26 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
|
|||||||
spin_lock(&c->erase_completion_lock);
|
spin_lock(&c->erase_completion_lock);
|
||||||
|
|
||||||
ic = jffs2_raw_ref_to_ic(ref);
|
ic = jffs2_raw_ref_to_ic(ref);
|
||||||
/* It seems we should never call jffs2_mark_node_obsolete() for
|
|
||||||
XATTR nodes.... yet. Make sure we notice if/when we change
|
|
||||||
that :) */
|
|
||||||
BUG_ON(ic->class != RAWNODE_CLASS_INODE_CACHE);
|
|
||||||
for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino))
|
for (p = &ic->nodes; (*p) != ref; p = &((*p)->next_in_ino))
|
||||||
;
|
;
|
||||||
|
|
||||||
*p = ref->next_in_ino;
|
*p = ref->next_in_ino;
|
||||||
ref->next_in_ino = NULL;
|
ref->next_in_ino = NULL;
|
||||||
|
|
||||||
if (ic->nodes == (void *)ic && ic->nlink == 0)
|
switch (ic->class) {
|
||||||
jffs2_del_ino_cache(c, ic);
|
#ifdef CONFIG_JFFS2_FS_XATTR
|
||||||
|
case RAWNODE_CLASS_XATTR_DATUM:
|
||||||
|
jffs2_release_xattr_datum(c, (struct jffs2_xattr_datum *)ic);
|
||||||
|
break;
|
||||||
|
case RAWNODE_CLASS_XATTR_REF:
|
||||||
|
jffs2_release_xattr_ref(c, (struct jffs2_xattr_ref *)ic);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
if (ic->nodes == (void *)ic && ic->nlink == 0)
|
||||||
|
jffs2_del_ino_cache(c, ic);
|
||||||
|
break;
|
||||||
|
}
|
||||||
spin_unlock(&c->erase_completion_lock);
|
spin_unlock(&c->erase_completion_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,20 +317,25 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
|
|||||||
struct jffs2_summary *s)
|
struct jffs2_summary *s)
|
||||||
{
|
{
|
||||||
struct jffs2_xattr_datum *xd;
|
struct jffs2_xattr_datum *xd;
|
||||||
uint32_t totlen, crc;
|
uint32_t xid, version, totlen, crc;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
crc = crc32(0, rx, sizeof(struct jffs2_raw_xattr) - 4);
|
crc = crc32(0, rx, sizeof(struct jffs2_raw_xattr) - 4);
|
||||||
if (crc != je32_to_cpu(rx->node_crc)) {
|
if (crc != je32_to_cpu(rx->node_crc)) {
|
||||||
if (je32_to_cpu(rx->node_crc) != 0xffffffff)
|
JFFS2_WARNING("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
|
||||||
JFFS2_WARNING("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
|
ofs, je32_to_cpu(rx->node_crc), crc);
|
||||||
ofs, je32_to_cpu(rx->node_crc), crc);
|
|
||||||
if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen))))
|
if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(rx->totlen))))
|
||||||
return err;
|
return err;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
totlen = PAD(sizeof(*rx) + rx->name_len + 1 + je16_to_cpu(rx->value_len));
|
xid = je32_to_cpu(rx->xid);
|
||||||
|
version = je32_to_cpu(rx->version);
|
||||||
|
|
||||||
|
totlen = sizeof(struct jffs2_raw_xattr);
|
||||||
|
if (version != XDATUM_DELETE_MARKER)
|
||||||
|
totlen += rx->name_len + 1 + je16_to_cpu(rx->value_len);
|
||||||
|
totlen = PAD(totlen);
|
||||||
if (totlen != je32_to_cpu(rx->totlen)) {
|
if (totlen != je32_to_cpu(rx->totlen)) {
|
||||||
JFFS2_WARNING("node length mismatch at %#08x, read=%u, calc=%u\n",
|
JFFS2_WARNING("node length mismatch at %#08x, read=%u, calc=%u\n",
|
||||||
ofs, je32_to_cpu(rx->totlen), totlen);
|
ofs, je32_to_cpu(rx->totlen), totlen);
|
||||||
@ -339,22 +344,24 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
xd = jffs2_setup_xattr_datum(c, je32_to_cpu(rx->xid), je32_to_cpu(rx->version));
|
xd = jffs2_setup_xattr_datum(c, xid, version);
|
||||||
if (IS_ERR(xd)) {
|
if (IS_ERR(xd))
|
||||||
if (PTR_ERR(xd) == -EEXIST) {
|
|
||||||
if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rx->totlen)))))
|
|
||||||
return err;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return PTR_ERR(xd);
|
return PTR_ERR(xd);
|
||||||
}
|
|
||||||
xd->xprefix = rx->xprefix;
|
|
||||||
xd->name_len = rx->name_len;
|
|
||||||
xd->value_len = je16_to_cpu(rx->value_len);
|
|
||||||
xd->data_crc = je32_to_cpu(rx->data_crc);
|
|
||||||
|
|
||||||
xd->node = jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, NULL);
|
if (xd->version > version) {
|
||||||
/* FIXME */ xd->node->next_in_ino = (void *)xd;
|
struct jffs2_raw_node_ref *raw
|
||||||
|
= jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, NULL);
|
||||||
|
raw->next_in_ino = xd->node->next_in_ino;
|
||||||
|
xd->node->next_in_ino = raw;
|
||||||
|
} else {
|
||||||
|
xd->version = version;
|
||||||
|
xd->xprefix = rx->xprefix;
|
||||||
|
xd->name_len = rx->name_len;
|
||||||
|
xd->value_len = je16_to_cpu(rx->value_len);
|
||||||
|
xd->data_crc = je32_to_cpu(rx->data_crc);
|
||||||
|
|
||||||
|
jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, totlen, (void *)xd);
|
||||||
|
}
|
||||||
|
|
||||||
if (jffs2_sum_active())
|
if (jffs2_sum_active())
|
||||||
jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset);
|
jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset);
|
||||||
@ -373,9 +380,8 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
|
|||||||
|
|
||||||
crc = crc32(0, rr, sizeof(*rr) - 4);
|
crc = crc32(0, rr, sizeof(*rr) - 4);
|
||||||
if (crc != je32_to_cpu(rr->node_crc)) {
|
if (crc != je32_to_cpu(rr->node_crc)) {
|
||||||
if (je32_to_cpu(rr->node_crc) != 0xffffffff)
|
JFFS2_WARNING("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
|
||||||
JFFS2_WARNING("node CRC failed at %#08x, read=%#08x, calc=%#08x\n",
|
ofs, je32_to_cpu(rr->node_crc), crc);
|
||||||
ofs, je32_to_cpu(rr->node_crc), crc);
|
|
||||||
if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rr->totlen)))))
|
if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rr->totlen)))))
|
||||||
return err;
|
return err;
|
||||||
return 0;
|
return 0;
|
||||||
@ -395,6 +401,7 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* BEFORE jffs2_build_xattr_subsystem() called,
|
/* BEFORE jffs2_build_xattr_subsystem() called,
|
||||||
|
* and AFTER xattr_ref is marked as a dead xref,
|
||||||
* ref->xid is used to store 32bit xid, xd is not used
|
* ref->xid is used to store 32bit xid, xd is not used
|
||||||
* ref->ino is used to store 32bit inode-number, ic is not used
|
* ref->ino is used to store 32bit inode-number, ic is not used
|
||||||
* Thoes variables are declared as union, thus using those
|
* Thoes variables are declared as union, thus using those
|
||||||
@ -404,11 +411,13 @@ static int jffs2_scan_xref_node(struct jffs2_sb_info *c, struct jffs2_eraseblock
|
|||||||
*/
|
*/
|
||||||
ref->ino = je32_to_cpu(rr->ino);
|
ref->ino = je32_to_cpu(rr->ino);
|
||||||
ref->xid = je32_to_cpu(rr->xid);
|
ref->xid = je32_to_cpu(rr->xid);
|
||||||
|
ref->xseqno = je32_to_cpu(rr->xseqno);
|
||||||
|
if (ref->xseqno > c->highest_xseqno)
|
||||||
|
c->highest_xseqno = (ref->xseqno & ~XREF_DELETE_MARKER);
|
||||||
ref->next = c->xref_temp;
|
ref->next = c->xref_temp;
|
||||||
c->xref_temp = ref;
|
c->xref_temp = ref;
|
||||||
|
|
||||||
ref->node = jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(rr->totlen)), NULL);
|
jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(rr->totlen)), (void *)ref);
|
||||||
/* FIXME */ ref->node->next_in_ino = (void *)ref;
|
|
||||||
|
|
||||||
if (jffs2_sum_active())
|
if (jffs2_sum_active())
|
||||||
jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset);
|
jffs2_sum_add_xref_mem(s, rr, ofs - jeb->offset);
|
||||||
|
@ -310,8 +310,6 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
|
|||||||
#ifdef CONFIG_JFFS2_FS_XATTR
|
#ifdef CONFIG_JFFS2_FS_XATTR
|
||||||
case JFFS2_NODETYPE_XATTR: {
|
case JFFS2_NODETYPE_XATTR: {
|
||||||
struct jffs2_sum_xattr_mem *temp;
|
struct jffs2_sum_xattr_mem *temp;
|
||||||
if (je32_to_cpu(node->x.version) == 0xffffffff)
|
|
||||||
return 0;
|
|
||||||
temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
|
temp = kmalloc(sizeof(struct jffs2_sum_xattr_mem), GFP_KERNEL);
|
||||||
if (!temp)
|
if (!temp)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
@ -327,10 +325,6 @@ int jffs2_sum_add_kvec(struct jffs2_sb_info *c, const struct kvec *invecs,
|
|||||||
}
|
}
|
||||||
case JFFS2_NODETYPE_XREF: {
|
case JFFS2_NODETYPE_XREF: {
|
||||||
struct jffs2_sum_xref_mem *temp;
|
struct jffs2_sum_xref_mem *temp;
|
||||||
|
|
||||||
if (je32_to_cpu(node->r.ino) == 0xffffffff
|
|
||||||
&& je32_to_cpu(node->r.xid) == 0xffffffff)
|
|
||||||
return 0;
|
|
||||||
temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
|
temp = kmalloc(sizeof(struct jffs2_sum_xref_mem), GFP_KERNEL);
|
||||||
if (!temp)
|
if (!temp)
|
||||||
goto no_mem;
|
goto no_mem;
|
||||||
@ -483,22 +477,20 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
|
|||||||
|
|
||||||
xd = jffs2_setup_xattr_datum(c, je32_to_cpu(spx->xid),
|
xd = jffs2_setup_xattr_datum(c, je32_to_cpu(spx->xid),
|
||||||
je32_to_cpu(spx->version));
|
je32_to_cpu(spx->version));
|
||||||
if (IS_ERR(xd)) {
|
if (IS_ERR(xd))
|
||||||
if (PTR_ERR(xd) == -EEXIST) {
|
|
||||||
/* a newer version of xd exists */
|
|
||||||
if ((err = jffs2_scan_dirty_space(c, jeb, je32_to_cpu(spx->totlen))))
|
|
||||||
return err;
|
|
||||||
sp += JFFS2_SUMMARY_XATTR_SIZE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
JFFS2_NOTICE("allocation of xattr_datum failed\n");
|
|
||||||
return PTR_ERR(xd);
|
return PTR_ERR(xd);
|
||||||
|
if (xd->version > je32_to_cpu(spx->version)) {
|
||||||
|
/* node is not the newest one */
|
||||||
|
struct jffs2_raw_node_ref *raw
|
||||||
|
= sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
|
||||||
|
PAD(je32_to_cpu(spx->totlen)), NULL);
|
||||||
|
raw->next_in_ino = xd->node->next_in_ino;
|
||||||
|
xd->node->next_in_ino = raw;
|
||||||
|
} else {
|
||||||
|
xd->version = je32_to_cpu(spx->version);
|
||||||
|
sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
|
||||||
|
PAD(je32_to_cpu(spx->totlen)), (void *)xd);
|
||||||
}
|
}
|
||||||
|
|
||||||
xd->node = sum_link_node_ref(c, jeb, je32_to_cpu(spx->offset) | REF_UNCHECKED,
|
|
||||||
PAD(je32_to_cpu(spx->totlen)), NULL);
|
|
||||||
/* FIXME */ xd->node->next_in_ino = (void *)xd;
|
|
||||||
|
|
||||||
*pseudo_random += je32_to_cpu(spx->xid);
|
*pseudo_random += je32_to_cpu(spx->xid);
|
||||||
sp += JFFS2_SUMMARY_XATTR_SIZE;
|
sp += JFFS2_SUMMARY_XATTR_SIZE;
|
||||||
|
|
||||||
@ -519,14 +511,11 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
|
|||||||
JFFS2_NOTICE("allocation of xattr_datum failed\n");
|
JFFS2_NOTICE("allocation of xattr_datum failed\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
ref->ino = 0xfffffffe;
|
|
||||||
ref->xid = 0xfffffffd;
|
|
||||||
ref->next = c->xref_temp;
|
ref->next = c->xref_temp;
|
||||||
c->xref_temp = ref;
|
c->xref_temp = ref;
|
||||||
|
|
||||||
ref->node = sum_link_node_ref(c, jeb, je32_to_cpu(spr->offset) | REF_UNCHECKED,
|
sum_link_node_ref(c, jeb, je32_to_cpu(spr->offset) | REF_UNCHECKED,
|
||||||
PAD(sizeof(struct jffs2_raw_xref)), NULL);
|
PAD(sizeof(struct jffs2_raw_xref)), (void *)ref);
|
||||||
/* FIXME */ ref->node->next_in_ino = (void *)ref;
|
|
||||||
|
|
||||||
*pseudo_random += ref->node->flash_offset;
|
*pseudo_random += ref->node->flash_offset;
|
||||||
sp += JFFS2_SUMMARY_XREF_SIZE;
|
sp += JFFS2_SUMMARY_XREF_SIZE;
|
||||||
|
740
fs/jffs2/xattr.c
740
fs/jffs2/xattr.c
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
|
#define JFFS2_XFLAGS_HOT (0x01) /* This datum is HOT */
|
||||||
#define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
|
#define JFFS2_XFLAGS_BIND (0x02) /* This datum is not reclaimed */
|
||||||
|
#define JFFS2_XFLAGS_INVALID (0x80) /* This datum contains crc error */
|
||||||
|
|
||||||
struct jffs2_xattr_datum
|
struct jffs2_xattr_datum
|
||||||
{
|
{
|
||||||
@ -23,7 +24,7 @@ struct jffs2_xattr_datum
|
|||||||
struct jffs2_raw_node_ref *node;
|
struct jffs2_raw_node_ref *node;
|
||||||
uint8_t class;
|
uint8_t class;
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
|
uint16_t xprefix; /* see JFFS2_XATTR_PREFIX_* */
|
||||||
|
|
||||||
struct list_head xindex; /* chained from c->xattrindex[n] */
|
struct list_head xindex; /* chained from c->xattrindex[n] */
|
||||||
uint32_t refcnt; /* # of xattr_ref refers this */
|
uint32_t refcnt; /* # of xattr_ref refers this */
|
||||||
@ -47,6 +48,7 @@ struct jffs2_xattr_ref
|
|||||||
uint8_t flags; /* Currently unused */
|
uint8_t flags; /* Currently unused */
|
||||||
u16 unused;
|
u16 unused;
|
||||||
|
|
||||||
|
uint32_t xseqno;
|
||||||
union {
|
union {
|
||||||
struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
|
struct jffs2_inode_cache *ic; /* reference to jffs2_inode_cache */
|
||||||
uint32_t ino; /* only used in scanning/building */
|
uint32_t ino; /* only used in scanning/building */
|
||||||
@ -58,6 +60,34 @@ struct jffs2_xattr_ref
|
|||||||
struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
|
struct jffs2_xattr_ref *next; /* chained from ic->xref_list */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define XDATUM_DELETE_MARKER (0xffffffff)
|
||||||
|
#define XREF_DELETE_MARKER (0x00000001)
|
||||||
|
static inline int is_xattr_datum_dead(struct jffs2_xattr_datum *xd)
|
||||||
|
{
|
||||||
|
return (xd->version == XDATUM_DELETE_MARKER);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void set_xattr_datum_dead(struct jffs2_xattr_datum *xd)
|
||||||
|
{
|
||||||
|
xd->version = XDATUM_DELETE_MARKER;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int is_xattr_ref_dead(struct jffs2_xattr_ref *ref)
|
||||||
|
{
|
||||||
|
return ((ref->xseqno & XREF_DELETE_MARKER) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void set_xattr_ref_dead(struct jffs2_xattr_ref *ref)
|
||||||
|
{
|
||||||
|
ref->xseqno |= XREF_DELETE_MARKER;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void clr_xattr_ref_dead(struct jffs2_xattr_ref *ref)
|
||||||
|
{
|
||||||
|
ref->xseqno &= ~XREF_DELETE_MARKER;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_JFFS2_FS_XATTR
|
#ifdef CONFIG_JFFS2_FS_XATTR
|
||||||
|
|
||||||
extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
|
extern void jffs2_init_xattr_subsystem(struct jffs2_sb_info *c);
|
||||||
@ -70,9 +100,13 @@ extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c
|
|||||||
extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
|
extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
|
||||||
extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
|
extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic);
|
||||||
|
|
||||||
extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
|
extern int jffs2_garbage_collect_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd,
|
||||||
extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
|
struct jffs2_raw_node_ref *raw);
|
||||||
|
extern int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref,
|
||||||
|
struct jffs2_raw_node_ref *raw);
|
||||||
extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
|
extern int jffs2_verify_xattr(struct jffs2_sb_info *c);
|
||||||
|
extern void jffs2_release_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd);
|
||||||
|
extern void jffs2_release_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref);
|
||||||
|
|
||||||
extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
|
extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname,
|
||||||
char *buffer, size_t size);
|
char *buffer, size_t size);
|
||||||
|
@ -186,6 +186,7 @@ struct jffs2_raw_xref
|
|||||||
jint32_t hdr_crc;
|
jint32_t hdr_crc;
|
||||||
jint32_t ino; /* inode number */
|
jint32_t ino; /* inode number */
|
||||||
jint32_t xid; /* XATTR identifier number */
|
jint32_t xid; /* XATTR identifier number */
|
||||||
|
jint32_t xseqno; /* xref sequencial number */
|
||||||
jint32_t node_crc;
|
jint32_t node_crc;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user