diff options
Diffstat (limited to 'fs/jffs2/nodelist.h')
-rw-r--r-- | fs/jffs2/nodelist.h | 90 |
1 files changed, 37 insertions, 53 deletions
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h index 24e0f28a8bac..80d1fda2212b 100644 --- a/fs/jffs2/nodelist.h +++ b/fs/jffs2/nodelist.h | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/jffs2.h> | 20 | #include <linux/jffs2.h> |
21 | #include "jffs2_fs_sb.h" | 21 | #include "jffs2_fs_sb.h" |
22 | #include "jffs2_fs_i.h" | 22 | #include "jffs2_fs_i.h" |
23 | #include "xattr.h" | ||
24 | #include "acl.h" | ||
23 | #include "summary.h" | 25 | #include "summary.h" |
24 | 26 | ||
25 | #ifdef __ECOS | 27 | #ifdef __ECOS |
@@ -80,7 +82,10 @@ struct jffs2_raw_node_ref | |||
80 | word so you know when you've got there :) */ | 82 | word so you know when you've got there :) */ |
81 | struct jffs2_raw_node_ref *next_phys; | 83 | struct jffs2_raw_node_ref *next_phys; |
82 | uint32_t flash_offset; | 84 | uint32_t flash_offset; |
85 | #define TEST_TOTLEN | ||
86 | #ifdef TEST_TOTLEN | ||
83 | uint32_t __totlen; /* This may die; use ref_totlen(c, jeb, ) below */ | 87 | uint32_t __totlen; /* This may die; use ref_totlen(c, jeb, ) below */ |
88 | #endif | ||
84 | }; | 89 | }; |
85 | 90 | ||
86 | /* flash_offset & 3 always has to be zero, because nodes are | 91 | /* flash_offset & 3 always has to be zero, because nodes are |
@@ -95,6 +100,11 @@ struct jffs2_raw_node_ref | |||
95 | #define ref_obsolete(ref) (((ref)->flash_offset & 3) == REF_OBSOLETE) | 100 | #define ref_obsolete(ref) (((ref)->flash_offset & 3) == REF_OBSOLETE) |
96 | #define mark_ref_normal(ref) do { (ref)->flash_offset = ref_offset(ref) | REF_NORMAL; } while(0) | 101 | #define mark_ref_normal(ref) do { (ref)->flash_offset = ref_offset(ref) | REF_NORMAL; } while(0) |
97 | 102 | ||
103 | /* NB: REF_PRISTINE for an inode-less node (ref->next_in_ino == NULL) indicates | ||
104 | it is an unknown node of type JFFS2_NODETYPE_RWCOMPAT_COPY, so it'll get | ||
105 | copied. If you need to do anything different to GC inode-less nodes, then | ||
106 | you need to modify gc.c accordingly. */ | ||
107 | |||
98 | /* For each inode in the filesystem, we need to keep a record of | 108 | /* For each inode in the filesystem, we need to keep a record of |
99 | nlink, because it would be a PITA to scan the whole directory tree | 109 | nlink, because it would be a PITA to scan the whole directory tree |
100 | at read_inode() time to calculate it, and to keep sufficient information | 110 | at read_inode() time to calculate it, and to keep sufficient information |
@@ -107,11 +117,16 @@ struct jffs2_inode_cache { | |||
107 | temporary lists of dirents, and later must be set to | 117 | temporary lists of dirents, and later must be set to |
108 | NULL to mark the end of the raw_node_ref->next_in_ino | 118 | NULL to mark the end of the raw_node_ref->next_in_ino |
109 | chain. */ | 119 | chain. */ |
120 | u8 class; /* It's used for identification */ | ||
121 | u8 flags; | ||
122 | uint16_t state; | ||
110 | struct jffs2_inode_cache *next; | 123 | struct jffs2_inode_cache *next; |
111 | struct jffs2_raw_node_ref *nodes; | 124 | struct jffs2_raw_node_ref *nodes; |
112 | uint32_t ino; | 125 | uint32_t ino; |
113 | int nlink; | 126 | int nlink; |
114 | int state; | 127 | #ifdef CONFIG_JFFS2_FS_XATTR |
128 | struct jffs2_xattr_ref *xref; | ||
129 | #endif | ||
115 | }; | 130 | }; |
116 | 131 | ||
117 | /* Inode states for 'state' above. We need the 'GC' state to prevent | 132 | /* Inode states for 'state' above. We need the 'GC' state to prevent |
@@ -125,6 +140,12 @@ struct jffs2_inode_cache { | |||
125 | #define INO_STATE_READING 5 /* In read_inode() */ | 140 | #define INO_STATE_READING 5 /* In read_inode() */ |
126 | #define INO_STATE_CLEARING 6 /* In clear_inode() */ | 141 | #define INO_STATE_CLEARING 6 /* In clear_inode() */ |
127 | 142 | ||
143 | #define INO_FLAGS_XATTR_CHECKED 0x01 /* has no duplicate xattr_ref */ | ||
144 | |||
145 | #define RAWNODE_CLASS_INODE_CACHE 0 | ||
146 | #define RAWNODE_CLASS_XATTR_DATUM 1 | ||
147 | #define RAWNODE_CLASS_XATTR_REF 2 | ||
148 | |||
128 | #define INOCACHE_HASHSIZE 128 | 149 | #define INOCACHE_HASHSIZE 128 |
129 | 150 | ||
130 | /* | 151 | /* |
@@ -203,57 +224,7 @@ static inline int jffs2_blocks_use_vmalloc(struct jffs2_sb_info *c) | |||
203 | return ((c->flash_size / c->sector_size) * sizeof (struct jffs2_eraseblock)) > (128 * 1024); | 224 | return ((c->flash_size / c->sector_size) * sizeof (struct jffs2_eraseblock)) > (128 * 1024); |
204 | } | 225 | } |
205 | 226 | ||
206 | /* Calculate totlen from surrounding nodes or eraseblock */ | 227 | #define ref_totlen(a, b, c) __jffs2_ref_totlen((a), (b), (c)) |
207 | static inline uint32_t __ref_totlen(struct jffs2_sb_info *c, | ||
208 | struct jffs2_eraseblock *jeb, | ||
209 | struct jffs2_raw_node_ref *ref) | ||
210 | { | ||
211 | uint32_t ref_end; | ||
212 | |||
213 | if (ref->next_phys) | ||
214 | ref_end = ref_offset(ref->next_phys); | ||
215 | else { | ||
216 | if (!jeb) | ||
217 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | ||
218 | |||
219 | /* Last node in block. Use free_space */ | ||
220 | BUG_ON(ref != jeb->last_node); | ||
221 | ref_end = jeb->offset + c->sector_size - jeb->free_size; | ||
222 | } | ||
223 | return ref_end - ref_offset(ref); | ||
224 | } | ||
225 | |||
226 | static inline uint32_t ref_totlen(struct jffs2_sb_info *c, | ||
227 | struct jffs2_eraseblock *jeb, | ||
228 | struct jffs2_raw_node_ref *ref) | ||
229 | { | ||
230 | uint32_t ret; | ||
231 | |||
232 | #if CONFIG_JFFS2_FS_DEBUG > 0 | ||
233 | if (jeb && jeb != &c->blocks[ref->flash_offset / c->sector_size]) { | ||
234 | printk(KERN_CRIT "ref_totlen called with wrong block -- at 0x%08x instead of 0x%08x; ref 0x%08x\n", | ||
235 | jeb->offset, c->blocks[ref->flash_offset / c->sector_size].offset, ref_offset(ref)); | ||
236 | BUG(); | ||
237 | } | ||
238 | #endif | ||
239 | |||
240 | #if 1 | ||
241 | ret = ref->__totlen; | ||
242 | #else | ||
243 | /* This doesn't actually work yet */ | ||
244 | ret = __ref_totlen(c, jeb, ref); | ||
245 | if (ret != ref->__totlen) { | ||
246 | printk(KERN_CRIT "Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n", | ||
247 | ref, ref_offset(ref), ref_offset(ref)+ref->__totlen, | ||
248 | ret, ref->__totlen); | ||
249 | if (!jeb) | ||
250 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | ||
251 | jffs2_dbg_dump_node_refs_nolock(c, jeb); | ||
252 | BUG(); | ||
253 | } | ||
254 | #endif | ||
255 | return ret; | ||
256 | } | ||
257 | 228 | ||
258 | #define ALLOC_NORMAL 0 /* Normal allocation */ | 229 | #define ALLOC_NORMAL 0 /* Normal allocation */ |
259 | #define ALLOC_DELETION 1 /* Deletion node. Best to allow it */ | 230 | #define ALLOC_DELETION 1 /* Deletion node. Best to allow it */ |
@@ -335,6 +306,11 @@ void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *t | |||
335 | int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_full_dnode *fn); | 306 | int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_full_dnode *fn); |
336 | void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); | 307 | void jffs2_truncate_fragtree (struct jffs2_sb_info *c, struct rb_root *list, uint32_t size); |
337 | int jffs2_add_older_frag_to_fragtree(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn); | 308 | 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, | ||
310 | struct jffs2_raw_node_ref *ref, uint32_t len); | ||
311 | extern uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, | ||
312 | struct jffs2_eraseblock *jeb, | ||
313 | struct jffs2_raw_node_ref *ref); | ||
338 | 314 | ||
339 | /* nodemgmt.c */ | 315 | /* nodemgmt.c */ |
340 | int jffs2_thread_should_wake(struct jffs2_sb_info *c); | 316 | int jffs2_thread_should_wake(struct jffs2_sb_info *c); |
@@ -342,7 +318,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs | |||
342 | uint32_t *len, int prio, uint32_t sumsize); | 318 | uint32_t *len, int prio, uint32_t sumsize); |
343 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, | 319 | int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, |
344 | uint32_t *len, uint32_t sumsize); | 320 | uint32_t *len, uint32_t sumsize); |
345 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new); | 321 | int jffs2_add_physical_node_ref(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *new, uint32_t len); |
346 | void jffs2_complete_reservation(struct jffs2_sb_info *c); | 322 | void jffs2_complete_reservation(struct jffs2_sb_info *c); |
347 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); | 323 | void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref *raw); |
348 | 324 | ||
@@ -385,6 +361,12 @@ struct jffs2_node_frag *jffs2_alloc_node_frag(void); | |||
385 | void jffs2_free_node_frag(struct jffs2_node_frag *); | 361 | void jffs2_free_node_frag(struct jffs2_node_frag *); |
386 | struct jffs2_inode_cache *jffs2_alloc_inode_cache(void); | 362 | struct jffs2_inode_cache *jffs2_alloc_inode_cache(void); |
387 | void jffs2_free_inode_cache(struct jffs2_inode_cache *); | 363 | void jffs2_free_inode_cache(struct jffs2_inode_cache *); |
364 | #ifdef CONFIG_JFFS2_FS_XATTR | ||
365 | struct jffs2_xattr_datum *jffs2_alloc_xattr_datum(void); | ||
366 | void jffs2_free_xattr_datum(struct jffs2_xattr_datum *); | ||
367 | struct jffs2_xattr_ref *jffs2_alloc_xattr_ref(void); | ||
368 | void jffs2_free_xattr_ref(struct jffs2_xattr_ref *); | ||
369 | #endif | ||
388 | 370 | ||
389 | /* gc.c */ | 371 | /* gc.c */ |
390 | int jffs2_garbage_collect_pass(struct jffs2_sb_info *c); | 372 | int jffs2_garbage_collect_pass(struct jffs2_sb_info *c); |
@@ -404,12 +386,14 @@ int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf, | |||
404 | uint32_t ofs, uint32_t len); | 386 | uint32_t ofs, uint32_t len); |
405 | struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uint32_t ino); | 387 | struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uint32_t ino); |
406 | int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); | 388 | int jffs2_scan_classify_jeb(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); |
389 | int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, uint32_t size); | ||
407 | 390 | ||
408 | /* build.c */ | 391 | /* build.c */ |
409 | int jffs2_do_mount_fs(struct jffs2_sb_info *c); | 392 | int jffs2_do_mount_fs(struct jffs2_sb_info *c); |
410 | 393 | ||
411 | /* erase.c */ | 394 | /* erase.c */ |
412 | void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count); | 395 | void jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count); |
396 | void jffs2_free_all_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); | ||
413 | 397 | ||
414 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 398 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
415 | /* wbuf.c */ | 399 | /* wbuf.c */ |