1 ext2, ext4: make mb block cache names more explicit
3 From: Tahsin Erdogan <tahsin@google.com>
5 There will be a second mb_cache instance that tracks ea_inodes. Make
6 existing names more explicit so that it is clear that they refer to
9 Signed-off-by: Tahsin Erdogan <tahsin@google.com>
10 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 - renamed s_mb_cache to s_mb_block_cache in both ext2 and ext4
14 - renamed local variables named ext[24]_mb_cache to mb_block_cache
15 - renamed macro EXT4_GET_MB_CACHE() to MB_BLOCK_CACHE()
16 - added MB_BLOCK_CACHE() to ext2 for consistency with ext4
19 fs/ext2/super.c | 16 ++++++-------
20 fs/ext2/xattr.c | 36 +++++++++++++++--------------
22 fs/ext4/super.c | 18 +++++++--------
23 fs/ext4/xattr.c | 71 ++++++++++++++++++++++++++++++---------------------------
24 6 files changed, 75 insertions(+), 70 deletions(-)
26 diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
27 index 03f5ce1d3dbe..23ebb92484c6 100644
30 @@ -113,7 +113,7 @@ struct ext2_sb_info {
31 * of the mount options.
34 - struct mb_cache *s_mb_cache;
35 + struct mb_cache *s_ea_block_cache;
38 static inline spinlock_t *
39 diff --git a/fs/ext2/super.c b/fs/ext2/super.c
40 index 9c2028b50e5c..7b1bc9059863 100644
43 @@ -147,9 +147,9 @@ static void ext2_put_super (struct super_block * sb)
45 ext2_quota_off_umount(sb);
47 - if (sbi->s_mb_cache) {
48 - ext2_xattr_destroy_cache(sbi->s_mb_cache);
49 - sbi->s_mb_cache = NULL;
50 + if (sbi->s_ea_block_cache) {
51 + ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
52 + sbi->s_ea_block_cache = NULL;
54 if (!(sb->s_flags & MS_RDONLY)) {
55 struct ext2_super_block *es = sbi->s_es;
56 @@ -1131,9 +1131,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
59 #ifdef CONFIG_EXT2_FS_XATTR
60 - sbi->s_mb_cache = ext2_xattr_create_cache();
61 - if (!sbi->s_mb_cache) {
62 - ext2_msg(sb, KERN_ERR, "Failed to create an mb_cache");
63 + sbi->s_ea_block_cache = ext2_xattr_create_cache();
64 + if (!sbi->s_ea_block_cache) {
65 + ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
69 @@ -1182,8 +1182,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
73 - if (sbi->s_mb_cache)
74 - ext2_xattr_destroy_cache(sbi->s_mb_cache);
75 + if (sbi->s_ea_block_cache)
76 + ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
77 percpu_counter_destroy(&sbi->s_freeblocks_counter);
78 percpu_counter_destroy(&sbi->s_freeinodes_counter);
79 percpu_counter_destroy(&sbi->s_dirs_counter);
80 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
81 index 1e5f76070580..1b9b1268d418 100644
84 @@ -121,6 +121,8 @@ const struct xattr_handler *ext2_xattr_handlers[] = {
88 +#define EA_BLOCK_CACHE(inode) (EXT2_SB(inode->i_sb)->s_ea_block_cache)
90 static inline const struct xattr_handler *
91 ext2_xattr_handler(int name_index)
93 @@ -150,7 +152,7 @@ ext2_xattr_get(struct inode *inode, int name_index, const char *name,
94 size_t name_len, size;
97 - struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache;
98 + struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
100 ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
101 name_index, name, buffer, (long)buffer_size);
102 @@ -195,7 +197,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
106 - if (ext2_xattr_cache_insert(ext2_mb_cache, bh))
107 + if (ext2_xattr_cache_insert(ea_block_cache, bh))
108 ea_idebug(inode, "cache insert failed");
111 @@ -208,7 +210,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
112 le16_to_cpu(entry->e_value_offs) + size > inode->i_sb->s_blocksize)
115 - if (ext2_xattr_cache_insert(ext2_mb_cache, bh))
116 + if (ext2_xattr_cache_insert(ea_block_cache, bh))
117 ea_idebug(inode, "cache insert failed");
120 @@ -246,7 +248,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
122 size_t rest = buffer_size;
124 - struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache;
125 + struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
127 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
128 buffer, (long)buffer_size);
129 @@ -281,7 +283,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
133 - if (ext2_xattr_cache_insert(ext2_mb_cache, bh))
134 + if (ext2_xattr_cache_insert(ea_block_cache, bh))
135 ea_idebug(inode, "cache insert failed");
137 /* list the attribute names */
138 @@ -493,7 +495,7 @@ bad_block: ext2_error(sb, "ext2_xattr_set",
139 * This must happen under buffer lock for
140 * ext2_xattr_set2() to reliably detect modified block
142 - mb_cache_entry_delete(EXT2_SB(sb)->s_mb_cache, hash,
143 + mb_cache_entry_delete(EA_BLOCK_CACHE(inode), hash,
146 /* keep the buffer locked while modifying it. */
147 @@ -627,7 +629,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
148 struct super_block *sb = inode->i_sb;
149 struct buffer_head *new_bh = NULL;
151 - struct mb_cache *ext2_mb_cache = EXT2_SB(sb)->s_mb_cache;
152 + struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
155 new_bh = ext2_xattr_cache_find(inode, header);
156 @@ -655,7 +657,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
157 don't need to change the reference count. */
160 - ext2_xattr_cache_insert(ext2_mb_cache, new_bh);
161 + ext2_xattr_cache_insert(ea_block_cache, new_bh);
163 /* We need to allocate a new block */
164 ext2_fsblk_t goal = ext2_group_first_block_no(sb,
165 @@ -676,7 +678,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
166 memcpy(new_bh->b_data, header, new_bh->b_size);
167 set_buffer_uptodate(new_bh);
168 unlock_buffer(new_bh);
169 - ext2_xattr_cache_insert(ext2_mb_cache, new_bh);
170 + ext2_xattr_cache_insert(ea_block_cache, new_bh);
172 ext2_xattr_update_super_block(sb);
174 @@ -721,7 +723,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
175 * This must happen under buffer lock for
176 * ext2_xattr_set2() to reliably detect freed block
178 - mb_cache_entry_delete(ext2_mb_cache, hash,
179 + mb_cache_entry_delete(ea_block_cache, hash,
181 /* Free the old block. */
182 ea_bdebug(old_bh, "freeing");
183 @@ -795,7 +797,7 @@ ext2_xattr_delete_inode(struct inode *inode)
184 * This must happen under buffer lock for ext2_xattr_set2() to
185 * reliably detect freed block
187 - mb_cache_entry_delete(EXT2_SB(inode->i_sb)->s_mb_cache, hash,
188 + mb_cache_entry_delete(EA_BLOCK_CACHE(inode), hash,
190 ext2_free_blocks(inode, EXT2_I(inode)->i_file_acl, 1);
192 @@ -897,13 +899,13 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
194 __u32 hash = le32_to_cpu(header->h_hash);
195 struct mb_cache_entry *ce;
196 - struct mb_cache *ext2_mb_cache = EXT2_SB(inode->i_sb)->s_mb_cache;
197 + struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
200 return NULL; /* never share */
201 ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
203 - ce = mb_cache_entry_find_first(ext2_mb_cache, hash);
204 + ce = mb_cache_entry_find_first(ea_block_cache, hash);
206 struct buffer_head *bh;
208 @@ -924,7 +926,7 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
209 * entry is still hashed is reliable.
211 if (hlist_bl_unhashed(&ce->e_hash_list)) {
212 - mb_cache_entry_put(ext2_mb_cache, ce);
213 + mb_cache_entry_put(ea_block_cache, ce);
217 @@ -937,14 +939,14 @@ ext2_xattr_cache_find(struct inode *inode, struct ext2_xattr_header *header)
218 } else if (!ext2_xattr_cmp(header, HDR(bh))) {
219 ea_bdebug(bh, "b_count=%d",
220 atomic_read(&(bh->b_count)));
221 - mb_cache_entry_touch(ext2_mb_cache, ce);
222 - mb_cache_entry_put(ext2_mb_cache, ce);
223 + mb_cache_entry_touch(ea_block_cache, ce);
224 + mb_cache_entry_put(ea_block_cache, ce);
230 - ce = mb_cache_entry_find_next(ext2_mb_cache, ce);
231 + ce = mb_cache_entry_find_next(ea_block_cache, ce);
235 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
236 index 580fdb753f29..e4a75c643731 100644
239 @@ -1516,7 +1516,7 @@ struct ext4_sb_info {
240 struct list_head s_es_list; /* List of inodes with reclaimable extents */
242 struct ext4_es_stats s_es_stats;
243 - struct mb_cache *s_mb_cache;
244 + struct mb_cache *s_ea_block_cache;
245 spinlock_t s_es_lock ____cacheline_aligned_in_smp;
247 /* Ratelimit ext4 messages. */
248 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
249 index b02a23ec92ca..380389740575 100644
250 --- a/fs/ext4/super.c
251 +++ b/fs/ext4/super.c
252 @@ -927,9 +927,9 @@ static void ext4_put_super(struct super_block *sb)
253 invalidate_bdev(sbi->journal_bdev);
254 ext4_blkdev_remove(sbi);
256 - if (sbi->s_mb_cache) {
257 - ext4_xattr_destroy_cache(sbi->s_mb_cache);
258 - sbi->s_mb_cache = NULL;
259 + if (sbi->s_ea_block_cache) {
260 + ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
261 + sbi->s_ea_block_cache = NULL;
264 kthread_stop(sbi->s_mmp_tsk);
265 @@ -4061,9 +4061,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
266 sbi->s_journal->j_commit_callback = ext4_journal_commit_callback;
269 - sbi->s_mb_cache = ext4_xattr_create_cache();
270 - if (!sbi->s_mb_cache) {
271 - ext4_msg(sb, KERN_ERR, "Failed to create an mb_cache");
272 + sbi->s_ea_block_cache = ext4_xattr_create_cache();
273 + if (!sbi->s_ea_block_cache) {
274 + ext4_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
275 goto failed_mount_wq;
278 @@ -4296,9 +4296,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
279 if (EXT4_SB(sb)->rsv_conversion_wq)
280 destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
282 - if (sbi->s_mb_cache) {
283 - ext4_xattr_destroy_cache(sbi->s_mb_cache);
284 - sbi->s_mb_cache = NULL;
285 + if (sbi->s_ea_block_cache) {
286 + ext4_xattr_destroy_cache(sbi->s_ea_block_cache);
287 + sbi->s_ea_block_cache = NULL;
289 if (sbi->s_journal) {
290 jbd2_journal_destroy(sbi->s_journal);
291 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
292 index fb437efa8688..fd73dbc92c21 100644
293 --- a/fs/ext4/xattr.c
294 +++ b/fs/ext4/xattr.c
296 # define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
299 -static void ext4_xattr_cache_insert(struct mb_cache *, struct buffer_head *);
300 -static struct buffer_head *ext4_xattr_cache_find(struct inode *,
301 - struct ext4_xattr_header *,
302 - struct mb_cache_entry **);
303 +static void ext4_xattr_block_cache_insert(struct mb_cache *,
304 + struct buffer_head *);
305 +static struct buffer_head *
306 +ext4_xattr_block_cache_find(struct inode *, struct ext4_xattr_header *,
307 + struct mb_cache_entry **);
308 static void ext4_xattr_rehash(struct ext4_xattr_header *,
309 struct ext4_xattr_entry *);
311 @@ -104,8 +105,8 @@ const struct xattr_handler *ext4_xattr_handlers[] = {
315 -#define EXT4_GET_MB_CACHE(inode) (((struct ext4_sb_info *) \
316 - inode->i_sb->s_fs_info)->s_mb_cache)
317 +#define EA_BLOCK_CACHE(inode) (((struct ext4_sb_info *) \
318 + inode->i_sb->s_fs_info)->s_ea_block_cache)
320 #ifdef CONFIG_LOCKDEP
321 void ext4_xattr_inode_set_class(struct inode *ea_inode)
322 @@ -374,7 +375,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
323 struct ext4_xattr_entry *entry;
326 - struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
327 + struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
329 ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
330 name_index, name, buffer, (long)buffer_size);
331 @@ -395,7 +396,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
332 error = -EFSCORRUPTED;
335 - ext4_xattr_cache_insert(ext4_mb_cache, bh);
336 + ext4_xattr_block_cache_insert(ea_block_cache, bh);
338 error = ext4_xattr_find_entry(&entry, name_index, name, 1);
340 @@ -541,7 +542,6 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
341 struct inode *inode = d_inode(dentry);
342 struct buffer_head *bh = NULL;
344 - struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
346 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
347 buffer, (long)buffer_size);
348 @@ -563,7 +563,7 @@ ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
349 error = -EFSCORRUPTED;
352 - ext4_xattr_cache_insert(ext4_mb_cache, bh);
353 + ext4_xattr_block_cache_insert(EA_BLOCK_CACHE(inode), bh);
354 error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
357 @@ -660,7 +660,7 @@ static void
358 ext4_xattr_release_block(handle_t *handle, struct inode *inode,
359 struct buffer_head *bh)
361 - struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
362 + struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
366 @@ -678,7 +678,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
367 * This must happen under buffer lock for
368 * ext4_xattr_block_set() to reliably detect freed block
370 - mb_cache_entry_delete(ext4_mb_cache, hash, bh->b_blocknr);
371 + mb_cache_entry_delete(ea_block_cache, hash, bh->b_blocknr);
374 ext4_free_blocks(handle, inode, bh, 0, 1,
375 @@ -690,11 +690,11 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
376 if (ref == EXT4_XATTR_REFCOUNT_MAX - 1) {
377 struct mb_cache_entry *ce;
379 - ce = mb_cache_entry_get(ext4_mb_cache, hash,
380 + ce = mb_cache_entry_get(ea_block_cache, hash,
384 - mb_cache_entry_put(ext4_mb_cache, ce);
385 + mb_cache_entry_put(ea_block_cache, ce);
389 @@ -1096,7 +1096,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
390 struct ext4_xattr_search *s = &s_copy;
391 struct mb_cache_entry *ce = NULL;
393 - struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
394 + struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
396 #define header(x) ((struct ext4_xattr_header *)(x))
398 @@ -1115,7 +1115,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
399 * ext4_xattr_block_set() to reliably detect modified
402 - mb_cache_entry_delete(ext4_mb_cache, hash,
403 + mb_cache_entry_delete(ea_block_cache, hash,
405 ea_bdebug(bs->bh, "modifying in-place");
406 error = ext4_xattr_set_entry(i, s, handle, inode);
407 @@ -1123,8 +1123,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
408 if (!IS_LAST_ENTRY(s->first))
409 ext4_xattr_rehash(header(s->base),
411 - ext4_xattr_cache_insert(ext4_mb_cache,
413 + ext4_xattr_block_cache_insert(ea_block_cache,
416 ext4_xattr_block_csum_set(inode, bs->bh);
417 unlock_buffer(bs->bh);
418 @@ -1177,7 +1177,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
421 if (!IS_LAST_ENTRY(s->first)) {
422 - new_bh = ext4_xattr_cache_find(inode, header(s->base), &ce);
423 + new_bh = ext4_xattr_block_cache_find(inode, header(s->base),
426 /* We found an identical block in the cache. */
427 if (new_bh == bs->bh)
428 @@ -1222,7 +1223,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
429 EXT4_C2B(EXT4_SB(sb),
432 - mb_cache_entry_put(ext4_mb_cache, ce);
433 + mb_cache_entry_put(ea_block_cache, ce);
437 @@ -1241,8 +1242,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
441 - mb_cache_entry_touch(ext4_mb_cache, ce);
442 - mb_cache_entry_put(ext4_mb_cache, ce);
443 + mb_cache_entry_touch(ea_block_cache, ce);
444 + mb_cache_entry_put(ea_block_cache, ce);
446 } else if (bs->bh && s->base == bs->bh->b_data) {
447 /* We were modifying this block in-place. */
448 @@ -1292,7 +1293,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
449 ext4_xattr_block_csum_set(inode, new_bh);
450 set_buffer_uptodate(new_bh);
451 unlock_buffer(new_bh);
452 - ext4_xattr_cache_insert(ext4_mb_cache, new_bh);
453 + ext4_xattr_block_cache_insert(ea_block_cache, new_bh);
454 error = ext4_handle_dirty_metadata(handle, inode,
457 @@ -1310,7 +1311,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
461 - mb_cache_entry_put(ext4_mb_cache, ce);
462 + mb_cache_entry_put(ea_block_cache, ce);
464 if (!(bs->bh && s->base == bs->bh->b_data))
466 @@ -2150,15 +2151,16 @@ void ext4_xattr_inode_array_free(struct ext4_xattr_inode_array *ea_inode_array)
470 - * ext4_xattr_cache_insert()
471 + * ext4_xattr_block_cache_insert()
473 - * Create a new entry in the extended attribute cache, and insert
474 + * Create a new entry in the extended attribute block cache, and insert
475 * it unless such an entry is already in the cache.
477 * Returns 0, or a negative error number on failure.
480 -ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh)
481 +ext4_xattr_block_cache_insert(struct mb_cache *ea_block_cache,
482 + struct buffer_head *bh)
484 struct ext4_xattr_header *header = BHDR(bh);
485 __u32 hash = le32_to_cpu(header->h_hash);
486 @@ -2166,7 +2168,7 @@ ext4_xattr_cache_insert(struct mb_cache *ext4_mb_cache, struct buffer_head *bh)
487 EXT4_XATTR_REFCOUNT_MAX;
490 - error = mb_cache_entry_create(ext4_mb_cache, GFP_NOFS, hash,
491 + error = mb_cache_entry_create(ea_block_cache, GFP_NOFS, hash,
492 bh->b_blocknr, reusable);
495 @@ -2216,7 +2218,7 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1,
499 - * ext4_xattr_cache_find()
500 + * ext4_xattr_block_cache_find()
502 * Find an identical extended attribute block.
504 @@ -2224,17 +2226,18 @@ ext4_xattr_cmp(struct ext4_xattr_header *header1,
505 * not found or an error occurred.
507 static struct buffer_head *
508 -ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header,
509 - struct mb_cache_entry **pce)
510 +ext4_xattr_block_cache_find(struct inode *inode,
511 + struct ext4_xattr_header *header,
512 + struct mb_cache_entry **pce)
514 __u32 hash = le32_to_cpu(header->h_hash);
515 struct mb_cache_entry *ce;
516 - struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
517 + struct mb_cache *ea_block_cache = EA_BLOCK_CACHE(inode);
520 return NULL; /* never share */
521 ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);
522 - ce = mb_cache_entry_find_first(ext4_mb_cache, hash);
523 + ce = mb_cache_entry_find_first(ea_block_cache, hash);
525 struct buffer_head *bh;
527 @@ -2247,7 +2250,7 @@ ext4_xattr_cache_find(struct inode *inode, struct ext4_xattr_header *header,
531 - ce = mb_cache_entry_find_next(ext4_mb_cache, ce);
532 + ce = mb_cache_entry_find_next(ea_block_cache, ce);
537 2.13.1.611.g7e3b11ae1-goog