Whamcloud - gitweb
LU-13437 lmv: check stripe FID sanity
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / sles12sp2 / ext4-disable-mb-cache.patch
1 mbcache provides absolutely no value for Lustre xattrs (because
2 they are unique and cannot be shared between files) and as we can
3 see it has a noticable overhead in some cases. In the past there
4 was a CONFIG_MBCACHE option that would allow it to be disabled,
5 but this was removed in newer kernels, so we will need to patch
6 ldiskfs to fix this.
7
8 Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/ext4.h
9 ===================================================================
10 --- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/ext4.h
11 +++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/ext4.h
12 @@ -944,6 +944,7 @@ struct ext4_inode_info {
13  /*
14   * Mount flags set via mount options or defaults
15   */
16 +#define EXT4_MOUNT_NO_MBCACHE          0x00001 /* Disable mbcache */
17  #define EXT4_MOUNT_GRPID               0x00004 /* Create files with directory's group */
18  #define EXT4_MOUNT_DEBUG               0x00008 /* Some debugging messages */
19  #define EXT4_MOUNT_ERRORS_CONT         0x00010 /* Continue on errors */
20 Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/super.c
21 ===================================================================
22 --- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/super.c
23 +++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/super.c
24 @@ -1157,6 +1157,7 @@ enum {
25         Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity,
26         Opt_inode_readahead_blks, Opt_journal_ioprio,
27         Opt_dioread_nolock, Opt_dioread_lock,
28 +       Opt_no_mbcache,
29         Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
30         Opt_max_dir_size_kb,
31  };
32 @@ -1231,6 +1232,7 @@ static const match_table_t tokens = {
33         {Opt_discard, "discard"},
34         {Opt_nodiscard, "nodiscard"},
35         {Opt_init_itable, "init_itable=%u"},
36 +       {Opt_no_mbcache, "no_mbcache"},
37         {Opt_init_itable, "init_itable"},
38         {Opt_noinit_itable, "noinit_itable"},
39         {Opt_max_dir_size_kb, "max_dir_size_kb=%u"},
40 @@ -1390,6 +1392,7 @@ static const struct mount_opts {
41         {Opt_noauto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_SET},
42         {Opt_auto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_CLEAR},
43         {Opt_noinit_itable, EXT4_MOUNT_INIT_INODE_TABLE, MOPT_CLEAR},
44 +       {Opt_no_mbcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET},
45         {Opt_commit, 0, MOPT_GTE0},
46         {Opt_max_batch_time, 0, MOPT_GTE0},
47         {Opt_min_batch_time, 0, MOPT_GTE0},
48 Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/xattr.c
49 ===================================================================
50 --- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/xattr.c
51 +++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/xattr.c
52 @@ -80,7 +80,7 @@
53  # define ea_bdebug(bh, fmt, ...)       no_printk(fmt, ##__VA_ARGS__)
54  #endif
55  
56 -static void ext4_xattr_cache_insert(struct mb_cache *, struct buffer_head *);
57 +static void _ext4_xattr_cache_insert(struct mb_cache *, struct buffer_head *);
58  static struct buffer_head *ext4_xattr_cache_find(struct inode *,
59                                                  struct ext4_xattr_header *,
60                                                  struct mb_cache_entry **);
61 @@ -401,7 +401,8 @@ bad_block:
62                 error = -EFSCORRUPTED;
63                 goto cleanup;
64         }
65 -       ext4_xattr_cache_insert(ext4_mb_cache, bh);
66 +       if (!test_opt(inode->i_sb, NO_MBCACHE))
67 +               _ext4_xattr_cache_insert(ext4_mb_cache, bh);
68         entry = BFIRST(bh);
69         error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1,
70                                       inode);
71 @@ -565,7 +566,8 @@ ext4_xattr_block_list(struct dentry *den
72                 error = -EFSCORRUPTED;
73                 goto cleanup;
74         }
75 -       ext4_xattr_cache_insert(ext4_mb_cache, bh);
76 +       if (!test_opt(inode->i_sb, NO_MBCACHE))
77 +               _ext4_xattr_cache_insert(ext4_mb_cache, bh);
78         error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
79  
80  cleanup:
81 @@ -678,7 +680,9 @@ ext4_xattr_release_block(handle_t *handl
82                  * This must happen under buffer lock for
83                  * ext4_xattr_block_set() to reliably detect freed block
84                  */
85 -               mb_cache_entry_delete_block(ext4_mb_cache, hash, bh->b_blocknr);
86 +               if (!test_opt(inode->i_sb, NO_MBCACHE))
87 +                       mb_cache_entry_delete_block(ext4_mb_cache,
88 +                                                   hash, bh->b_blocknr);
89                 get_bh(bh);
90                 unlock_buffer(bh);
91                 ext4_free_blocks(handle, inode, bh, 0, 1,
92 @@ -690,9 +694,10 @@ ext4_xattr_release_block(handle_t *handl
93  
94  
95                 if (ref == EXT4_XATTR_REFCOUNT_MAX - 1) {
96 -                       struct mb_cache_entry *ce;
97 +                       struct mb_cache_entry *ce = NULL;
98  
99 -                       ce = mb_cache_entry_get(ext4_mb_cache, hash,
100 +                       if (!test_opt(inode->i_sb, NO_MBCACHE))
101 +                               ce = mb_cache_entry_get(ext4_mb_cache, hash,
102                                                 bh->b_blocknr);
103                         if (ce) {
104                                 ce->e_reusable = 1;
105 @@ -1107,7 +1112,8 @@ ext4_xattr_block_set(handle_t *handle, s
106                          * ext4_xattr_block_set() to reliably detect modified
107                          * block
108                          */
109 -                       mb_cache_entry_delete_block(ext4_mb_cache, hash,
110 +                       if (!test_opt(inode->i_sb, NO_MBCACHE))
111 +                               mb_cache_entry_delete_block(ext4_mb_cache, hash,
112                                                     bs->bh->b_blocknr);
113                         ea_bdebug(bs->bh, "modifying in-place");
114                         error = ext4_xattr_set_entry(i, s, handle, inode);
115 @@ -1115,8 +1121,9 @@ ext4_xattr_block_set(handle_t *handle, s
116                                 if (!IS_LAST_ENTRY(s->first))
117                                         ext4_xattr_rehash(header(s->base),
118                                                           s->here);
119 -                               ext4_xattr_cache_insert(ext4_mb_cache,
120 -                                       bs->bh);
121 +                               if (!test_opt(inode->i_sb, NO_MBCACHE))
122 +                                       _ext4_xattr_cache_insert(ext4_mb_cache,
123 +                                                               bs->bh);
124                         }
125                         unlock_buffer(bs->bh);
126                         if (error == -EFSCORRUPTED)
127 @@ -1277,7 +1284,8 @@ getblk_failed:
128                         memcpy(new_bh->b_data, s->base, new_bh->b_size);
129                         set_buffer_uptodate(new_bh);
130                         unlock_buffer(new_bh);
131 -                       ext4_xattr_cache_insert(ext4_mb_cache, new_bh);
132 +                       if (!test_opt(inode->i_sb, NO_MBCACHE))
133 +                               _ext4_xattr_cache_insert(ext4_mb_cache, new_bh);
134                         error = ext4_handle_dirty_xattr_block(handle,
135                                                               inode, new_bh);
136                         if (error)
137 @@ -2068,7 +2076,7 @@ ext4_xattr_inode_array_free(struct inode
138   * Returns 0, or a negative error number on failure.
139   */
140  static void
141 -ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh)
142 +_ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh)
143  {
144         struct ext4_xattr_header *header = BHDR(bh);
145         __u32 hash = le32_to_cpu(header->h_hash);
146 @@ -2140,6 +2148,8 @@ ext4_xattr_cache_find(struct inode *inod
147         struct mb_cache_entry *ce;
148         struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
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);