1 /* $Id: jffs2_fs_sb.h,v 1.16.2.1 2002/02/23 14:13:34 dwmw2 Exp $ */ 2 3 #ifndef _JFFS2_FS_SB 4 #define _JFFS2_FS_SB 5 6 #include <linux/types.h> 7 #include <linux/spinlock.h> 8 #include <linux/completion.h> 9 #include <asm/semaphore.h> 10 #include <linux/list.h> 11 12 #define INOCACHE_HASHSIZE 1 13 14 #define JFFS2_SB_FLAG_RO 1 15 #define JFFS2_SB_FLAG_MOUNTING 2 16 17 /* A struct for the overall file system control. Pointers to 18 jffs2_sb_info structs are named `c' in the source code. 19 Nee jffs_control 20 */ 21 struct jffs2_sb_info { 22 struct mtd_info *mtd; 23 24 __u32 highest_ino; 25 unsigned int flags; 26 spinlock_t nodelist_lock; 27 28 // pid_t thread_pid; /* GC thread's PID */ 29 struct task_struct *gc_task; /* GC task struct */ 30 struct semaphore gc_thread_start; /* GC thread start mutex */ 31 struct completion gc_thread_exit; /* GC thread exit completion port */ 32 // __u32 gc_minfree_threshold; /* GC trigger thresholds */ 33 // __u32 gc_maxdirty_threshold; 34 35 struct semaphore alloc_sem; /* Used to protect all the following 36 fields, and also to protect against 37 out-of-order writing of nodes. 38 And GC. 39 */ 40 __u32 flash_size; 41 __u32 used_size; 42 __u32 dirty_size; 43 __u32 free_size; 44 __u32 erasing_size; 45 __u32 bad_size; 46 __u32 sector_size; 47 // __u32 min_free_size; 48 // __u32 max_chunk_size; 49 50 __u32 nr_free_blocks; 51 __u32 nr_erasing_blocks; 52 53 __u32 nr_blocks; 54 struct jffs2_eraseblock *blocks; /* The whole array of blocks. Used for getting blocks 55 * from the offset (blocks[ofs / sector_size]) */ 56 struct jffs2_eraseblock *nextblock; /* The block we're currently filling */ 57 58 struct jffs2_eraseblock *gcblock; /* The block we're currently garbage-collecting */ 59 60 struct list_head clean_list; /* Blocks 100% full of clean data */ 61 struct list_head dirty_list; /* Blocks with some dirty space */ 62 struct list_head erasing_list; /* Blocks which are currently erasing */ 63 struct list_head erase_pending_list; /* Blocks which need erasing */ 64 struct list_head erase_complete_list; /* Blocks which are erased and need the clean marker written to them */ 65 struct list_head free_list; /* Blocks which are free and ready to be used */ 66 struct list_head bad_list; /* Bad blocks. */ 67 struct list_head bad_used_list; /* Bad blocks with valid data in. */ 68 69 spinlock_t erase_completion_lock; /* Protect free_list and erasing_list 70 against erase completion handler */ 71 wait_queue_head_t erase_wait; /* For waiting for erases to complete */ 72 struct jffs2_inode_cache *inocache_list[INOCACHE_HASHSIZE]; 73 spinlock_t inocache_lock; 74 }; 75 76 #ifdef JFFS2_OUT_OF_KERNEL 77 #define JFFS2_SB_INFO(sb) ((struct jffs2_sb_info *) &(sb)->u) 78 #else 79 #define JFFS2_SB_INFO(sb) (&sb->u.jffs2_sb) 80 #endif 81 82 #define OFNI_BS_2SFFJ(c) ((struct super_block *) ( ((char *)c) - ((char *)(&((struct super_block *)NULL)->u)) ) ) 83 84 #endif /* _JFFS2_FB_SB */ 85