Whamcloud - gitweb
LU-136 change "force_over_16tb" mount option to "force_over_128tb"
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-disable-mb-cache-rhel6.patch
1 Index: linux-stage/fs/ext4/ext4.h
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ext4.h     2011-03-14 16:16:45.000000000 +0800
4 +++ linux-stage/fs/ext4/ext4.h  2011-03-14 16:17:08.732676431 +0800
5 @@ -758,7 +758,8 @@
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-stage/fs/ext4/super.c
16 ===================================================================
17 --- linux-stage.orig/fs/ext4/super.c    2011-03-14 16:16:45.000000000 +0800
18 +++ linux-stage/fs/ext4/super.c 2011-03-14 16:18:13.831956469 +0800
19 @@ -1502,6 +1502,7 @@
20         Opt_inode_readahead_blks, Opt_journal_ioprio,
21         Opt_discard, Opt_nodiscard,
22         Opt_mballoc, Opt_bigendian_extents, Opt_force_over_128tb,
23 +       Opt_no_mbcache,
24         Opt_extents, Opt_noextents,
25  };
26  
27 @@ -1574,6 +1575,7 @@
28         {Opt_mballoc, "mballoc"},
29         {Opt_discard, "discard"},
30         {Opt_nodiscard, "nodiscard"},
31 +       {Opt_no_mbcache, "no_mbcache"},
32         {Opt_extents, "extents"},
33         {Opt_noextents, "noextents"},
34         {Opt_err, NULL},
35 @@ -2049,6 +2051,9 @@
36                         }
37                         clear_opt(sbi->s_mount_opt, EXTENTS);
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-stage/fs/ext4/xattr.c
46 ===================================================================
47 --- linux-stage.orig/fs/ext4/xattr.c    2011-03-14 16:16:43.000000000 +0800
48 +++ linux-stage/fs/ext4/xattr.c 2011-03-14 16:17:08.806677883 +0800
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 @@ -234,7 +235,7 @@
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         if (error == -EIO)
68 @@ -376,7 +377,7 @@
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 @@ -473,7 +474,9 @@
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 @@ -700,8 +703,10 @@
89         if (i->value && i->value_len > sb->s_blocksize)
90                 return -ENOSPC;
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 @@ -718,7 +723,7 @@
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 @@ -801,7 +806,8 @@
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 @@ -845,7 +851,7 @@
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 @@ -1403,12 +1409,15 @@
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 @@ -1482,6 +1491,8 @@
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);