I'm having a weird problem with snapshots and exclusive quotas. After
creating a snapshot of a subvolume and setting an exclusive quota of
50MB for the snapshot, everything seems to work fine. I can write
approximately 50MB before the quota kicks in.

However, if I create a snapshot, set an exclusive quota and just wait
for some time, I suddenly cannot even create an empty file because I'm
getting a "quota exceeded" error. The time until the bug appears seems
to vary. During the waiting time, I'm changing neither the snapshot nor
the original subvolume. "qgroup show -e" reports an exclusive use of
only a few kilobytes for the snapshot, which is nowhere near the limit.

Steps to reproduce (/media/extern is a fresh and empty btrfs partition):

Enable quota and create an empty subvolume:
    root@t420:/media/extern# btrfs quota enable .
    root@t420:/media/extern# btrfs subvolume create sub
    Create subvolume './sub'

Snapshot the subvolume and set a limit:
    root@t420:/media/extern# btrfs subvolume snapshot sub snap
    Create a snapshot of 'sub' in './snap'
    root@t420:/media/extern# cd snap/
    root@t420:/media/extern/snap# btrfs qgroup limit -e 50M .

Sometimes it takes "longer" for the quota to kick in, so I'm touching a
file every 5 minutes here:

    root@t420:/media/extern/snap# for file in {1..100}; do touch $file;
sleep 5m; done
    touch: cannot touch ‘7’: Disk quota exceeded
    ^C
    root@t420:/media/extern/snap# btrfs qgroup show -e .
    qgroupid         rfer         excl     max_excl
    --------         ----         ----     --------
    0/5          16.00KiB     16.00KiB         none
    0/257        16.00KiB     16.00KiB         none
    0/258        16.00KiB     16.00KiB     50.00MiB

Any idea why this happens?

Thanks,
Johannes

System info:
    
    Linux t420 4.3.0-rc5 #1 SMP Tue Oct 13 13:21:02 CEST 2015 x86_64
GNU/Linux
    
    Label: none  uuid: 9551e3ca-1608-469c-9d8c-77b99ce0e8ec
        Total devices 1 FS bytes used 816.00KiB
        devid    1 size 931.51GiB used 2.04GiB path /dev/sdb1

    btrfs-progs v4.1.2

    Data, single: total=8.00MiB, used=256.00KiB
    System, DUP: total=8.00MiB, used=16.00KiB
    System, single: total=4.00MiB, used=0.00B
    Metadata, DUP: total=1.00GiB, used=544.00KiB
    Metadata, single: total=8.00MiB, used=0.00B
    GlobalReserve, single: total=16.00MiB, used=0.00B

    [249174.151820]  sdb: sdb1
    [249184.387377]  sdb: sdb1
    [249184.573096]  sdb: sdb1
    [249184.656274] BTRFS: device fsid
9551e3ca-1608-469c-9d8c-77b99ce0e8ec devid 1 transid 3 /dev/sdb1
    [249186.323915]  sdb: sdb1
    [249186.534505]  sdb: sdb1
    [249186.538420]  sdb: sdb1
    [249196.781978] BTRFS info (device sdb1): disk space caching is enabled
    [249196.781986] BTRFS: has skinny extents
    [249196.781990] BTRFS: flagging fs with big metadata feature
    [249196.818164] BTRFS: creating UUID tree
    [249202.311983] BTRFS info (device sdb1): qgroup scan completed
(inconsistency flag cleared)

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to