linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: allow user to insert property compression=none to file.
@ 2022-01-16  8:52 Li Zhang
  2022-01-17 13:44 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Li Zhang @ 2022-01-16  8:52 UTC (permalink / raw)
  To: linux-btrfs; +Cc: zhanglikernel

1. If the user adds the property "compression=none" to the file,
remove the code that converts the None string to an empty string.

Signed-off-by: Li Zhang <zhanglikernel@gmail.com>
---
 cmds/property.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/cmds/property.c b/cmds/property.c
index b3ccc0f..ec1b408 100644
--- a/cmds/property.c
+++ b/cmds/property.c
@@ -190,8 +190,6 @@ static int prop_compression(enum prop_object_type type,
 	xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
 
 	if (value) {
-		if (strcmp(value, "no") == 0 || strcmp(value, "none") == 0)
-			value = "";
 		sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
 	} else {
 		sret = fgetxattr(fd, xattr_name, NULL, 0);
-- 
1.8.3.1


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

* Re: [PATCH] btrfs-progs: allow user to insert property compression=none to file.
  2022-01-16  8:52 [PATCH] btrfs-progs: allow user to insert property compression=none to file Li Zhang
@ 2022-01-17 13:44 ` David Sterba
  2022-01-19 10:49   ` li zhang
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2022-01-17 13:44 UTC (permalink / raw)
  To: Li Zhang; +Cc: linux-btrfs

On Sun, Jan 16, 2022 at 04:52:43PM +0800, Li Zhang wrote:
> 1. If the user adds the property "compression=none" to the file,
> remove the code that converts the None string to an empty string.

This is related to 5548c8c6f55b ("btrfs: props: change how empty value
is interpreted") and needs some explanation that what it does on old and
new kernel. Maybe some backward compatibility code in progs is needed to
take the version into account.

> 
> Signed-off-by: Li Zhang <zhanglikernel@gmail.com>
> ---
>  cmds/property.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/cmds/property.c b/cmds/property.c
> index b3ccc0f..ec1b408 100644
> --- a/cmds/property.c
> +++ b/cmds/property.c
> @@ -190,8 +190,6 @@ static int prop_compression(enum prop_object_type type,
>  	xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
>  
>  	if (value) {
> -		if (strcmp(value, "no") == 0 || strcmp(value, "none") == 0)
> -			value = "";
>  		sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
>  	} else {
>  		sret = fgetxattr(fd, xattr_name, NULL, 0);
> -- 
> 1.8.3.1

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

* Re: [PATCH] btrfs-progs: allow user to insert property compression=none to file.
  2022-01-17 13:44 ` David Sterba
@ 2022-01-19 10:49   ` li zhang
  2022-02-16 10:44     ` Qu Wenruo
  0 siblings, 1 reply; 4+ messages in thread
From: li zhang @ 2022-01-19 10:49 UTC (permalink / raw)
  To: David Sterba, Li Zhang, linux-btrfs

Old behavior:
# Insert compressed none in the file
$ btrfs property set file compression none
$ btrfs property gets file
# no output, (none value converted to empty string)

New behavior:
# Insert compressed none in the file
$ btrfs property set file compression none
$ btrfs property gets file
compression=none
(with compression=none inserted in the file's xattr)


Convert the attribute compression=none to an empty string "", which was
introduced in commit df11e2787b5b57ecdb313f2725dc5c9a5e549576(btrfs-progs),
according to the comments, in the past it seemed that the empty string
"" represented
no compression, but after commit 5548c8c6f55b(btrfs-devel), the
character The string
"none" means no compression. so the command
"btrfs property set <file> compression none" is not working.

David Sterba <dsterba@suse.cz> 于2022年1月17日周一 21:45写道:
>
> On Sun, Jan 16, 2022 at 04:52:43PM +0800, Li Zhang wrote:
> > 1. If the user adds the property "compression=none" to the file,
> > remove the code that converts the None string to an empty string.
>
> This is related to 5548c8c6f55b ("btrfs: props: change how empty value
> is interpreted") and needs some explanation that what it does on old and
> new kernel. Maybe some backward compatibility code in progs is needed to
> take the version into account.
>
> >
> > Signed-off-by: Li Zhang <zhanglikernel@gmail.com>
> > ---
> >  cmds/property.c | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/cmds/property.c b/cmds/property.c
> > index b3ccc0f..ec1b408 100644
> > --- a/cmds/property.c
> > +++ b/cmds/property.c
> > @@ -190,8 +190,6 @@ static int prop_compression(enum prop_object_type type,
> >       xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
> >
> >       if (value) {
> > -             if (strcmp(value, "no") == 0 || strcmp(value, "none") == 0)
> > -                     value = "";
> >               sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
> >       } else {
> >               sret = fgetxattr(fd, xattr_name, NULL, 0);
> > --
> > 1.8.3.1

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

* Re: [PATCH] btrfs-progs: allow user to insert property compression=none to file.
  2022-01-19 10:49   ` li zhang
@ 2022-02-16 10:44     ` Qu Wenruo
  0 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2022-02-16 10:44 UTC (permalink / raw)
  To: li zhang, David Sterba, linux-btrfs

Furthermore, that kernel commit has a big problem for a lot of
compression users:

  No way to disable compression on a per-file basis, if using
compression= mount option.

As progs always convert "none"/"no" to "", this leads means older progs
on newer kernel will use default value, and no way to really set
"none"/"no".

This is already a big behavior breakage.

Thanks,
Qu

On 2022/1/19 18:49, li zhang wrote:
> Old behavior:
> # Insert compressed none in the file
> $ btrfs property set file compression none
> $ btrfs property gets file
> # no output, (none value converted to empty string)
>
> New behavior:
> # Insert compressed none in the file
> $ btrfs property set file compression none
> $ btrfs property gets file
> compression=none
> (with compression=none inserted in the file's xattr)
>
>
> Convert the attribute compression=none to an empty string "", which was
> introduced in commit df11e2787b5b57ecdb313f2725dc5c9a5e549576(btrfs-progs),
> according to the comments, in the past it seemed that the empty string
> "" represented
> no compression, but after commit 5548c8c6f55b(btrfs-devel), the
> character The string
> "none" means no compression. so the command
> "btrfs property set <file> compression none" is not working.
>
> David Sterba <dsterba@suse.cz> 于2022年1月17日周一 21:45写道:
>>
>> On Sun, Jan 16, 2022 at 04:52:43PM +0800, Li Zhang wrote:
>>> 1. If the user adds the property "compression=none" to the file,
>>> remove the code that converts the None string to an empty string.
>>
>> This is related to 5548c8c6f55b ("btrfs: props: change how empty value
>> is interpreted") and needs some explanation that what it does on old and
>> new kernel. Maybe some backward compatibility code in progs is needed to
>> take the version into account.
>>
>>>
>>> Signed-off-by: Li Zhang <zhanglikernel@gmail.com>
>>> ---
>>>   cmds/property.c | 2 --
>>>   1 file changed, 2 deletions(-)
>>>
>>> diff --git a/cmds/property.c b/cmds/property.c
>>> index b3ccc0f..ec1b408 100644
>>> --- a/cmds/property.c
>>> +++ b/cmds/property.c
>>> @@ -190,8 +190,6 @@ static int prop_compression(enum prop_object_type type,
>>>        xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
>>>
>>>        if (value) {
>>> -             if (strcmp(value, "no") == 0 || strcmp(value, "none") == 0)
>>> -                     value = "";
>>>                sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
>>>        } else {
>>>                sret = fgetxattr(fd, xattr_name, NULL, 0);
>>> --
>>> 1.8.3.1

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

end of thread, other threads:[~2022-02-16 10:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-16  8:52 [PATCH] btrfs-progs: allow user to insert property compression=none to file Li Zhang
2022-01-17 13:44 ` David Sterba
2022-01-19 10:49   ` li zhang
2022-02-16 10:44     ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).