| 1 | --- a/fs/yaffs2/yaffs_vfs_glue.c |
| 2 | +++ b/fs/yaffs2/yaffs_vfs_glue.c |
| 3 | @@ -220,11 +220,34 @@ static struct inode *yaffs_iget(struct s |
| 4 | #define yaffs_SuperToDevice(sb) ((yaffs_dev_t *)sb->u.generic_sbp) |
| 5 | #endif |
| 6 | |
| 7 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0)) |
| 8 | +static inline void yaffs_set_nlink(struct inode *inode, unsigned int nlink) |
| 9 | +{ |
| 10 | + set_nlink(inode, nlink); |
| 11 | +} |
| 12 | + |
| 13 | +static inline void yaffs_dec_link_count(struct inode *inode) |
| 14 | +{ |
| 15 | + inode_dec_link_count(inode); |
| 16 | +} |
| 17 | +#else |
| 18 | +static inline void yaffs_set_nlink(struct inode *inode, unsigned int nlink) |
| 19 | +{ |
| 20 | + inode->i_nlink = nlink; |
| 21 | +} |
| 22 | + |
| 23 | +static inline void yaffs_dec_link_count(struct inode *inode) |
| 24 | +{ |
| 25 | + inode->i_nlink--; |
| 26 | + mark_inode_dirty(inode) |
| 27 | +} |
| 28 | +#endif |
| 29 | + |
| 30 | |
| 31 | #define update_dir_time(dir) do {\ |
| 32 | (dir)->i_ctime = (dir)->i_mtime = CURRENT_TIME; \ |
| 33 | } while(0) |
| 34 | - |
| 35 | + |
| 36 | static void yaffs_put_super(struct super_block *sb); |
| 37 | |
| 38 | static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, |
| 39 | @@ -238,7 +261,10 @@ static int yaffs_file_flush(struct file |
| 40 | static int yaffs_file_flush(struct file *file); |
| 41 | #endif |
| 42 | |
| 43 | -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)) |
| 44 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0)) |
| 45 | +static int yaffs_sync_object(struct file *file, loff_t start, loff_t end, |
| 46 | + int datasync); |
| 47 | +#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)) |
| 48 | static int yaffs_sync_object(struct file *file, int datasync); |
| 49 | #else |
| 50 | static int yaffs_sync_object(struct file *file, struct dentry *dentry, |
| 51 | @@ -513,7 +539,7 @@ static unsigned yaffs_gc_control_callbac |
| 52 | { |
| 53 | return yaffs_gc_control; |
| 54 | } |
| 55 | - |
| 56 | + |
| 57 | static void yaffs_gross_lock(yaffs_dev_t *dev) |
| 58 | { |
| 59 | T(YAFFS_TRACE_LOCK, (TSTR("yaffs locking %p\n"), current)); |
| 60 | @@ -1362,7 +1388,7 @@ static void yaffs_fill_inode_from_obj(st |
| 61 | inode->i_size = yaffs_get_obj_length(obj); |
| 62 | inode->i_blocks = (inode->i_size + 511) >> 9; |
| 63 | |
| 64 | - inode->i_nlink = yaffs_get_obj_link_count(obj); |
| 65 | + yaffs_set_nlink(inode, yaffs_get_obj_link_count(obj)); |
| 66 | |
| 67 | T(YAFFS_TRACE_OS, |
| 68 | (TSTR("yaffs_fill_inode mode %x uid %d gid %d size %d count %d\n"), |
| 69 | @@ -1810,10 +1836,9 @@ static int yaffs_unlink(struct inode *di |
| 70 | retVal = yaffs_unlinker(obj, dentry->d_name.name); |
| 71 | |
| 72 | if (retVal == YAFFS_OK) { |
| 73 | - dentry->d_inode->i_nlink--; |
| 74 | + yaffs_dec_link_count(dentry->d_inode); |
| 75 | dir->i_version++; |
| 76 | yaffs_gross_unlock(dev); |
| 77 | - mark_inode_dirty(dentry->d_inode); |
| 78 | update_dir_time(dir); |
| 79 | return 0; |
| 80 | } |
| 81 | @@ -1844,7 +1869,8 @@ static int yaffs_link(struct dentry *old |
| 82 | obj); |
| 83 | |
| 84 | if (link) { |
| 85 | - old_dentry->d_inode->i_nlink = yaffs_get_obj_link_count(obj); |
| 86 | + yaffs_set_nlink(old_dentry->d_inode, |
| 87 | + yaffs_get_obj_link_count(obj)); |
| 88 | d_instantiate(dentry, old_dentry->d_inode); |
| 89 | atomic_inc(&old_dentry->d_inode->i_count); |
| 90 | T(YAFFS_TRACE_OS, |
| 91 | @@ -1894,7 +1920,10 @@ static int yaffs_symlink(struct inode *d |
| 92 | return -ENOMEM; |
| 93 | } |
| 94 | |
| 95 | -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)) |
| 96 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 2, 0)) |
| 97 | +static int yaffs_sync_object(struct file *file, loff_t start, loff_t end, |
| 98 | + int datasync) |
| 99 | +#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 34)) |
| 100 | static int yaffs_sync_object(struct file *file, int datasync) |
| 101 | #else |
| 102 | static int yaffs_sync_object(struct file *file, struct dentry *dentry, |
| 103 | @@ -1961,11 +1990,9 @@ static int yaffs_rename(struct inode *ol |
| 104 | yaffs_gross_unlock(dev); |
| 105 | |
| 106 | if (retVal == YAFFS_OK) { |
| 107 | - if (target) { |
| 108 | - new_dentry->d_inode->i_nlink--; |
| 109 | - mark_inode_dirty(new_dentry->d_inode); |
| 110 | - } |
| 111 | - |
| 112 | + if (target) |
| 113 | + yaffs_dec_link_count(new_dentry->d_inode); |
| 114 | + |
| 115 | update_dir_time(old_dir); |
| 116 | if(old_dir != new_dir) |
| 117 | update_dir_time(new_dir); |
| 118 | @@ -1985,7 +2012,7 @@ static int yaffs_setattr(struct dentry * |
| 119 | (TSTR("yaffs_setattr of object %d\n"), |
| 120 | yaffs_InodeToObject(inode)->obj_id)); |
| 121 | |
| 122 | - /* Fail if a requested resize >= 2GB */ |
| 123 | + /* Fail if a requested resize >= 2GB */ |
| 124 | if (attr->ia_valid & ATTR_SIZE && |
| 125 | (attr->ia_size >> 31)) |
| 126 | error = -EINVAL; |
| 127 | @@ -2216,7 +2243,7 @@ static void yaffs_flush_inodes(struct su |
| 128 | { |
| 129 | struct inode *iptr; |
| 130 | yaffs_obj_t *obj; |
| 131 | - |
| 132 | + |
| 133 | list_for_each_entry(iptr,&sb->s_inodes, i_sb_list){ |
| 134 | obj = yaffs_InodeToObject(iptr); |
| 135 | if(obj){ |
| 136 | @@ -2230,10 +2257,10 @@ static void yaffs_flush_inodes(struct su |
| 137 | |
| 138 | static void yaffs_flush_super(struct super_block *sb, int do_checkpoint) |
| 139 | { |
| 140 | - yaffs_dev_t *dev = yaffs_SuperToDevice(sb); |
| 141 | + yaffs_dev_t *dev = yaffs_SuperToDevice(sb); |
| 142 | if(!dev) |
| 143 | return; |
| 144 | - |
| 145 | + |
| 146 | yaffs_flush_inodes(sb); |
| 147 | yaffs_update_dirty_dirs(dev); |
| 148 | yaffs_flush_whole_cache(dev); |
| 149 | @@ -2301,7 +2328,7 @@ static int yaffs_do_sync_fs(struct super |
| 150 | * yaffs_bg_start() launches the background thread. |
| 151 | * yaffs_bg_stop() cleans up the background thread. |
| 152 | * |
| 153 | - * NB: |
| 154 | + * NB: |
| 155 | * The thread should only run after the yaffs is initialised |
| 156 | * The thread should be stopped before yaffs is unmounted. |
| 157 | * The thread should not do any writing while the fs is in read only. |
| 158 | @@ -2872,7 +2899,7 @@ static struct super_block *yaffs_interna |
| 159 | |
| 160 | dev = kmalloc(sizeof(yaffs_dev_t), GFP_KERNEL); |
| 161 | context = kmalloc(sizeof(struct yaffs_LinuxContext),GFP_KERNEL); |
| 162 | - |
| 163 | + |
| 164 | if(!dev || !context ){ |
| 165 | if(dev) |
| 166 | kfree(dev); |
| 167 | @@ -2905,7 +2932,7 @@ static struct super_block *yaffs_interna |
| 168 | #else |
| 169 | sb->u.generic_sbp = dev; |
| 170 | #endif |
| 171 | - |
| 172 | + |
| 173 | dev->driver_context = mtd; |
| 174 | param->name = mtd->name; |
| 175 | |
| 176 | @@ -3005,7 +3032,7 @@ static struct super_block *yaffs_interna |
| 177 | param->gc_control = yaffs_gc_control_callback; |
| 178 | |
| 179 | yaffs_dev_to_lc(dev)->superBlock= sb; |
| 180 | - |
| 181 | + |
| 182 | |
| 183 | #ifndef CONFIG_YAFFS_DOES_ECC |
| 184 | param->use_nand_ecc = 1; |
| 185 | @@ -3047,10 +3074,10 @@ static struct super_block *yaffs_interna |
| 186 | T(YAFFS_TRACE_OS, |
| 187 | (TSTR("yaffs_read_super: guts initialised %s\n"), |
| 188 | (err == YAFFS_OK) ? "OK" : "FAILED")); |
| 189 | - |
| 190 | + |
| 191 | if(err == YAFFS_OK) |
| 192 | yaffs_bg_start(dev); |
| 193 | - |
| 194 | + |
| 195 | if(!context->bgThread) |
| 196 | param->defered_dir_update = 0; |
| 197 | |
| 198 | @@ -3125,7 +3152,7 @@ static struct dentry *yaffs2_read_super( |
| 199 | void *data) |
| 200 | { |
| 201 | return mount_bdev(fs, flags, dev_name, data, |
| 202 | - yaffs_internal_read_super_mtd); |
| 203 | + yaffs2_internal_read_super_mtd); |
| 204 | } |
| 205 | |
| 206 | static struct file_system_type yaffs2_fs_type = { |
| 207 | @@ -3223,7 +3250,7 @@ static int yaffs_proc_read(char *page, |
| 208 | buf += sprintf(buf,"\n"); |
| 209 | else { |
| 210 | step-=2; |
| 211 | - |
| 212 | + |
| 213 | down(&yaffs_context_lock); |
| 214 | |
| 215 | /* Locate and print the Nth entry. Order N-squared but N is small. */ |
| 216 | @@ -3240,7 +3267,7 @@ static int yaffs_proc_read(char *page, |
| 217 | buf = yaffs_dump_dev_part0(buf, dev); |
| 218 | } else |
| 219 | buf = yaffs_dump_dev_part1(buf, dev); |
| 220 | - |
| 221 | + |
| 222 | break; |
| 223 | } |
| 224 | up(&yaffs_context_lock); |
| 225 | @@ -3267,7 +3294,7 @@ static int yaffs_stats_proc_read(char *p |
| 226 | int erasedChunks; |
| 227 | |
| 228 | erasedChunks = dev->n_erased_blocks * dev->param.chunks_per_block; |
| 229 | - |
| 230 | + |
| 231 | buf += sprintf(buf,"%d, %d, %d, %u, %u, %u, %u\n", |
| 232 | n, dev->n_free_chunks, erasedChunks, |
| 233 | dev->bg_gcs, dev->oldest_dirty_gc_count, |
| 234 | --- a/fs/yaffs2/yaffs_mtdif1.c |
| 235 | +++ b/fs/yaffs2/yaffs_mtdif1.c |
| 236 | @@ -34,6 +34,7 @@ |
| 237 | #include "linux/version.h" |
| 238 | #include "linux/types.h" |
| 239 | #include "linux/mtd/mtd.h" |
| 240 | +#include "mtd/mtd-abi.h" |
| 241 | |
| 242 | /* Don't compile this module if we don't have MTD's mtd_oob_ops interface */ |
| 243 | #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17)) |
| 244 | @@ -127,7 +128,7 @@ int nandmtd1_WriteChunkWithTagsToNAND(ya |
| 245 | #endif |
| 246 | |
| 247 | memset(&ops, 0, sizeof(ops)); |
| 248 | - ops.mode = MTD_OOB_AUTO; |
| 249 | + ops.mode = MTD_OPS_AUTO_OOB; |
| 250 | ops.len = (data) ? chunkBytes : 0; |
| 251 | ops.ooblen = YTAG1_SIZE; |
| 252 | ops.datbuf = (__u8 *)data; |
| 253 | @@ -179,7 +180,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(y |
| 254 | int deleted; |
| 255 | |
| 256 | memset(&ops, 0, sizeof(ops)); |
| 257 | - ops.mode = MTD_OOB_AUTO; |
| 258 | + ops.mode = MTD_OPS_AUTO_OOB; |
| 259 | ops.len = (data) ? chunkBytes : 0; |
| 260 | ops.ooblen = YTAG1_SIZE; |
| 261 | ops.datbuf = data; |
| 262 | --- a/fs/yaffs2/yaffs_mtdif2.c |
| 263 | +++ b/fs/yaffs2/yaffs_mtdif2.c |
| 264 | @@ -21,6 +21,7 @@ |
| 265 | #include "linux/mtd/mtd.h" |
| 266 | #include "linux/types.h" |
| 267 | #include "linux/time.h" |
| 268 | +#include "mtd/mtd-abi.h" |
| 269 | |
| 270 | #include "yaffs_packedtags2.h" |
| 271 | |
| 272 | @@ -71,7 +72,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(ya |
| 273 | yaffs_PackTags2(&pt, tags, !dev->param.no_tags_ecc); |
| 274 | |
| 275 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 276 | - ops.mode = MTD_OOB_AUTO; |
| 277 | + ops.mode = MTD_OPS_AUTO_OOB; |
| 278 | ops.ooblen = (dev->param.inband_tags) ? 0 : packed_tags_size; |
| 279 | ops.len = dev->param.total_bytes_per_chunk; |
| 280 | ops.ooboffs = 0; |
| 281 | @@ -136,7 +137,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(y |
| 282 | retval = mtd->read(mtd, addr, dev->param.total_bytes_per_chunk, |
| 283 | &dummy, data); |
| 284 | else if (tags) { |
| 285 | - ops.mode = MTD_OOB_AUTO; |
| 286 | + ops.mode = MTD_OPS_AUTO_OOB; |
| 287 | ops.ooblen = packed_tags_size; |
| 288 | ops.len = data ? dev->data_bytes_per_chunk : packed_tags_size; |
| 289 | ops.ooboffs = 0; |
| 290 | |