Whamcloud - gitweb
e04b1257f8cdc836379a4c03ca0f2a6918cc190d
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-disable-mb-cache-rhel5.patch
1 Index: linux-stage/fs/ext4/xattr.c
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/xattr.c
4 +++ linux-stage/fs/ext4/xattr.c
5 @@ -86,7 +86,8 @@
6  # define ea_bdebug(f...)
7  #endif
8  
9 -static void ext4_xattr_cache_insert(struct buffer_head *);
10 +static void ext4_xattr_cache_insert(struct super_block *,
11 +                                   struct buffer_head *);
12  static struct buffer_head *ext4_xattr_cache_find(struct inode *,
13                                                  struct ext4_xattr_header *,
14                                                  struct mb_cache_entry **);
15 @@ -233,7 +234,7 @@ bad_block:  ext4_error(inode->i_sb, __fun
16                 error = -EIO;
17                 goto cleanup;
18         }
19 -       ext4_xattr_cache_insert(bh);
20 +       ext4_xattr_cache_insert(inode->i_sb, bh);
21         entry = BFIRST(bh);
22         error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
23         if (error == -EIO)
24 @@ -375,7 +376,7 @@ ext4_xattr_block_list(struct inode *inod
25                 error = -EIO;
26                 goto cleanup;
27         }
28 -       ext4_xattr_cache_insert(bh);
29 +       ext4_xattr_cache_insert(inode->i_sb, bh);
30         error = ext4_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size);
31  
32  cleanup:
33 @@ -472,7 +473,9 @@ ext4_xattr_release_block(handle_t *handl
34         struct mb_cache_entry *ce = NULL;
35         int error = 0;
36  
37 -       ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, bh->b_blocknr);
38 +       if (!test_opt(inode->i_sb, NO_MBCACHE))
39 +               ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev,
40 +                                       bh->b_blocknr);
41         error = ext4_journal_get_write_access(handle, bh);
42         if (error)
43                 goto out;
44 @@ -700,8 +703,10 @@ ext4_xattr_block_set(handle_t *handle, s
45         if (i->value && i->value_len > sb->s_blocksize)
46                 return -ENOSPC;
47         if (s->base) {
48 -               ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev,
49 -                                       bs->bh->b_blocknr);
50 +               if (!test_opt(inode->i_sb, NO_MBCACHE))
51 +                       ce = mb_cache_entry_get(ext4_xattr_cache,
52 +                                               bs->bh->b_bdev,
53 +                                               bs->bh->b_blocknr);
54                 error = ext4_journal_get_write_access(handle, bs->bh);
55                 if (error)
56                         goto cleanup;
57 @@ -718,7 +723,7 @@ ext4_xattr_block_set(handle_t *handle, s
58                                 if (!IS_LAST_ENTRY(s->first))
59                                         ext4_xattr_rehash(header(s->base),
60                                                           s->here);
61 -                               ext4_xattr_cache_insert(bs->bh);
62 +                               ext4_xattr_cache_insert(sb, bs->bh);
63                         }
64                         unlock_buffer(bs->bh);
65                         if (error == -EIO)
66 @@ -801,7 +806,8 @@ inserted:
67                                 if (error)
68                                         goto cleanup_dquot;
69                         }
70 -                       mb_cache_entry_release(ce);
71 +                       if (ce)
72 +                               mb_cache_entry_release(ce);
73                         ce = NULL;
74                 } else if (bs->bh && s->base == bs->bh->b_data) {
75                         /* We were modifying this block in-place. */
76 @@ -845,7 +851,7 @@ getblk_failed:
77                         memcpy(new_bh->b_data, s->base, new_bh->b_size);
78                         set_buffer_uptodate(new_bh);
79                         unlock_buffer(new_bh);
80 -                       ext4_xattr_cache_insert(new_bh);
81 +                       ext4_xattr_cache_insert(sb, new_bh);
82                         error = ext4_handle_dirty_metadata(handle,
83                                                            inode, new_bh);
84                         if (error)
85 @@ -1404,12 +1410,15 @@ ext4_xattr_put_super(struct super_block 
86   * Returns 0, or a negative error number on failure.
87   */
88  static void
89 -ext4_xattr_cache_insert(struct buffer_head *bh)
90 +ext4_xattr_cache_insert(struct super_block *sb, struct buffer_head *bh)
91  {
92         __u32 hash = le32_to_cpu(BHDR(bh)->h_hash);
93         struct mb_cache_entry *ce;
94         int error;
95  
96 +       if (test_opt(sb, NO_MBCACHE))
97 +               return;
98 +
99         ce = mb_cache_entry_alloc(ext4_xattr_cache);
100         if (!ce) {
101                 ea_bdebug(bh, "out of memory");
102 @@ -1483,6 +1492,8 @@ ext4_xattr_cache_find(struct inode *inod
103         __u32 hash = le32_to_cpu(header->h_hash);
104         struct mb_cache_entry *ce;
105  
106 +       if (test_opt(inode->i_sb, NO_MBCACHE))
107 +               return NULL;
108         if (!header->h_hash)
109                 return NULL;  /* never share */
110         ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
111 Index: linux-stage/fs/ext4/super.c
112 ===================================================================
113 --- linux-stage.orig/fs/ext4/super.c
114 +++ linux-stage/fs/ext4/super.c
115 @@ -1481,6 +1481,7 @@ enum {
116
117         Opt_iopen, Opt_noiopen, Opt_iopen_nopriv, Opt_bigendian_extents,
118         Opt_force_over_16tb,
119 +       Opt_no_mbcache,
120  };
121  
122  static match_table_t tokens = {
123 @@ -1554,6 +1555,7 @@ static match_table_t tokens = {
124         {Opt_noauto_da_alloc, "noauto_da_alloc"},
125         {Opt_bigendian_extents, "bigendian_extents"},
126         {Opt_force_over_16tb, "force_over_16tb"},
127 +       {Opt_no_mbcache, "no_mbcache"},
128         {Opt_err, NULL},
129  };
130  
131 @@ -2030,6 +2032,9 @@ set_qf_format:
132                         }
133                         clear_opt(sbi->s_mount_opt, EXTENTS);
134                         break;
135 +               case Opt_no_mbcache:
136 +                       set_opt(sbi->s_mount_opt, NO_MBCACHE);
137 +                       break;
138                 default:
139                         ext4_msg(sb, KERN_ERR,
140                                "Unrecognized mount option \"%s\" "
141 Index: linux-stage/fs/ext4/ext4.h
142 ===================================================================
143 --- linux-stage.orig/fs/ext4/ext4.h
144 +++ linux-stage/fs/ext4/ext4.h
145 @@ -715,7 +715,8 @@ struct ext4_inode_info {
146  /*
147   * Mount flags
148   */
149 -#define EXT4_MOUNT_OLDALLOC            0x00002  /* Don't use the new Orlov allocator */
150 +#define EXT4_MOUNT_NO_MBCACHE           0x00001 /* Disable mbcache */
151 +#define EXT4_MOUNT_OLDALLOC            0x00002 /* Don't use the new Orlov allocator */
152  #define EXT4_MOUNT_GRPID               0x00004 /* Create files with directory's group */
153  #define EXT4_MOUNT_DEBUG               0x00008 /* Some debugging messages */
154  #define EXT4_MOUNT_ERRORS_CONT         0x00010 /* Continue on errors */