Whamcloud - gitweb
LU-4708 ldiskfs: do not copy NUL terminator from direntry
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / sles11sp2 / ext4-disable-mb-cache.patch
1 diff -ru linux-stage.orig/fs/ext4/ext4.h linux-stage/fs/ext4/ext4.h
2 --- linux-stage.orig/fs/ext4/ext4.h     2012-12-31 15:58:19.000000000 -0500
3 +++ linux-stage/fs/ext4/ext4.h  2012-12-31 15:58:42.000000000 -0500
4 @@ -894,7 +894,8 @@
5  /*
6   * Mount flags
7   */
8 -#define EXT4_MOUNT_OLDALLOC            0x00002  /* Don't use the new Orlov allocator */
9 +#define EXT4_MOUNT_NO_MBCACHE          0x00001 /* Disable mbcache */
10 +#define EXT4_MOUNT_OLDALLOC            0x00002 /* Don't use the new Orlov allocator */
11  #define EXT4_MOUNT_GRPID               0x00004 /* Create files with directory's group */
12  #define EXT4_MOUNT_DEBUG               0x00008 /* Some debugging messages */
13  #define EXT4_MOUNT_ERRORS_CONT         0x00010 /* Continue on errors */
14 diff -ru linux-stage.orig/fs/ext4/super.c linux-stage/fs/ext4/super.c
15 --- linux-stage.orig/fs/ext4/super.c    2012-12-31 15:58:19.000000000 -0500
16 +++ linux-stage/fs/ext4/super.c 2012-12-31 15:59:19.000000000 -0500
17 @@ -1306,6 +1306,7 @@
18         Opt_dioread_nolock, Opt_dioread_lock,
19         Opt_mballoc, Opt_bigendian_extents, Opt_force_over_128tb,
20         Opt_extents, Opt_noextents,
21 +       Opt_no_mbcache,
22         Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
23  };
24
25 @@ -1383,6 +1384,7 @@
26         {Opt_bigendian_extents, "bigendian_extents"},
27         {Opt_force_over_128tb, "force_over_128tb"},
28         {Opt_mballoc, "mballoc"},
29 +       {Opt_no_mbcache, "no_mbcache"},
30         {Opt_extents, "extents"},
31         {Opt_noextents, "noextents"},
32         {Opt_discard, "discard"},
33 @@ -1919,6 +1921,9 @@
34                         }
35                         clear_opt(sb, EXTENTS);
36                         break;
37 +               case Opt_no_mbcache:
38 +                       set_opt(sb, NO_MBCACHE);
39 +                       break;
40                 default:
41                         ext4_msg(sb, KERN_ERR,
42                                "Unrecognized mount option \"%s\" "
43 diff -ru linux-stage.orig/fs/ext4/xattr.c linux-stage/fs/ext4/xattr.c
44 --- linux-stage.orig/fs/ext4/xattr.c    2012-12-31 15:58:19.000000000 -0500
45 +++ linux-stage/fs/ext4/xattr.c 2012-12-31 16:46:21.000000000 -0500
46 @@ -86,7 +86,8 @@
47  # define ea_bdebug(f...)
48  #endif
49
50 -static void ext4_xattr_cache_insert(struct buffer_head *);
51 +static void ext4_xattr_cache_insert(struct super_block *,
52 +                                   struct buffer_head *);
53  static struct buffer_head *ext4_xattr_cache_find(struct inode *,
54                                                  struct ext4_xattr_header *,
55                                                  struct mb_cache_entry **);
56 @@ -332,7 +333,7 @@
57                 error = -EIO;
58                 goto cleanup;
59         }
60 -       ext4_xattr_cache_insert(bh);
61 +       ext4_xattr_cache_insert(inode->i_sb, bh);
62         entry = BFIRST(bh);
63         error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1,
64                                       inode);
65 @@ -492,7 +493,7 @@
66                 error = -EIO;
67                 goto cleanup;
68         }
69 -       ext4_xattr_cache_insert(bh);
70 +       ext4_xattr_cache_insert(inode->i_sb, bh);
71         error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
72
73  cleanup:
74 @@ -589,7 +590,9 @@
75         struct mb_cache_entry *ce = NULL;
76         int error = 0;
77
78 -       ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, bh->b_blocknr);
79 +       if (!test_opt(inode->i_sb, NO_MBCACHE))
80 +               ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev,
81 +                                       bh->b_blocknr);
82         error = ext4_journal_get_write_access(handle, bh);
83         if (error)
84                 goto out;
85 @@ -989,8 +992,10 @@
86  #define header(x) ((struct ext4_xattr_header *)(x))
87
88         if (s->base) {
89 -               ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev,
90 -                                       bs->bh->b_blocknr);
91 +               if (!test_opt(inode->i_sb, NO_MBCACHE))
92 +                       ce = mb_cache_entry_get(ext4_xattr_cache,
93 +                                               bs->bh->b_bdev,
94 +                                               bs->bh->b_blocknr);
95                 error = ext4_journal_get_write_access(handle, bs->bh);
96                 if (error)
97                         goto cleanup;
98 @@ -1007,7 +1012,7 @@
99                                 if (!IS_LAST_ENTRY(s->first))
100                                         ext4_xattr_rehash(header(s->base),
101                                                           s->here);
102 -                               ext4_xattr_cache_insert(bs->bh);
103 +                               ext4_xattr_cache_insert(sb, bs->bh);
104                         }
105                         unlock_buffer(bs->bh);
106                         if (error == -EIO)
107 @@ -1090,7 +1095,8 @@
108                                 if (error)
109                                         goto cleanup_dquot;
110                         }
111 -                       mb_cache_entry_release(ce);
112 +                       if (ce)
113 +                               mb_cache_entry_release(ce);
114                         ce = NULL;
115                 } else if (bs->bh && s->base == bs->bh->b_data) {
116                         /* We were modifying this block in-place. */
117 @@ -1141,7 +1147,7 @@
118                         memcpy(new_bh->b_data, s->base, new_bh->b_size);
119                         set_buffer_uptodate(new_bh);
120                         unlock_buffer(new_bh);
121 -                       ext4_xattr_cache_insert(new_bh);
122 +                       ext4_xattr_cache_insert(sb, new_bh);
123                         error = ext4_handle_dirty_metadata(handle,
124                                                            inode, new_bh);
125                         if (error)
126 @@ -1761,12 +1767,15 @@
127   * Returns 0, or a negative error number on failure.
128   */
129  static void
130 -ext4_xattr_cache_insert(struct buffer_head *bh)
131 +ext4_xattr_cache_insert(struct super_block *sb, struct buffer_head *bh)
132  {
133         __u32 hash = le32_to_cpu(BHDR(bh)->h_hash);
134         struct mb_cache_entry *ce;
135         int error;
136
137 +       if (test_opt(sb, NO_MBCACHE))
138 +               return;
139 +
140         ce = mb_cache_entry_alloc(ext4_xattr_cache, GFP_NOFS);
141         if (!ce) {
142                 ea_bdebug(bh, "out of memory");
143 @@ -1839,6 +1848,8 @@
144         __u32 hash = le32_to_cpu(header->h_hash);
145         struct mb_cache_entry *ce;
146
147 +       if (test_opt(inode->i_sb, NO_MBCACHE))
148 +               return NULL;
149         if (!header->h_hash)
150                 return NULL;  /* never share */
151         ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);