Whamcloud - gitweb
b38db4fc6ba40d430eefac7918a546da05b8c8e4
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel6.3 / ext4-disable-mb-cache.patch
1 Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/ext4.h
2 ===================================================================
3 --- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/ext4.h
4 +++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/ext4.h
5 @@ -873,7 +873,8 @@ struct ext4_inode_info {
6  /*
7   * Mount flags
8   */
9 -#define EXT4_MOUNT_OLDALLOC            0x00002  /* Don't use the new Orlov allocator */
10 +#define EXT4_MOUNT_NO_MBCACHE          0x00001 /* Disable mbcache */
11 +#define EXT4_MOUNT_OLDALLOC            0x00002 /* Don't use the new Orlov allocator */
12  #define EXT4_MOUNT_GRPID               0x00004 /* Create files with directory's group */
13  #define EXT4_MOUNT_DEBUG               0x00008 /* Some debugging messages */
14  #define EXT4_MOUNT_ERRORS_CONT         0x00010 /* Continue on errors */
15 Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/super.c
16 ===================================================================
17 --- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/super.c
18 +++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/super.c
19 @@ -1252,6 +1252,7 @@ enum {
20         Opt_stripe, Opt_delalloc, Opt_nodelalloc,
21         Opt_block_validity, Opt_noblock_validity,
22         Opt_inode_readahead_blks, Opt_journal_ioprio,
23 +       Opt_no_mbcache,
24         Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
25  };
26  
27 @@ -1320,6 +1321,7 @@ static const match_table_t tokens = {
28         {Opt_auto_da_alloc, "auto_da_alloc=%u"},
29         {Opt_auto_da_alloc, "auto_da_alloc"},
30         {Opt_noauto_da_alloc, "noauto_da_alloc"},
31 +       {Opt_no_mbcache, "no_mbcache"},
32         {Opt_discard, "discard"},
33         {Opt_nodiscard, "nodiscard"},
34         {Opt_init_itable, "init_itable=%u"},
35 @@ -1780,6 +1782,9 @@ set_qf_format:
36                 case Opt_noinit_itable:
37                         clear_opt(sbi->s_mount_opt, INIT_INODE_TABLE);
38                         break;
39 +               case Opt_no_mbcache:
40 +                       set_opt(sbi->s_mount_opt, NO_MBCACHE);
41 +                       break;
42                 default:
43                         ext4_msg(sb, KERN_ERR,
44                                "Unrecognized mount option \"%s\" "
45 Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/xattr.c
46 ===================================================================
47 --- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/xattr.c
48 +++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/xattr.c
49 @@ -86,7 +86,8 @@
50  # define ea_bdebug(f...)
51  #endif
52  
53 -static void ext4_xattr_cache_insert(struct buffer_head *);
54 +static void ext4_xattr_cache_insert(struct super_block *,
55 +                                   struct buffer_head *);
56  static struct buffer_head *ext4_xattr_cache_find(struct inode *,
57                                                  struct ext4_xattr_header *,
58                                                  struct mb_cache_entry **);
59 @@ -333,7 +334,7 @@ bad_block:
60                 error = -EIO;
61                 goto cleanup;
62         }
63 -       ext4_xattr_cache_insert(bh);
64 +       ext4_xattr_cache_insert(inode->i_sb, bh);
65         entry = BFIRST(bh);
66         error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1,
67                                       inode);
68 @@ -492,7 +493,7 @@ ext4_xattr_block_list(struct inode *inod
69                 error = -EIO;
70                 goto cleanup;
71         }
72 -       ext4_xattr_cache_insert(bh);
73 +       ext4_xattr_cache_insert(inode->i_sb, bh);
74         error = ext4_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size);
75  
76  cleanup:
77 @@ -589,7 +590,9 @@ ext4_xattr_release_block(handle_t *handl
78         struct mb_cache_entry *ce = NULL;
79         int error = 0;
80  
81 -       ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, bh->b_blocknr);
82 +       if (!test_opt(inode->i_sb, NO_MBCACHE))
83 +               ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev,
84 +                                       bh->b_blocknr);
85         error = ext4_journal_get_write_access(handle, bh);
86         if (error)
87                 goto out;
88 @@ -988,8 +991,10 @@ ext4_xattr_block_set(handle_t *handle, s
89  #define header(x) ((struct ext4_xattr_header *)(x))
90  
91         if (s->base) {
92 -               ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev,
93 -                                       bs->bh->b_blocknr);
94 +               if (!test_opt(inode->i_sb, NO_MBCACHE))
95 +                       ce = mb_cache_entry_get(ext4_xattr_cache,
96 +                                               bs->bh->b_bdev,
97 +                                               bs->bh->b_blocknr);
98                 error = ext4_journal_get_write_access(handle, bs->bh);
99                 if (error)
100                         goto cleanup;
101 @@ -1006,7 +1011,7 @@ ext4_xattr_block_set(handle_t *handle, s
102                                 if (!IS_LAST_ENTRY(s->first))
103                                         ext4_xattr_rehash(header(s->base),
104                                                           s->here);
105 -                               ext4_xattr_cache_insert(bs->bh);
106 +                               ext4_xattr_cache_insert(sb, bs->bh);
107                         }
108                         unlock_buffer(bs->bh);
109                         if (error == -EIO)
110 @@ -1089,7 +1094,8 @@ inserted:
111                                 if (error)
112                                         goto cleanup_dquot;
113                         }
114 -                       mb_cache_entry_release(ce);
115 +                       if (ce)
116 +                               mb_cache_entry_release(ce);
117                         ce = NULL;
118                 } else if (bs->bh && s->base == bs->bh->b_data) {
119                         /* We were modifying this block in-place. */
120 @@ -1140,7 +1146,7 @@ getblk_failed:
121                         memcpy(new_bh->b_data, s->base, new_bh->b_size);
122                         set_buffer_uptodate(new_bh);
123                         unlock_buffer(new_bh);
124 -                       ext4_xattr_cache_insert(new_bh);
125 +                       ext4_xattr_cache_insert(sb, new_bh);
126                         error = ext4_handle_dirty_metadata(handle,
127                                                            inode, new_bh);
128                         if (error)
129 @@ -1857,12 +1863,15 @@ ext4_xattr_put_super(struct super_block
130   * Returns 0, or a negative error number on failure.
131   */
132  static void
133 -ext4_xattr_cache_insert(struct buffer_head *bh)
134 +ext4_xattr_cache_insert(struct super_block *sb, struct buffer_head *bh)
135  {
136         __u32 hash = le32_to_cpu(BHDR(bh)->h_hash);
137         struct mb_cache_entry *ce;
138         int error;
139  
140 +       if (test_opt(sb, NO_MBCACHE))
141 +               return;
142 +
143         ce = mb_cache_entry_alloc(ext4_xattr_cache, GFP_NOFS);
144         if (!ce) {
145                 ea_bdebug(bh, "out of memory");
146 @@ -1935,6 +1944,8 @@ ext4_xattr_cache_find(struct inode *inod
147         __u32 hash = le32_to_cpu(header->h_hash);
148         struct mb_cache_entry *ce;
149  
150 +       if (test_opt(inode->i_sb, NO_MBCACHE))
151 +               return NULL;
152         if (!header->h_hash)
153                 return NULL;  /* never share */
154         ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);