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