X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=yaffs_vfs_multi.c;h=fdb0137159aeb080809dd7501098d6119d054126;hp=acf43480b69bd13ad931be86d2e9364184f865f3;hb=80d031a7c6cbfc952e9646c5cc3c838ddb4d073f;hpb=6648cbf52d6695755941ff8607fd7a0cda542e05 diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c index acf4348..fdb0137 100644 --- a/yaffs_vfs_multi.c +++ b/yaffs_vfs_multi.c @@ -72,7 +72,9 @@ #include #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)) #include +#endif #include #include #include @@ -146,6 +148,12 @@ #define YAFFS_USE_WRITE_BEGIN_END 0 #endif + + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)) +#define set_nlink(inode, count) do { (inode)->i_nlink = (count); } while(0) +#endif + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28)) static uint32_t YCALCBLOCKS(uint64_t partition_size, uint32_t block_size) { @@ -176,7 +184,7 @@ unsigned int yaffs_wr_attempts = YAFFS_WR_ATTEMPTS; unsigned int yaffs_auto_checkpoint = 1; unsigned int yaffs_gc_control = 1; unsigned int yaffs_bg_enable = 1; - +unsigned int yaffs_auto_select = 1; /* Module Parameters */ #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) module_param(yaffs_trace_mask, uint, 0644); @@ -237,7 +245,9 @@ static int yaffs_file_flush(struct file *file, fl_owner_t id); static int yaffs_file_flush(struct file *file); #endif -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) +static int yaffs_sync_object(struct file *file, loff_t start, loff_t end, int datasync); +#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)) static int yaffs_sync_object(struct file *file, int datasync); #else static int yaffs_sync_object(struct file *file, struct dentry *dentry, @@ -307,14 +317,12 @@ static int yaffs_writepage(struct page *page, struct writeback_control *wbc); static int yaffs_writepage(struct page *page); #endif -#ifdef CONFIG_YAFFS_XATTR static int yaffs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); static ssize_t yaffs_getxattr(struct dentry *dentry, const char *name, void *buff, size_t size); static int yaffs_removexattr(struct dentry *dentry, const char *name); static ssize_t yaffs_listxattr(struct dentry *dentry, char *buff, size_t size); -#endif #if (YAFFS_USE_WRITE_BEGIN_END != 0) static int yaffs_write_begin(struct file *filp, struct address_space *mapping, @@ -409,12 +417,10 @@ static void zero_user_segment(struct page *page, unsigned start, unsigned end) static const struct inode_operations yaffs_file_inode_operations = { .setattr = yaffs_setattr, -#ifdef CONFIG_YAFFS_XATTR .setxattr = yaffs_setxattr, .getxattr = yaffs_getxattr, .listxattr = yaffs_listxattr, .removexattr = yaffs_removexattr, -#endif }; static const struct inode_operations yaffs_symlink_inode_operations = { @@ -424,12 +430,10 @@ static const struct inode_operations yaffs_symlink_inode_operations = { .put_link = yaffs_put_link, #endif .setattr = yaffs_setattr, -#ifdef CONFIG_YAFFS_XATTR .setxattr = yaffs_setxattr, .getxattr = yaffs_getxattr, .listxattr = yaffs_listxattr, .removexattr = yaffs_removexattr, -#endif }; static const struct inode_operations yaffs_dir_inode_operations = { @@ -443,12 +447,10 @@ static const struct inode_operations yaffs_dir_inode_operations = { .mknod = yaffs_mknod, .rename = yaffs_rename, .setattr = yaffs_setattr, -#ifdef CONFIG_YAFFS_XATTR .setxattr = yaffs_setxattr, .getxattr = yaffs_getxattr, .listxattr = yaffs_listxattr, .removexattr = yaffs_removexattr, -#endif }; static const struct file_operations yaffs_dir_operations = { @@ -1334,7 +1336,7 @@ static void yaffs_fill_inode_from_obj(struct inode *inode, inode->i_size = yaffs_get_obj_length(obj); inode->i_blocks = (inode->i_size + 511) >> 9; - inode->i_nlink = yaffs_get_obj_link_count(obj); + set_nlink(inode, yaffs_get_obj_link_count(obj)); yaffs_trace(YAFFS_TRACE_OS, "yaffs_fill_inode mode %x uid %d gid %d size %d count %d", @@ -1748,10 +1750,9 @@ static int yaffs_unlink(struct inode *dir, struct dentry *dentry) ret_val = yaffs_unlinker(obj, dentry->d_name.name); if (ret_val == YAFFS_OK) { - dentry->d_inode->i_nlink--; + inode_dec_link_count(dentry->d_inode); dir->i_version++; yaffs_gross_unlock(dev); - mark_inode_dirty(dentry->d_inode); update_dir_time(dir); return 0; } @@ -1783,7 +1784,7 @@ static int yaffs_link(struct dentry *old_dentry, struct inode *dir, obj); if (link) { - old_dentry->d_inode->i_nlink = yaffs_get_obj_link_count(obj); + set_nlink(old_dentry->d_inode, yaffs_get_obj_link_count(obj)); d_instantiate(dentry, old_dentry->d_inode); atomic_inc(&old_dentry->d_inode->i_count); yaffs_trace(YAFFS_TRACE_OS, @@ -1813,6 +1814,14 @@ static int yaffs_symlink(struct inode *dir, struct dentry *dentry, yaffs_trace(YAFFS_TRACE_OS, "yaffs_symlink"); + if (strnlen(dentry->d_name.name, YAFFS_MAX_NAME_LENGTH + 1) > + YAFFS_MAX_NAME_LENGTH) + return -ENAMETOOLONG; + + if (strnlen(symname, YAFFS_MAX_ALIAS_LENGTH + 1) > + YAFFS_MAX_ALIAS_LENGTH) + return -ENAMETOOLONG; + dev = yaffs_inode_to_obj(dir)->my_dev; yaffs_gross_lock(dev); obj = yaffs_create_symlink(yaffs_inode_to_obj(dir), dentry->d_name.name, @@ -1834,7 +1843,9 @@ static int yaffs_symlink(struct inode *dir, struct dentry *dentry, return -ENOMEM; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) +static int yaffs_sync_object(struct file *file, loff_t start, loff_t end, int datasync) +#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)) static int yaffs_sync_object(struct file *file, int datasync) #else static int yaffs_sync_object(struct file *file, struct dentry *dentry, @@ -1899,10 +1910,8 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, yaffs_gross_unlock(dev); if (ret_val == YAFFS_OK) { - if (target) { - new_dentry->d_inode->i_nlink--; - mark_inode_dirty(new_dentry->d_inode); - } + if (target) + inode_dec_link_count(new_dentry->d_inode); update_dir_time(old_dir); if (old_dir != new_dir) @@ -1962,7 +1971,6 @@ static int yaffs_setattr(struct dentry *dentry, struct iattr *attr) return error; } -#ifdef CONFIG_YAFFS_XATTR static int yaffs_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) { @@ -2065,7 +2073,6 @@ static ssize_t yaffs_listxattr(struct dentry * dentry, char *buff, size_t size) return error; } -#endif #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) static int yaffs_statfs(struct dentry *dentry, struct kstatfs *buf) @@ -2534,6 +2541,7 @@ struct yaffs_options { int lazy_loading_overridden; int empty_lost_and_found; int empty_lost_and_found_overridden; + int disable_summary; }; #define MAX_OPT_LEN 30 @@ -2575,6 +2583,8 @@ static int yaffs_parse_options(struct yaffs_options *options, } else if (!strcmp(cur_opt, "lazy-loading-on")) { options->lazy_loading_enabled = 1; options->lazy_loading_overridden = 1; + } else if (!strcmp(cur_opt, "disable-summary")) { + options->disable_summary = 1; } else if (!strcmp(cur_opt, "empty-lost-and-found-off")) { options->empty_lost_and_found = 0; options->empty_lost_and_found_overridden = 1; @@ -2709,9 +2719,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, yaffs_trace(YAFFS_TRACE_OS, " size %lld", mtd->size); #endif -#ifdef CONFIG_YAFFS_AUTO_YAFFS2 - - if (yaffs_version == 1 && WRITE_SIZE(mtd) >= 2048) { + if (yaffs_auto_select && yaffs_version == 1 && WRITE_SIZE(mtd) >= 2048) { yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting yaffs2"); yaffs_version = 2; } @@ -2722,7 +2730,6 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting yaffs1"); yaffs_version = 1; } -#endif if (yaffs_version == 2) { /* Check for version 2 style functions */ @@ -2839,40 +2846,18 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, param->n_caches = (options.no_cache) ? 0 : 10; param->inband_tags = options.inband_tags; -#ifdef CONFIG_YAFFS_DISABLE_LAZY_LOAD - param->disable_lazy_load = 1; -#endif -#ifdef CONFIG_YAFFS_XATTR param->enable_xattr = 1; -#endif if (options.lazy_loading_overridden) param->disable_lazy_load = !options.lazy_loading_enabled; -#ifdef CONFIG_YAFFS_DISABLE_TAGS_ECC - param->no_tags_ecc = 1; -#endif - -#ifdef CONFIG_YAFFS_DISABLE_BACKGROUND -#else param->defered_dir_update = 1; -#endif if (options.tags_ecc_overridden) param->no_tags_ecc = !options.tags_ecc_on; -#ifdef CONFIG_YAFFS_EMPTY_LOST_AND_FOUND param->empty_lost_n_found = 1; -#endif - -#ifdef CONFIG_YAFFS_DISABLE_BLOCK_REFRESHING - param->refresh_period = 0; -#else param->refresh_period = 500; -#endif - -#ifdef CONFIG_YAFFS__ALWAYS_CHECK_CHUNK_ERASED - param->always_check_erased = 1; -#endif + param->disable_summary = options.disable_summary; if (options.empty_lost_and_found_overridden) param->empty_lost_n_found = options.empty_lost_and_found; @@ -2921,13 +2906,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, yaffs_dev_to_lc(dev)->super = sb; -#ifndef CONFIG_YAFFS_DOES_ECC param->use_nand_ecc = 1; -#endif - -#ifdef CONFIG_YAFFS_DISABLE_WIDE_TNODES - param->wide_tnodes_disabled = 1; -#endif param->skip_checkpt_rd = options.skip_checkpoint_read; param->skip_checkpt_wr = options.skip_checkpoint_write; @@ -3011,7 +2990,13 @@ static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data, return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -EINVAL; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) +static struct dentry *yaffs_mount(struct file_system_type *fs_type, int flags, + const char *dev_name, void *data) +{ + return mount_bdev(fs_type, flags, dev_name, data, yaffs_internal_read_super_mtd); +} +#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) static int yaffs_read_super(struct file_system_type *fs, int flags, const char *dev_name, void *data, struct vfsmount *mnt) @@ -3034,8 +3019,12 @@ static struct super_block *yaffs_read_super(struct file_system_type *fs, static struct file_system_type yaffs_fs_type = { .owner = THIS_MODULE, .name = "yaffs", - .get_sb = yaffs_read_super, - .kill_sb = kill_block_super, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) + .mount = yaffs_mount, +#else + .get_sb = yaffs_read_super, +#endif + .kill_sb = kill_block_super, .fs_flags = FS_REQUIRES_DEV, }; #else @@ -3049,7 +3038,6 @@ static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV); #endif -#ifdef CONFIG_YAFFS_YAFFS2 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data, @@ -3058,7 +3046,13 @@ static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data, return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -EINVAL; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) +static struct dentry *yaffs2_mount(struct file_system_type *fs_type, int flags, + const char *dev_name, void *data) +{ + return mount_bdev(fs_type, flags, dev_name, data, yaffs2_internal_read_super_mtd); +} +#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) static int yaffs2_read_super(struct file_system_type *fs, int flags, const char *dev_name, void *data, struct vfsmount *mnt) @@ -3080,8 +3074,12 @@ static struct super_block *yaffs2_read_super(struct file_system_type *fs, static struct file_system_type yaffs2_fs_type = { .owner = THIS_MODULE, .name = "yaffs2", - .get_sb = yaffs2_read_super, - .kill_sb = kill_block_super, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)) + .mount = yaffs2_mount, +#else + .get_sb = yaffs2_read_super, +#endif + .kill_sb = kill_block_super, .fs_flags = FS_REQUIRES_DEV, }; #else @@ -3095,7 +3093,6 @@ static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super, FS_REQUIRES_DEV); #endif -#endif /* CONFIG_YAFFS_YAFFS2 */ static struct proc_dir_entry *my_proc_entry; @@ -3152,8 +3149,8 @@ static char *yaffs_dump_dev_part1(char *buf, struct yaffs_dev *dev) dev->oldest_dirty_gc_count); buf += sprintf(buf, "n_gc_blocks.......... %u\n", dev->n_gc_blocks); buf += sprintf(buf, "bg_gcs............... %u\n", dev->bg_gcs); - buf += sprintf(buf, "n_retired_writes..... %u\n", - dev->n_retired_writes); + buf += sprintf(buf, "n_retried_writes..... %u\n", + dev->n_retried_writes); buf += sprintf(buf, "n_retired_blocks..... %u\n", dev->n_retired_blocks); buf += sprintf(buf, "n_ecc_fixed.......... %u\n", dev->n_ecc_fixed); @@ -3168,6 +3165,8 @@ static char *yaffs_dump_dev_part1(char *buf, struct yaffs_dev *dev) dev->n_unlinked_files); buf += sprintf(buf, "refresh_count........ %u\n", dev->refresh_count); buf += sprintf(buf, "n_bg_deletions....... %u\n", dev->n_bg_deletions); + buf += sprintf(buf, "tags_used............ %u\n", dev->tags_used); + buf += sprintf(buf, "summary_used......... %u\n", dev->summary_used); return buf; } @@ -3394,12 +3393,6 @@ static int __init init_yaffs_fs(void) yaffs_trace(YAFFS_TRACE_ALWAYS, "yaffs built " __DATE__ " " __TIME__ " Installing."); -#ifdef CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED - yaffs_trace(YAFFS_TRACE_ALWAYS, - " \n\n\n\nYAFFS-WARNING CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED selected.\n\n\n\n" - ); -#endif - mutex_init(&yaffs_context_lock); /* Install the proc_fs entries */