- int isMounted;
-
- // Stuff to support block offsetting to support start block zero
- int internalStartBlock;
- int internalEndBlock;
- int blockOffset;
- int chunkOffset;
-
- // Block Info
- yaffs_BlockInfo *blockInfo;
- __u8 *chunkBits; // bitmap of chunks in use
- int chunkBitmapStride; // Number of bytes of chunkBits per block.
- // Must be consistent with nChunksPerBlock.
-
- int nErasedBlocks;
- int allocationBlock; // Current block being allocated off
- __u32 allocationPage;
- int allocationBlockFinder; // Used to search for next allocation block
-
- // Runtime state
- int nTnodesCreated;
- yaffs_Tnode *freeTnodes;
- int nFreeTnodes;
- yaffs_TnodeList *allocatedTnodeList;
-
- int isDoingGC;
-
- int nObjectsCreated;
- yaffs_Object *freeObjects;
- int nFreeObjects;
-
- yaffs_ObjectList *allocatedObjectList;
-
- yaffs_ObjectBucket objectBucket[YAFFS_NOBJECT_BUCKETS];
-
- int nFreeChunks;
-
- int currentDirtyChecker; // Used to find current dirtiest block
-
- __u32 *gcCleanupList; // objects to delete at the end of a GC.
-
- // Operations since mount
- int nPageWrites;
- int nPageReads;
- int nBlockErasures;
- int nErasureFailures;
- int nGCCopies;
- int garbageCollections;
- int passiveGarbageCollections;
- int nRetriedWrites;
- int nRetiredBlocks;
- int eccFixed;
- int eccUnfixed;
- int tagsEccFixed;
- int tagsEccUnfixed;
- int nDeletions;
- int nUnmarkedDeletions;
-
- yaffs_Object *rootDir;
- yaffs_Object *lostNFoundDir;
-
- // Buffer areas for storing data to recover from write failures TODO
- // __u8 bufferedData[YAFFS_CHUNKS_PER_BLOCK][YAFFS_BYTES_PER_CHUNK];
- // yaffs_Spare bufferedSpare[YAFFS_CHUNKS_PER_BLOCK];
-
- int bufferedBlock; // Which block is buffered here?
- int doingBufferedBlockRewrite;
+ struct ylist_head dev_list;
+
+ /* Runtime parameters. Set up by YAFFS. */
+ int data_bytes_per_chunk;
+
+ /* Non-wide tnode stuff */
+ __u16 chunk_grp_bits; /* Number of bits that need to be resolved if
+ * the tnodes are not wide enough.
+ */
+ __u16 chunk_grp_size; /* == 2^^chunk_grp_bits */
+
+ /* Stuff to support wide tnodes */
+ __u32 tnode_width;
+ __u32 tnode_mask;
+ __u32 tnode_size;
+
+ /* Stuff for figuring out file offset to chunk conversions */
+ __u32 chunk_shift; /* Shift value */
+ __u32 chunk_div; /* Divisor after shifting: 1 for power-of-2 sizes */
+ __u32 chunk_mask; /* Mask to use for power-of-2 case */
+
+
+
+ int is_mounted;
+ int read_only;
+ int is_checkpointed;
+
+
+ /* Stuff to support block offsetting to support start block zero */
+ int internal_start_block;
+ int internal_end_block;
+ int block_offset;
+ int chunk_offset;
+
+
+ /* Runtime checkpointing stuff */
+ int checkpt_page_seq; /* running sequence number of checkpoint pages */
+ int checkpt_byte_count;
+ int checkpt_byte_offs;
+ __u8 *checkpt_buffer;
+ int checkpt_open_write;
+ int blocks_in_checkpt;
+ int checkpt_cur_chunk;
+ int checkpt_cur_block;
+ int checkpt_next_block;
+ int *checkpt_block_list;
+ int checkpt_max_blocks;
+ __u32 checkpt_sum;
+ __u32 checkpt_xor;
+
+ int checkpoint_blocks_required; /* Number of blocks needed to store current checkpoint set */
+
+ /* Block Info */
+ yaffs_block_info_t *block_info;
+ __u8 *chunk_bits; /* bitmap of chunks in use */
+ unsigned block_info_alt:1; /* was allocated using alternative strategy */
+ unsigned chunk_bits_alt:1; /* was allocated using alternative strategy */
+ int chunk_bit_stride; /* Number of bytes of chunk_bits per block.
+ * Must be consistent with chunks_per_block.
+ */
+
+ int n_erased_blocks;
+ int alloc_block; /* Current block being allocated off */
+ __u32 alloc_page;
+ int alloc_block_finder; /* Used to search for next allocation block */
+
+ /* Object and Tnode memory management */
+ void *allocator;
+ int n_obj;
+ int n_tnodes;
+
+ int n_hardlinks;
+
+ yaffs_obj_bucket obj_bucket[YAFFS_NOBJECT_BUCKETS];
+ __u32 bucket_finder;
+
+ int n_free_chunks;
+
+ /* Garbage collection control */
+ __u32 *gc_cleanup_list; /* objects to delete at the end of a GC. */
+ __u32 n_clean_ups;
+
+ unsigned has_pending_prioritised_gc; /* We think this device might have pending prioritised gcs */
+ unsigned gc_disable;
+ unsigned gc_block_finder;
+ unsigned gc_dirtiest;
+ unsigned gc_pages_in_use;
+ unsigned gc_not_done;
+ unsigned gc_block;
+ unsigned gc_chunk;
+ unsigned gc_skip;
+
+ /* Special directories */
+ yaffs_obj_t *root_dir;
+ yaffs_obj_t *lost_n_found;
+
+ /* Buffer areas for storing data to recover from write failures TODO
+ * __u8 buffered_data[YAFFS_CHUNKS_PER_BLOCK][YAFFS_BYTES_PER_CHUNK];
+ * yaffs_spare buffered_spare[YAFFS_CHUNKS_PER_BLOCK];
+ */
+
+ int buffered_block; /* Which block is buffered here? */
+ int doing_buffered_block_rewrite;
+
+ yaffs_cache_t *cache;
+ int cache_last_use;
+
+ /* Stuff for background deletion and unlinked files.*/
+ yaffs_obj_t *unlinked_dir; /* Directory where unlinked and deleted files live. */
+ yaffs_obj_t *del_dir; /* Directory where deleted objects are sent to disappear. */
+ yaffs_obj_t *unlinked_deletion; /* Current file being background deleted.*/
+ int n_deleted_files; /* Count of files awaiting deletion;*/
+ int n_unlinked_files; /* Count of unlinked files. */
+ int n_bg_deletions; /* Count of background deletions. */
+
+ /* Temporary buffer management */
+ yaffs_buffer_t temp_buffer[YAFFS_N_TEMP_BUFFERS];
+ int max_temp;
+ int temp_in_use;
+ int unmanaged_buffer_allocs;
+ int unmanaged_buffer_deallocs;
+
+ /* yaffs2 runtime stuff */
+ unsigned seq_number; /* Sequence number of currently allocating block */
+ unsigned oldest_dirty_seq;
+ unsigned oldest_dirty_block;
+
+ /* Block refreshing */
+ int refresh_skip; /* A skip down counter. Refresh happens when this gets to zero. */
+
+ /* Dirty directory handling */
+ struct ylist_head dirty_dirs; /* List of dirty directories */
+
+
+ /* Statistcs */
+ __u32 n_page_writes;
+ __u32 n_page_reads;
+ __u32 n_erasures;
+ __u32 n_erase_failures;
+ __u32 n_gc_copies;
+ __u32 all_gcs;
+ __u32 passive_gc_count;
+ __u32 oldest_dirty_gc_count;
+ __u32 n_gc_blocks;
+ __u32 bg_gcs;
+ __u32 n_retired_writes;
+ __u32 n_retired_blocks;
+ __u32 n_ecc_fixed;
+ __u32 n_ecc_unfixed;
+ __u32 n_tags_ecc_fixed;
+ __u32 n_tags_ecc_unfixed;
+ __u32 n_deletions;
+ __u32 n_unmarked_deletions;
+ __u32 refresh_count;
+ __u32 cache_hits;
+
+};
+
+typedef struct yaffs_dev_s yaffs_dev_t;
+
+/* The static layout of block usage etc is stored in the super block header */
+typedef struct {
+ int StructType;
+ int version;
+ int checkpt_start_block;
+ int checkpt_end_block;
+ int start_block;
+ int end_block;
+ int rfu[100];
+} yaffs_sb_header;
+
+/* The CheckpointDevice structure holds the device information that changes at runtime and
+ * must be preserved over unmount/mount cycles.
+ */
+typedef struct {
+ int struct_type;
+ int n_erased_blocks;
+ int alloc_block; /* Current block being allocated off */
+ __u32 alloc_page;
+ int n_free_chunks;