pfcache: silently drop "trusted.pfcache" xattr when set on inappropriate fs

Submitted by Konstantin Khorenko on Jan. 16, 2019, 4:24 p.m.

Details

Message ID 20190116162455.12341-1-khorenko@virtuozzo.com
State New
Series "pfcache: silently drop "trusted.pfcache" xattr when set on inappropriate fs"
Headers show

Commit Message

Konstantin Khorenko Jan. 16, 2019, 4:24 p.m.
Currently we deny setting "trusted.pfcache" xattr on a fs mounted
without "pfcache_csum" mount flag, returning error.

But there is a usecase when people mount a Container snapshot
and rsync data from it (to some usual fs without "pfcache_csum" flag).
"rsync -X" detects "trusted.pfcache" xattr on source file, tries to set
it on destination file and fails.

Let's workaround it by silently dropping "trusted.pfcache" xattr when
set on a fs without "pfcache_csum".

https://jira.sw.ru/browse/PSBM-90740

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 fs/ext4/pfcache.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/ext4/pfcache.c b/fs/ext4/pfcache.c
index 792f75960b30..eb3950b50088 100644
--- a/fs/ext4/pfcache.c
+++ b/fs/ext4/pfcache.c
@@ -702,8 +702,12 @@  static int ext4_xattr_trusted_csum_set(struct dentry *dentry, const char *name,
 	if (strcmp(name, ""))
 		return -ENODATA;
 
+	/*
+	 * Silently drop "trusted.pfcache" xattr, useful for the case when
+	 * a file with csum is copied to non-pfcache-enabled fs.
+	 */
 	if (!test_opt2(inode->i_sb, PFCACHE_CSUM))
-		return -EOPNOTSUPP;
+		return 0;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;

Comments

Pavel Tikhomirov Jan. 18, 2019, 12:11 p.m.
On 1/16/19 7:24 PM, Konstantin Khorenko wrote:
> Currently we deny setting "trusted.pfcache" xattr on a fs mounted
> without "pfcache_csum" mount flag, returning error.
> 
> But there is a usecase when people mount a Container snapshot
> and rsync data from it (to some usual fs without "pfcache_csum" flag).
> "rsync -X" detects "trusted.pfcache" xattr on source file, tries to set
> it on destination file and fails.
> 
> Let's workaround it by silently dropping "trusted.pfcache" xattr when
> set on a fs without "pfcache_csum".
> 
> https://jira.sw.ru/browse/PSBM-90740
> 
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>

Reviewed-by: Tikhomirov Pavel <ptikhomirov@virtuozzo.com>

> ---
>   fs/ext4/pfcache.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/pfcache.c b/fs/ext4/pfcache.c
> index 792f75960b30..eb3950b50088 100644
> --- a/fs/ext4/pfcache.c
> +++ b/fs/ext4/pfcache.c
> @@ -702,8 +702,12 @@ static int ext4_xattr_trusted_csum_set(struct dentry *dentry, const char *name,
>   	if (strcmp(name, ""))
>   		return -ENODATA;
>   
> +	/*
> +	 * Silently drop "trusted.pfcache" xattr, useful for the case when
> +	 * a file with csum is copied to non-pfcache-enabled fs.
> +	 */
>   	if (!test_opt2(inode->i_sb, PFCACHE_CSUM))
> -		return -EOPNOTSUPP;
> +		return 0;
>   
>   	if (!capable(CAP_SYS_ADMIN))
>   		return -EPERM;
>