btrfs-progs/Documentation/btrfs-property.rst
Li Zhang 7781d1a2da 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>
2022-04-25 18:30:28 +02:00

91 lines
3.0 KiB
ReStructuredText

btrfs-property(8)
=================
SYNOPSIS
--------
**btrfs property** <subcommand> <args>
DESCRIPTION
-----------
**btrfs property** is used to get/set/list property for given filesystem object.
The object can be an inode (file or directory), subvolume or the whole
filesystem. See the description of **get** subcommand for more information about
both btrfs object and property.
***btrfs property** provides an unified and user-friendly method to tune different
btrfs properties instead of using the traditional method like ``chattr(1)`` or
``lsattr(1)``.
SUBCOMMAND
----------
get [-t <type>] <object> [<name>]
get property from a btrfs *object* of given *type*
A btrfs object, which is set by *object*, can be a btrfs filesystem
itself, a btrfs subvolume, an inode (file or directory) inside btrfs,
or a device on which a btrfs exists.
The option *-t* can be used to explicitly
specify what type of object you meant. This is only needed when a
property could be set for more then one object type.
Possible types are *s[ubvol]*, *f[ilesystem]*, *i[node]* and *d[evice]*, where
the first lettes is a shortcut.
Set the name of property by *name*. If no *name* is specified,
all properties for the given object are printed. *name* is one of
the following:
ro
read-only flag of subvolume: true or false. Please also see section *SUBVOLUME FLAGS*
in ``btrfs-subvolume(8)`` for possible implications regarding incremental send.
label
label of the filesystem. For an unmounted filesystem, provide a path to a block
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 *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.
See the description of **get** subcommand for the meaning of each option.
set [-f] [-t <type>] <object> <name> <value>
Sets a property on a btrfs object.
See the description of **get** subcommand for the meaning of each option.
``Options``
-f
Force the change. Changing some properties may involve safety checks or
additional changes that depend on the properties semantics.
EXIT STATUS
-----------
**btrfs property** returns a zero exit status if it succeeds. Non zero is
returned in case of failure.
AVAILABILITY
------------
**btrfs** is part of btrfs-progs.
Please refer to the btrfs wiki http://btrfs.wiki.kernel.org for
further details.
SEE ALSO
--------
``mkfs.btrfs(8)``,
``lsattr(1)``,
``chattr(1)``