Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_intent-2.6-suse.patch
1 Index: linux-2.6.5-12.1/fs/exec.c
2 ===================================================================
3 --- linux-2.6.5-12.1.orig/fs/exec.c     2004-05-10 19:21:56.000000000 +0300
4 +++ linux-2.6.5-12.1/fs/exec.c  2004-05-25 17:32:14.038494200 +0300
5 @@ -125,9 +125,10 @@
6         struct nameidata nd;
7         int error;
8  
9 -       nd.intent.open.flags = FMODE_READ;
10 +       intent_init(&nd.intent, IT_OPEN);
11  
12 -       FSHOOK_BEGIN_USER_WALK(open,
13 +       nd.intent.it_flags = FMODE_READ;
14 +       FSHOOK_BEGIN_USER_WALK_IT(open,
15                 error,
16                 library,
17                 LOOKUP_FOLLOW|LOOKUP_OPEN,
18 @@ -144,7 +145,7 @@
19                 goto out;
20         }
21  
22 -       file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
23 +       file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
24         error = PTR_ERR(file);
25         if (IS_ERR(file))
26                 goto out;
27 @@ -495,8 +496,9 @@
28  
29         FSHOOK_BEGIN(open, err, .filename = name, .flags = O_RDONLY)
30  
31 -       nd.intent.open.flags = FMODE_READ;
32 -       err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
33 +       intent_init(&nd.intent, IT_OPEN);
34 +       nd.intent.it_flags = FMODE_READ;
35 +       err = path_lookup(name, LOOKUP_FOLLOW, &nd);
36         file = ERR_PTR(err);
37  
38         if (!err) {
39 @@ -509,7 +511,7 @@
40                                 err = -EACCES;
41                         file = ERR_PTR(err);
42                         if (!err) {
43 -                               file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
44 +                               file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
45                                 if (!IS_ERR(file)) {
46                                         err = deny_write_access(file);
47                                         if (err) {
48 Index: linux-2.6.5-12.1/fs/namei.c
49 ===================================================================
50 --- linux-2.6.5-12.1.orig/fs/namei.c    2004-05-10 19:21:56.000000000 +0300
51 +++ linux-2.6.5-12.1/fs/namei.c 2004-05-25 17:32:14.040493896 +0300
52 @@ -270,8 +270,19 @@
53         return 0;
54  }
55  
56 +void intent_release(struct lookup_intent *it)
57 +{
58 +       if (!it)
59 +               return;
60 +       if (it->it_magic != INTENT_MAGIC)
61 +               return;
62 +       if (it->it_op_release)
63 +               it->it_op_release(it);
64 +}
65 +
66  void path_release(struct nameidata *nd)
67  {
68 +       intent_release(&nd->intent);
69         dput(nd->dentry);
70         mntput(nd->mnt);
71  }
72 @@ -348,7 +359,10 @@
73  {
74         struct dentry * result;
75         struct inode *dir = parent->d_inode;
76 +       int counter = 0;
77  
78 +again:
79 +       counter++;
80         down(&dir->i_sem);
81         /*
82          * First re-do the cached lookup just in case it was created
83 @@ -387,7 +401,10 @@
84         if (result->d_op && result->d_op->d_revalidate) {
85                 if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) {
86                         dput(result);
87 -                       result = ERR_PTR(-ENOENT);
88 +                       if (counter > 10)
89 +                               result = ERR_PTR(-ESTALE);
90 +                       if (!IS_ERR(result))
91 +                               goto again;
92                 }
93         }
94         return result;
95 @@ -564,6 +581,33 @@
96         return PTR_ERR(dentry);
97  }
98  
99 +static int revalidate_special(struct nameidata *nd)
100 +{
101 +       struct dentry *dentry = nd->dentry;
102 +       int err, counter = 0;
103 +
104 + revalidate_again:
105 +       if (!dentry->d_op || !dentry->d_op->d_revalidate)
106 +               return 0;
107 +       if (!dentry->d_op->d_revalidate(dentry, nd)) {
108 +               struct dentry *new;
109 +               if ((err = permission(dentry->d_parent->d_inode, MAY_EXEC, nd)))
110 +                       return err;
111 +               new = real_lookup(dentry->d_parent, &dentry->d_name, nd);
112 +               if (IS_ERR(new))
113 +                       return PTR_ERR(new);
114 +               d_invalidate(dentry);
115 +               dput(dentry);
116 +               nd->dentry = dentry = new;
117 +               counter++;
118 +               if (counter < 10)
119 +                       goto revalidate_again;
120 +               printk("excessive revalidate_it loops\n");
121 +               return -ESTALE;
122 +       }
123 +       return 0;
124 +}
125 +
126  /*
127   * Name resolution.
128   *
129 @@ -664,7 +708,9 @@
130  
131                 if (inode->i_op->follow_link) {
132                         mntget(next.mnt);
133 +                       nd->flags |= LOOKUP_LINK_NOTLAST;
134                         err = do_follow_link(next.dentry, nd);
135 +                       nd->flags &= ~LOOKUP_LINK_NOTLAST;
136                         dput(next.dentry);
137                         mntput(next.mnt);
138                         if (err)
139 @@ -703,14 +749,29 @@
140                                 inode = nd->dentry->d_inode;
141                                 /* fallthrough */
142                         case 1:
143 +                               nd->flags |= LOOKUP_LAST;
144 +                               err = revalidate_special(nd);
145 +                               nd->flags &= ~LOOKUP_LAST;
146 +                               if (err)
147 +                                       break;
148                                 goto return_reval;
149                 }
150 +               
151 +               if (err) {
152 +                       if (!nd->dentry->d_inode)
153 +                               err = -ENOENT;
154 +                       
155 +                       goto return_err;                        
156 +               }
157 +               
158                 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) {
159                         err = nd->dentry->d_op->d_hash(nd->dentry, &this);
160                         if (err < 0)
161                                 break;
162                 }
163 +               nd->flags |= LOOKUP_LAST;
164                 err = do_lookup(nd, &this, &next);
165 +               nd->flags &= ~LOOKUP_LAST;
166                 if (err)
167                         break;
168                 follow_mount(&next.mnt, &next.dentry);
169 @@ -936,7 +997,7 @@
170  }
171  
172  /* SMP-safe */
173 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
174 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct nameidata *nd)
175  {
176         unsigned long hash;
177         struct qstr this;
178 @@ -956,11 +1017,16 @@
179         }
180         this.hash = end_name_hash(hash);
181  
182 -       return lookup_hash(&this, base);
183 +       return __lookup_hash(&this, base, nd);
184  access:
185         return ERR_PTR(-EACCES);
186  }
187  
188 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
189 +{
190 +       return lookup_one_len_it(name, base, len, NULL);
191 +}
192 +
193  /*
194   *     namei()
195   *
196 @@ -972,7 +1038,8 @@
197   * that namei follows links, while lnamei does not.
198   * SMP-safe
199   */
200 -int fastcall __user_walk(const char __user *name, unsigned flags, struct nameidata *nd, const char **pname)
201 +int fastcall __user_walk_it(const char __user *name, unsigned flags,
202 +                           struct nameidata *nd, const char **pname)
203  {
204         char *tmp = getname(name);
205         int err = PTR_ERR(tmp);
206 @@ -987,6 +1054,13 @@
207         return err;
208  }
209  
210 +int __user_walk(const char __user *name, unsigned flags,
211 +               struct nameidata *nd, const char **pname)
212 +{
213 +       intent_init(&nd->intent, IT_LOOKUP);
214 +       return __user_walk_it(name, flags, nd, pname);
215 +}
216 +
217  /*
218   * It's inline, so penalty for filesystems that don't use sticky bit is
219   * minimal.
220 @@ -1259,8 +1333,8 @@
221                 acc_mode |= MAY_APPEND;
222  
223         /* Fill in the open() intent data */
224 -       nd->intent.open.flags = flag;
225 -       nd->intent.open.create_mode = mode;
226 +       nd->intent.it_flags = flag;
227 +       nd->intent.it_create_mode = mode;
228  
229         /*
230          * The simplest case - just a plain lookup.
231 @@ -1275,6 +1349,7 @@
232         /*
233          * Create - we need to know the parent.
234          */
235 +       nd->intent.it_op |= IT_CREAT;
236         error = path_lookup(pathname, LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE, nd);
237         if (error)
238                 return error;
239 @@ -1291,7 +1366,9 @@
240         dir = nd->dentry;
241         nd->flags &= ~LOOKUP_PARENT;
242         down(&dir->d_inode->i_sem);
243 +       nd->flags |= LOOKUP_LAST;
244         dentry = __lookup_hash(&nd->last, nd->dentry, nd);
245 +       nd->flags &= ~LOOKUP_LAST;
246  
247  do_last:
248         error = PTR_ERR(dentry);
249 @@ -1396,7 +1473,9 @@
250         }
251         dir = nd->dentry;
252         down(&dir->d_inode->i_sem);
253 +       nd->flags |= LOOKUP_LAST;
254         dentry = __lookup_hash(&nd->last, nd->dentry, nd);
255 +       nd->flags &= ~LOOKUP_LAST;
256         putname(nd->last.name);
257         goto do_last;
258  }
259 @@ -2196,7 +2275,9 @@
260  __vfs_follow_link(struct nameidata *nd, const char *link)
261  {
262         int res = 0;
263 +       struct lookup_intent it = nd->intent;
264         char *name;
265 +
266         if (IS_ERR(link))
267                 goto fail;
268  
269 @@ -2206,6 +2287,10 @@
270                         /* weird __emul_prefix() stuff did it */
271                         goto out;
272         }
273 +
274 +       intent_init(&nd->intent, it.it_op);
275 +       nd->intent.it_flags = it.it_flags;
276 +       nd->intent.it_create_mode = it.it_create_mode;
277         res = link_path_walk(link, nd);
278  out:
279         if (current->link_count || res || nd->last_type!=LAST_NORM)
280 Index: linux-2.6.5-12.1/fs/namespace.c
281 ===================================================================
282 --- linux-2.6.5-12.1.orig/fs/namespace.c        2004-05-10 19:21:56.000000000 +0300
283 +++ linux-2.6.5-12.1/fs/namespace.c     2004-05-25 17:33:44.385759328 +0300
284 @@ -108,6 +108,7 @@
285  
286  static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
287  {
288 +       memset(old_nd, 0, sizeof(*old_nd));
289         old_nd->dentry = mnt->mnt_mountpoint;
290         old_nd->mnt = mnt->mnt_parent;
291         mnt->mnt_parent = mnt;
292 @@ -533,6 +534,8 @@
293                 return err;
294         if (!old_name || !*old_name)
295                 return -EINVAL;
296 +
297 +       intent_init(&old_nd.intent, IT_LOOKUP);
298         err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
299         if (err)
300                 return err;
301 @@ -601,6 +604,7 @@
302                 return -EPERM;
303         if (!old_name || !*old_name)
304                 return -EINVAL;
305 +       intent_init(&old_nd.intent, IT_LOOKUP);
306         err = path_lookup(old_name, LOOKUP_FOLLOW, &old_nd);
307         if (err)
308                 return err;
309 @@ -750,6 +754,7 @@
310         int retval = 0;
311         int mnt_flags = 0;
312  
313 +       intent_init(&nd.intent, IT_LOOKUP);
314         /* Discard magic */
315         if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
316                 flags &= ~MS_MGC_MSK;
317 Index: linux-2.6.5-12.1/fs/open.c
318 ===================================================================
319 --- linux-2.6.5-12.1.orig/fs/open.c     2004-05-10 19:21:56.000000000 +0300
320 +++ linux-2.6.5-12.1/fs/open.c  2004-05-25 17:32:14.042493592 +0300
321 @@ -227,12 +227,12 @@
322         struct nameidata nd;
323         struct inode * inode;
324         int error;
325 -
326 +       intent_init(&nd.intent, IT_GETATTR);
327         error = -EINVAL;
328         if (length < 0) /* sorry, but loff_t says... */
329                 goto out;
330  
331 -       FSHOOK_BEGIN_USER_PATH_WALK(truncate, error, path, nd, filename, .length = length)
332 +       FSHOOK_BEGIN_USER_PATH_WALK_IT(truncate, error, path, nd, filename, .length = length)
333  
334         inode = nd.dentry->d_inode;
335  
336 @@ -466,6 +466,7 @@
337         int old_fsuid, old_fsgid;
338         kernel_cap_t old_cap;
339         int res;
340 +       intent_init(&nd.intent, IT_GETATTR);
341  
342         if (mode & ~S_IRWXO)    /* where's F_OK, X_OK, W_OK, R_OK? */
343                 return -EINVAL;
344 @@ -490,7 +491,7 @@
345         else
346                 current->cap_effective = current->cap_permitted;
347  
348 -       FSHOOK_BEGIN_USER_WALK(access,
349 +       FSHOOK_BEGIN_USER_WALK_IT(access,
350                 res,
351                 filename,
352                 LOOKUP_FOLLOW|LOOKUP_ACCESS,
353 @@ -506,6 +507,7 @@
354                 if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
355                    && !special_file(nd.dentry->d_inode->i_mode))
356                         res = -EROFS;
357 +
358                 path_release(&nd);
359  
360         FSHOOK_END_USER_WALK(access, res, path)
361 @@ -545,11 +547,13 @@
362  
363  asmlinkage long sys_fchdir(unsigned int fd)
364  {
365 +       struct nameidata nd;
366         struct file *file;
367         struct dentry *dentry;
368         struct inode *inode;
369         struct vfsmount *mnt;
370         int error;
371 +       intent_init(&nd.intent, IT_GETATTR);
372  
373         FSHOOK_BEGIN(fchdir, error, .fd = fd)
374  
375 @@ -582,8 +586,9 @@
376  {
377         struct nameidata nd;
378         int error;
379 +       intent_init(&nd.intent, IT_GETATTR);
380  
381 -       FSHOOK_BEGIN_USER_WALK(chroot,
382 +       FSHOOK_BEGIN_USER_WALK_IT(chroot,
383                 error,
384                 filename,
385                 LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT,
386 @@ -670,7 +675,7 @@
387         error = -EROFS;
388         if (IS_RDONLY(inode))
389                 goto dput_and_out;
390 -
391 +       
392         error = -EPERM;
393         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
394                 goto dput_and_out;
395 @@ -804,27 +809,8 @@
396   * for the internal routines (ie open_namei()/follow_link() etc). 00 is
397   * used by symlinks.
398   */
399 -struct file *filp_open(const char * filename, int flags, int mode)
400 -{
401 -       int namei_flags, error;
402 -       struct nameidata nd;
403 -
404 -       namei_flags = flags;
405 -       if ((namei_flags+1) & O_ACCMODE)
406 -               namei_flags++;
407 -       if (namei_flags & O_TRUNC)
408 -               namei_flags |= 2;
409 -
410 -       error = open_namei(filename, namei_flags, mode, &nd);
411 -       if (!error)
412 -               return dentry_open(nd.dentry, nd.mnt, flags);
413 -
414 -       return ERR_PTR(error);
415 -}
416 -
417 -EXPORT_SYMBOL(filp_open);
418 -
419 -struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
420 +struct file *dentry_open_it(struct dentry *dentry, struct vfsmount *mnt, int flags,
421 +                           struct lookup_intent *it)
422  {
423         struct file * f;
424         struct inode *inode;
425 @@ -836,6 +822,7 @@
426                 goto cleanup_dentry;
427         f->f_flags = flags;
428         f->f_mode = (flags+1) & O_ACCMODE;
429 +       f->f_it = it;
430         inode = dentry->d_inode;
431         if (f->f_mode & FMODE_WRITE) {
432                 error = get_write_access(inode);
433 @@ -855,6 +842,7 @@
434                 error = f->f_op->open(inode,f);
435                 if (error)
436                         goto cleanup_all;
437 +               intent_release(it);
438         }
439         f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
440  
441 @@ -879,6 +867,7 @@
442  cleanup_file:
443         put_filp(f);
444  cleanup_dentry:
445 +       intent_release(it);
446         dput(dentry);
447         mntput(mnt);
448         return ERR_PTR(error);
449 @@ -886,6 +875,36 @@
450  
451  EXPORT_SYMBOL(dentry_open);
452  
453 +struct file *filp_open(const char * filename, int flags, int mode)
454 +{
455 +       int namei_flags, error;
456 +       struct file * temp_filp;
457 +       struct nameidata nd;
458 +       intent_init(&nd.intent, IT_OPEN);
459 +
460 +       namei_flags = flags;
461 +       if ((namei_flags+1) & O_ACCMODE)
462 +               namei_flags++;
463 +       if (namei_flags & O_TRUNC)
464 +               namei_flags |= 2;
465 +
466 +       error = open_namei(filename, namei_flags, mode, &nd);
467 +       if (!error) {
468 +               temp_filp = dentry_open_it(nd.dentry, nd.mnt, flags, &nd.intent);
469 +               return temp_filp;
470 +       }       
471 +       return ERR_PTR(error);
472 +}
473 +
474 +
475 +struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
476 +{
477 +       struct lookup_intent it;
478 +       intent_init(&it, IT_LOOKUP);
479 +
480 +       return dentry_open_it(dentry, mnt, flags, &it);
481 +}
482 +
483  /*
484   * Find an empty file descriptor entry, and mark it busy.
485   */
486 Index: linux-2.6.5-12.1/fs/stat.c
487 ===================================================================
488 --- linux-2.6.5-12.1.orig/fs/stat.c     2004-05-10 19:21:56.000000000 +0300
489 +++ linux-2.6.5-12.1/fs/stat.c  2004-05-25 17:32:14.042493592 +0300
490 @@ -37,7 +37,7 @@
491  
492  EXPORT_SYMBOL(generic_fillattr);
493  
494 -int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
495 +int vfs_getattr_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat *stat)
496  {
497         struct inode *inode = dentry->d_inode;
498         int retval;
499 @@ -46,6 +46,8 @@
500         if (retval)
501                 return retval;
502  
503 +       if (inode->i_op->getattr_it)
504 +               return inode->i_op->getattr_it(mnt, dentry, it, stat);
505         if (inode->i_op->getattr)
506                 return inode->i_op->getattr(mnt, dentry, stat);
507  
508 @@ -62,14 +64,20 @@
509  
510  EXPORT_SYMBOL(vfs_getattr);
511  
512 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
513 +{
514 +       return vfs_getattr_it(mnt, dentry, NULL, stat);
515 +}
516 +
517  int vfs_stat(char __user *name, struct kstat *stat)
518  {
519         struct nameidata nd;
520         int error;
521 +       intent_init(&nd.intent, IT_GETATTR);
522  
523 -       FSHOOK_BEGIN_USER_PATH_WALK(stat, error, name, nd, path, .link = false)
524 +       FSHOOK_BEGIN_USER_PATH_WALK_IT(stat, error, name, nd, path, .link = false)
525  
526 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
527 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
528                 path_release(&nd);
529  
530         FSHOOK_END_USER_WALK(stat, error, path)
531 @@ -83,10 +91,11 @@
532  {
533         struct nameidata nd;
534         int error;
535 +       intent_init(&nd.intent, IT_GETATTR);
536  
537 -       FSHOOK_BEGIN_USER_PATH_WALK_LINK(stat, error, name, nd, path, .link = true)
538 +       FSHOOK_BEGIN_USER_PATH_WALK_LINK_IT(stat, error, name, nd, path, .link = true)
539  
540 -               error = vfs_getattr(nd.mnt, nd.dentry, stat);
541 +               error = vfs_getattr_it(nd.mnt, nd.dentry, &nd.intent, stat);
542                 path_release(&nd);
543  
544         FSHOOK_END_USER_WALK(stat, error, path)
545 @@ -99,6 +108,8 @@
546  int vfs_fstat(unsigned int fd, struct kstat *stat)
547  {
548         int error;
549 +       struct nameidata nd;
550 +       intent_init(&nd.intent, IT_GETATTR);
551  
552         FSHOOK_BEGIN(fstat, error, .fd = fd)
553  
554 @@ -106,7 +117,8 @@
555  
556         error = -EBADF;
557         if (f) {
558 -               error = vfs_getattr(f->f_vfsmnt, f->f_dentry, stat);
559 +               error = vfs_getattr_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
560 +               intent_release(&nd.intent);
561                 fput(f);
562         }
563  
564 Index: linux-2.6.5-12.1/fs/nfs/dir.c
565 ===================================================================
566 --- linux-2.6.5-12.1.orig/fs/nfs/dir.c  2004-05-10 19:21:53.000000000 +0300
567 +++ linux-2.6.5-12.1/fs/nfs/dir.c       2004-05-25 17:32:14.043493440 +0300
568 @@ -709,7 +709,7 @@
569                 return 0;
570         if (!nd || (nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_CREATE))
571                 return 0;
572 -       return (nd->intent.open.flags & O_EXCL) != 0;
573 +       return (nd->intent.it_flags & O_EXCL) != 0;
574  }
575  
576  static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
577 @@ -1026,7 +1026,7 @@
578         attr.ia_valid = ATTR_MODE;
579  
580         if (nd && (nd->flags & LOOKUP_CREATE))
581 -               open_flags = nd->intent.open.flags;
582 +               open_flags = nd->intent.it_flags;
583  
584         /*
585          * The 0 argument passed into the create function should one day
586 Index: linux-2.6.5-12.1/fs/inode.c
587 ===================================================================
588 --- linux-2.6.5-12.1.orig/fs/inode.c    2004-05-10 19:21:56.000000000 +0300
589 +++ linux-2.6.5-12.1/fs/inode.c 2004-05-25 17:32:14.044493288 +0300
590 @@ -221,6 +221,7 @@
591         inodes_stat.nr_unused--;
592  }
593  
594 +EXPORT_SYMBOL(__iget);
595  /**
596   * clear_inode - clear an inode
597   * @inode: inode to clear
598 Index: linux-2.6.5-12.1/fs/super.c
599 ===================================================================
600 --- linux-2.6.5-12.1.orig/fs/super.c    2004-05-10 19:21:56.000000000 +0300
601 +++ linux-2.6.5-12.1/fs/super.c 2004-05-25 17:32:14.045493136 +0300
602 @@ -789,6 +789,8 @@
603         return (struct vfsmount *)sb;
604  }
605  
606 +EXPORT_SYMBOL(do_kern_mount);
607 +
608  struct vfsmount *kern_mount(struct file_system_type *type)
609  {
610         return do_kern_mount(type->name, 0, type->name, NULL);
611 Index: linux-2.6.5-12.1/include/linux/dcache.h
612 ===================================================================
613 --- linux-2.6.5-12.1.orig/include/linux/dcache.h        2004-04-04 06:38:24.000000000 +0300
614 +++ linux-2.6.5-12.1/include/linux/dcache.h     2004-05-25 17:32:14.045493136 +0300
615 @@ -4,6 +4,7 @@
616  #ifdef __KERNEL__
617  
618  #include <asm/atomic.h>
619 +#include <linux/string.h>
620  #include <linux/list.h>
621  #include <linux/spinlock.h>
622  #include <linux/cache.h>
623 @@ -35,6 +36,8 @@
624         char name_str[0];
625  };
626  
627 +#include <linux/namei.h>
628 +
629  struct dentry_stat_t {
630         int nr_dentry;
631         int nr_unused;
632 Index: linux-2.6.5-12.1/include/linux/fs.h
633 ===================================================================
634 --- linux-2.6.5-12.1.orig/include/linux/fs.h    2004-05-10 19:21:56.000000000 +0300
635 +++ linux-2.6.5-12.1/include/linux/fs.h 2004-05-25 17:32:14.046492984 +0300
636 @@ -250,6 +250,8 @@
637  #define ATTR_ATTR_FLAG 1024
638  #define ATTR_KILL_SUID 2048
639  #define ATTR_KILL_SGID 4096
640 +#define ATTR_RAW               8192    /* file system, not vfs will massage attrs */
641 +#define ATTR_FROM_OPEN         16384    /* called from open path, ie O_TRUNC */
642  
643  /*
644   * This is the Inode Attributes structure, used for notify_change().  It
645 @@ -423,6 +425,7 @@
646         struct block_device     *i_bdev;
647         struct cdev             *i_cdev;
648         int                     i_cindex;
649 +       void                    *i_filterdata;
650  
651         unsigned long           i_dnotify_mask; /* Directory notify events */
652         struct dnotify_struct   *i_dnotify; /* for directory notifications */
653 @@ -556,6 +559,7 @@
654         spinlock_t              f_ep_lock;
655  #endif /* #ifdef CONFIG_EPOLL */
656         struct address_space    *f_mapping;
657 +       struct lookup_intent    *f_it;
658  };
659  extern spinlock_t files_lock;
660  #define file_list_lock() spin_lock(&files_lock);
661 @@ -886,7 +890,9 @@
662         void (*truncate) (struct inode *);
663         int (*permission) (struct inode *, int, struct nameidata *);
664         int (*setattr) (struct dentry *, struct iattr *);
665 +       int (*setattr_raw) (struct inode *, struct iattr *);
666         int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
667 +       int (*getattr_it) (struct vfsmount *, struct dentry *, struct lookup_intent *, struct kstat *);
668         int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
669         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
670         ssize_t (*listxattr) (struct dentry *, char *, size_t);
671 @@ -1114,6 +1120,7 @@
672  extern int unregister_filesystem(struct file_system_type *);
673  extern struct vfsmount *kern_mount(struct file_system_type *);
674  extern int may_umount(struct vfsmount *);
675 +struct vfsmount *do_kern_mount(const char *type, int flags, const char *name, void *data);
676  extern long do_mount(char *, char *, char *, unsigned long, void *);
677  
678  extern int vfs_statfs(struct super_block *, struct kstatfs *);
679 @@ -1178,6 +1185,7 @@
680  extern int do_truncate(struct dentry *, loff_t start);
681  extern struct file *filp_open(const char *, int, int);
682  extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);
683 +extern struct file * dentry_open_it(struct dentry *, struct vfsmount *, int, struct lookup_intent *);
684  extern int filp_close(struct file *, fl_owner_t id);
685  extern char * getname(const char __user *);
686  
687 Index: linux-2.6.5-12.1/include/linux/namei.h
688 ===================================================================
689 --- linux-2.6.5-12.1.orig/include/linux/namei.h 2004-05-10 19:21:56.000000000 +0300
690 +++ linux-2.6.5-12.1/include/linux/namei.h      2004-05-25 17:32:14.047492832 +0300
691 @@ -2,25 +2,55 @@
692  #define _LINUX_NAMEI_H
693  
694  #include <linux/linkage.h>
695 +#include <linux/string.h>
696  
697  struct vfsmount;
698 +struct nameidata;
699  
700 -struct open_intent {
701 -       int     flags;
702 -       int     create_mode;
703 +/* intent opcodes */
704 +#define IT_OPEN     (1)
705 +#define IT_CREAT    (1<<1)
706 +#define IT_READDIR  (1<<2)
707 +#define IT_GETATTR  (1<<3)
708 +#define IT_LOOKUP   (1<<4)
709 +#define IT_UNLINK   (1<<5)
710 +#define IT_TRUNC    (1<<6)
711 +#define IT_GETXATTR (1<<7)
712 +
713 +struct lustre_intent_data {
714 +       int       it_disposition;
715 +       int       it_status;
716 +       __u64     it_lock_handle;
717 +       void     *it_data;
718 +       int       it_lock_mode;
719  };
720  
721 +#define INTENT_MAGIC 0x19620323
722 +struct lookup_intent {
723 +       int     it_magic;
724 +       void    (*it_op_release)(struct lookup_intent *);
725 +       int     it_op;
726 +       int     it_flags;
727 +       int     it_create_mode;
728 +       union {
729 +               struct lustre_intent_data lustre;
730 +       } d;
731 +};
732 +
733 +static inline void intent_init(struct lookup_intent *it, int op)
734 +{
735 +       memset(it, 0, sizeof(*it));
736 +       it->it_magic = INTENT_MAGIC;
737 +       it->it_op = op;
738 +}
739 +
740  struct nameidata {
741         struct dentry   *dentry;
742         struct vfsmount *mnt;
743         struct qstr     last;
744         unsigned int    flags;
745         int             last_type;
746 -
747 -       /* Intent data */
748 -       union {
749 -               struct open_intent open;
750 -       } intent;
751 +       struct lookup_intent intent;
752  };
753  
754  /*
755 @@ -41,6 +71,9 @@
756  #define LOOKUP_CONTINUE                 4
757  #define LOOKUP_PARENT          16
758  #define LOOKUP_NOALT           32
759 +#define LOOKUP_LAST             (1<<6)
760 +#define LOOKUP_LINK_NOTLAST     (1<<7)
761 +
762  /*
763   * Intent data
764   */
765 @@ -49,6 +82,12 @@
766  #define LOOKUP_ACCESS          (0x0400)
767  
768  extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *, const char **));
769 +extern int FASTCALL(__user_walk_it(const char __user *, unsigned, struct nameidata *, const char **));
770 +#define user_path_walk_it(name,nd) \
771 +       __user_walk_it(name, LOOKUP_FOLLOW, nd, 0)
772 +#define user_path_walk_link_it(name,nd) \
773 +       __user_walk_it(name, 0, nd, 0)
774 +extern void intent_release(struct lookup_intent *);
775  #define user_path_walk(name,nd) \
776         __user_walk(name, LOOKUP_FOLLOW, nd, 0)
777  #define user_path_walk_link(name,nd) \
778 @@ -60,7 +99,6 @@
779  
780  extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
781  extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
782 -
783  extern int follow_down(struct vfsmount **, struct dentry **);
784  extern int follow_up(struct vfsmount **, struct dentry **);
785  
786 Index: linux-2.6.5-12.1/kernel/exit.c
787 ===================================================================
788 --- linux-2.6.5-12.1.orig/kernel/exit.c 2004-05-10 19:21:56.000000000 +0300
789 +++ linux-2.6.5-12.1/kernel/exit.c      2004-05-25 17:32:14.047492832 +0300
790 @@ -260,6 +260,8 @@
791         write_unlock_irq(&tasklist_lock);
792  }
793  
794 +EXPORT_SYMBOL(reparent_to_init);
795 +
796  void __set_special_pids(pid_t session, pid_t pgrp)
797  {
798         struct task_struct *curr = current;
799 @@ -429,6 +431,8 @@
800         __exit_files(tsk);
801  }
802  
803 +EXPORT_SYMBOL(exit_files);
804 +
805  static inline void __put_fs_struct(struct fs_struct *fs)
806  {
807         /* No need to hold fs->lock if we are killing it */
808 Index: linux-2.6.5-12.1/include/linux/fshooks.h
809 ===================================================================
810 --- linux-2.6.5-12.1.orig/include/linux/fshooks.h       2004-05-10 19:21:56.000000000 +0300
811 +++ linux-2.6.5-12.1/include/linux/fshooks.h    2004-05-25 17:32:14.048492680 +0300
812 @@ -90,12 +90,18 @@
813  
814  #define FSHOOK_BEGIN_USER_WALK(type, err, path, flags, nd, field, args...) \
815                 FSHOOK_BEGIN_USER_WALK_COMMON(type, err, __user_walk(path, flags, &nd, &info.field), nd, args)
816 +#define FSHOOK_BEGIN_USER_WALK_IT(type, err, path, flags, nd, field, args...) \
817 +               FSHOOK_BEGIN_USER_WALK_COMMON(type, err, __user_walk_it(path, flags, &nd, &info.field), nd, args)
818  
819  #define FSHOOK_BEGIN_USER_PATH_WALK(type, err, path, nd, field, args...) \
820                 FSHOOK_BEGIN_USER_WALK_COMMON(type, err, __user_walk(path, LOOKUP_FOLLOW, &nd, &info.field), nd, args)
821 +#define FSHOOK_BEGIN_USER_PATH_WALK_IT(type, err, path, nd, field, args...) \
822 +               FSHOOK_BEGIN_USER_WALK_COMMON(type, err, __user_walk_it(path, LOOKUP_FOLLOW, &nd, &info.field), nd, args)
823  
824  #define FSHOOK_BEGIN_USER_PATH_WALK_LINK(type, err, path, nd, field, args...) \
825                 FSHOOK_BEGIN_USER_WALK_COMMON(type, err, __user_walk(path, 0, &nd, &info.field), nd, args)
826 +#define FSHOOK_BEGIN_USER_PATH_WALK_LINK_IT(type, err, path, nd, field, args...) \
827 +               FSHOOK_BEGIN_USER_WALK_COMMON(type, err, __user_walk_it(path, 0, &nd, &info.field), nd, args)
828  
829  #define FSHOOK_END_USER_WALK(type, err, field) \
830                                 (void)(&info != (struct fshook_##type##_info *)-1L); \
831 @@ -126,12 +132,18 @@
832  
833  #define FSHOOK_BEGIN_USER_WALK(type, err, path, flags, nd, field, args...) \
834         if (!(err = __user_walk(path, flags, &nd, 0))) {
835 +#define FSHOOK_BEGIN_USER_WALK_IT(type, err, path, flags, nd, field, args...) \
836 +       if (!(err = __user_walk_it(path, flags, &nd, 0))) {
837  
838  #define FSHOOK_BEGIN_USER_PATH_WALK(type, err, path, nd, field, args...) \
839         if (!(err = user_path_walk(path, &nd))) {
840 +#define FSHOOK_BEGIN_USER_PATH_WALK_IT(type, err, path, nd, field, args...) \
841 +       if (!(err = user_path_walk_it(path, &nd))) {
842  
843  #define FSHOOK_BEGIN_USER_PATH_WALK_LINK(type, err, path, nd, field, args...) \
844         if (!(err = user_path_walk_link(path, &nd))) {
845 +#define FSHOOK_BEGIN_USER_PATH_WALK_LINK_IT(type, err, path, nd, field, args...) \
846 +       if (!(err = user_path_walk_link_it(path, &nd))) {
847  
848  #define FSHOOK_END_USER_WALK(type, err, field) ((void)0);}
849  
850 Index: linux-2.6.5-12.1/fs/block_dev.c
851 ===================================================================
852 --- linux-2.6.5-12.1.orig/fs/block_dev.c        2004-05-10 19:21:55.000000000 +0300
853 +++ linux-2.6.5-12.1/fs/block_dev.c     2004-05-25 17:32:39.517620784 +0300
854 @@ -834,6 +834,7 @@
855         if (!path || !*path)
856                 return ERR_PTR(-EINVAL);
857  
858 +       intent_init(&nd.intent, IT_LOOKUP);
859         error = path_lookup(path, LOOKUP_FOLLOW, &nd);
860         if (error)
861                 return ERR_PTR(error);