Skip to contentSkip to conversation

The -c option of btrfs qgroup limit

DISCUSSION Koen De Wit 2 participants 2 messages Mar 26, 2013 – Mar 27, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

All,

The "btrfs qgroup limit" command has an option -c which means "limit amount of data after compression". Whether this option is specified or not, I seem to be able to write more well-compressible data than the specified limit. I was expecting that omitting the -c option would never allow me to write more data than specified by the limit. Am I missing something? Which difference in behavior should I expect from the -c option?

Koen.

---

This is what I did:

Mount a btrfs filesystem with the compress option and turn on quota:

  # mkfs.btrfs -f /dev/sdg2
  # mount -o compress /dev/sdg2 /mnt
  # cd /mnt
  # btrfs quota enable ./

Create a subvol and limit the amount of data after compression. Write some well-compressible files:

  # btrfs subvol create subvol1
  # btrfs qgroup limit -c 3m ./subvol1
  # for i in `seq 1 5`; do
        dd if=/dev/zero of=subvol1/file$i bs=1024 count=1000;
        sync;
    done
  (no errors)
  # du -s subvol1
  5000 subvol1
We can write 5 MB of data to a file that is limited to 3 MB, which is normal
in this case because data from /dev/zero is very good compressible.

Create a subvol and limit the amount of data after compression. Write some poorly compressible files:

  # btrfs subvol create subvol2
  # btrfs qgroup limit -c 3m ./subvol2
  # for i in `seq 1 5`; do
        dd if=/dev/urandom of=subvol2/file$i bs=1024 count=1000;
        sync;
    done
  dd: writing `subvol2/file4': Disk quota exceeded
  dd: opening `subvol2/file5': Disk quota exceeded
  # du -s subvol2
  3056 subvol2
Here we get quota violations, because data from /dev/urandom is poorly
compressible.

Now write some well-compressible data to a subvol that is limited without the -c option:

  # btrfs subvol create subvol3
  # btrfs qgroup limit 3m ./subvol3
  # for i in `seq 1 5`; do
        dd if=/dev/zero of=subvol3/file$i bs=1024 count=1000;
        sync;
  done
  (no errors)
  # du -s subvol3
  5000 subvol3
We're still able to write 5 MB of data to a subvol that is limited to 3 MB.
#1 lore raw

Hi Koen,

Quoted 6 lines · Koen De Wit

The "btrfs qgroup limit" command has an option -c which means "limit amount of data after compression". Whether this option is specified or not, I seem to be able to write more well-compressible data than the specified limit. I was expecting that omitting the -c option would never allow me to write more data than specified by the limit. Am I missing something? Which difference in behavior should I expect from the -c option?

Today: none. In the future: The one you describe. That option is planned but not implemented. We should have mentioned that in the qgroup usage, I agree.

-Jan