All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: inplace xattr block update fails to deduplicate blocks
@ 2017-07-15  0:25 Tahsin Erdogan
  2017-07-15  9:49 ` Andreas Dilger
  0 siblings, 1 reply; 3+ messages in thread
From: Tahsin Erdogan @ 2017-07-15  0:25 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger, linux-ext4
  Cc: linux-kernel, Tahsin Erdogan

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>
---
 fs/ext4/xattr.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index cff4f41ced61..ad4ea1cf685f 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1815,9 +1815,6 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
 			ea_bdebug(bs->bh, "modifying in-place");
 			error = ext4_xattr_set_entry(i, s, handle, inode,
 						     true /* is_block */);
-			if (!error)
-				ext4_xattr_block_cache_insert(ea_block_cache,
-							      bs->bh);
 			ext4_xattr_block_csum_set(inode, bs->bh);
 			unlock_buffer(bs->bh);
 			if (error == -EFSCORRUPTED)
@@ -1973,6 +1970,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
 		} else if (bs->bh && s->base == bs->bh->b_data) {
 			/* We were modifying this block in-place. */
 			ea_bdebug(bs->bh, "keeping this block");
+			ext4_xattr_block_cache_insert(ea_block_cache, bs->bh);
 			new_bh = bs->bh;
 			get_bh(new_bh);
 		} else {
-- 
2.13.2.932.g7449e964c-goog

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: inplace xattr block update fails to deduplicate blocks
  2017-07-15  0:25 [PATCH] ext4: inplace xattr block update fails to deduplicate blocks Tahsin Erdogan
@ 2017-07-15  9:49 ` Andreas Dilger
  2017-08-06  2:50   ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Dilger @ 2017-07-15  9:49 UTC (permalink / raw)
  To: Tahsin Erdogan; +Cc: Theodore Ts'o, linux-ext4, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2215 bytes --]

On Jul 14, 2017, at 5:25 PM, Tahsin Erdogan <tahsin@google.com> wrote:
> 
> 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>

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> fs/ext4/xattr.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index cff4f41ced61..ad4ea1cf685f 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -1815,9 +1815,6 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
> 			ea_bdebug(bs->bh, "modifying in-place");
> 			error = ext4_xattr_set_entry(i, s, handle, inode,
> 						     true /* is_block */);
> -			if (!error)
> -				ext4_xattr_block_cache_insert(ea_block_cache,
> -							      bs->bh);
> 			ext4_xattr_block_csum_set(inode, bs->bh);
> 			unlock_buffer(bs->bh);
> 			if (error == -EFSCORRUPTED)
> @@ -1973,6 +1970,7 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
> 		} else if (bs->bh && s->base == bs->bh->b_data) {
> 			/* We were modifying this block in-place. */
> 			ea_bdebug(bs->bh, "keeping this block");
> +			ext4_xattr_block_cache_insert(ea_block_cache, bs->bh);
> 			new_bh = bs->bh;
> 			get_bh(new_bh);
> 		} else {
> --
> 2.13.2.932.g7449e964c-goog
> 


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: inplace xattr block update fails to deduplicate blocks
  2017-07-15  9:49 ` Andreas Dilger
@ 2017-08-06  2:50   ` Theodore Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2017-08-06  2:50 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: Tahsin Erdogan, linux-ext4, linux-kernel

On Sat, Jul 15, 2017 at 02:49:05AM -0700, Andreas Dilger wrote:
> On Jul 14, 2017, at 5:25 PM, Tahsin Erdogan <tahsin@google.com> wrote:
> > 
> > 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>
> 
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>

Thanks, applied.

					- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-06  2:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-15  0:25 [PATCH] ext4: inplace xattr block update fails to deduplicate blocks Tahsin Erdogan
2017-07-15  9:49 ` Andreas Dilger
2017-08-06  2:50   ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.