/* This is all we need to keep in-core for each raw node during normal operation. As and when we do read_inode on a particular inode, we can scan the nodes which are listed for it and build up a proper map of which nodes are currently valid. JFFSv1 always used to keep that whole map in core for each inode.
*/ struct jffs2_raw_node_ref
{ struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref for this object. If this _is_ the last, it points to the inode_cache, xattr_ref or xattr_datum instead. The common part of those structures
has NULL in the first word. See jffs2_raw_ref_to_ic() below */
uint32_t flash_offset; #undef TEST_TOTLEN #ifdef TEST_TOTLEN
uint32_t __totlen; /* This may die; use ref_totlen(c, jeb, ) below */ #endif
};
/* Link to another block of refs */ if (ref->flash_offset == REF_LINK_NODE) {
ref = ref->next_in_ino; if (!ref) return ref;
}
/* End of chain */ if (ref->flash_offset == REF_EMPTY_NODE) return NULL;
return ref;
}
staticinlinestruct 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 always aligned at 4 bytes. So we have a couple of extra bits
to play with, which indicate the node's status; see below: */ #define REF_UNCHECKED 0 /* We haven't yet checked the CRC or built its inode */ #define REF_OBSOLETE 1 /* Obsolete, can be completely ignored */ #define REF_PRISTINE 2 /* Completely clean. GC without looking */ #define REF_NORMAL 3 /* Possibly overlapped. Read the page and write again on GC */ #define ref_flags(ref) ((ref)->flash_offset & 3) #define ref_offset(ref) ((ref)->flash_offset & ~3) #define ref_obsolete(ref) (((ref)->flash_offset & 3) == REF_OBSOLETE) #define mark_ref_normal(ref) do { (ref)->flash_offset = ref_offset(ref) | REF_NORMAL; } while(0)
/* Dirent nodes should be REF_PRISTINE only if they are not a deletion dirent. Deletion dirents should be REF_NORMAL so that GC gets to
throw them away when appropriate */ #define dirent_node_state(rd) ( (je32_to_cpu((rd)->ino)?REF_PRISTINE:REF_NORMAL) )
/* NB: REF_PRISTINE for an inode-less node (ref->next_in_ino == NULL) indicates it is an unknown node of type JFFS2_NODETYPE_RWCOMPAT_COPY, so it'll get copied. If you need to do anything different to GC inode-less nodes, then
you need to modify gc.c accordingly. */
/* For each inode in the filesystem, we need to keep a record of nlink, because it would be a PITA to scan the whole directory tree at read_inode() time to calculate it, and to keep sufficient information in the raw_node_ref (basically both parent and child inode number for dirent nodes) would take more space than this does. We also keep a pointer to the first physical node which is part of this inode, too.
*/ 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 temporary lists of dirents, and later must be set to NULL to mark the end of the raw_node_ref->next_in_ino
chain. */ 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; struct jffs2_inode_cache *next; #ifdef CONFIG_JFFS2_FS_XATTR struct jffs2_xattr_ref *xref; #endif
uint32_t pino_nlink; /* Directories store parent inode here; other inodes store nlink. Zero always means that it's
completely unlinked. */
};
/* Inode states for 'state' above. We need the 'GC' state to prevent someone from doing a read_inode() while we're moving a 'REF_PRISTINE'
node without going through all the iget() nonsense */ #define INO_STATE_UNCHECKED 0 /* CRC checks not yet done */ #define INO_STATE_CHECKING 1 /* CRC checks in progress */ #define INO_STATE_PRESENT 2 /* In core */ #define INO_STATE_CHECKEDABSENT 3 /* Checked, cleared again */ #define INO_STATE_GC 4 /* GCing a 'pristine' node */ #define INO_STATE_READING 5 /* In read_inode() */ #define INO_STATE_CLEARING 6 /* In clear_inode() */
#define INO_FLAGS_XATTR_CHECKED 0x01 /* has no duplicate xattr_ref */ #define INO_FLAGS_IS_DIR 0x02 /* is a directory */
/* Larger representation of a raw node, kept in-core only when the struct inode for this particular ino is instantiated.
*/
struct jffs2_full_dnode
{ struct jffs2_raw_node_ref *raw;
uint32_t ofs; /* The offset to which the data of this node belongs */
uint32_t size;
uint32_t frags; /* Number of fragments which currently refer to this node. When this reaches zero,
the node is obsolete. */
};
/* Even larger representation of a raw node, kept in-core only while we're actually building up the original map of which nodes go where, in read_inode()
*/ struct jffs2_tmp_dnode_info
{ struct rb_node rb; struct jffs2_full_dnode *fn;
uint32_t version;
uint32_t data_crc;
uint32_t partial_crc;
uint32_t csize;
uint16_t overlapped;
};
/* Temporary data structure used during readinode. */ struct jffs2_readinode_info
{ struct rb_root tn_root; struct jffs2_tmp_dnode_info *mdata_tn;
uint32_t highest_version;
uint32_t latest_mctime;
uint32_t mctime_ver; struct jffs2_full_dirent *fds; struct jffs2_raw_node_ref *latest_ref;
};
struct jffs2_full_dirent
{ union { struct jffs2_raw_node_ref *raw; struct jffs2_inode_cache *ic; /* Just during part of build */
}; struct jffs2_full_dirent *next;
uint32_t version;
uint32_t ino; /* == zero for unlink */ unsignedint nhash; unsignedchar type; unsignedchar name[];
};
/* Fragments - used to build a map of which raw node to obtain data from for each part of the ino
*/ struct jffs2_node_frag
{ struct rb_node rb; struct jffs2_full_dnode *node; /* NULL for holes */
uint32_t size;
uint32_t ofs; /* The offset to which this fragment belongs */
};
struct jffs2_eraseblock
{ struct list_head list; int bad_count;
uint32_t offset; /* of this block in the MTD */
uint32_t unchecked_size;
uint32_t used_size;
uint32_t dirty_size;
uint32_t wasted_size;
uint32_t free_size; /* Note that sector_size - free_size
is the address of the first free space */
uint32_t allocated_refs; struct jffs2_raw_node_ref *first_node; struct jffs2_raw_node_ref *last_node;
struct jffs2_raw_node_ref *gc_node; /* Next node to be garbage collected */
};
#define ref_totlen(a, b, c) __jffs2_ref_totlen((a), (b), (c))
#define ALLOC_NORMAL 0 /* Normal allocation */ #define ALLOC_DELETION 1 /* Deletion node. Best to allow it */ #define ALLOC_GC 2 /* Space requested for GC. Give it or die */ #define ALLOC_NORETRY 3 /* For jffs2_write_dnode: On failure, return -EAGAIN instead of retrying */
/* How much dirty space before it goes on the very_dirty_list */ #define VERYDIRTY(c, size) ((size) >= ((c)->sector_size / 2))
/* check if dirty space is more than 255 Byte */ #define ISDIRTY(size) ((size) > sizeof (struct jffs2_raw_inode) + JFFS2_MIN_DATA_LEN)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.