btrfs-qgroup(8)

SYNOPSIS 概要 

btrfs qgroup <subcommand> <args>

DESCRIPTION 描述 

btrfs qgroup is used to control quota group (qgroup) of a btrfs filesystem.
btrfs qgroup 用于控制 btrfs 文件系统的配额组(qgroup)。

Note 注意

To use qgroup you need to enable quota first using btrfs quota enable command.
要使用 qgroup,您需要首先使用 btrfs quota enable 命令启用配额。

Warning 警告

Qgroup is not stable yet and will impact performance in current mainline kernel (v4.14).
Qgroup 还不稳定,会影响当前主线内核(v4.14)的性能。

QGROUP

Quota groups or qgroup in btrfs make a tree hierarchy, the leaf qgroups are attached to subvolumes. The size limits are set per qgroup and apply when any limit is reached in tree that contains a given subvolume.
Btrfs 中的配额组或 qgroup 形成树形层次结构,叶子 qgroup 附加到子卷上。每个 qgroup 都设置了大小限制,当包含给定子卷的树中达到任何限制时,这些限制就会应用。

The limits are separated between shared and exclusive and reflect the extent ownership. For example a fresh snapshot shares almost all the blocks with the original subvolume, new writes to either subvolume will raise towards the exclusive limit.
限制在共享和独占之间分隔,并反映所有权的范围。例如,新快照几乎与原始子卷共享所有块,对任一子卷的新写入将提升至独占限制。

The qgroup identifiers conform to level/id where level 0 is reserved to the qgroups associated with subvolumes. Such qgroups are created automatically.
qgroup 标识符符合级别/ID,其中级别 0 保留给与子卷关联的 qgroups。此类 qgroups 将自动创建。

The qgroup hierarchy is built by commands create and assign.
qgroup 层次结构是通过 create 和 assign 命令构建的。

Note 注意

If the qgroup of a subvolume is destroyed, quota about the subvolume will not be functional until qgroup 0/<subvolume id> is created again.
如果子卷的 qgroup 被销毁,则在重新创建 qgroup 0/<subvolume id> 之前,关于子卷的配额将无法正常工作。

SUBCOMMAND 子命令 

assign [options] <src> <dst> <path>
分配 [选项] <src> <dst> <path>

Assign qgroup src as the child qgroup of dst in the btrfs filesystem identified by path.
在由路径标识的 btrfs 文件系统中,将 qgroup src 分配为 dst 的子 qgroup。

Options

--rescan

(default since: 4.19) Automatically schedule quota rescan if the new qgroup assignment would lead to quota inconsistency. See QUOTA RESCAN for more information.
(默认自 4.19 起)如果新的 qgroup 分配会导致配额不一致,自动安排配额重新扫描。有关更多信息,请参阅 QUOTA RESCAN。

--no-rescan

Explicitly ask not to do a rescan, even if the assignment will make the quotas inconsistent. This may be useful for repeated calls where the rescan would add unnecessary overhead.
明确要求不进行重新扫描,即使分配会使配额不一致。这对于重复调用而重新扫描会增加不必要的开销可能很有用。

create <qgroupid> <path> 创建<qgroupid> <path>

Create a subvolume quota group.
创建一个子卷配额组。

For the 0/<subvolume id> qgroup, a qgroup can be created even before the subvolume is created.
对于 0/<子卷 id> qgroup,甚至在创建子卷之前就可以创建一个 qgroup。

destroy <qgroupid> <path>
销毁 <qgroupid> <路径>

Destroy a qgroup. 销毁一个 qgroup。

If a qgroup is not isolated, meaning it is a parent or child qgroup, then it can only be destroyed after the relationship is removed.
如果一个 qgroup 不是孤立的,也就是它是一个父 qgroup 或子 qgroup,那么只有在关系移除后才能销毁它。

clear-stale <path> 清除陈旧的 <路径>

