Bug #43049: backport ext3 mbcache provides absolutely no value for Lustre xattrs (because they are unique and cannot be shared between files) and as we can see it has a noticable overhead in some cases. In the past there was a CONFIG_MBCACHE option that would allow it to be disabled, but this was removed in newer kernels, so we will need to patch ldiskfs to fix this. --- a/fs/ext3/ext3.h +++ b/fs/ext3/ext3.h @@ -340,6 +340,7 @@ struct ext3_inode_info { * Mount flags */ #define EXT3_MOUNT_CHECK 0x00001 /* Do mount-time checks */ +#define EXT3_MOUNT_NO_MBCACHE 0x00002 /* Disable mbcache */ /* EXT3_MOUNT_OLDALLOC was there */ #define EXT3_MOUNT_GRPID 0x00004 /* Create files with directory's group */ #define EXT3_MOUNT_DEBUG 0x00008 /* Some debugging messages */ --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -814,6 +814,7 @@ enum { Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, Opt_resize, Opt_usrquota, Opt_grpquota + ,Opt_no_mbcache }; static const match_table_t tokens = { @@ -871,6 +872,7 @@ static const match_table_t tokens = { {Opt_nobarrier, "nobarrier"}, {Opt_resize, "resize"}, {Opt_err, NULL}, + {Opt_no_mbcache, "no_mbcache"}, }; static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb) @@ -1275,6 +1277,9 @@ static inst parse_options { ext3_msg(sb, KERN_WARNING, "warning: ignoring deprecated bh option"); break; + case Opt_no_mbcache: + set_opt(sbi->s_mount_opt, EXT3_MOUNT_NO_MBCACHE); + break; default: ext3_msg(sb, KERN_ERR, "error: unrecognized mount option \"%s\" " --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c @@ -88,7 +88,7 @@ # define ea_bdebug(f...) #endif -static void ext3_xattr_cache_insert(struct buffer_head *); +static void ext3_xattr_cache_insert(struct inode *, struct buffer_head *); static struct buffer_head *ext3_xattr_cache_find(struct inode *, struct ext3_xattr_header *, struct mb_cache_entry **); @@ -235,7 +234,7 @@ bad_block: error = -EIO; goto cleanup; } - ext3_xattr_cache_insert(bh); + ext3_xattr_cache_insert(inode, bh); entry = BFIRST(bh); error = ext3_xattr_find_entry(&entry, name_index, name, bh->b_size, 1); if (error == -EIO) @@ -379,7 +377,7 @@ ext3_xattr_block_list(struct dentry *den error = -EIO; goto cleanup; } - ext3_xattr_cache_insert(bh); + ext3_xattr_cache_insert(inode, bh); error = ext3_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); cleanup: @@ -476,7 +474,8 @@ ext3_xattr_release_block(handle_t *handl struct mb_cache_entry *ce = NULL; int error = 0; - ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_bdev, bh->b_blocknr); + if (!test_opt(inode->i_sb, NO_MBCACHE)) + ce = mb_cache_entry_get(ext3_xattr_cache, bh->b_bdev, bh->b_blocknr); error = ext3_journal_get_write_access(handle, bh); if (error) goto out; @@ -687,8 +686,9 @@ ext3_xattr_block_set(handle_t *handle, s if (i->value && i->value_len > sb->s_blocksize) return -ENOSPC; if (s->base) { - ce = mb_cache_entry_get(ext3_xattr_cache, bs->bh->b_bdev, - bs->bh->b_blocknr); + if (!test_opt(inode->i_sb, NO_MBCACHE)) + ce = mb_cache_entry_get(ext3_xattr_cache, bs->bh->b_bdev, + bs->bh->b_blocknr); error = ext3_journal_get_write_access(handle, bs->bh); if (error) goto cleanup; @@ -705,7 +705,7 @@ ext3_xattr_block_set(handle_t *handle, s if (!IS_LAST_ENTRY(s->first)) ext3_xattr_rehash(header(s->base), s->here); - ext3_xattr_cache_insert(bs->bh); + ext3_xattr_cache_insert(inode, bs->bh); } unlock_buffer(bs->bh); if (error == -EIO) @@ -787,7 +787,8 @@ inserted: if (error) goto cleanup_dquot; } - mb_cache_entry_release(ce); + if (ce) + mb_cache_entry_release(ce); ce = NULL; } else if (bs->bh && s->base == bs->bh->b_data) { /* We were modifying this block in-place. */ @@ -828,7 +828,7 @@ getblk_failed: memcpy(new_bh->b_data, s->base, new_bh->b_size); set_buffer_uptodate(new_bh); unlock_buffer(new_bh); - ext3_xattr_cache_insert(new_bh); + ext3_xattr_cache_insert(inode, new_bh); error = ext3_journal_dirty_metadata(handle, new_bh); if (error) goto cleanup; @@ -1131,12 +1132,16 @@ ext3_xattr_put_super(struct super_block * Returns 0, or a negative error number on failure. */ static void -ext3_xattr_cache_insert(struct buffer_head *bh) +ext3_xattr_cache_insert(struct inode *inode, struct buffer_head *bh) { + struct super_block *sb = inode->i_sb; __u32 hash = le32_to_cpu(BHDR(bh)->h_hash); struct mb_cache_entry *ce; int error; + if (test_opt(sb, NO_MBCACHE)) + return; + ce = mb_cache_entry_alloc(ext3_xattr_cache, GFP_NOFS); if (!ce) { ea_bdebug(bh, "out of memory"); @@ -1210,6 +1216,8 @@ ext3_xattr_cache_find(struct inode *inod __u32 hash = le32_to_cpu(header->h_hash); struct mb_cache_entry *ce; + if (test_opt(inode->i_sb, NO_MBCACHE)) + return NULL; if (!header->h_hash) return NULL; /* never share */ ea_idebug(inode, "looking for cached blocks [%x]", (int)hash);