btrfs-progs: props: don't translate value of compression=none
Currently, if user specifies value 'no' or 'none' on the command line, it gets translated to an empty value that is passed to kernel. There was a change in kernel 5.14 done by commit 5548c8c6f55b ("btrfs: props: change how empty value is interpreted") that changes the behaviour in that case. The empty value is supposed to mean 'the default value' for any property. For compression there is a need to distinguish resetting the value and also setting the NOCOMPRESS property. The translation to empty value makes that impossible. The explanation and behaviour copied from the kernel patch: Old behaviour: $ lsattr file ---------------------- file # the NOCOMPRESS bit is set $ btrfs prop set file compression '' $ lsattr file ---------------------m file This is equivalent to 'btrfs prop set file compression no' in current btrfs-progs as the 'no' or 'none' values are translated to an empty string. This is where the new behaviour is different: empty string drops the compression flag (-c) and nocompress (-m): $ lsattr file ---------------------- file # No change $ btrfs prop set file compression '' $ lsattr file ---------------------- file $ btrfs prop set file compression lzo $ lsattr file --------c------------- file $ btrfs prop get file compression compression=lzo $ btrfs prop set file compression '' # Reset to the initial state $ lsattr file ---------------------- file # Set NOCOMPRESS bit $ btrfs prop set file compression no $ lsattr file ---------------------m file This obviously brings problems with backward compatibility, so this patch should not be backported without making sure the updated btrfs-progs are also used and that scripts have been updated to use the new semantics. Summary: - old kernel: no, none, "" - set NOCOMPRESS bit - new kernel: no, none - set NOCOMPRESS bit "" - drop all compression flags, ie. COMPRESS and NOCOMPRESS Signed-off-by: Li Zhang <zhanglikernel@gmail.com> [ update changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
fd4bab06a4
commit
7781d1a2da
|
@ -47,7 +47,11 @@ get [-t <type>] <object> [<name>]
|
|||
device as object. For a mounted filesystem, specify a mount point.
|
||||
compression
|
||||
compression algorithm set for an inode, possible values: *lzo*, *zlib*, *zstd*.
|
||||
To disable compression use "" (empty string), *no* or *none*.
|
||||
To disable compression use *no* or *none*. Empty value resets the
|
||||
property and sets a default value.
|
||||
.. note::
|
||||
This has changed in version 5.18 of btrfs-progs and
|
||||
requires kernel 5.14 or newer to work.
|
||||
|
||||
list [-t <type>] <object>
|
||||
Lists available properties with their descriptions for the given object.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue