Whamcloud - gitweb
b=13620
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs_races-2.6-rhel5.patch
1 diff -urp linux-2.6.18.rawops/fs/dcache.c linux-2.6.18.races/fs/dcache.c
2 --- linux-2.6.18.rawops/fs/dcache.c     2007-02-08 19:00:31.000000000 +0200
3 +++ linux-2.6.18.races/fs/dcache.c      2007-02-14 19:23:49.000000000 +0200
4 @@ -230,6 +230,13 @@ int d_invalidate(struct dentry * dentry)
5                 spin_unlock(&dcache_lock);
6                 return 0;
7         }
8 +
9 +       /* network invalidation by Lustre */
10 +       if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {
11 +               spin_unlock(&dcache_lock);
12 +               return 0;
13 +       }
14 +
15         /*
16          * Check whether to do a partial shrink_dcache
17          * to get rid of unused child entries.
18 @@ -1400,13 +1407,21 @@ static void _d_rehash(struct dentry * en
19   * Adds a dentry to the hash according to its name.
20   */
21   
22 -void d_rehash(struct dentry * entry)
23 +void d_rehash_cond(struct dentry * entry, int lock)
24  {
25 -       spin_lock(&dcache_lock);
26 +       if (lock)
27 +           spin_lock(&dcache_lock);
28         spin_lock(&entry->d_lock);
29         _d_rehash(entry);
30         spin_unlock(&entry->d_lock);
31 -       spin_unlock(&dcache_lock);
32 +       if (lock)       
33 +           spin_unlock(&dcache_lock);
34 +}
35 +EXPORT_SYMBOL(d_rehash_cond);
36 +
37 +void d_rehash(struct dentry * entry)
38 +{
39 +       d_rehash_cond(entry, 1);
40  }
41  
42  #define do_switch(x,y) do { \
43 @@ -1481,14 +1496,13 @@ static void switch_names(struct dentry *
44   * dcache entries should not be moved in this way.
45   */
46  
47 -void d_move(struct dentry * dentry, struct dentry * target)
48 +void __d_move(struct dentry * dentry, struct dentry * target)
49  {
50         struct hlist_head *list;
51  
52         if (!dentry->d_inode)
53                 printk(KERN_WARNING "VFS: moving negative dcache entry\n");
54  
55 -       spin_lock(&dcache_lock);
56         write_seqlock(&rename_lock);
57         /*
58          * XXXX: do we really need to take target->d_lock?
59 @@ -1549,6 +1563,14 @@ already_unhashed:
60         fsnotify_d_move(dentry);
61         spin_unlock(&dentry->d_lock);
62         write_sequnlock(&rename_lock);
63 +}
64 +
65 +EXPORT_SYMBOL(__d_move);
66 +
67 +void d_move(struct dentry *dentry, struct dentry *target)
68 +{
69 +       spin_lock(&dcache_lock);
70 +       __d_move(dentry, target);
71         spin_unlock(&dcache_lock);
72  }
73  
74 diff -urp linux-2.6.18.rawops/include/linux/dcache.h linux-2.6.18.races/include/linux/dcache.h
75 --- linux-2.6.18.rawops/include/linux/dcache.h  2007-02-14 16:52:37.000000000 +0200
76 +++ linux-2.6.18.races/include/linux/dcache.h   2007-02-14 19:21:14.000000000 +0200
77 @@ -177,6 +177,7 @@ d_iput:             no              no              no       yes
78  
79  #define DCACHE_REFERENCED      0x0008  /* Recently used, don't discard. */
80  #define DCACHE_UNHASHED                0x0010  
81 +#define DCACHE_LUSTRE_INVALID  0x0040  /* Lustre invalidated */
82  
83  #define DCACHE_INOTIFY_PARENT_WATCHED  0x0020 /* Parent inode is watched */
84  
85 @@ -254,6 +255,7 @@ extern int have_submounts(struct dentry 
86   * This adds the entry to the hash queues.
87   */
88  extern void d_rehash(struct dentry *);
89 +extern void d_rehash_cond(struct dentry *, int lock);
90  
91  /**
92   * d_add - add dentry to hash queues
93 @@ -289,6 +291,7 @@ static inline struct dentry *d_add_uniqu
94  
95  /* used for rename() and baskets */
96  extern void d_move(struct dentry *, struct dentry *);
97 +extern void __d_move(struct dentry *, struct dentry *);
98  
99  /* appendix may either be NULL or be used for transname suffixes */
100  extern struct dentry * d_lookup(struct dentry *, struct qstr *);