Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_nointent-2.6-fc5.patch
1 Index: linux-2.6.16.i686/net/unix/af_unix.c
2 ===================================================================
3 --- linux-2.6.16.i686.orig/net/unix/af_unix.c   2006-03-20 13:53:29.000000000 +0800
4 +++ linux-2.6.16.i686/net/unix/af_unix.c        2006-05-30 22:27:40.000000000 +0800
5 @@ -673,6 +673,7 @@
6         int err = 0;
7         
8         if (sunname->sun_path[0]) {
9 +               intent_init(&nd.intent, IT_LOOKUP);
10                 err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd);
11                 if (err)
12                         goto fail;
13 Index: linux-2.6.16.i686/fs/open.c
14 ===================================================================
15 --- linux-2.6.16.i686.orig/fs/open.c    2006-05-30 22:10:06.000000000 +0800
16 +++ linux-2.6.16.i686/fs/open.c 2006-05-30 22:27:40.000000000 +0800
17 @@ -197,9 +197,10 @@
18  }
19  
20  int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
21 -       struct file *filp)
22 +       struct file *filp, int called_from_open)
23  {
24         int err;
25 +       struct inode_operations *op = dentry->d_inode->i_op;
26         struct iattr newattrs;
27  
28         /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
29 @@ -214,7 +215,17 @@
30         }
31  
32         mutex_lock(&dentry->d_inode->i_mutex);
33 -       err = notify_change(dentry, &newattrs);
34 +       if (called_from_open)
35 +                newattrs.ia_valid |= ATTR_FROM_OPEN;
36 +        if (op->setattr_raw) {
37 +                newattrs.ia_valid |= ATTR_RAW;
38 +                newattrs.ia_ctime = CURRENT_TIME;
39 +                down_write(&dentry->d_inode->i_alloc_sem);
40 +                err = op->setattr_raw(dentry->d_inode, &newattrs);
41 +                up_write(&dentry->d_inode->i_alloc_sem);
42 +        } else
43 +                err = notify_change(dentry, &newattrs);
44 +
45         mutex_unlock(&dentry->d_inode->i_mutex);
46         return err;
47  }
48 @@ -269,7 +280,7 @@
49         error = locks_verify_truncate(inode, NULL, length);
50         if (!error) {
51                 DQUOT_INIT(inode);
52 -               error = do_truncate(nd.dentry, length, 0, NULL);
53 +               error = do_truncate(nd.dentry, length, 0, NULL, 0);
54         }
55         put_write_access(inode);
56  
57 @@ -321,7 +332,7 @@
58  
59         error = locks_verify_truncate(inode, file, length);
60         if (!error)
61 -               error = do_truncate(dentry, length, 0, file);
62 +               error = do_truncate(dentry, length, 0, file, 0);
63  out_putf:
64         fput(file);
65  out:
66 @@ -406,9 +417,20 @@
67                     (error = vfs_permission(&nd, MAY_WRITE)) != 0)
68                         goto dput_and_out;
69         }
70 -       mutex_lock(&inode->i_mutex);
71 -       error = notify_change(nd.dentry, &newattrs);
72 -       mutex_unlock(&inode->i_mutex);
73 +       if (inode->i_op->setattr_raw) {
74 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
75
76 +               newattrs.ia_valid |= ATTR_RAW;
77 +               error = op->setattr_raw(inode, &newattrs);
78 +               /* the file system wants to use normal vfs path now */
79 +               if (error != -EOPNOTSUPP)
80 +                       goto dput_and_out;
81 +       } else {
82 +               mutex_lock(&inode->i_mutex);
83 +               error = notify_change(nd.dentry, &newattrs);
84 +               mutex_unlock(&inode->i_mutex);
85 +       }
86 +
87  dput_and_out:
88         path_release(&nd);
89  out:
90 @@ -623,77 +645,74 @@
91  }
92  
93  EXPORT_SYMBOL_GPL(sys_chroot);
94 -
95 -asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
96 +  
97 +int chmod_common(struct dentry *dentry, mode_t mode)
98  {
99 -       struct inode * inode;
100 -       struct dentry * dentry;
101 -       struct file * file;
102 -       int err = -EBADF;
103 -       struct iattr newattrs;
104 -
105 -       file = fget(fd);
106 -       if (!file)
107 -               goto out;
108 -
109 -       dentry = file->f_dentry;
110 -       inode = dentry->d_inode;
111 -
112 -       err = -EROFS;
113 -       if (IS_RDONLY(inode))
114 -               goto out_putf;
115 -       err = -EPERM;
116 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
117 -               goto out_putf;
118 +       struct inode * inode = dentry->d_inode;
119 +       struct iattr newattrs;
120 +       int error = -EROFS;
121 +  
122 +       if (IS_RDONLY(inode))
123 +               goto out;
124 +       
125 +       if (inode->i_op->setattr_raw) {
126 +               struct inode_operations *op = dentry->d_inode->i_op;
127
128 +               newattrs.ia_mode = mode;
129 +               newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
130 +               newattrs.ia_valid |= ATTR_RAW;
131 +               error = op->setattr_raw(inode, &newattrs);
132 +               /* the file system wants to use normal vfs path now */
133 +               if (error != -EOPNOTSUPP)
134 +                       goto out;
135 +       }
136 +  
137 +       error = -EPERM;
138 +       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
139 +               goto out;
140
141         mutex_lock(&inode->i_mutex);
142 -       if (mode == (mode_t) -1)
143 -               mode = inode->i_mode;
144 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
145 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
146 -       err = notify_change(dentry, &newattrs);
147 +       if (mode == (mode_t) -1)
148 +               mode = inode->i_mode;
149 +       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
150 +       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
151 +       error = notify_change(dentry, &newattrs);
152         mutex_unlock(&inode->i_mutex);
153 +out:
154 +       return error;
155 +}
156  
157 -out_putf:
158 -       fput(file);
159 +asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
160 +{
161 +       struct file * file;
162 +       int err = -EBADF;
163
164 +       file = fget(fd);
165 +       if (!file)
166 +               goto out;
167
168 +       err = chmod_common(file->f_dentry, mode);
169 +       fput(file);
170  out:
171 -       return err;
172 +       return err;
173  }
174  
175  asmlinkage long sys_fchmodat(int dfd, const char __user *filename,
176                              mode_t mode)
177  {
178         struct nameidata nd;
179 -       struct inode * inode;
180         int error;
181 -       struct iattr newattrs;
182  
183         error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
184         if (error)
185                 goto out;
186 -       inode = nd.dentry->d_inode;
187 -
188 -       error = -EROFS;
189 -       if (IS_RDONLY(inode))
190 -               goto dput_and_out;
191 -
192 -       error = -EPERM;
193 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
194 -               goto dput_and_out;
195 -
196 -       mutex_lock(&inode->i_mutex);
197 -       if (mode == (mode_t) -1)
198 -               mode = inode->i_mode;
199 -       newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
200 -       newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
201 -       error = notify_change(nd.dentry, &newattrs);
202 -       mutex_unlock(&inode->i_mutex);
203 -
204 -dput_and_out:
205 -       path_release(&nd);
206 +       error = chmod_common(nd.dentry, mode);
207 +       path_release(&nd);
208  out:
209 -       return error;
210 +       return error;
211  }
212  
213 +
214  asmlinkage long sys_chmod(const char __user *filename, mode_t mode)
215  {
216         return sys_fchmodat(AT_FDCWD, filename, mode);
217 @@ -714,6 +733,18 @@
218         if (IS_RDONLY(inode))
219                 goto out;
220         error = -EPERM;
221 +       if (inode->i_op->setattr_raw) {
222 +               struct inode_operations *op = dentry->d_inode->i_op;
223 +
224 +               newattrs.ia_uid = user;
225 +               newattrs.ia_gid = group;
226 +               newattrs.ia_valid = ATTR_UID | ATTR_GID | ATTR_CTIME;
227 +               newattrs.ia_valid |= ATTR_RAW;
228 +               error = op->setattr_raw(inode, &newattrs);
229 +               /* the file system wants to use normal vfs path now */
230 +               if (error != -EOPNOTSUPP)
231 +                       return error;
232 +       }
233         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
234                 goto out;
235         newattrs.ia_valid =  ATTR_CTIME;
236 Index: linux-2.6.16.i686/fs/namei.c
237 ===================================================================
238 --- linux-2.6.16.i686.orig/fs/namei.c   2006-05-30 22:24:53.000000000 +0800
239 +++ linux-2.6.16.i686/fs/namei.c        2006-05-30 22:27:51.000000000 +0800
240 @@ -1644,7 +1644,7 @@
241                 if (!error) {
242                         DQUOT_INIT(inode);
243                         
244 -                       error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME, NULL);
245 +                       error = do_truncate(dentry, 0, ATTR_MTIME|ATTR_CTIME, NULL, 1);
246                 }
247                 put_write_access(inode);
248                 if (error)
249 @@ -1912,6 +1912,7 @@
250         char * tmp;
251         struct dentry * dentry;
252         struct nameidata nd;
253 +       intent_init(&nd.intent, IT_LOOKUP);
254  
255         if (S_ISDIR(mode))
256                 return -EPERM;
257 @@ -1922,6 +1923,15 @@
258         error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd);
259         if (error)
260                 goto out;
261 +
262 +       if (nd.dentry->d_inode->i_op->mknod_raw) {
263 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
264 +               error = op->mknod_raw(&nd, mode, dev);
265 +               /* the file system wants to use normal vfs path now */
266 +               if (error != -EOPNOTSUPP)
267 +                       goto out2;
268 +       }
269 +
270         dentry = lookup_create(&nd, 0);
271         error = PTR_ERR(dentry);
272  
273 @@ -1948,6 +1958,7 @@
274                 dput(dentry);
275         }
276         mutex_unlock(&nd.dentry->d_inode->i_mutex);
277 +out2:
278         path_release(&nd);
279  out:
280         putname(tmp);
281 @@ -1993,9 +2004,18 @@
282                 struct dentry *dentry;
283                 struct nameidata nd;
284  
285 +               intent_init(&nd.intent, IT_LOOKUP);
286                 error = do_path_lookup(dfd, tmp, LOOKUP_PARENT, &nd);
287                 if (error)
288                         goto out;
289 +               if (nd.dentry->d_inode->i_op->mkdir_raw) {
290 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
291 +                       error = op->mkdir_raw(&nd, mode);
292 +                       /* the file system wants to use normal vfs path now */
293 +                       if (error != -EOPNOTSUPP)
294 +                               goto out2;
295 +               }
296 +
297                 dentry = lookup_create(&nd, 1);
298                 error = PTR_ERR(dentry);
299                 if (!IS_ERR(dentry)) {
300 @@ -2005,6 +2025,7 @@
301                         dput(dentry);
302                 }
303                 mutex_unlock(&nd.dentry->d_inode->i_mutex);
304 +out2:
305                 path_release(&nd);
306  out:
307                 putname(tmp);
308 @@ -2085,6 +2106,7 @@
309         char * name;
310         struct dentry *dentry;
311         struct nameidata nd;
312 +       intent_init(&nd.intent, IT_LOOKUP);
313  
314         name = getname(pathname);
315         if(IS_ERR(name))
316 @@ -2105,6 +2127,14 @@
317                         error = -EBUSY;
318                         goto exit1;
319         }
320 +       if (nd.dentry->d_inode->i_op->rmdir_raw) {
321 +                struct inode_operations *op = nd.dentry->d_inode->i_op;
322 +
323 +                error = op->rmdir_raw(&nd);
324 +                /* the file system wants to use normal vfs path now */
325 +                if (error != -EOPNOTSUPP)
326 +                        goto exit1;
327 +        }
328         mutex_lock(&nd.dentry->d_inode->i_mutex);
329         dentry = lookup_hash(&nd);
330         error = PTR_ERR(dentry);
331 @@ -2168,6 +2198,7 @@
332         struct dentry *dentry;
333         struct nameidata nd;
334         struct inode *inode = NULL;
335 +       intent_init(&nd.intent, IT_LOOKUP);
336  
337         name = getname(pathname);
338         if(IS_ERR(name))
339 @@ -2179,6 +2210,13 @@
340         error = -EISDIR;
341         if (nd.last_type != LAST_NORM)
342                 goto exit1;
343 +       if (nd.dentry->d_inode->i_op->unlink_raw) {
344 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
345 +               error = op->unlink_raw(&nd);
346 +                /* the file system wants to use normal vfs path now */
347 +               if (error != -EOPNOTSUPP)
348 +                       goto exit1;
349 +        }
350         mutex_lock(&nd.dentry->d_inode->i_mutex);
351         dentry = lookup_hash(&nd);
352         error = PTR_ERR(dentry);
353 @@ -2261,9 +2299,17 @@
354                 struct dentry *dentry;
355                 struct nameidata nd;
356  
357 +               intent_init(&nd.intent, IT_LOOKUP);
358                 error = do_path_lookup(newdfd, to, LOOKUP_PARENT, &nd);
359                 if (error)
360                         goto out;
361 +               if (nd.dentry->d_inode->i_op->symlink_raw) {
362 +                       struct inode_operations *op = nd.dentry->d_inode->i_op;
363 +                       error = op->symlink_raw(&nd, from);
364 +                       /* the file system wants to use normal vfs path now */
365 +                       if (error != -EOPNOTSUPP)
366 +                               goto out2;
367 +               }
368                 dentry = lookup_create(&nd, 0);
369                 error = PTR_ERR(dentry);
370                 if (!IS_ERR(dentry)) {
371 @@ -2271,6 +2317,7 @@
372                         dput(dentry);
373                 }
374                 mutex_unlock(&nd.dentry->d_inode->i_mutex);
375 +out2:          
376                 path_release(&nd);
377  out:
378                 putname(to);
379 @@ -2358,6 +2405,13 @@
380         error = -EXDEV;
381         if (old_nd.mnt != nd.mnt)
382                 goto out_release;
383 +       if (nd.dentry->d_inode->i_op->link_raw) {
384 +               struct inode_operations *op = nd.dentry->d_inode->i_op;
385 +               error = op->link_raw(&old_nd, &nd);
386 +               /* the file system wants to use normal vfs path now */
387 +               if (error != -EOPNOTSUPP)
388 +                       goto out_release;
389 +       }
390         new_dentry = lookup_create(&nd, 0);
391         error = PTR_ERR(new_dentry);
392         if (!IS_ERR(new_dentry)) {
393 @@ -2534,6 +2588,8 @@
394         struct dentry * old_dentry, *new_dentry;
395         struct dentry * trap;
396         struct nameidata oldnd, newnd;
397 +       intent_init(&oldnd.intent, IT_LOOKUP);
398 +       intent_init(&newnd.intent, IT_LOOKUP);
399  
400         error = do_path_lookup(olddfd, oldname, LOOKUP_PARENT, &oldnd);
401         if (error)
402 @@ -2556,6 +2612,13 @@
403         if (newnd.last_type != LAST_NORM)
404                 goto exit2;
405  
406 +       if (old_dir->d_inode->i_op->rename_raw) {
407 +               error = old_dir->d_inode->i_op->rename_raw(&oldnd, &newnd);
408 +               /* the file system wants to use normal vfs path now */
409 +               if (error != -EOPNOTSUPP)
410 +                       goto exit2;
411 +       }
412 +
413         trap = lock_rename(new_dir, old_dir);
414  
415         old_dentry = lookup_hash(&oldnd);
416 @@ -2587,8 +2650,7 @@
417         if (new_dentry == trap)
418                 goto exit5;
419  
420 -       error = vfs_rename(old_dir->d_inode, old_dentry,
421 -                                  new_dir->d_inode, new_dentry);
422 +       error = vfs_rename(old_dir->d_inode, old_dentry, new_dir->d_inode, new_dentry);
423  exit5:
424         dput(new_dentry);
425  exit4:
426 Index: linux-2.6.16.i686/fs/exec.c
427 ===================================================================
428 --- linux-2.6.16.i686.orig/fs/exec.c    2006-05-30 21:33:00.000000000 +0800
429 +++ linux-2.6.16.i686/fs/exec.c 2006-05-30 22:27:40.000000000 +0800
430 @@ -1517,7 +1517,7 @@
431                 goto close_fail;
432         if (!file->f_op->write)
433                 goto close_fail;
434 -       if (do_truncate(file->f_dentry, 0, 0, file) != 0)
435 +       if (do_truncate(file->f_dentry, 0, 0, file, 0) != 0)
436                 goto close_fail;
437  
438         retval = binfmt->core_dump(signr, regs, file);
439 Index: linux-2.6.16.i686/include/linux/fs.h
440 ===================================================================
441 --- linux-2.6.16.i686.orig/include/linux/fs.h   2006-05-30 21:33:00.000000000 +0800
442 +++ linux-2.6.16.i686/include/linux/fs.h        2006-05-30 22:27:40.000000000 +0800
443 @@ -1035,13 +1035,20 @@
444         int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
445         struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
446         int (*link) (struct dentry *,struct inode *,struct dentry *);
447 +       int (*link_raw) (struct nameidata *,struct nameidata *);
448         int (*unlink) (struct inode *,struct dentry *);
449 +       int (*unlink_raw) (struct nameidata *);
450         int (*symlink) (struct inode *,struct dentry *,const char *);
451 +       int (*symlink_raw) (struct nameidata *,const char *);
452         int (*mkdir) (struct inode *,struct dentry *,int);
453 +       int (*mkdir_raw) (struct nameidata *,int);
454         int (*rmdir) (struct inode *,struct dentry *);
455 +       int (*rmdir_raw) (struct nameidata *);
456         int (*mknod) (struct inode *,struct dentry *,int,dev_t);
457 +       int (*mknod_raw) (struct nameidata *,int,dev_t);
458         int (*rename) (struct inode *, struct dentry *,
459                         struct inode *, struct dentry *);
460 +       int (*rename_raw) (struct nameidata *, struct nameidata *);
461         int (*readlink) (struct dentry *, char __user *,int);
462         void * (*follow_link) (struct dentry *, struct nameidata *);
463         void (*put_link) (struct dentry *, struct nameidata *, void *);
464 @@ -1351,7 +1358,7 @@
465  /* fs/open.c */
466  
467  extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
468 -                      struct file *filp);
469 +                      struct file *filp, int called_from_open);
470  extern long do_sys_open(int fdf, const char __user *filename, int flags,
471                         int mode);
472  extern struct file *filp_open(const char *, int, int);