Clear all stale qgroups whose subvolume does not exist anymore, this is the level 0 qgroup like 0/subvolid. Higher level qgroups are not deleted even if they don’t have any child qgroups.
清除所有过时的 qgroups,其子卷不再存在,这是类似 0/subvolid 的级别 0 qgroup。即使没有任何子 qgroups,也不会删除更高级别的 qgroups。

limit [options] <size>|none [<qgroupid>] <path>
限制 [选项] <大小>|无 [<qgroupid>] <路径>

Limit the size of a qgroup to size or no limit in the btrfs filesystem identified by path.
限制由路径标识的 btrfs 文件系统中的 qgroup 的大小为大小或无限制。

If qgroupid is not given, qgroup of the subvolume identified by path is used if possible.
如果未提供 qgroupid,则尽可能使用路径标识的子卷的 qgroup。

Options

-c

limit amount of data after compression. This is the default, it is currently not possible to turn off this option.
限制压缩后的数据量。这是默认设置,目前无法关闭此选项。

-e

limit space exclusively assigned to this qgroup.
限制专门分配给此 qgroup 的空间。

remove <src> <dst> <path>
删除 <src> <dst> <path>

Remove the relationship between child qgroup src and parent qgroup dst in the btrfs filesystem identified by path.
在由路径标识的 btrfs 文件系统中删除子 qgroup src 与父 qgroup dst 之间的关系。

Options

--rescan

(default since: 4.19) Automatically schedule quota rescan if the removed qgroup relation would lead to quota inconsistency. See QUOTA RESCAN for more information.
(默认自 4.19 版本起)如果删除的 qgroup 关系会导致配额不一致,则自动安排配额重新扫描。有关更多信息,请参阅 QUOTA RESCAN。

--no-rescan

Explicitly ask not to do a rescan, even if the removal will make the quotas inconsistent. This may be useful for repeated calls where the rescan would add unnecessary overhead.
明确要求不要进行重新扫描,即使删除会使配额不一致。这对于重复调用可能很有用,因为重新扫描会增加不必要的开销。

show [options] <path> 显示 [选项] <路径>

Show all qgroups in the btrfs filesystem identified by <path>.
显示由 <路径> 标识的 btrfs 文件系统中的所有 qgroups。

Options

-p

print parent qgroup id.
打印父 qgroup id。

-c

print child qgroup id.
打印子 qgroup id。

-r

print limit of referenced size of qgroup.
打印 qgroup 引用大小的限制。

-e

print limit of exclusive size of qgroup.
打印独占 qgroup 大小的限制。

-F

list all qgroups which impact the given path(include ancestral qgroups)
列出影响给定路径的所有 qgroup(包括祖先 qgroup)。

-f

list all qgroups which impact the given path(exclude ancestral qgroups)
列出影响给定路径的所有 qgroup(不包括祖先 qgroup)。

--raw

raw numbers in bytes, without the B suffix.
以字节为单位显示原始数字,不带 B 后缀。

--human-readable

print human friendly numbers, base 1024, this is the default
打印人类友好的数字,基数为 1024,这是默认设置

--iec

select the 1024 base for the following options, according to the IEC standard.
根据 IEC 标准,选择 1024 为以下选项的基数。

--si

select the 1000 base for the following options, according to the SI standard.
根据国际标准选择以下选项的 1000 进制基数。

--kbytes

show sizes in KiB, or kB with --si.
使用--si 选项以 KiB 或 kB 显示大小。

--mbytes

show sizes in MiB, or MB with --si.
使用--si 选项以 MiB 或 MB 显示大小。

--gbytes

show sizes in GiB, or GB with --si.
以 GiB 显示大小,或使用 --si 以 GB 显示。

--tbytes

show sizes in TiB, or TB with --si.
以 TiB 显示大小,或使用 --si 以 TB 显示。

--sort=[+/-]<attr>[,[+/-]<attr>]…

list qgroups in order of <attr>.
按照<attr>的顺序列出 qgroups。

