aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTahsin Erdogan <tahsin@google.com>2017-08-05 22:41:42 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-08-05 22:41:42 -0400
commitec00022030da5761518476096626338bd67df57a (patch)
treee6d9d86c05a0a98e625a0f0cafb1f944f3b611ac
parent77a2e84d51729da7957d19283523af7b571d61f6 (diff)
ext4: inplace xattr block update fails to deduplicate blocks
When an xattr block has a single reference, block is updated inplace and it is reinserted to the cache. Later, a cache lookup is performed to see whether an existing block has the same contents. This cache lookup will most of the time return the just inserted entry so deduplication is not achieved. Running the following test script will produce two xattr blocks which can be observed in "File ACL: " line of debugfs output: mke2fs -b 1024 -I 128 -F -O extent /dev/sdb 1G mount /dev/sdb /mnt/sdb touch /mnt/sdb/{x,y} setfattr -n user.1 -v aaa /mnt/sdb/x setfattr -n user.2 -v bbb /mnt/sdb/x setfattr -n user.1 -v aaa /mnt/sdb/y setfattr -n user.2 -v bbb /mnt/sdb/y debugfs -R 'stat x' /dev/sdb | cat debugfs -R 'stat y' /dev/sdb | cat This patch defers the reinsertion to the cache so that we can locate other blocks with the same contents. Signed-off-by: Tahsin Erdogan <tahsin@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Andreas Dilger <adilger@dilger.ca>
-rw-r--r--fs/ext4/xattr.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index de217a094733..4025666c5991 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1816,9 +1816,6 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
1816 ea_bdebug(bs->bh, "modifying in-place"); 1816 ea_bdebug(bs->bh, "modifying in-place");
1817 error = ext4_xattr_set_entry(i, s, handle, inode, 1817 error = ext4_xattr_set_entry(i, s, handle, inode,
1818 true /* is_block */); 1818 true /* is_block */);
1819 if (!error)
1820 ext4_xattr_block_cache_insert(ea_block_cache,
1821 bs->bh);
1822 ext4_xattr_block_csum_set(inode, bs->bh); 1819 ext4_xattr_block_csum_set(inode, bs->bh);
1823 unlock_buffer(bs->bh); 1820 unlock_buffer(bs->bh);
1824 if (error == -EFSCORRUPTED) 1821 if (error == -EFSCORRUPTED)
@@ -1974,6 +1971,7 @@ inserted:
1974 } else if (bs->bh && s->base == bs->bh->b_data) { 1971 } else if (bs->bh && s->base == bs->bh->b_data) {
1975 /* We were modifying this block in-place. */ 1972 /* We were modifying this block in-place. */
1976 ea_bdebug(bs->bh, "keeping this block"); 1973 ea_bdebug(bs->bh, "keeping this block");
1974 ext4_xattr_block_cache_insert(ea_block_cache, bs->bh);
1977 new_bh = bs->bh; 1975 new_bh = bs->bh;
1978 get_bh(new_bh); 1976 get_bh(new_bh);
1979 } else { 1977 } else {