1cbb9a561SDavid Woodhouse /* $Id: jffs2_fs_sb.h,v 1.54 2005/09/21 13:37:34 dedekind Exp $ */ 2cbb9a561SDavid Woodhouse 3cbb9a561SDavid Woodhouse #ifndef _JFFS2_FS_SB 4cbb9a561SDavid Woodhouse #define _JFFS2_FS_SB 5cbb9a561SDavid Woodhouse 6cbb9a561SDavid Woodhouse #include <linux/types.h> 7cbb9a561SDavid Woodhouse #include <linux/spinlock.h> 8cbb9a561SDavid Woodhouse #include <linux/workqueue.h> 9cbb9a561SDavid Woodhouse #include <linux/completion.h> 10cbb9a561SDavid Woodhouse #include <asm/semaphore.h> 11cbb9a561SDavid Woodhouse #include <linux/timer.h> 12cbb9a561SDavid Woodhouse #include <linux/wait.h> 13cbb9a561SDavid Woodhouse #include <linux/list.h> 14cbb9a561SDavid Woodhouse #include <linux/rwsem.h> 15cbb9a561SDavid Woodhouse 16cbb9a561SDavid Woodhouse #define JFFS2_SB_FLAG_RO 1 17cbb9a561SDavid Woodhouse #define JFFS2_SB_FLAG_SCANNING 2 /* Flash scanning is in progress */ 18cbb9a561SDavid Woodhouse #define JFFS2_SB_FLAG_BUILDING 4 /* File system building is in progress */ 19cbb9a561SDavid Woodhouse 20cbb9a561SDavid Woodhouse struct jffs2_inodirty; 21cbb9a561SDavid Woodhouse 22cbb9a561SDavid Woodhouse /* A struct for the overall file system control. Pointers to 23cbb9a561SDavid Woodhouse jffs2_sb_info structs are named `c' in the source code. 24cbb9a561SDavid Woodhouse Nee jffs_control 25cbb9a561SDavid Woodhouse */ 26cbb9a561SDavid Woodhouse struct jffs2_sb_info { 27cbb9a561SDavid Woodhouse struct mtd_info *mtd; 28cbb9a561SDavid Woodhouse 29cbb9a561SDavid Woodhouse uint32_t highest_ino; 30cbb9a561SDavid Woodhouse uint32_t checked_ino; 31cbb9a561SDavid Woodhouse 32cbb9a561SDavid Woodhouse unsigned int flags; 33cbb9a561SDavid Woodhouse 34cbb9a561SDavid Woodhouse struct task_struct *gc_task; /* GC task struct */ 35cbb9a561SDavid Woodhouse struct completion gc_thread_start; /* GC thread start completion */ 36cbb9a561SDavid Woodhouse struct completion gc_thread_exit; /* GC thread exit completion port */ 37cbb9a561SDavid Woodhouse 38cbb9a561SDavid Woodhouse struct semaphore alloc_sem; /* Used to protect all the following 39cbb9a561SDavid Woodhouse fields, and also to protect against 40cbb9a561SDavid Woodhouse out-of-order writing of nodes. And GC. */ 41cbb9a561SDavid Woodhouse uint32_t cleanmarker_size; /* Size of an _inline_ CLEANMARKER 42cbb9a561SDavid Woodhouse (i.e. zero for OOB CLEANMARKER */ 43cbb9a561SDavid Woodhouse 44cbb9a561SDavid Woodhouse uint32_t flash_size; 45cbb9a561SDavid Woodhouse uint32_t used_size; 46cbb9a561SDavid Woodhouse uint32_t dirty_size; 47cbb9a561SDavid Woodhouse uint32_t wasted_size; 48cbb9a561SDavid Woodhouse uint32_t free_size; 49cbb9a561SDavid Woodhouse uint32_t erasing_size; 50cbb9a561SDavid Woodhouse uint32_t bad_size; 51cbb9a561SDavid Woodhouse uint32_t sector_size; 52cbb9a561SDavid Woodhouse uint32_t unchecked_size; 53cbb9a561SDavid Woodhouse 54cbb9a561SDavid Woodhouse uint32_t nr_free_blocks; 55cbb9a561SDavid Woodhouse uint32_t nr_erasing_blocks; 56cbb9a561SDavid Woodhouse 57cbb9a561SDavid Woodhouse /* Number of free blocks there must be before we... */ 58cbb9a561SDavid Woodhouse uint8_t resv_blocks_write; /* ... allow a normal filesystem write */ 59cbb9a561SDavid Woodhouse uint8_t resv_blocks_deletion; /* ... allow a normal filesystem deletion */ 60cbb9a561SDavid Woodhouse uint8_t resv_blocks_gctrigger; /* ... wake up the GC thread */ 61cbb9a561SDavid Woodhouse uint8_t resv_blocks_gcbad; /* ... pick a block from the bad_list to GC */ 62cbb9a561SDavid Woodhouse uint8_t resv_blocks_gcmerge; /* ... merge pages when garbage collecting */ 63cbb9a561SDavid Woodhouse 64cbb9a561SDavid Woodhouse uint32_t nospc_dirty_size; 65cbb9a561SDavid Woodhouse 66cbb9a561SDavid Woodhouse uint32_t nr_blocks; 67cbb9a561SDavid Woodhouse struct jffs2_eraseblock *blocks; /* The whole array of blocks. Used for getting blocks 68cbb9a561SDavid Woodhouse * from the offset (blocks[ofs / sector_size]) */ 69cbb9a561SDavid Woodhouse struct jffs2_eraseblock *nextblock; /* The block we're currently filling */ 70cbb9a561SDavid Woodhouse 71cbb9a561SDavid Woodhouse struct jffs2_eraseblock *gcblock; /* The block we're currently garbage-collecting */ 72cbb9a561SDavid Woodhouse 73cbb9a561SDavid Woodhouse struct list_head clean_list; /* Blocks 100% full of clean data */ 74cbb9a561SDavid Woodhouse struct list_head very_dirty_list; /* Blocks with lots of dirty space */ 75cbb9a561SDavid Woodhouse struct list_head dirty_list; /* Blocks with some dirty space */ 76cbb9a561SDavid Woodhouse struct list_head erasable_list; /* Blocks which are completely dirty, and need erasing */ 77cbb9a561SDavid Woodhouse struct list_head erasable_pending_wbuf_list; /* Blocks which need erasing but only after the current wbuf is flushed */ 78cbb9a561SDavid Woodhouse struct list_head erasing_list; /* Blocks which are currently erasing */ 79cbb9a561SDavid Woodhouse struct list_head erase_pending_list; /* Blocks which need erasing now */ 80cbb9a561SDavid Woodhouse struct list_head erase_complete_list; /* Blocks which are erased and need the clean marker written to them */ 81cbb9a561SDavid Woodhouse struct list_head free_list; /* Blocks which are free and ready to be used */ 82cbb9a561SDavid Woodhouse struct list_head bad_list; /* Bad blocks. */ 83cbb9a561SDavid Woodhouse struct list_head bad_used_list; /* Bad blocks with valid data in. */ 84cbb9a561SDavid Woodhouse 85cbb9a561SDavid Woodhouse spinlock_t erase_completion_lock; /* Protect free_list and erasing_list 86cbb9a561SDavid Woodhouse against erase completion handler */ 87cbb9a561SDavid Woodhouse wait_queue_head_t erase_wait; /* For waiting for erases to complete */ 88cbb9a561SDavid Woodhouse 89cbb9a561SDavid Woodhouse wait_queue_head_t inocache_wq; 90cbb9a561SDavid Woodhouse struct jffs2_inode_cache **inocache_list; 91cbb9a561SDavid Woodhouse spinlock_t inocache_lock; 92cbb9a561SDavid Woodhouse 93cbb9a561SDavid Woodhouse /* Sem to allow jffs2_garbage_collect_deletion_dirent to 94cbb9a561SDavid Woodhouse drop the erase_completion_lock while it's holding a pointer 95cbb9a561SDavid Woodhouse to an obsoleted node. I don't like this. Alternatives welcomed. */ 96cbb9a561SDavid Woodhouse struct semaphore erase_free_sem; 97cbb9a561SDavid Woodhouse 98cbb9a561SDavid Woodhouse uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */ 99cbb9a561SDavid Woodhouse 100cbb9a561SDavid Woodhouse #ifdef CONFIG_JFFS2_FS_WRITEBUFFER 101cbb9a561SDavid Woodhouse /* Write-behind buffer for NAND flash */ 102cbb9a561SDavid Woodhouse unsigned char *wbuf; 103cbb9a561SDavid Woodhouse uint32_t wbuf_ofs; 104cbb9a561SDavid Woodhouse uint32_t wbuf_len; 105cbb9a561SDavid Woodhouse struct jffs2_inodirty *wbuf_inodes; 106cbb9a561SDavid Woodhouse 107cbb9a561SDavid Woodhouse struct rw_semaphore wbuf_sem; /* Protects the write buffer */ 108cbb9a561SDavid Woodhouse 109cbb9a561SDavid Woodhouse /* Information about out-of-band area usage... */ 110cbb9a561SDavid Woodhouse struct nand_oobinfo *oobinfo; 111cbb9a561SDavid Woodhouse uint32_t badblock_pos; 112cbb9a561SDavid Woodhouse uint32_t fsdata_pos; 113cbb9a561SDavid Woodhouse uint32_t fsdata_len; 114cbb9a561SDavid Woodhouse #endif 115cbb9a561SDavid Woodhouse 116cbb9a561SDavid Woodhouse struct jffs2_summary *summary; /* Summary information */ 117cbb9a561SDavid Woodhouse 118aa98d7cfSKaiGai Kohei #ifdef CONFIG_JFFS2_FS_XATTR 119aa98d7cfSKaiGai Kohei #define XATTRINDEX_HASHSIZE (57) 120aa98d7cfSKaiGai Kohei uint32_t highest_xid; 121aa98d7cfSKaiGai Kohei struct list_head xattrindex[XATTRINDEX_HASHSIZE]; 122aa98d7cfSKaiGai Kohei struct list_head xattr_temp; 123aa98d7cfSKaiGai Kohei struct list_head xattr_unchecked; 124aa98d7cfSKaiGai Kohei struct rw_semaphore xattr_sem; 125aa98d7cfSKaiGai Kohei uint32_t xdatum_mem_usage; 126aa98d7cfSKaiGai Kohei uint32_t xdatum_mem_threshold; 127aa98d7cfSKaiGai Kohei #endif 128cbb9a561SDavid Woodhouse /* OS-private pointer for getting back to master superblock info */ 129cbb9a561SDavid Woodhouse void *os_priv; 130cbb9a561SDavid Woodhouse }; 131cbb9a561SDavid Woodhouse 132cbb9a561SDavid Woodhouse #endif /* _JFFS2_FB_SB */ 133