Initialize for btrfsprogs
This commit is contained in:
commit
bb727004d7
15 changed files with 2860 additions and 0 deletions
123
btrfs-progs_props_dont_translate_value_of_compression_none.patch
Normal file
123
btrfs-progs_props_dont_translate_value_of_compression_none.patch
Normal file
|
@ -0,0 +1,123 @@
|
|||
From 7781d1a2daa6564c3988dc268eb0680e057027f5 Mon Sep 17 00:00:00 2001
|
||||
From: Li Zhang <zhanglikernel@gmail.com>
|
||||
Date: Sun, 16 Jan 2022 16:52:43 +0800
|
||||
Subject: [PATCH] btrfs-progs: props: don't translate value of compression=none
|
||||
References: JSC#PED-1711
|
||||
|
||||
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>
|
||||
|
||||
---
|
||||
Documentation/btrfs-property.8 | 11 +++++++++--
|
||||
Documentation/btrfs-property.asciidoc | 3 ++-
|
||||
cmds/property.c | 2 --
|
||||
3 files changed, 11 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/Documentation/btrfs-property.8
|
||||
+++ b/Documentation/btrfs-property.8
|
||||
@@ -82,10 +82,17 @@
|
||||
compression algorithm set for an inode, possible values:
|
||||
\fIlzo\fR,
|
||||
\fIzlib\fR,
|
||||
-\fIzstd\fR\&. To disable compression use "" (empty string),
|
||||
+\fIzstd\fR\&. To disable compression use
|
||||
\fIno\fR
|
||||
or
|
||||
-\fInone\fR\&.
|
||||
+\fInone\fR\&. Empty value resets the property and sets a default value.
|
||||
+.br
|
||||
+.PP
|
||||
+.ps +1
|
||||
+\fBNote\fR
|
||||
+.ps -1
|
||||
+.br
|
||||
+An empty value resetting compression property has changed since kernel 5.14. Earlier versions would disable compression.
|
||||
.RE
|
||||
.RE
|
||||
.PP
|
||||
--- a/Documentation/btrfs-property.asciidoc
|
||||
+++ b/Documentation/btrfs-property.asciidoc
|
||||
@@ -47,7 +47,8 @@
|
||||
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'. An empty string "" resets the property and sets a default value.
|
||||
+'Note:' An empty value resetting compression property has changed since kernel 5.14. Earlier versions would disable compression.
|
||||
|
||||
*list* [-t <type>] <object>::
|
||||
Lists available properties with their descriptions for the given object.
|
||||
--- a/cmds/property.c
|
||||
+++ b/cmds/property.c
|
||||
@@ -126,8 +126,6 @@
|
||||
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…
Add table
Add a link
Reference in a new issue