btrfs-progs: add qgroup commands

This adds the necessary interface to control the qgroups feature. The
command set is still preliminary and low-level. It is planned to add
some convenience commands to manage common usecases. There's still work
to be done to define a good representation for the end user.
I'll add a manpage in a later version, when we settle on an interface.

See http://sensille.com/qgroups.pdf for an explanation of the concepts.

Commands added by this patch:

btrfs quota enable
    Enable subvolume quota support for a filesystem. It creates the quota
    tree.

btrfs quota disable
    Disable subvolume quota support for a filesystem. It removes the quota
    tree and with it all configuration information.

btrfs quota rescan
    Triggers a full re-init of quota information, doing a full fs rescan.
    Kernel side currently does not implement it yet.

btrfs qgroup assign <srcid> <destid> <path>
    Assigns the lower level qgroup src to the higher level qgroup dest in the
    btrfs found in <path>. It is used to build qgroup hierarchies.

btrfs qgroup remove <srcid> <destid> <path>
    Remove the qgroup src from the qgroup dest.

btrfs qgroup create <qgroupid> <path>
    Creates a qgroup with id <qgroupid> for the btrfs found in <path>. It will
    not be part of any hierarchy.

btrfs qgroup destroy <qgroupid> <path>
    Removes the qgroup qgroupid from the btrfs found in <path>. It will also
    be removed from any higher-level qgroups.

btrfs qgroup show
    Lists all configured qgroup together with the current exclusive and
    referenced values.

btrfs qgroup limit <size>|none <path-to-subvol>
btrfs qgroup limit <size>|none <qgroupid> <path-to-btrfs>
    Impose a limit of <size> for the amount of referenced space onto the
    qgroup <qgroupid> in btrfs <path-to-btrfs> or onto the qgroup referenced
    by <path-to-subvol>. A size of none removes the limit.

Commands extended for this patch:
btrfs subvolume create [-i <qid>] [-c <cspec>] [-x <cspec>] <name>
btrfs subvolume snapshot [-i <qid>] [-c <cspec>] [-x <cspec>] <source> <name>
    With the creation of a subvolume either by subvolume create or subvolume
    snapshot a qgroup gets created automatically. With -i this qgroup can be
    added to a higher level qgroup <qid> at creation time. This option can be
    given multiple times.
    -c and -x copy the values from one qgroup to another at creation time.
    In some usecases this is necessary to keep the values consistent. See
    the above mentioned concept paper for details. The copy spec <cspec>
    consists of two qgroupid separated by ':', giving <srcid>:<dstid>. -c
    copies the 'referenced' value, -x copies the 'exclusive' value.  These
    options can be given multiple times.

Signed-off-by: Arne Jansen <sensille@gmx.net>
7 files changed