f65e6018bf415f92736573549802995a0ec10240
[openwrt.git] / target / linux / generic / patches-3.6 / 505-yaffs-3.2_fix.patch
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 @@ -513,7 +536,7 @@ static unsigned yaffs_gc_control_callbac
40  {
41         return yaffs_gc_control;
42  }
43 -                                                                                                                       
44 +
45  static void yaffs_gross_lock(yaffs_dev_t *dev)
46  {
47         T(YAFFS_TRACE_LOCK, (TSTR("yaffs locking %p\n"), current));
48 @@ -1362,7 +1385,7 @@ static void yaffs_fill_inode_from_obj(st
49                 inode->i_size = yaffs_get_obj_length(obj);
50                 inode->i_blocks = (inode->i_size + 511) >> 9;
51  
52 -               inode->i_nlink = yaffs_get_obj_link_count(obj);
53 +               yaffs_set_nlink(inode, yaffs_get_obj_link_count(obj));
54  
55                 T(YAFFS_TRACE_OS,
56                         (TSTR("yaffs_fill_inode mode %x uid %d gid %d size %d count %d\n"),
57 @@ -1784,10 +1807,9 @@ static int yaffs_unlink(struct inode *di
58         retVal = yaffs_unlinker(obj, dentry->d_name.name);
59  
60         if (retVal == YAFFS_OK) {
61 -               dentry->d_inode->i_nlink--;
62 +               yaffs_dec_link_count(dentry->d_inode);
63                 dir->i_version++;
64                 yaffs_gross_unlock(dev);
65 -               mark_inode_dirty(dentry->d_inode);
66                 update_dir_time(dir);
67                 return 0;
68         }
69 @@ -1818,7 +1840,8 @@ static int yaffs_link(struct dentry *old
70                         obj);
71  
72         if (link) {
73 -               old_dentry->d_inode->i_nlink = yaffs_get_obj_link_count(obj);
74 +               yaffs_set_nlink(old_dentry->d_inode,
75 +                               yaffs_get_obj_link_count(obj));
76                 d_instantiate(dentry, old_dentry->d_inode);
77                 atomic_inc(&old_dentry->d_inode->i_count);
78                 T(YAFFS_TRACE_OS,
79 @@ -1937,11 +1960,9 @@ static int yaffs_rename(struct inode *ol
80         yaffs_gross_unlock(dev);
81  
82         if (retVal == YAFFS_OK) {
83 -               if (target) {
84 -                       new_dentry->d_inode->i_nlink--;
85 -                       mark_inode_dirty(new_dentry->d_inode);
86 -               }
87 -               
88 +               if (target)
89 +                       yaffs_dec_link_count(new_dentry->d_inode);
90 +
91                 update_dir_time(old_dir);
92                 if(old_dir != new_dir)
93                         update_dir_time(new_dir);
94 @@ -1961,7 +1982,7 @@ static int yaffs_setattr(struct dentry *
95                 (TSTR("yaffs_setattr of object %d\n"),
96                 yaffs_InodeToObject(inode)->obj_id));
97  
98 -       /* Fail if a requested resize >= 2GB */         
99 +       /* Fail if a requested resize >= 2GB */
100         if (attr->ia_valid & ATTR_SIZE &&
101                 (attr->ia_size >> 31))
102                 error = -EINVAL;
103 @@ -2192,7 +2213,7 @@ static void yaffs_flush_inodes(struct su
104  {
105         struct inode *iptr;
106         yaffs_obj_t *obj;
107 -       
108 +
109         list_for_each_entry(iptr,&sb->s_inodes, i_sb_list){
110                 obj = yaffs_InodeToObject(iptr);
111                 if(obj){
112 @@ -2206,10 +2227,10 @@ static void yaffs_flush_inodes(struct su
113  
114  static void yaffs_flush_super(struct super_block *sb, int do_checkpoint)
115  {
116 -       yaffs_dev_t *dev = yaffs_SuperToDevice(sb);     
117 +       yaffs_dev_t *dev = yaffs_SuperToDevice(sb);
118         if(!dev)
119                 return;
120 -       
121 +
122         yaffs_flush_inodes(sb);
123         yaffs_update_dirty_dirs(dev);
124         yaffs_flush_whole_cache(dev);
125 @@ -2277,7 +2298,7 @@ static int yaffs_do_sync_fs(struct super
126   * yaffs_bg_start() launches the background thread.
127   * yaffs_bg_stop() cleans up the background thread.
128   *
129 - * NB: 
130 + * NB:
131   * The thread should only run after the yaffs is initialised
132   * The thread should be stopped before yaffs is unmounted.
133   * The thread should not do any writing while the fs is in read only.
134 @@ -2848,7 +2869,7 @@ static struct super_block *yaffs_interna
135  
136         dev = kmalloc(sizeof(yaffs_dev_t), GFP_KERNEL);
137         context = kmalloc(sizeof(struct yaffs_LinuxContext),GFP_KERNEL);
138 -       
139 +
140         if(!dev || !context ){
141                 if(dev)
142                         kfree(dev);
143 @@ -2881,7 +2902,7 @@ static struct super_block *yaffs_interna
144  #else
145         sb->u.generic_sbp = dev;
146  #endif
147 -       
148 +
149         dev->driver_context = mtd;
150         param->name = mtd->name;
151  
152 @@ -2981,7 +3002,7 @@ static struct super_block *yaffs_interna
153         param->gc_control = yaffs_gc_control_callback;
154  
155         yaffs_dev_to_lc(dev)->superBlock= sb;
156 -       
157 +
158  
159  #ifndef CONFIG_YAFFS_DOES_ECC
160         param->use_nand_ecc = 1;
161 @@ -3023,10 +3044,10 @@ static struct super_block *yaffs_interna
162         T(YAFFS_TRACE_OS,
163           (TSTR("yaffs_read_super: guts initialised %s\n"),
164            (err == YAFFS_OK) ? "OK" : "FAILED"));
165 -          
166 +
167         if(err == YAFFS_OK)
168                 yaffs_bg_start(dev);
169 -               
170 +
171         if(!context->bgThread)
172                 param->defered_dir_update = 0;
173  
174 @@ -3282,7 +3303,7 @@ static int yaffs_proc_read(char *page,
175                                 buf = yaffs_dump_dev_part0(buf, dev);
176                         } else
177                                 buf = yaffs_dump_dev_part1(buf, dev);
178 -                       
179 +
180                         break;
181                 }
182                 mutex_unlock(&yaffs_context_lock);
183 @@ -3309,7 +3330,7 @@ static int yaffs_stats_proc_read(char *p
184                 int erasedChunks;
185  
186                 erasedChunks = dev->n_erased_blocks * dev->param.chunks_per_block;
187 -               
188 +
189                 buf += sprintf(buf,"%d, %d, %d, %u, %u, %u, %u\n",
190                                 n, dev->n_free_chunks, erasedChunks,
191                                 dev->bg_gcs, dev->oldest_dirty_gc_count,
192 --- a/fs/yaffs2/yaffs_mtdif1.c
193 +++ b/fs/yaffs2/yaffs_mtdif1.c
194 @@ -34,6 +34,7 @@
195  #include "linux/version.h"
196  #include "linux/types.h"
197  #include "linux/mtd/mtd.h"
198 +#include "mtd/mtd-abi.h"
199  
200  /* Don't compile this module if we don't have MTD's mtd_oob_ops interface */
201  #if (MTD_VERSION_CODE > MTD_VERSION(2, 6, 17))
202 @@ -127,7 +128,7 @@ int nandmtd1_WriteChunkWithTagsToNAND(ya
203  #endif
204  
205         memset(&ops, 0, sizeof(ops));
206 -       ops.mode = MTD_OOB_AUTO;
207 +       ops.mode = MTD_OPS_AUTO_OOB;
208         ops.len = (data) ? chunkBytes : 0;
209         ops.ooblen = YTAG1_SIZE;
210         ops.datbuf = (__u8 *)data;
211 @@ -179,7 +180,7 @@ int nandmtd1_ReadChunkWithTagsFromNAND(y
212         int deleted;
213  
214         memset(&ops, 0, sizeof(ops));
215 -       ops.mode = MTD_OOB_AUTO;
216 +       ops.mode = MTD_OPS_AUTO_OOB;
217         ops.len = (data) ? chunkBytes : 0;
218         ops.ooblen = YTAG1_SIZE;
219         ops.datbuf = data;
220 --- a/fs/yaffs2/yaffs_mtdif2.c
221 +++ b/fs/yaffs2/yaffs_mtdif2.c
222 @@ -21,6 +21,7 @@
223  #include "linux/mtd/mtd.h"
224  #include "linux/types.h"
225  #include "linux/time.h"
226 +#include "mtd/mtd-abi.h"
227  
228  #include "yaffs_packedtags2.h"
229  
230 @@ -71,7 +72,7 @@ int nandmtd2_WriteChunkWithTagsToNAND(ya
231                 yaffs_PackTags2(&pt, tags, !dev->param.no_tags_ecc);
232  
233  #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
234 -       ops.mode = MTD_OOB_AUTO;
235 +       ops.mode = MTD_OPS_AUTO_OOB;
236         ops.ooblen = (dev->param.inband_tags) ? 0 : packed_tags_size;
237         ops.len = dev->param.total_bytes_per_chunk;
238         ops.ooboffs = 0;
239 @@ -136,7 +137,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(y
240                 retval = mtd->read(mtd, addr, dev->param.total_bytes_per_chunk,
241                                 &dummy, data);
242         else if (tags) {
243 -               ops.mode = MTD_OOB_AUTO;
244 +               ops.mode = MTD_OPS_AUTO_OOB;
245                 ops.ooblen = packed_tags_size;
246                 ops.len = data ? dev->data_bytes_per_chunk : packed_tags_size;
247                 ops.ooboffs = 0;