Possible bugs with quotas in 12.0-RELEASE-p11.

I have been fighting with quotas in jails and have found a number of inconsistencies with quotas and associated commands on both the host system and the jails. In prior releases, I have successfully deployed jails supporting quotated users with ezjail. I'm looking to move to 12.x and have been working with Joe who developed qjail. All of this is on a 12.0-RELEASE-p11 system.

Before the usual objections arise, consider this environment:
  • Any UID which will use quotas will normally, by policy, insured to be unique to a single jail. Test users (i.e. sysadmins) may violate this policy and are expected to deal with the implications.
  • Normal users who have quotas applied do not have root or sudo access on the jail or accounts on the host.
  • I understand that applying a quota to a UID should apply that at the filesystem level, including files on the host as well as any jails.
  • For a number of reasons, UFS is the correct solution. ZFS is not an option.
For testing, I have done the following with an md backed file system to make starting with a clean slate easy. Similar issues arise with disk based file systems. The following issues/bugs are demonstrated:
  1. The repquota command appears to fail on both the host and the jail
  2. When a user, on either the host or the jail, overruns his quota, a proper error message is written but an additional improper message that the filesystem is full is also printed. Mostly cosmetic but it caused me to panic when I first saw it.
  3. The quota command fails on a jail, This means that there is no way for a user, running on in a jail, to check his own quotas, despite the quota.user file being viable to the jailed user.
    I would expect this behavior if I had specified a different quota file location, inaccessible to the jail, in the hosts /etc/fstab but in this case, I did not.
Before I file a PR, I was looking for another set of eyes to check my findings.

Create a clean ufs disk to work on and mount it so the jail can see it
Code:
host % sudo dd if=/dev/zero of=/usr/jails/ww4/QuotaedFs bs=1k count=25k
host % sudo mdmfs -F QuotaedFs -s 25m md0 /usr/jails/ww4/mnt
Set quotas for normal user
[code]
host % sudo edquota wayne
Quotas for user wayne:
/usr/jails/ww4/mnt: in use: 968k, limits (soft = 500k, hard = 1000k)
        inodes in use: 3, limits (soft = 0, hard = 0)[/ICODE]
On the host, enable quotas and shut off automount
[code]
host % grep quota /etc/fstab
/dev/md0        /usr/jails/ww4/mnt ufs  rw,userquota,noauto 2   2[/ICODE]
quota command works correctly on host
Code:
host % quota wayne
Disk quotas for user wayne (uid 5147):
Filesystem        usage    quota   limit   grace  files   quota  limit   grace
/usr/jails/ww4/mnt
                    968*     500    1000   7days      3       0      0
repquota command fails on host
host % sudo repquota -a | grep wayne
(nothing printed, error)
The quota file is there (cksum confirms they are the same)
Code:
host % % ls -l /usr/jails/ww4/mnt/quota.user
-rw-r-----  1 root  operator  329536 Nov 20 23:33 /usr/jails/ww4/mnt/quota.user
jail % ls -l /mnt/quota.user
-rw-r-----  1 root  operator  329536 Nov 20 23:33 /mnt/quota.user
Quotas are enforced correctly on host.
System prints an extra message that the file system is full, which is incorrect
Code:
host % dd if=/dev/random > foo
/usr/jails/ww4/mnt: warning, user disk quota exceeded
/usr/jails/ww4/mnt: write failed, user disk limit reached
/usr/jails/ww4/mnt: write failed, filesystem is full
dd: stdout: Disc quota exceeded
1857+0 records in
1856+0 records out
950272 bytes transferred in 0.015728 secs (60419609 bytes/sec)
File system is not full:
Code:
host % df .
Filesystem 1K-blocks Used Avail Capacity  Mounted on
/dev/md0       24348 1012 21392     5%    /usr/jails/ww4/mnt
Remove foo, created on host, test again from jail.
Quotas enforced correctly on jail, again with the extra message about the file system.
Code:
jail % rm foo
jail % df .
Filesystem 1K-blocks Used Avail Capacity  Mounted on
/dev/md0       24348   52 22352     0%    [restricted]
jail % dd if=/dev/random > bar
/usr/jails/ww4/mnt: warning, user disk quota exceeded
/usr/jails/ww4/mnt: write failed, user disk limit reached
/usr/jails/ww4/mnt: write failed, filesystem is full
dd: stdout: Disc quota exceeded
1857+0 records in
1856+0 records out
950272 bytes transferred in 0.016952 secs (56055559 bytes/sec)
quota command fails on jail
Code:
jail % quota
Disk quotas for user wayne (uid 5147): none
repquota command fails on jail, same as host
Code:
jail % sudo repquota -a | grep wayne
(nothing printed, error)
 
Last edited by a moderator:
Back
Top