X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_guts.c;h=40a5b46cf6caff782ed5bddd68430d944ba3f81f;hp=3023011612875cce3eb21618391939dbfc1e4d8a;hb=refs%2Fheads%2Fmaster;hpb=b21bef3bd5ef583feed45f0500a1058cbaa47136 diff --git a/yaffs_guts.c b/yaffs_guts.c index 3023011..b83fa63 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -163,6 +163,8 @@ u8 *yaffs_get_temp_buffer(struct yaffs_dev * dev) } +/* Frees all the temp_buffer objects in the yaffs_dev instance +*/ void yaffs_release_temp_buffer(struct yaffs_dev *dev, u8 *buffer) { int i; @@ -2471,6 +2473,8 @@ static unsigned yaffs_find_gc_block(struct yaffs_dev *dev, struct yaffs_block_info *bi; u32 threshold = dev->param.chunks_per_block; + (void) prioritised; + /* First let's see if we need to grab a prioritised block */ if (dev->has_pending_prioritised_gc && !aggressive) { dev->gc_dirtiest = 0; @@ -2725,6 +2729,7 @@ int yaffs_bg_gc(struct yaffs_dev *dev, unsigned urgency) { int erased_chunks = dev->n_erased_blocks * dev->param.chunks_per_block; + (void) urgency; yaffs_trace(YAFFS_TRACE_BACKGROUND, "Background gc %u", urgency); yaffs_check_gc(dev, 1); @@ -2759,6 +2764,7 @@ void yaffs_chunk_del(struct yaffs_dev *dev, int chunk_id, int mark_flash, struct yaffs_ext_tags tags; struct yaffs_block_info *bi; + (void) lyn; if (chunk_id <= 0) return; @@ -3013,8 +3019,10 @@ static void yaffs_check_obj_details_loaded(struct yaffs_obj *in) result = yaffs_rd_chunk_tags_nand(dev, in->hdr_chunk, buf, &tags); - if (result == YAFFS_FAIL) + if (result == YAFFS_FAIL) { + yaffs_release_temp_buffer(dev, buf); return; + } oh = (struct yaffs_obj_hdr *)buf; @@ -3197,7 +3205,6 @@ int yaffs_update_oh(struct yaffs_obj *in, const YCHAR *name, int force, bi->has_shrink_hdr = 1; } - return new_chunk_id; } @@ -4537,11 +4544,16 @@ int yaffs_guts_ll_init(struct yaffs_dev *dev) return YAFFS_FAIL; } + if (!yaffs_init_tmp_buffers(dev)) + return YAFFS_FAIL; + if (yaffs_init_nand(dev) != YAFFS_OK) { yaffs_trace(YAFFS_TRACE_ALWAYS, "InitialiseNAND failed"); return YAFFS_FAIL; } + dev->ll_init = 1; + return YAFFS_OK; } @@ -4688,15 +4700,9 @@ int yaffs_guts_initialise(struct yaffs_dev *dev) yaffs_endian_config(dev); - /* Initialise temporary buffers and caches. */ - if (!yaffs_init_tmp_buffers(dev)) - init_failed = 1; - + /* Initialise temporary caches. */ dev->gc_cleanup_list = NULL; - - dev->cache = NULL; - if (!init_failed) init_failed = yaffs_cache_init(dev) < 0; @@ -4823,6 +4829,7 @@ void yaffs_deinitialise(struct yaffs_dev *dev) kfree(dev->checkpt_block_list); dev->checkpt_block_list = NULL; + dev->ll_init = 0; dev->is_mounted = 0; yaffs_deinit_nand(dev); @@ -4860,18 +4867,12 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev) int n_free; int n_dirty_caches; int blocks_for_checkpt; - u32 i; n_free = dev->n_free_chunks; n_free += dev->n_deleted_files; /* Now count and subtract the number of dirty chunks in the cache. */ - - for (n_dirty_caches = 0, i = 0; i < dev->param.n_caches; i++) { - if (dev->cache[i].dirty) - n_dirty_caches++; - } - + n_dirty_caches = yaffs_count_dirty_caches(dev); n_free -= n_dirty_caches; n_free -= @@ -4888,6 +4889,85 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev) return n_free; } +/* + * Marshalling functions to get the appropriate time values saved + * and restored to/from obj headers. + * + * Note that the WinCE time fields are used to store the 32-bit values. + */ + +static void yaffs_oh_time_load(u32 *yst_time, u32 *win_time, YTIME_T timeval) +{ + u32 upper; + u32 lower; + + lower = timeval & 0xffffffff; + /* we have to use #defines here insted of an if statement + otherwise the compiler throws an error saying that + right shift count >= width of type when we are using 32 bit time. + */ + #ifdef CONFIG_YAFFS_USE_32_BIT_TIME_T + upper = 0; + #else + upper = (timeval >> 32) & 0xffffffff; + #endif + + *yst_time = lower; + win_time[0] = lower; + win_time[1] = upper; +} + +static YTIME_T yaffs_oh_time_fetch(const u32 *yst_time, const u32 *win_time) +{ + u32 upper; + u32 lower; + + if (win_time[1] == 0xffffffff) { + upper = 0; + lower = *yst_time; + } else { + upper = win_time[1]; + lower = win_time[0]; + } + if (sizeof(YTIME_T) > sizeof(u32)) { + u64 ret; + ret = (((u64)upper) << 32) | lower; + return (YTIME_T) ret; + + } else + return (YTIME_T) lower; +} + +YTIME_T yaffs_oh_ctime_fetch(struct yaffs_obj_hdr *oh) +{ + return yaffs_oh_time_fetch(&oh->yst_ctime, oh->win_ctime); +} + +YTIME_T yaffs_oh_mtime_fetch(struct yaffs_obj_hdr *oh) +{ + return yaffs_oh_time_fetch(&oh->yst_mtime, oh->win_mtime); +} + +YTIME_T yaffs_oh_atime_fetch(struct yaffs_obj_hdr *oh) +{ + return yaffs_oh_time_fetch(&oh->yst_atime, oh->win_atime); +} + +void yaffs_oh_ctime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh) +{ + yaffs_oh_time_load(&oh->yst_ctime, oh->win_ctime, obj->yst_ctime); +} + +void yaffs_oh_mtime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh) +{ + yaffs_oh_time_load(&oh->yst_mtime, oh->win_mtime, obj->yst_mtime); +} + +void yaffs_oh_atime_load(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh) +{ + yaffs_oh_time_load(&oh->yst_atime, oh->win_atime, obj->yst_atime); +} + /* * Marshalling functions to get loff_t file sizes into and out of