On 2017年12月06日 02:47, Andrei Borzenkov wrote:
> 02.12.2017 03:27, Qu Wenruo пишет:
>>
>> That's the difference between how sub show and quota works.
>>
>> For quota, it's per-root owner check.
>> Means even a file extent is shared between different inodes, if all
>> inodes are inside the same subvolume, it's counted as exclusive.
>> And if any of the file extent belongs to other subvolume, then it's
>> counted as shared.
>>
> 
> Could you also explain how parent qgroup computes exclusive space? I.e.
> 
> 10:~ # mkfs -t btrfs -f /dev/sdb1
> btrfs-progs v4.13.3
> See http://btrfs.wiki.kernel.org for more information.
> 
> Performing full device TRIM /dev/sdb1 (1023.00MiB) ...
> Label:              (null)
> UUID:               b9b0643f-a248-4667-9e69-acf5baaef05b
> Node size:          16384
> Sector size:        4096
> Filesystem size:    1023.00MiB
> Block group profiles:
>   Data:             single            8.00MiB
>   Metadata:         DUP              51.12MiB
>   System:           DUP               8.00MiB
> SSD detected:       no
> Incompat features:  extref, skinny-metadata
> Number of devices:  1
> Devices:
>    ID        SIZE  PATH
>     1  1023.00MiB  /dev/sdb1
> 
> 10:~ # mount -t btrfs /dev/sdb1 /mnt
> 10:~ # cd /mnt
> 10:/mnt # btrfs quota enable .
> 10:/mnt # btrfs su cre sub1
> Create subvolume './sub1'
> 10:/mnt # dd if=/dev/urandom of=sub1/file1 bs=1K count=1024
> 1024+0 records in
> 1024+0 records out
> 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00833739 s, 126 MB/s
> 10:/mnt # dd if=/dev/urandom of=sub1/file2 bs=1K count=1024
> 1024+0 records in
> 1024+0 records out
> 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0179272 s, 58.5 MB/s
> 10:/mnt # btrfs subvolume snapshot sub1 sub2
> Create a snapshot of 'sub1' in './sub2'
> 10:/mnt # dd if=/dev/urandom of=sub2/file2 bs=1K count=1024 conv=notrunc
> 1024+0 records in
> 1024+0 records out
> 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0348762 s, 30.1 MB/s
> 10:/mnt # btrfs qgroup show --sync -p .
> qgroupid         rfer         excl parent
> --------         ----         ---- ------
> 0/5          16.00KiB     16.00KiB ---
> 0/256         2.02MiB      1.02MiB ---
> 0/257         2.02MiB      1.02MiB ---
> 
> So far so good. This is expected, each subvolume has 1MiB shared and
> 1MiB exclusive.
> 
> 10:/mnt # btrfs qgroup create 22/7 /mnt
> 10:/mnt # btrfs qgroup assign --rescan 0/256 22/7 /mnt
> Quota data changed, rescan scheduled
> 10:/mnt # btrfs quota rescan -s /mnt
> no rescan operation in progress
> 10:/mnt # btrfs qgroup assign --rescan 0/257 22/7 /mnt
> Quota data changed, rescan scheduled
> 10:/mnt # btrfs quota rescan -s /mnt
> no rescan operation in progress
> 10:/mnt # btrfs qgroup show --sync -p .
> qgroupid         rfer         excl parent
> --------         ----         ---- ------
> 0/5          16.00KiB     16.00KiB ---
> 0/256         2.02MiB      1.02MiB 22/7
> 0/257         2.02MiB      1.02MiB 22/7
> 22/7          3.03MiB      3.03MiB ---
> 10:/mnt #
> 
> Oops. Total for 22/7 is correct (1MiB shared + 2 * 1MiB exclusive) but
> why all data is treated as exclusive here? It does not match your
> explanation ...


Why? The qgroup calculates it correctly without problem.

All extents in subvolume 256 and 257 belongs to qgroup 22/7.
the 1M shared data all belongs to qgroup 22/7 so it's counted as exclusive.

Not to mention the already exclusive extent from 0/256 and 0/257.


The name "exclusive" just means, all referencer(s) of one extent are all
in the qgroup.
So the explanation is still correct.


Please read btrfs-quota(8) 'SUBVOLUME QUOTA GROUPS' section for more
details.

Thanks,
Qu

> 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to