X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=yaffs_yaffs2.c;h=17b9210d7c9755a18d40e15460ff35e251a9d22c;hb=refs%2Fheads%2Fclean-up;hp=5761e960e646c816c0628a2c7b64470bb55c04f1;hpb=d7388fb75a13610d14d0afc397f826bd44c972e1;p=yaffs2.git diff --git a/yaffs_yaffs2.c b/yaffs_yaffs2.c index 5761e96..17b9210 100644 --- a/yaffs_yaffs2.c +++ b/yaffs_yaffs2.c @@ -29,7 +29,7 @@ * the partition is at least this big. */ #define YAFFS_CHECKPOINT_MIN_BLOCKS 60 -#define YAFFS_SMALL_HOLE_THRESHOLD 4 +#define YAFFS_SMALL_HOLE_BLOCKS 4 /* * Oldest Dirty Sequence Number handling. @@ -41,7 +41,7 @@ */ void yaffs_calc_oldest_dirty_seq(struct yaffs_dev *dev) { - int i; + u32 i; unsigned seq; unsigned block_no = 0; struct yaffs_block_info *b; @@ -55,7 +55,7 @@ void yaffs_calc_oldest_dirty_seq(struct yaffs_dev *dev) for (i = dev->internal_start_block; i <= dev->internal_end_block; i++) { if (b->block_state == YAFFS_BLOCK_STATE_FULL && (b->pages_in_use - b->soft_del_pages) < - dev->param.chunks_per_block && + (int)dev->param.chunks_per_block && b->seq_number < seq) { seq = b->seq_number; block_no = i; @@ -309,7 +309,7 @@ static void yaffs_checkpt_dev_to_dev(struct yaffs_dev *dev, static int yaffs2_wr_checkpt_dev(struct yaffs_dev *dev) { struct yaffs_checkpt_dev cp; - u32 n_bytes; + int n_bytes; u32 n_blocks = dev->internal_end_block - dev->internal_start_block + 1; int ok; @@ -337,7 +337,7 @@ static int yaffs2_wr_checkpt_dev(struct yaffs_dev *dev) static int yaffs2_rd_checkpt_dev(struct yaffs_dev *dev) { struct yaffs_checkpt_dev cp; - u32 n_bytes; + int n_bytes; u32 n_blocks = (dev->internal_end_block - dev->internal_start_block + 1); int ok; @@ -473,7 +473,7 @@ static int yaffs2_checkpt_tnode_worker(struct yaffs_obj *in, sizeof(base_offset)); if (ok) ok = (yaffs2_checkpt_wr(dev, tn, dev->tnode_size) == - dev->tnode_size); + (int)dev->tnode_size); return ok; } @@ -516,7 +516,7 @@ static int yaffs2_rd_checkpt_tnodes(struct yaffs_obj *obj) tn = yaffs_get_tnode(dev); if (tn) ok = (yaffs2_checkpt_rd(dev, tn, dev->tnode_size) == - dev->tnode_size); + (int)dev->tnode_size); else ok = 0; @@ -606,7 +606,7 @@ static int yaffs2_rd_checkpt_objs(struct yaffs_dev *dev) cp.obj_id, cp.parent_id, cp.variant_type, cp.hdr_chunk); - if (ok && cp.obj_id == ~0) { + if (ok && cp.obj_id == (u32)(~0)) { done = 1; } else if (ok) { obj = @@ -836,7 +836,7 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size) * of hole marker. */ loff_t old_file_size; - int increase; + loff_t increase; int small_hole; int result = YAFFS_OK; struct yaffs_dev *dev = NULL; @@ -862,8 +862,9 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size) increase = new_size - old_file_size; - if (increase < YAFFS_SMALL_HOLE_THRESHOLD * dev->data_bytes_per_chunk && - yaffs_check_alloc_available(dev, YAFFS_SMALL_HOLE_THRESHOLD + 1)) + if (increase < + (loff_t)(YAFFS_SMALL_HOLE_BLOCKS * dev->data_bytes_per_chunk) && + yaffs_check_alloc_available(dev, YAFFS_SMALL_HOLE_BLOCKS + 1)) small_hole = 1; else small_hole = 0; @@ -873,7 +874,7 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size) if (local_buffer) { /* fill hole with zero bytes */ - int pos = old_file_size; + loff_t pos = old_file_size; int this_write; int written; memset(local_buffer, 0, dev->data_bytes_per_chunk); @@ -881,7 +882,7 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size) while (increase > 0 && small_increase_ok) { this_write = increase; - if (this_write > dev->data_bytes_per_chunk) + if (this_write > (int)dev->data_bytes_per_chunk) this_write = dev->data_bytes_per_chunk; written = yaffs_do_file_wr(obj, local_buffer, pos, this_write, @@ -942,11 +943,10 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, struct yaffs_obj *in; struct yaffs_obj *parent; int equiv_id; - int file_size; + loff_t file_size; int is_shrink; int is_unlinked; struct yaffs_ext_tags tags; - int result; int alloc_failed = 0; int chunk = blk * dev->param.chunks_per_block + chunk_in_block; struct yaffs_file_var *file_var; @@ -954,12 +954,12 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, struct yaffs_symlink_var *sl_var; if (summary_available) { - result = yaffs_summary_fetch(dev, &tags, chunk_in_block); + yaffs_summary_fetch(dev, &tags, chunk_in_block); tags.seq_number = bi->seq_number; } if (!summary_available || tags.obj_id == 0) { - result = yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags); + yaffs_rd_chunk_tags_nand(dev, chunk, NULL, &tags); dev->tags_used++; } else { dev->summary_used++; @@ -1034,8 +1034,8 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, dev->n_free_chunks++; } else if (tags.chunk_id > 0) { /* chunk_id > 0 so it is a data chunk... */ - unsigned int endpos; - u32 chunk_base = (tags.chunk_id - 1) * + loff_t endpos; + loff_t chunk_base = (tags.chunk_id - 1) * dev->data_bytes_per_chunk; *found_chunks = 1; @@ -1114,7 +1114,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, * invalid data until needed. */ - result = yaffs_rd_chunk_tags_nand(dev, + yaffs_rd_chunk_tags_nand(dev, chunk, chunk_data, NULL); @@ -1157,9 +1157,9 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, (tags.extra_available && tags.extra_obj_type == YAFFS_OBJECT_TYPE_FILE) )) { - u32 this_size = (oh) ? - oh->file_size : - tags.extra_length; + loff_t this_size = (oh) ? + yaffs_oh_to_size(oh) : + tags.extra_file_size; u32 parent_obj_id = (oh) ? oh->parent_obj_id : tags.extra_parent_id; @@ -1193,12 +1193,14 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, } if (!in->valid && in->variant_type != - (oh ? oh->type : tags.extra_obj_type)) + (oh ? oh->type : tags.extra_obj_type)) { yaffs_trace(YAFFS_TRACE_ERROR, - "yaffs tragedy: Bad object type, %d != %d, for object %d at chunk %d during scan", + "yaffs tragedy: Bad type, %d != %d, for object %d at chunk %d during scan", oh ? oh->type : tags.extra_obj_type, in->variant_type, tags.obj_id, chunk); + in = yaffs_retype_obj(in, oh ? oh->type : tags.extra_obj_type); + } if (!in->valid && (tags.obj_id == YAFFS_OBJECTID_ROOT || @@ -1233,7 +1235,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, parent = yaffs_find_or_create_by_number(dev, oh->parent_obj_id, YAFFS_OBJECT_TYPE_DIRECTORY); - file_size = oh->file_size; + file_size = yaffs_oh_to_size(oh); is_shrink = oh->is_shrink; equiv_id = oh->equiv_id; } else { @@ -1241,7 +1243,7 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, parent = yaffs_find_or_create_by_number(dev, tags.extra_parent_id, YAFFS_OBJECT_TYPE_DIRECTORY); - file_size = tags.extra_length; + file_size = tags.extra_file_size; is_shrink = tags.extra_is_shrink; equiv_id = tags.extra_equiv_id; in->lazy_loaded = 1; @@ -1342,14 +1344,13 @@ static inline int yaffs2_scan_chunk(struct yaffs_dev *dev, int yaffs2_scan_backwards(struct yaffs_dev *dev) { - int blk; + u32 blk; int block_iter; int start_iter; int end_iter; int n_to_scan = 0; enum yaffs_block_state state; int c; - int deleted; LIST_HEAD(hard_list); struct yaffs_block_info *bi; u32 seq_number; @@ -1439,7 +1440,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev) bi++; } - yaffs_trace(YAFFS_TRACE_SCAN, "%d blocks to be sorted...", n_to_scan); + yaffs_trace(YAFFS_TRACE_ALWAYS, "%d blocks to be sorted...", n_to_scan); cond_resched(); @@ -1467,13 +1468,12 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev) /* get the block to scan in the correct order */ blk = block_index[block_iter].block; bi = yaffs_get_block_info(dev, blk); - deleted = 0; summary_available = yaffs_summary_read(dev, dev->sum_tags, blk); /* For each chunk in each block that needs scanning.... */ found_chunks = 0; - if(summary_available) + if (summary_available) c = dev->chunks_per_summary - 1; else c = dev->param.chunks_per_block - 1;