提交 987d47b7 编写于 作者: D David Woodhouse

[JFFS2] Put list of nodes in common part of ic/x_ref/x_datum structure

We'll be using a proper list of nodes in the jffs2_xattr_datum and
jffs2_xattr_ref structures, because the existing code to overwrite
them is just broken. Put it in the common part at the front of the
structure which is shared with the jffs2_inode_cache, so that the
jffs2_link_node_ref() function can do the right thing.
Signed-off-by: NDavid Woodhouse <dwmw2@infradead.org>
上级 0eac940b
...@@ -77,9 +77,9 @@ ...@@ -77,9 +77,9 @@
struct jffs2_raw_node_ref struct jffs2_raw_node_ref
{ {
struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref
for this inode. If this is the last, it points to the inode_cache for this object. If this _is_ the last, it points to the inode_cache,
for this inode instead. The inode_cache will have NULL in the first xattr_ref or xattr_datum instead. The common part of those structures
word so you know when you've got there :) */ has NULL in the first word. See jffs2_raw_ref_to_ic() below */
struct jffs2_raw_node_ref *next_phys; struct jffs2_raw_node_ref *next_phys;
uint32_t flash_offset; uint32_t flash_offset;
#define TEST_TOTLEN #define TEST_TOTLEN
...@@ -88,6 +88,18 @@ struct jffs2_raw_node_ref ...@@ -88,6 +88,18 @@ struct jffs2_raw_node_ref
#endif #endif
}; };
static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
{
while(raw->next_in_ino) {
raw = raw->next_in_ino;
}
/* NB. This can be a jffs2_xattr_datum or jffs2_xattr_ref and
not actually a jffs2_inode_cache. Check ->class */
return ((struct jffs2_inode_cache *)raw);
}
/* flash_offset & 3 always has to be zero, because nodes are /* flash_offset & 3 always has to be zero, because nodes are
always aligned at 4 bytes. So we have a couple of extra bits always aligned at 4 bytes. So we have a couple of extra bits
to play with, which indicate the node's status; see below: */ to play with, which indicate the node's status; see below: */
...@@ -113,20 +125,27 @@ struct jffs2_raw_node_ref ...@@ -113,20 +125,27 @@ struct jffs2_raw_node_ref
a pointer to the first physical node which is part of this inode, too. a pointer to the first physical node which is part of this inode, too.
*/ */
struct jffs2_inode_cache { struct jffs2_inode_cache {
/* First part of structure is shared with other objects which
can terminate the raw node refs' next_in_ino list -- which
currently struct jffs2_xattr_datum and struct jffs2_xattr_ref. */
struct jffs2_full_dirent *scan_dents; /* Used during scan to hold struct jffs2_full_dirent *scan_dents; /* Used during scan to hold
temporary lists of dirents, and later must be set to temporary lists of dirents, and later must be set to
NULL to mark the end of the raw_node_ref->next_in_ino NULL to mark the end of the raw_node_ref->next_in_ino
chain. */ chain. */
u8 class; /* It's used for identification */
u8 flags;
uint16_t state;
struct jffs2_inode_cache *next;
struct jffs2_raw_node_ref *nodes; struct jffs2_raw_node_ref *nodes;
uint8_t class; /* It's used for identification */
/* end of shared structure */
uint8_t flags;
uint16_t state;
uint32_t ino; uint32_t ino;
int nlink; struct jffs2_inode_cache *next;
#ifdef CONFIG_JFFS2_FS_XATTR #ifdef CONFIG_JFFS2_FS_XATTR
struct jffs2_xattr_ref *xref; struct jffs2_xattr_ref *xref;
#endif #endif
int nlink;
}; };
/* Inode states for 'state' above. We need the 'GC' state to prevent /* Inode states for 'state' above. We need the 'GC' state to prevent
...@@ -250,15 +269,6 @@ static inline int jffs2_encode_dev(union jffs2_device_node *jdev, dev_t rdev) ...@@ -250,15 +269,6 @@ static inline int jffs2_encode_dev(union jffs2_device_node *jdev, dev_t rdev)
} }
} }
static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw)
{
while(raw->next_in_ino) {
raw = raw->next_in_ino;
}
return ((struct jffs2_inode_cache *)raw);
}
static inline struct jffs2_node_frag *frag_first(struct rb_root *root) static inline struct jffs2_node_frag *frag_first(struct rb_root *root)
{ {
struct rb_node *node = root->rb_node; struct rb_node *node = root->rb_node;
......
...@@ -20,11 +20,11 @@ ...@@ -20,11 +20,11 @@
struct jffs2_xattr_datum struct jffs2_xattr_datum
{ {
void *always_null; void *always_null;
u8 class;
u8 flags;
u16 xprefix; /* see JFFS2_XATTR_PREFIX_* */
struct jffs2_raw_node_ref *node; struct jffs2_raw_node_ref *node;
uint8_t class;
uint8_t flags;
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 */
uint32_t xid; uint32_t xid;
...@@ -42,11 +42,11 @@ struct jffs2_inode_cache; ...@@ -42,11 +42,11 @@ struct jffs2_inode_cache;
struct jffs2_xattr_ref struct jffs2_xattr_ref
{ {
void *always_null; void *always_null;
u8 class; struct jffs2_raw_node_ref *node;
u8 flags; /* Currently unused */ uint8_t class;
uint8_t flags; /* Currently unused */
u16 unused; u16 unused;
struct jffs2_raw_node_ref *node;
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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册