Whamcloud - gitweb
LU-11310 ldiskfs: Support for SUSE 15 GA and SP1
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / suse15 / 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: b/fs/ext4/ext4.h
9 ===================================================================
10 --- a/fs/ext4/ext4.h
11 +++ b/fs/ext4/ext4.h
12 @@ -1119,6 +1119,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: b/fs/ext4/super.c
21 ===================================================================
22 --- a/fs/ext4/super.c
23 +++ b/fs/ext4/super.c
24 @@ -1335,6 +1335,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, Opt_nojournal_checksum,
31  };
32 @@ -1416,6 +1417,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 @@ -1580,6 +1582,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: b/fs/ext4/xattr.c
49 ===================================================================
50 --- a/fs/ext4/xattr.c
51 +++ b/fs/ext4/xattr.c
52 @@ -73,7 +73,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 @@ -413,7 +413,8 @@ ext4_xattr_block_get(struct inode *inode
62         error = ext4_xattr_check_block(inode, bh);
63         if (error)
64                 goto cleanup;
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         end = bh->b_data + bh->b_size;
70         error = xattr_find_entry(inode, &entry, end, name_index, name, 1);
71 @@ -579,7 +580,8 @@ ext4_xattr_block_list(struct dentry *den
72         error = ext4_xattr_check_block(inode, bh);
73         if (error)
74                 goto cleanup;
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 @@ -694,7 +696,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 @@ -704,9 +708,10 @@ ext4_xattr_release_block(handle_t *handl
93                 ref--;
94                 BHDR(bh)->h_refcount = cpu_to_le32(ref);
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 @@ -1147,7 +1152,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 @@ -1155,8 +1161,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                         ext4_xattr_block_csum_set(inode, bs->bh);
126                         unlock_buffer(bs->bh);
127 @@ -1324,7 +1331,8 @@ getblk_failed:
128                         ext4_xattr_block_csum_set(inode, new_bh);
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_metadata(handle, inode,
135                                                            new_bh);
136                         if (error)
137 @@ -2127,7 +2135,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 @@ -2199,6 +2207,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);