Whamcloud - gitweb
28b3758195c1a2322716b345cfee1f7d65dde782
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext3-disable-mb-cache.patch
1 Index: linux-stage/fs/ext3/xattr.c
2 ===================================================================
3 --- linux-stage.orig/fs/ext3/xattr.c
4 +++ linux-stage/fs/ext3/xattr.c
5 @@ -93,7 +93,8 @@
6  # define ea_bdebug(f...)
7  #endif
8  
9 -static void ext3_xattr_cache_insert(struct buffer_head *);
10 +static void ext3_xattr_cache_insert(struct super_block *,
11 +                                   struct buffer_head *);
12  static struct buffer_head *ext3_xattr_cache_find(struct inode *,
13                                                  struct ext3_xattr_header *,
14                                                  struct mb_cache_entry **);
15 @@ -238,7 +239,7 @@ bad_block:  ext3_error(inode->i_sb, __FUN
16                 error = -EIO;
17                 goto cleanup;
18         }
19 -       ext3_xattr_cache_insert(bh);
20 +       ext3_xattr_cache_insert(inode->i_sb, bh);
21         entry = BFIRST(bh);
22         error = ext3_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
23         if (error == -EIO)
24 @@ -380,7 +381,7 @@ ext3_xattr_block_list(struct inode *inod
25                 error = -EIO;
26                 goto cleanup;
27         }
28 -       ext3_xattr_cache_insert(bh);
29 +       ext3_xattr_cache_insert(inode->i_sb, bh);
30         error = ext3_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size);
31  
32  cleanup:
33 @@ -479,7 +480,9 @@ ext3_xattr_release_block(handle_t *handl
34  {
35         struct mb_cache_entry *ce = NULL;
36  
37 -       ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_bdev, bh->b_blocknr);
38 +       if (!test_opt(inode->i_sb, NO_MBCACHE))
39 +               ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_bdev,
40 +                                       bh->b_blocknr);
41         if (BHDR(bh)->h_refcount == cpu_to_le32(1)) {
42                 ea_bdebug(bh, "refcount now=0; freeing");
43                 if (ce)
44 @@ -699,8 +702,10 @@ ext3_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(ext3_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(ext3_xattr_cache,
52 +                                               bs->bh->b_bdev,
53 +                                               bs->bh->b_blocknr);
54                 if (header(s->base)->h_refcount == cpu_to_le32(1)) {
55                         if (ce) {
56                                 mb_cache_entry_free(ce);
57 @@ -716,7 +721,7 @@ ext3_xattr_block_set(handle_t *handle, s
58                                 if (!IS_LAST_ENTRY(s->first))
59                                         ext3_xattr_rehash(header(s->base),
60                                                           s->here);
61 -                               ext3_xattr_cache_insert(bs->bh);
62 +                               ext3_xattr_cache_insert(sb, bs->bh);
63                         }
64                         unlock_buffer(bs->bh);
65                         if (error == -EIO)
66 @@ -797,7 +802,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 @@ -832,7 +838,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 -                       ext3_xattr_cache_insert(new_bh);
81 +                       ext3_xattr_cache_insert(sb, new_bh);
82                         error = ext3_journal_dirty_metadata(handle, new_bh);
83                         if (error)
84                                 goto cleanup;
85 @@ -1387,12 +1393,15 @@ ext3_xattr_put_super(struct super_block 
86   * Returns 0, or a negative error number on failure.
87   */
88  static void
89 -ext3_xattr_cache_insert(struct buffer_head *bh)
90 +ext3_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(ext3_xattr_cache);
100         if (!ce) {
101                 ea_bdebug(bh, "out of memory");
102 @@ -1466,6 +1475,8 @@ ext3_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/ext3/super.c
112 ===================================================================
113 --- linux-stage.orig/fs/ext3/super.c
114 +++ linux-stage/fs/ext3/super.c
115 @@ -722,6 +722,7 @@ enum {
116         Opt_grpquota,
117         Opt_extents, Opt_noextents, Opt_bigendian_extents, Opt_extdebug,
118         Opt_mballoc, Opt_nomballoc, Opt_stripe, Opt_maxdirsize, Opt_force_over_8tb,
119 +       Opt_no_mbcache,
120  };
121  
122  static match_table_t tokens = {
123 @@ -788,6 +789,7 @@ static match_table_t tokens = {
124         {Opt_force_over_8tb, "force_over_8tb"},
125         {Opt_resize, "resize"},
126         {Opt_maxdirsize, "maxdirsize=%u"},
127 +       {Opt_no_mbcache, "no_mbcache"},
128         {Opt_err, NULL}
129  };
130  
131 @@ -1175,6 +1177,9 @@ clear_qf_name:
132                 case Opt_force_over_8tb:
133                         force_over_8tb = 1;
134                         break;
135 +               case Opt_no_mbcache:
136 +                       set_opt(sbi->s_mount_opt, NO_MBCACHE);
137 +                       break;
138                 default:
139                         printk (KERN_ERR
140                                 "EXT3-fs: Unrecognized mount option \"%s\" "
141 Index: linux-stage/include/linux/ext3_fs.h
142 ===================================================================
143 --- linux-stage.orig/include/linux/ext3_fs.h
144 +++ linux-stage/include/linux/ext3_fs.h
145 @@ -483,6 +483,8 @@ do {                                                                               \
146  #define EXT3_MOUNT_JOURNAL_ASYNC_COMMIT 0x20000000 /* Journal Async Commit */
147  #endif
148  
149 +#define EXT3_MOUNT_NO_MBCACHE           0x40000000 /* Disable mbcache */
150 +
151  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
152  #ifndef clear_opt
153  #define clear_opt(o, opt)              o &= ~EXT3_MOUNT_##opt