diff options
Diffstat (limited to 'fs/jffs2/nodelist.h')
-rw-r--r-- | fs/jffs2/nodelist.h | 75 |
1 files changed, 49 insertions, 26 deletions
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h index 80d1fda2212b..76f1b9419eea 100644 --- a/fs/jffs2/nodelist.h +++ b/fs/jffs2/nodelist.h | |||
@@ -77,9 +77,9 @@ | |||
77 | struct jffs2_raw_node_ref | 77 | struct jffs2_raw_node_ref |
78 | { | 78 | { |
79 | struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref | 79 | struct jffs2_raw_node_ref *next_in_ino; /* Points to the next raw_node_ref |
80 | for this inode. If this is the last, it points to the inode_cache | 80 | for this object. If this _is_ the last, it points to the inode_cache, |
81 | for this inode instead. The inode_cache will have NULL in the first | 81 | xattr_ref or xattr_datum instead. The common part of those structures |
82 | word so you know when you've got there :) */ | 82 | has NULL in the first word. See jffs2_raw_ref_to_ic() below */ |
83 | struct jffs2_raw_node_ref *next_phys; | 83 | struct jffs2_raw_node_ref *next_phys; |
84 | uint32_t flash_offset; | 84 | uint32_t flash_offset; |
85 | #define TEST_TOTLEN | 85 | #define TEST_TOTLEN |
@@ -88,6 +88,18 @@ struct jffs2_raw_node_ref | |||
88 | #endif | 88 | #endif |
89 | }; | 89 | }; |
90 | 90 | ||
91 | static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw) | ||
92 | { | ||
93 | while(raw->next_in_ino) { | ||
94 | raw = raw->next_in_ino; | ||
95 | } | ||
96 | |||
97 | /* NB. This can be a jffs2_xattr_datum or jffs2_xattr_ref and | ||
98 | not actually a jffs2_inode_cache. Check ->class */ | ||
99 | return ((struct jffs2_inode_cache *)raw); | ||
100 | } | ||
101 | |||
102 | |||
91 | /* flash_offset & 3 always has to be zero, because nodes are | 103 | /* flash_offset & 3 always has to be zero, because nodes are |
92 | always aligned at 4 bytes. So we have a couple of extra bits | 104 | always aligned at 4 bytes. So we have a couple of extra bits |
93 | to play with, which indicate the node's status; see below: */ | 105 | to play with, which indicate the node's status; see below: */ |
@@ -113,20 +125,27 @@ struct jffs2_raw_node_ref | |||
113 | a pointer to the first physical node which is part of this inode, too. | 125 | a pointer to the first physical node which is part of this inode, too. |
114 | */ | 126 | */ |
115 | struct jffs2_inode_cache { | 127 | struct jffs2_inode_cache { |
128 | /* First part of structure is shared with other objects which | ||
129 | can terminate the raw node refs' next_in_ino list -- which | ||
130 | currently struct jffs2_xattr_datum and struct jffs2_xattr_ref. */ | ||
131 | |||
116 | struct jffs2_full_dirent *scan_dents; /* Used during scan to hold | 132 | struct jffs2_full_dirent *scan_dents; /* Used during scan to hold |
117 | temporary lists of dirents, and later must be set to | 133 | temporary lists of dirents, and later must be set to |
118 | NULL to mark the end of the raw_node_ref->next_in_ino | 134 | NULL to mark the end of the raw_node_ref->next_in_ino |
119 | chain. */ | 135 | chain. */ |
120 | u8 class; /* It's used for identification */ | ||
121 | u8 flags; | ||
122 | uint16_t state; | ||
123 | struct jffs2_inode_cache *next; | ||
124 | struct jffs2_raw_node_ref *nodes; | 136 | struct jffs2_raw_node_ref *nodes; |
137 | uint8_t class; /* It's used for identification */ | ||
138 | |||
139 | /* end of shared structure */ | ||
140 | |||
141 | uint8_t flags; | ||
142 | uint16_t state; | ||
125 | uint32_t ino; | 143 | uint32_t ino; |
126 | int nlink; | 144 | struct jffs2_inode_cache *next; |
127 | #ifdef CONFIG_JFFS2_FS_XATTR | 145 | #ifdef CONFIG_JFFS2_FS_XATTR |
128 | struct jffs2_xattr_ref *xref; | 146 | struct jffs2_xattr_ref *xref; |
129 | #endif | 147 | #endif |
148 | int nlink; | ||
130 | }; | 149 | }; |
131 | 150 | ||
132 | /* Inode states for 'state' above. We need the 'GC' state to prevent | 151 | /* Inode states for 'state' above. We need the 'GC' state to prevent |
@@ -148,6 +167,8 @@ struct jffs2_inode_cache { | |||
148 | 167 | ||
149 | #define INOCACHE_HASHSIZE 128 | 168 | #define INOCACHE_HASHSIZE 128 |
150 | 169 | ||
170 | #define write_ofs(c) ((c)->nextblock->offset + (c)->sector_size - (c)->nextblock->free_size) | ||
171 | |||
151 | /* | 172 | /* |
152 | Larger representation of a raw node, kept in-core only when the | 173 | Larger representation of a raw node, kept in-core only when the |
153 | struct inode for this particular ino is instantiated. | 174 | struct inode for this particular ino is instantiated. |
@@ -250,15 +271,6 @@ static inline int jffs2_encode_dev(union jffs2_device_node *jdev, dev_t rdev) | |||
250 | } | 271 | } |
251 | } | 272 | } |
252 | 273 | ||
253 | static inline struct jffs2_inode_cache *jffs2_raw_ref_to_ic(struct jffs2_raw_node_ref *raw) | ||
254 | { | ||
255 | while(raw->next_in_ino) { | ||
256 | raw = raw->next_in_ino; | ||
257 | } | ||
258 | |||
259 | return ((struct jffs2_inode_cache *)raw); | ||
260 | } | ||
261 | |||
262 | static inline struct jffs2_node_frag *frag_first(struct rb_root *root) | 274 | static inline struct jffs2_node_frag *frag_first(struct rb_root *root) |
263 | { | 275 | { |
264 | struct rb_node *node = root->rb_node; | 276 | struct rb_node *node = root->rb_node; |
@@ -307,32 +319,43 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in | |||
307 | void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); | 319 | void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); |
308 | int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn); | 320 | int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn); |
309 | void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, | 321 | void jffs2_link_node_ref(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, |
310 | struct jffs2_raw_node_ref *ref, uint32_t len); | 322 | struct jffs2_raw_node_ref *ref, uint32_t len, |
323 | struct jffs2_inode_cache *ic); | ||
311 | extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, | 324 | extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, |
312 | struct jffs2_eraseblock *jeb, | 325 | struct jffs2_eraseblock *jeb, |
313 | struct jffs2_raw_node_ref *ref); | 326 | struct jffs2_raw_node_ref *ref); |
314 | 327 | ||
315 | /* nodemgmt.c */ | 328 | /* nodemgmt.c */ |
316 | int jffs2_thread_should_wake(struct jffs2_sb_info *c); | 329 | int jffs2_thread_should_wake(struct jffs2_sb_info *c); |
317 | int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, | 330 | int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, |
318 | uint32_t *len, int prio, uint32_t sumsize); | 331 | uint32_t *len, int prio, uint32_t sumsize); |
319 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, | 332 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, |
320 | uint32_t *len, uint32_t sumsize); | 333 | uint32_t *len, uint32_t sumsize); |
321 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len); | 334 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, |
335 | struct jffs2_raw_node_ref *new, | ||
336 | uint32_t len, | ||
337 | struct jffs2_inode_cache *ic); | ||
322 | void jffs2_complete_reservation(struct jffs2_sb_info *c); | 338 | void jffs2_complete_reservation(struct jffs2_sb_info *c); |
323 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); | 339 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); |
324 | 340 | ||
325 | /* write.c */ | 341 | /* write.c */ |
326 | int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri); | 342 | int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint32_t mode, struct jffs2_raw_inode *ri); |
327 | 343 | ||
328 | struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const unsigned char *data, uint32_t datalen, uint32_t flash_ofs, int alloc_mode); | 344 | struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
329 | struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_raw_dirent *rd, const unsigned char *name, uint32_t namelen, uint32_t flash_ofs, int alloc_mode); | 345 | struct jffs2_raw_inode *ri, const unsigned char *data, |
346 | uint32_t datalen, int alloc_mode); | ||
347 | struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | ||
348 | struct jffs2_raw_dirent *rd, const unsigned char *name, | ||
349 | uint32_t namelen, int alloc_mode); | ||
330 | int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | 350 | int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, |
331 | struct jffs2_raw_inode *ri, unsigned char *buf, | 351 | struct jffs2_raw_inode *ri, unsigned char *buf, |
332 | uint32_t offset, uint32_t writelen, uint32_t *retlen); | 352 | uint32_t offset, uint32_t writelen, uint32_t *retlen); |
333 | int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, struct jffs2_raw_inode *ri, const char *name, int namelen); | 353 | int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, struct jffs2_inode_info *f, |
334 | int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name, int namelen, struct jffs2_inode_info *dead_f, uint32_t time); | 354 | struct jffs2_raw_inode *ri, const char *name, int namelen); |
335 | int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino, uint8_t type, const char *name, int namelen, uint32_t time); | 355 | int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, const char *name, |
356 | int namelen, struct jffs2_inode_info *dead_f, uint32_t time); | ||
357 | int jffs2_do_link(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint32_t ino, | ||
358 | uint8_t type, const char *name, int namelen, uint32_t time); | ||
336 | 359 | ||
337 | 360 | ||
338 | /* readinode.c */ | 361 | /* readinode.c */ |