X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_vfs_multi.c;h=1d9ca00717a5ae7ecd0b69afcab24ce041c48d48;hp=c4e3b978920d1edbe96111f8cc624cef4db3b322;hb=256ce201932cb4fb035c9996c7ae700b24818c17;hpb=3ecea787c3d99a5e13bf3b826dd3ad772fbad810 diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c index c4e3b97..1d9ca00 100644 --- a/yaffs_vfs_multi.c +++ b/yaffs_vfs_multi.c @@ -510,14 +510,14 @@ static unsigned yaffs_gc_control_callback(struct yaffs_dev *dev) static void yaffs_gross_lock(struct yaffs_dev *dev) { T(YAFFS_TRACE_LOCK, (TSTR("yaffs locking %p\n"), current)); - down(&(yaffs_dev_to_lc(dev)->gross_lock)); + mutex_lock(&(yaffs_dev_to_lc(dev)->gross_lock)); T(YAFFS_TRACE_LOCK, (TSTR("yaffs locked %p\n"), current)); } static void yaffs_gross_unlock(struct yaffs_dev *dev) { T(YAFFS_TRACE_LOCK, (TSTR("yaffs unlocking %p\n"), current)); - up(&(yaffs_dev_to_lc(dev)->gross_lock)); + mutex_unlock(&(yaffs_dev_to_lc(dev)->gross_lock)); } #ifdef YAFFS_COMPILE_EXPORTFS @@ -2334,11 +2334,13 @@ static int yaffs_bg_thread_fn(void *data) next_gc = now + HZ / 10 + 1; else next_gc = now + HZ * 2; - } else /* + } else { + /* * gc not running so set to next_dir_update * to cut down on wake ups */ next_gc = next_dir_update; + } } yaffs_gross_unlock(dev); #if 1 @@ -2511,7 +2513,7 @@ static void yaffs_read_inode(struct inode *inode) #endif static LIST_HEAD(yaffs_context_list); -struct semaphore yaffs_context_lock; +struct mutex yaffs_context_lock; static void yaffs_put_super(struct super_block *sb) { @@ -2536,9 +2538,9 @@ static void yaffs_put_super(struct super_block *sb) yaffs_gross_unlock(dev); - down(&yaffs_context_lock); + mutex_lock(&yaffs_context_lock); list_del_init(&(yaffs_dev_to_lc(dev)->context_list)); - up(&yaffs_context_lock); + mutex_unlock(&yaffs_context_lock); if (yaffs_dev_to_lc(dev)->spare_buffer) { YFREE(yaffs_dev_to_lc(dev)->spare_buffer); @@ -2605,9 +2607,9 @@ static int yaffs_parse_options(struct yaffs_options *options, options_str++; } - if (!strcmp(cur_opt, "inband-tags")) + if (!strcmp(cur_opt, "inband-tags")) { options->inband_tags = 1; - else if (!strcmp(cur_opt, "tags-ecc-off")) { + } else if (!strcmp(cur_opt, "tags-ecc-off")) { options->tags_ecc_on = 0; options->tags_ecc_overridden = 1; } else if (!strcmp(cur_opt, "tags-ecc-on")) { @@ -2625,13 +2627,13 @@ static int yaffs_parse_options(struct yaffs_options *options, } else if (!strcmp(cur_opt, "empty-lost-and-found-on")) { options->empty_lost_and_found = 1; options->empty_lost_and_found_overridden = 1; - } else if (!strcmp(cur_opt, "no-cache")) + } else if (!strcmp(cur_opt, "no-cache")) { options->no_cache = 1; - else if (!strcmp(cur_opt, "no-checkpoint-read")) + } else if (!strcmp(cur_opt, "no-checkpoint-read")) { options->skip_checkpoint_read = 1; - else if (!strcmp(cur_opt, "no-checkpoint-write")) + } else if (!strcmp(cur_opt, "no-checkpoint-write")) { options->skip_checkpoint_write = 1; - else if (!strcmp(cur_opt, "no-checkpoint")) { + } else if (!strcmp(cur_opt, "no-checkpoint")) { options->skip_checkpoint_read = 1; options->skip_checkpoint_write = 1; } else { @@ -2970,7 +2972,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, param->skip_checkpt_rd = options.skip_checkpoint_read; param->skip_checkpt_wr = options.skip_checkpoint_write; - down(&yaffs_context_lock); + mutex_lock(&yaffs_context_lock); /* Get a mount id */ found = 0; for (mount_id = 0; !found; mount_id++) { @@ -2987,13 +2989,13 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, list_add_tail(&(yaffs_dev_to_lc(dev)->context_list), &yaffs_context_list); - up(&yaffs_context_lock); + mutex_unlock(&yaffs_context_lock); /* Directory search handling... */ INIT_LIST_HEAD(&(yaffs_dev_to_lc(dev)->search_contexts)); param->remove_obj_fn = yaffs_remove_obj_callback; - init_MUTEX(&(yaffs_dev_to_lc(dev)->gross_lock)); + mutex_init(&(yaffs_dev_to_lc(dev)->gross_lock)); yaffs_gross_lock(dev); @@ -3250,7 +3252,7 @@ static int yaffs_proc_read(char *page, else { step -= 2; - down(&yaffs_context_lock); + mutex_lock(&yaffs_context_lock); /* Locate and print the Nth entry. Order N-squared but N is small. */ list_for_each(item, &yaffs_context_list) { @@ -3268,12 +3270,13 @@ static int yaffs_proc_read(char *page, sprintf(buf, "\nDevice %d \"%s\"\n", n, dev->param.name); buf = yaffs_dump_dev_part0(buf, dev); - } else + } else { buf = yaffs_dump_dev_part1(buf, dev); + } break; } - up(&yaffs_context_lock); + mutex_unlock(&yaffs_context_lock); } return buf - page < count ? buf - page : count; @@ -3287,7 +3290,7 @@ static int yaffs_stats_proc_read(char *page, char *buf = page; int n = 0; - down(&yaffs_context_lock); + mutex_lock(&yaffs_context_lock); /* Locate and print the Nth entry. Order N-squared but N is small. */ list_for_each(item, &yaffs_context_list) { @@ -3305,7 +3308,7 @@ static int yaffs_stats_proc_read(char *page, dev->bg_gcs, dev->oldest_dirty_gc_count, dev->n_obj, dev->n_tnodes); } - up(&yaffs_context_lock); + mutex_unlock(&yaffs_context_lock); return buf - page < count ? buf - page : count; } @@ -3320,35 +3323,36 @@ static struct { char *mask_name; unsigned mask_bitfield; } mask_flags[] = { - { - "allocate", YAFFS_TRACE_ALLOCATE}, { - "always", YAFFS_TRACE_ALWAYS}, { - "background", YAFFS_TRACE_BACKGROUND}, { - "bad_blocks", YAFFS_TRACE_BAD_BLOCKS}, { - "buffers", YAFFS_TRACE_BUFFERS}, { - "bug", YAFFS_TRACE_BUG}, { - "checkpt", YAFFS_TRACE_CHECKPOINT}, { - "deletion", YAFFS_TRACE_DELETION}, { - "erase", YAFFS_TRACE_ERASE}, { - "error", YAFFS_TRACE_ERROR}, { - "gc_detail", YAFFS_TRACE_GC_DETAIL}, { - "gc", YAFFS_TRACE_GC}, { - "lock", YAFFS_TRACE_LOCK}, { - "mtd", YAFFS_TRACE_MTD}, { - "nandaccess", YAFFS_TRACE_NANDACCESS}, { - "os", YAFFS_TRACE_OS}, { - "scan_debug", YAFFS_TRACE_SCAN_DEBUG}, { - "scan", YAFFS_TRACE_SCAN}, { - "tracing", YAFFS_TRACE_TRACING}, { - "sync", YAFFS_TRACE_SYNC}, { - "write", YAFFS_TRACE_WRITE}, { - "verify", YAFFS_TRACE_VERIFY}, { - "verify_nand", YAFFS_TRACE_VERIFY_NAND}, { - "verify_full", YAFFS_TRACE_VERIFY_FULL}, { - "verify_all", YAFFS_TRACE_VERIFY_ALL}, { - "all", 0xffffffff}, { - "none", 0}, { -NULL, 0},}; + {"allocate", YAFFS_TRACE_ALLOCATE}, + {"always", YAFFS_TRACE_ALWAYS}, + {"background", YAFFS_TRACE_BACKGROUND}, + {"bad_blocks", YAFFS_TRACE_BAD_BLOCKS}, + {"buffers", YAFFS_TRACE_BUFFERS}, + {"bug", YAFFS_TRACE_BUG}, + {"checkpt", YAFFS_TRACE_CHECKPOINT}, + {"deletion", YAFFS_TRACE_DELETION}, + {"erase", YAFFS_TRACE_ERASE}, + {"error", YAFFS_TRACE_ERROR}, + {"gc_detail", YAFFS_TRACE_GC_DETAIL}, + {"gc", YAFFS_TRACE_GC}, + {"lock", YAFFS_TRACE_LOCK}, + {"mtd", YAFFS_TRACE_MTD}, + {"nandaccess", YAFFS_TRACE_NANDACCESS}, + {"os", YAFFS_TRACE_OS}, + {"scan_debug", YAFFS_TRACE_SCAN_DEBUG}, + {"scan", YAFFS_TRACE_SCAN}, + {"mount", YAFFS_TRACE_MOUNT}, + {"tracing", YAFFS_TRACE_TRACING}, + {"sync", YAFFS_TRACE_SYNC}, + {"write", YAFFS_TRACE_WRITE}, + {"verify", YAFFS_TRACE_VERIFY}, + {"verify_nand", YAFFS_TRACE_VERIFY_NAND}, + {"verify_full", YAFFS_TRACE_VERIFY_FULL}, + {"verify_all", YAFFS_TRACE_VERIFY_ALL}, + {"all", 0xffffffff}, + {"none", 0}, + {NULL, 0}, +}; #define MAX_MASK_NAME_LENGTH 40 static int yaffs_proc_write_trace_options(struct file *file, const char *buf, @@ -3479,7 +3483,7 @@ static int __init init_yaffs_fs(void) (" \n\n\n\nYAFFS-WARNING CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED selected.\n\n\n\n"))); #endif - init_MUTEX(&yaffs_context_lock); + mutex_init(&yaffs_context_lock); /* Install the proc_fs entries */ my_proc_entry = create_proc_entry("yaffs", @@ -3489,8 +3493,9 @@ static int __init init_yaffs_fs(void) my_proc_entry->write_proc = yaffs_proc_write; my_proc_entry->read_proc = yaffs_proc_read; my_proc_entry->data = NULL; - } else + } else { return -ENOMEM; + } debug_proc_entry = create_proc_entry("yaffs_stats", S_IRUGO | S_IFREG, YPROC_ROOT); @@ -3499,8 +3504,9 @@ static int __init init_yaffs_fs(void) debug_proc_entry->write_proc = NULL; debug_proc_entry->read_proc = yaffs_stats_proc_read; debug_proc_entry->data = NULL; - } else + } else { return -ENOMEM; + } /* Now add the file system entries */