<attr> can be one or more of qgroupid,rfer,excl,max_rfer,max_excl.
<attr> 可以是 qgroupid、rfer、excl、max_rfer、max_excl 中的一个或多个。

Prefix + means ascending order and - means descending order of attr. If no prefix is given, use ascending order by default.
前缀 + 表示按属性的升序排列,- 表示按属性的降序排列。如果没有给出前缀,则默认使用升序排列。

If multiple attr values are given, use comma to separate.
如果给出多个属性值,请使用逗号进行分隔。

--sync

To retrieve information after updating the state of qgroups, force sync of the filesystem identified by path before getting information.
在获取更新了 qgroups 状态的信息之后,强制同步由路径标识的文件系统以获取信息。

QUOTA RESCAN 配额重新扫描 

The rescan reads all extent sharing metadata and updates the respective qgroups accordingly.
重新扫描读取所有范围共享元数据,并相应地更新各自的 qgroups。

The information consists of bytes owned exclusively (excl) or shared/referred to (rfer). There’s no explicit information about which extents are shared or owned exclusively. This means when qgroup relationship changes, extent owners change and qgroup numbers are no longer consistent unless we do a full rescan.
该信息包括独占拥有的字节(excl)或共享/引用的字节(rfer)。关于哪些范围是共享的或独占拥有的没有明确的信息。这意味着当 qgroup 关系发生变化时,范围所有者也会发生变化,除非进行完整的重新扫描,否则 qgroup 号码将不再一致。

However there are cases where we can avoid a full rescan, if a subvolume whose rfer number equals its excl number, which means all bytes are exclusively owned, then assigning/removing this subvolume only needs to add/subtract rfer number from its parent qgroup. This can speed up the rescan.
但是有些情况下我们可以避免进行完整的重新扫描,如果一个子卷的 rfer 数等于其 excl 数,这意味着所有字节都是独占拥有的,那么分配/移除这个子卷只需要从其父 qgroup 中添加/减去 rfer 数即可。这可以加快重新扫描的速度。

EXAMPLES 示例

Make a parent group that has two quota group children
创建一个具有两个配额组子项的父组

Given the following filesystem mounted at /mnt/my-vault
给定以下挂载在 /mnt/my-vault 的文件系统

Label: none  uuid: 60d2ab3b-941a-4f22-8d1a-315f329797b2
       Total devices 1 FS bytes used 128.00KiB
       devid    1 size 5.00GiB used 536.00MiB path /dev/vdb

Enable quota and create subvolumes. Check subvolume ids.
启用配额并创建子卷。检查子卷 ID。

$ cd /mnt/my-vault
$ btrfs quota enable .
$ btrfs subvolume create a
$ btrfs subvolume create b
$ btrfs subvolume list .

ID 261 gen 61 top level 5 path a
ID 262 gen 62 top level 5 path b

Create qgroup and set limit to 10MiB.
创建 qgroup 并将限制设置为 10MiB。

$ btrfs qgroup create 1/100 .
$ btrfs qgroup limit 10M 1/100 .
$ btrfs qgroup assign 0/261 1/100 .
$ btrfs qgroup assign 0/262 1/100 .

And check qgroups. 然后检查 qgroups。

$ btrfs qgroup show .

qgroupid         rfer         excl
--------         ----         ----
0/5          16.00KiB     16.00KiB
0/261        16.00KiB     16.00KiB
0/262        16.00KiB     16.00KiB
1/100        32.00KiB     32.00KiB

EXIT STATUS 退出状态 

btrfs qgroup returns a zero exit status if it succeeds. Non zero is returned in case of failure.
如果成功,btrfs qgroup 返回零退出状态。如果失败,则返回非零状态。

AVAILABILITY 可用性 

btrfs is part of btrfs-progs. Please refer to the documentation at https://btrfs.readthedocs.io.
btrfs 是 btrfs-progs 的一部分。请参考 https://btrfs.readthedocs.io 上的文档。

SEE ALSO 参见 

btrfs-quota(8), btrfs-subvolume(8), mkfs.btrfs(8)