Bug 254682 - quota enabled filesystem doesn't show enabled running mount command
Summary: quota enabled filesystem doesn't show enabled running mount command
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-31 20:49 UTC by Christos Chatzaras
Modified: 2021-04-18 17:14 UTC (History)
1 user (show)

See Also:


Attachments
Proposed fix for bug. (634 bytes, patch)
2021-04-13 00:22 UTC, Kirk McKusick
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christos Chatzaras 2021-03-31 20:49:37 UTC
When I reboot a server which has quotas enabled for /home and run "mount" I get this:

/dev/mirror/gm0p2 on / (ufs, local, noatime)
devfs on /dev (devfs)
/dev/mirror/gm0p7 on /home (ufs, local, noatime, nosuid, soft-updates, acls)
/dev/mirror/gm0p8 on /home2 (ufs, local, noatime, noexec, nosuid, soft-updates)
/dev/mirror/gm0p4 on /tmp (ufs, local, noatime, nosuid, soft-updates)
/dev/mirror/gm0p6 on /usr (ufs, local, noatime, soft-updates)
/dev/mirror/gm0p5 on /var (ufs, local, noatime, soft-updates)
tmpfs on /tmpfs (tmpfs, local, nosuid)

-------

But the quotas work fine as I am able to add/remove files and "quota" command shows immediately the changes.

-------

At about 03:00 something possibly runs using cron and then "mount" shows that I have quotas enabled:

/dev/mirror/gm0p2 on / (ufs, local, noatime)
devfs on /dev (devfs)
/dev/mirror/gm0p7 on /home (ufs, local, noatime, nosuid, with quotas, soft-updates, acls)
/dev/mirror/gm0p8 on /home2 (ufs, local, noatime, noexec, nosuid, soft-updates)
/dev/mirror/gm0p4 on /tmp (ufs, local, noatime, nosuid, soft-updates)
/dev/mirror/gm0p6 on /usr (ufs, local, noatime, soft-updates)
/dev/mirror/gm0p5 on /var (ufs, local, noatime, soft-updates)
tmpfs on /tmpfs (tmpfs, local, nosuid)

-------

Also as I monitor filesystem using Monit I get this e-mail:

Filesystem flags changed Service home

 Date: Wed, 31 Mar 2021 03:01:31
 Action: alert
 Host: server1.example.com
 Description: filesystem flags changed to nosuid, soft updates, acls, noatime, localnosuid, soft updates, acls, noatime, local, quota
Comment 1 Christos Chatzaras 2021-04-10 10:03:26 UTC
ls -la /var/log/mount.today
-rw-------   1 root  wheel      1379 Jan 27 03:01 mount.today

So the mount command shows correct information about quotas enabled after cron runs "periodic daily", which runs "periodic security", which runs /etc/periodic/security/200.chkmounts

Also if I manually execute /etc/periodic/security/200.chkmounts then immediately mount shows "with quotas".
Comment 2 Kirk McKusick freebsd_committer 2021-04-13 00:22:41 UTC
Created attachment 224070 [details]
Proposed fix for bug.

See if this patch solves your problem. It should apply to a 12-stable with possibly a line or two of "fuzz".
Comment 3 Christos Chatzaras 2021-04-14 07:38:20 UTC
(In reply to Kirk McKusick from comment #2)

Yes this patch solves the problem. I test it with releng/13.0. Can you MFC it to stable/13 ? Thank you.
Comment 4 commit-hook freebsd_committer 2021-04-14 22:21:44 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=14d0cd7225e250015eb6d9c79a7eb4e944211b23

commit 14d0cd7225e250015eb6d9c79a7eb4e944211b23
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2021-04-14 22:22:12 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2021-04-14 22:25:08 +0000

    Ensure that the mount command shows "with quotas" when quotas are enabled.

    When quotas are enabled with the quotaon(8) command, it sets the
    MNT_QUOTA flag in the mount structure mnt_flag field. The mount
    structure holds a cached copy of the filesystem statfs structure
    in mnt_stat that includes a copy of the mnt_flag field in
    mnt_stat.f_flags. The mnt_stat structure may not be updated for
    hours. Since the mount command requests mount details using the
    MNT_NOWAIT option, it gets the mount's mnt_stat statfs structure
    whose f_flags field does not yet show the MNT_QUOTA flag being set
    in mnt_flag.

    The fix is to have quotaon(8) set the MNT_QUOTA flag in both mnt_flag
    and in mnt_stat.f_flags so that it will be immediately visible to
    callers of statfs(2).

    Reported by:  Christos Chatzaras
    Tested by:    Christos Chatzaras
    PR:           254682
    MFC after:    3 days
    Sponsored by: Netflix

 sys/ufs/ufs/ufs_quota.c | 2 ++
 1 file changed, 2 insertions(+)
Comment 5 Kirk McKusick freebsd_committer 2021-04-14 22:28:19 UTC
Will be MFC'ed to stable/12 and stable/13 in three days if no problems are reported with it.
Comment 6 Christos Chatzaras 2021-04-14 22:44:04 UTC
(In reply to Kirk McKusick from comment #5)

Thank you. I am not 100% sure but I didn't notice this problem with 12.2. At least Monit didn't report filesystem flags changes with 12.2. But I have not a system with 12.2 any more to check it.
Comment 7 Kirk McKusick freebsd_committer 2021-04-18 17:14:44 UTC
The change has been MFC'ed to stable/13 and stable/12.