Whamcloud - gitweb
5e88d3557927e88ccdf4c96ad1a73519ef64f302
[fs/lustre-release.git] / lustre / kernel_patches / patches / lustre-2.5.patch
1 # This is a BitKeeper generated patch for the following project:
2 # Project Name: Linux kernel tree
3 # This patch format is intended for GNU patch command version 2.5 or higher.
4 # This patch includes the following deltas:
5 #                  ChangeSet    1.810   -> 1.811  
6 #             kernel/ksyms.c    1.149   -> 1.150  
7 #        fs/driverfs/inode.c    1.52    -> 1.53   
8 #         include/linux/fs.h    1.175   -> 1.176  
9 #       include/linux/namei.h   1.3     -> 1.4    
10 #                 fs/namei.c    1.56    -> 1.57   
11 #              fs/nfsd/vfs.c    1.44    -> 1.45   
12 #       arch/um/kernel/mem.c    1.5     -> 1.6    
13 #         net/unix/af_unix.c    1.29    -> 1.30   
14 #                  mm/slab.c    1.33    -> 1.34   
15 #           fs/sysfs/inode.c    1.55    -> 1.56   
16 #       include/linux/slab.h    1.13    -> 1.14   
17 #       include/linux/dcache.h  1.19    -> 1.20   
18 #
19 # The following is the BitKeeper ChangeSet Log
20 # --------------------------------------------
21 # 02/10/20      braam@clusterfs.com     1.811
22 # Changes for Lustre
23 # --------------------------------------------
24 #
25 diff -Nru a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
26 --- a/arch/um/kernel/mem.c      Sun Dec  8 02:49:38 2002
27 +++ b/arch/um/kernel/mem.c      Sun Dec  8 02:49:38 2002
28 @@ -656,6 +656,22 @@
29         return(phys_mem_map(pte_val(pte)));
30  }
31  
32 +struct page *check_get_page(unsigned long kaddr)
33 +{
34 +        struct page *page;
35 +        struct mem_region *mr;
36 +        unsigned long phys = __pa(kaddr);
37 +       unsigned int n = phys_region_index(phys);
38 +
39 +       if(regions[n] == NULL) 
40 +                return NULL; 
41 +
42 +        mr = regions[n];
43 +        page = (struct page *) mr->mem_map;
44 +       return page + ((phys_addr(phys)) >> PAGE_SHIFT);
45 +}
46 +
47 +
48  struct mem_region *page_region(struct page *page, int *index_out)
49  {
50         int i;
51 @@ -743,7 +759,7 @@
52                    (addr <= region->start + region->len))
53                         return(mk_phys(addr - region->start, i));
54         }
55 -       panic("region_pa : no region for virtual address");
56 +       //panic("region_pa : no region for virtual address");
57         return(0);
58  }
59  
60 diff -Nru a/fs/driverfs/inode.c b/fs/driverfs/inode.c
61 --- a/fs/driverfs/inode.c       Sun Dec  8 02:49:38 2002
62 +++ b/fs/driverfs/inode.c       Sun Dec  8 02:49:38 2002
63 @@ -523,7 +523,7 @@
64         qstr.name = name;
65         qstr.len = strlen(name);
66         qstr.hash = full_name_hash(name,qstr.len);
67 -       return lookup_hash(&qstr,parent);
68 +       return lookup_hash(&qstr,parent, NULL);
69  }
70  
71  /**
72 diff -Nru a/fs/namei.c b/fs/namei.c
73 --- a/fs/namei.c        Sun Dec  8 02:49:38 2002
74 +++ b/fs/namei.c        Sun Dec  8 02:49:38 2002
75 @@ -265,6 +265,9 @@
76  
77  void path_release(struct nameidata *nd)
78  {
79 +        if (nd->dentry && nd->dentry->d_op && 
80 +            nd->dentry->d_op->d_intent_release)
81 +                nd->dentry->d_op->d_intent_release(nd->dentry, &nd->it);
82         dput(nd->dentry);
83         mntput(nd->mnt);
84  }
85 @@ -273,10 +276,18 @@
86   * Internal lookup() using the new generic dcache.
87   * SMP-safe
88   */
89 -static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
90 +static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags, struct lookup_intent *it)
91  {
92         struct dentry * dentry = d_lookup(parent, name);
93         
94 +       if (dentry && dentry->d_op && dentry->d_op->d_revalidate2) {
95 +               if (!dentry->d_op->d_revalidate2(dentry, flags, it) &&
96 +                   !d_invalidate(dentry)) {
97 +                       dput(dentry);
98 +                       dentry = NULL;
99 +               }
100 +               return dentry;
101 +       } else
102         if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
103                 if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
104                         dput(dentry);
105 @@ -351,7 +362,7 @@
106   * make sure that nobody added the entry to the dcache in the meantime..
107   * SMP-safe
108   */
109 -static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags)
110 +static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, int flags, struct lookup_intent *it)
111  {
112         struct dentry * result;
113         struct inode *dir = parent->d_inode;
114 @@ -369,7 +380,10 @@
115                 struct dentry * dentry = d_alloc(parent, name);
116                 result = ERR_PTR(-ENOMEM);
117                 if (dentry) {
118 -                       result = dir->i_op->lookup(dir, dentry);
119 +                       if (dir->i_op->lookup2)
120 +                               result = dir->i_op->lookup2(dir, dentry, it);
121 +                       else
122 +                                result = dir->i_op->lookup(dir, dentry);
123                         if (result)
124                                 dput(dentry);
125                         else {
126 @@ -391,6 +405,12 @@
127                         dput(result);
128                         result = ERR_PTR(-ENOENT);
129                 }
130 +       } else if (result->d_op && result->d_op->d_revalidate2) {
131 +               if (!result->d_op->d_revalidate2(result, flags, it) &&
132 +                   !d_invalidate(result)) {
133 +                       dput(result);
134 +                       result = ERR_PTR(-ENOENT);
135 +               }
136         }
137         return result;
138  }
139 @@ -534,7 +554,7 @@
140         unlock_nd(nd);
141  
142  need_lookup:
143 -       dentry = real_lookup(nd->dentry, name, LOOKUP_CONTINUE);
144 +       dentry = real_lookup(nd->dentry, name, LOOKUP_CONTINUE, &nd->it);
145         if (IS_ERR(dentry))
146                 goto fail;
147         mntget(mnt);
148 @@ -684,7 +704,7 @@
149                         nd->dentry = next.dentry;
150                 }
151                 err = -ENOTDIR; 
152 -               if (!inode->i_op->lookup)
153 +               if (!inode->i_op->lookup && !inode->i_op->lookup2)
154                         break;
155                 continue;
156                 /* here ends the main loop */
157 @@ -737,7 +757,8 @@
158                         break;
159                 if (lookup_flags & LOOKUP_DIRECTORY) {
160                         err = -ENOTDIR; 
161 -                       if (!inode->i_op || !inode->i_op->lookup)
162 +                       if (!inode->i_op || 
163 +                            (!inode->i_op->lookup && !inode->i_op->lookup2))
164                                 break;
165                 }
166                 goto return_base;
167 @@ -886,7 +907,8 @@
168   * needs parent already locked. Doesn't follow mounts.
169   * SMP-safe.
170   */
171 -struct dentry * lookup_hash(struct qstr *name, struct dentry * base)
172 +struct dentry * lookup_hash(struct qstr *name, struct dentry * base, 
173 +                            struct lookup_intent *it)
174  {
175         struct dentry * dentry;
176         struct inode *inode;
177 @@ -909,13 +931,16 @@
178                         goto out;
179         }
180  
181 -       dentry = cached_lookup(base, name, 0);
182 +       dentry = cached_lookup(base, name, 0, it);
183         if (!dentry) {
184                 struct dentry *new = d_alloc(base, name);
185                 dentry = ERR_PTR(-ENOMEM);
186                 if (!new)
187                         goto out;
188 -               dentry = inode->i_op->lookup(inode, new);
189 +                if (inode->i_op->lookup2) 
190 +                        dentry = inode->i_op->lookup2(inode, new, it);
191 +                else 
192 +                        dentry = inode->i_op->lookup(inode, new);
193                 if (!dentry) {
194                         dentry = new;
195                         security_ops->inode_post_lookup(inode, dentry);
196 @@ -927,7 +952,7 @@
197  }
198  
199  /* SMP-safe */
200 -struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
201 +struct dentry * lookup_one_len_it(const char * name, struct dentry * base, int len, struct lookup_intent *it)
202  {
203         unsigned long hash;
204         struct qstr this;
205 @@ -947,11 +972,16 @@
206         }
207         this.hash = end_name_hash(hash);
208  
209 -       return lookup_hash(&this, base);
210 +       return lookup_hash(&this, base, it);
211  access:
212         return ERR_PTR(-EACCES);
213  }
214  
215 +struct dentry * lookup_one_len(const char * name, struct dentry * base, int len)
216 +{
217 +        return lookup_one_len_it(name, base, len, NULL);
218 +}
219 +
220  /*
221   *     namei()
222   *
223 @@ -1268,7 +1298,7 @@
224  
225         dir = nd->dentry;
226         down(&dir->d_inode->i_sem);
227 -       dentry = lookup_hash(&nd->last, nd->dentry);
228 +       dentry = lookup_hash(&nd->last, nd->dentry, &nd->it);
229  
230  do_last:
231         error = PTR_ERR(dentry);
232 @@ -1370,7 +1400,7 @@
233         }
234         dir = nd->dentry;
235         down(&dir->d_inode->i_sem);
236 -       dentry = lookup_hash(&nd->last, nd->dentry);
237 +       dentry = lookup_hash(&nd->last, nd->dentry, &nd->it);
238         putname(nd->last.name);
239         goto do_last;
240  }
241 @@ -1384,7 +1414,7 @@
242         dentry = ERR_PTR(-EEXIST);
243         if (nd->last_type != LAST_NORM)
244                 goto fail;
245 -       dentry = lookup_hash(&nd->last, nd->dentry);
246 +       dentry = lookup_hash(&nd->last, nd->dentry, &nd->it);
247         if (IS_ERR(dentry))
248                 goto fail;
249         if (!is_dir && nd->last.name[nd->last.len] && !dentry->d_inode)
250 @@ -1614,7 +1644,7 @@
251                         goto exit1;
252         }
253         down(&nd.dentry->d_inode->i_sem);
254 -       dentry = lookup_hash(&nd.last, nd.dentry);
255 +       dentry = lookup_hash(&nd.last, nd.dentry, &nd.it);
256         error = PTR_ERR(dentry);
257         if (!IS_ERR(dentry)) {
258                 error = vfs_rmdir(nd.dentry->d_inode, dentry);
259 @@ -1675,7 +1705,7 @@
260         if (nd.last_type != LAST_NORM)
261                 goto exit1;
262         down(&nd.dentry->d_inode->i_sem);
263 -       dentry = lookup_hash(&nd.last, nd.dentry);
264 +       dentry = lookup_hash(&nd.last, nd.dentry, &nd.it);
265         error = PTR_ERR(dentry);
266         if (!IS_ERR(dentry)) {
267                 /* Why not before? Because we want correct error value */
268 @@ -1949,7 +1979,8 @@
269  }
270  
271  int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
272 -              struct inode *new_dir, struct dentry *new_dentry)
273 +              struct inode *new_dir, struct dentry *new_dentry, 
274 +               struct lookup_intent *it)
275  {
276         int error;
277         int is_dir = S_ISDIR(old_dentry->d_inode->i_mode);
278 @@ -2020,7 +2051,7 @@
279  
280         trap = lock_rename(new_dir, old_dir);
281  
282 -       old_dentry = lookup_hash(&oldnd.last, old_dir);
283 +       old_dentry = lookup_hash(&oldnd.last, old_dir, &oldnd.it);
284         error = PTR_ERR(old_dentry);
285         if (IS_ERR(old_dentry))
286                 goto exit3;
287 @@ -2040,7 +2071,7 @@
288         error = -EINVAL;
289         if (old_dentry == trap)
290                 goto exit4;
291 -       new_dentry = lookup_hash(&newnd.last, new_dir);
292 +       new_dentry = lookup_hash(&newnd.last, new_dir, &newnd.it);
293         error = PTR_ERR(new_dentry);
294         if (IS_ERR(new_dentry))
295                 goto exit4;
296 @@ -2050,7 +2081,7 @@
297                 goto exit5;
298  
299         error = vfs_rename(old_dir->d_inode, old_dentry,
300 -                                  new_dir->d_inode, new_dentry);
301 +                                  new_dir->d_inode, new_dentry, NULL);
302  exit5:
303         dput(new_dentry);
304  exit4:
305 diff -Nru a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
306 --- a/fs/nfsd/vfs.c     Sun Dec  8 02:49:38 2002
307 +++ b/fs/nfsd/vfs.c     Sun Dec  8 02:49:38 2002
308 @@ -1292,7 +1292,7 @@
309                         err = nfserr_perm;
310         } else
311  #endif
312 -       err = vfs_rename(fdir, odentry, tdir, ndentry);
313 +       err = vfs_rename(fdir, odentry, tdir, ndentry, NULL);
314         if (!err && EX_ISSYNC(tfhp->fh_export)) {
315                 nfsd_sync_dir(tdentry);
316                 nfsd_sync_dir(fdentry);
317 diff -Nru a/fs/sysfs/inode.c b/fs/sysfs/inode.c
318 --- a/fs/sysfs/inode.c  Sun Dec  8 02:49:39 2002
319 +++ b/fs/sysfs/inode.c  Sun Dec  8 02:49:39 2002
320 @@ -471,7 +471,7 @@
321         qstr.name = name;
322         qstr.len = strlen(name);
323         qstr.hash = full_name_hash(name,qstr.len);
324 -       return lookup_hash(&qstr,parent);
325 +       return lookup_hash(&qstr,parent,NULL);
326  }
327  
328  /**
329 diff -Nru a/include/linux/dcache.h b/include/linux/dcache.h
330 --- a/include/linux/dcache.h    Sun Dec  8 02:49:39 2002
331 +++ b/include/linux/dcache.h    Sun Dec  8 02:49:39 2002
332 @@ -9,6 +9,24 @@
333  #include <linux/spinlock.h>
334  #include <asm/page.h>                  /* for BUG() */
335  
336 +#define IT_OPEN  (1)
337 +#define IT_CREAT  (1<<1)
338 +#define IT_MKDIR  (1<<2)
339 +#define IT_LINK  (1<<3)
340 +#define IT_LINK2  (1<<4)
341 +#define IT_SYMLINK  (1<<5)
342 +#define IT_UNLINK  (1<<6)
343 +#define IT_RMDIR  (1<<7)
344 +#define IT_RENAME  (1<<8)
345 +#define IT_RENAME2  (1<<9)
346 +#define IT_READDIR  (1<<10)
347 +#define IT_GETATTR  (1<<11)
348 +#define IT_SETATTR  (1<<12)
349 +#define IT_READLINK  (1<<13)
350 +#define IT_MKNOD  (1<<14)
351 +#define IT_LOOKUP  (1<<15)
352 +
353 +
354  /*
355   * linux/include/linux/dcache.h
356   *
357 @@ -30,6 +48,8 @@
358         unsigned int hash;
359  };
360  
361 +#include <linux/namei.h>
362 +
363  struct dentry_stat_t {
364         int nr_dentry;
365         int nr_unused;
366 @@ -79,6 +99,7 @@
367         struct list_head d_subdirs;     /* our children */
368         struct list_head d_alias;       /* inode alias list */
369         int d_mounted;
370 +        struct lookup_intent *d_it;
371         struct qstr d_name;
372         unsigned long d_time;           /* used by d_revalidate */
373         struct dentry_operations  *d_op;
374 @@ -96,6 +117,8 @@
375         int (*d_delete)(struct dentry *);
376         void (*d_release)(struct dentry *);
377         void (*d_iput)(struct dentry *, struct inode *);
378 +       int (*d_revalidate2)(struct dentry *, int, struct lookup_intent *);
379 +       void (*d_intent_release)(struct  dentry *, struct lookup_intent *);
380  };
381  
382  /* the dentry parameter passed to d_hash and d_compare is the parent
383 diff -Nru a/include/linux/fs.h b/include/linux/fs.h
384 --- a/include/linux/fs.h        Sun Dec  8 02:49:38 2002
385 +++ b/include/linux/fs.h        Sun Dec  8 02:49:38 2002
386 @@ -700,7 +700,7 @@
387  extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
388  extern int vfs_rmdir(struct inode *, struct dentry *);
389  extern int vfs_unlink(struct inode *, struct dentry *);
390 -extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
391 +extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct lookup_intent *it);
392  
393  /*
394   * File types
395 @@ -769,6 +769,8 @@
396  struct inode_operations {
397         int (*create) (struct inode *,struct dentry *,int);
398         struct dentry * (*lookup) (struct inode *,struct dentry *);
399 +       struct dentry * (*lookup2) (struct inode *,struct dentry *, 
400 +                                    struct lookup_intent *);
401         int (*link) (struct dentry *,struct inode *,struct dentry *);
402         int (*unlink) (struct inode *,struct dentry *);
403         int (*symlink) (struct inode *,struct dentry *,const char *);
404 @@ -995,6 +997,7 @@
405  extern int unregister_filesystem(struct file_system_type *);
406  extern struct vfsmount *kern_mount(struct file_system_type *);
407  extern int may_umount(struct vfsmount *);
408 +struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
409  extern long do_mount(char *, char *, char *, unsigned long, void *);
410  
411  #define kern_umount mntput
412 diff -Nru a/include/linux/namei.h b/include/linux/namei.h
413 --- a/include/linux/namei.h     Sun Dec  8 02:49:38 2002
414 +++ b/include/linux/namei.h     Sun Dec  8 02:49:38 2002
415 @@ -5,6 +5,17 @@
416  
417  struct vfsmount;
418  
419 +struct lookup_intent {
420 +       int it_op;
421 +       int it_mode;
422 +       int it_disposition;
423 +       int it_status;
424 +       struct iattr *it_iattr;
425 +       __u64 it_lock_handle[2];
426 +       int it_lock_mode;
427 +       void *it_data;
428 +};
429 +
430  struct nameidata {
431         struct dentry   *dentry;
432         struct vfsmount *mnt;
433 @@ -13,6 +24,7 @@
434         int             last_type;
435         struct dentry   *old_dentry;
436         struct vfsmount *old_mnt;
437 +        struct lookup_intent it;
438  };
439  
440  /*
441 @@ -46,7 +58,7 @@
442  extern void path_release(struct nameidata *);
443  
444  extern struct dentry * lookup_one_len(const char *, struct dentry *, int);
445 -extern struct dentry * lookup_hash(struct qstr *, struct dentry *);
446 +extern struct dentry * lookup_hash(struct qstr *, struct dentry *, struct lookup_intent *);
447  
448  extern int follow_down(struct vfsmount **, struct dentry **);
449  extern int follow_up(struct vfsmount **, struct dentry **);
450 diff -Nru a/include/linux/slab.h b/include/linux/slab.h
451 --- a/include/linux/slab.h      Sun Dec  8 02:49:39 2002
452 +++ b/include/linux/slab.h      Sun Dec  8 02:49:39 2002
453 @@ -56,6 +56,7 @@
454  extern int kmem_cache_shrink(kmem_cache_t *);
455  extern void *kmem_cache_alloc(kmem_cache_t *, int);
456  extern void kmem_cache_free(kmem_cache_t *, void *);
457 +extern int kmem_cache_validate(kmem_cache_t *cachep, void *objp);
458  extern unsigned int kmem_cache_size(kmem_cache_t *);
459  
460  extern void *kmalloc(size_t, int);
461 diff -Nru a/kernel/ksyms.c b/kernel/ksyms.c
462 --- a/kernel/ksyms.c    Sun Dec  8 02:49:38 2002
463 +++ b/kernel/ksyms.c    Sun Dec  8 02:49:38 2002
464 @@ -365,6 +365,13 @@
465  EXPORT_SYMBOL(tty_get_baud_rate);
466  EXPORT_SYMBOL(do_SAK);
467  
468 +/* lustre */
469 +EXPORT_SYMBOL(panic_notifier_list);
470 +//EXPORT_SYMBOL(pagecache_lock_cacheline);
471 +EXPORT_SYMBOL(do_kern_mount);
472 +EXPORT_SYMBOL(exit_files);
473 +EXPORT_SYMBOL(kmem_cache_validate);
474 +
475  /* filesystem registration */
476  EXPORT_SYMBOL(register_filesystem);
477  EXPORT_SYMBOL(unregister_filesystem);
478 diff -Nru a/mm/slab.c b/mm/slab.c
479 --- a/mm/slab.c Sun Dec  8 02:49:39 2002
480 +++ b/mm/slab.c Sun Dec  8 02:49:39 2002
481 @@ -1236,6 +1236,59 @@
482   * Called with the cache-lock held.
483   */
484  
485 +extern struct page *check_get_page(unsigned long kaddr);
486 +struct page *page_mem_map(struct page *page);
487 +static int kmem_check_cache_obj (kmem_cache_t * cachep,
488 +                                slab_t *slabp, void * objp)
489 +{
490 +       int i;
491 +       unsigned int objnr;
492 +
493 +#if DEBUG
494 +       if (cachep->flags & SLAB_RED_ZONE) {
495 +               objp -= BYTES_PER_WORD;
496 +               if ( *(unsigned long *)objp != RED_MAGIC2)
497 +                       /* Either write before start, or a double free. */
498 +                       return 0;
499 +               if (*(unsigned long *)(objp+cachep->objsize -
500 +                               BYTES_PER_WORD) != RED_MAGIC2)
501 +                       /* Either write past end, or a double free. */
502 +                       return 0;
503 +       }
504 +#endif
505 +
506 +       objnr = (objp-slabp->s_mem)/cachep->objsize;
507 +       if (objnr >= cachep->num)
508 +               return 0;
509 +       if (objp != slabp->s_mem + objnr*cachep->objsize)
510 +               return 0;
511 +
512 +       /* Check slab's freelist to see if this obj is there. */
513 +       for (i = slabp->free; i != BUFCTL_END; i = slab_bufctl(slabp)[i]) {
514 +               if (i == objnr)
515 +                       return 0;
516 +       }
517 +       return 1;
518 +}
519 +
520 +
521 +int kmem_cache_validate(kmem_cache_t *cachep, void *objp)
522 +{
523 +       struct page *page = check_get_page((unsigned long)objp);
524 +
525 +       if (!page_mem_map(page))
526 +               return 0;
527 +
528 +       if (!PageSlab(page))
529 +               return 0;
530 +
531 +       /* XXX check for freed slab objects ? */
532 +       if (!kmem_check_cache_obj(cachep, GET_PAGE_SLAB(page), objp))
533 +               return 0;
534 +
535 +       return (cachep == GET_PAGE_CACHE(page));
536 +}
537 +
538  #if DEBUG
539  static int kmem_extra_free_checks (kmem_cache_t * cachep,
540                         slab_t *slabp, void * objp)
541 diff -Nru a/net/unix/af_unix.c b/net/unix/af_unix.c
542 --- a/net/unix/af_unix.c        Sun Dec  8 02:49:38 2002
543 +++ b/net/unix/af_unix.c        Sun Dec  8 02:49:38 2002
544 @@ -715,7 +715,7 @@
545                 /*
546                  * Do the final lookup.
547                  */
548 -               dentry = lookup_hash(&nd.last, nd.dentry);
549 +               dentry = lookup_hash(&nd.last, nd.dentry, NULL);
550                 err = PTR_ERR(dentry);
551                 if (IS_ERR(dentry))
552                         goto out_mknod_unlock;