Bug 224851 - Bug in getmntinfo(3) / getfsstat(2) ?
Summary: Bug in getmntinfo(3) / getfsstat(2) ?
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Edward Tomasz Napierala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-02 23:15 UTC by Jamie Landeg-Jones
Modified: 2018-04-16 17:34 UTC (History)
2 users (show)

See Also:


Attachments
test file to demonstrate the problem (668 bytes, text/x-csrc)
2018-01-02 23:15 UTC, Jamie Landeg-Jones
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jamie Landeg-Jones 2018-01-02 23:15:19 UTC
Created attachment 189351 [details]
test file to demonstrate the problem

There appears to be a bug in the system call related to getmntinfo(3) / getfsstat(2), when if the "automount" flag is set on "nullfs" mounts, it is not returned on a getfsstat "WAIT" call. The non-refreshed, non-blocking "MNT_NOWAIT" produces the correct result.

I first noticed this when debugging why my nullfs autofs partitions weren't being automatically unmounted. (FreeBSD current and release)

If this is actually intended behaviour, please reassign this as something that needs to be worked around in the autofs code (I think this is similar in this regard to #195161 )

The somewhat hacked attached snippet from automount.c in the example below demonstrates this - When called with no parameters, it performs a MNT_WAIT request, otherwise a MNT_NOWAIT request is performed. The results are:


| 14:24 [2] (1) "autofs" root@thompson# df
 | Filesystem        1K-blocks     Used      Avail Capacity  Mounted on
 | /dev/ada1p2         5061628   707264    3949436    15%    /
 | devfs                     1        1          0   100%    /dev
 | /dev/ada1p4         5061628   535004    4121696    11%    /var
 | /dev/ada1p5       978973296 21689416  878966020     2%    /usr
 |
 | 14:24 [2] (2) "autofs" root@thompson# mount
 | /dev/ada1p2 on / (ufs, local)
 | devfs on /dev (devfs, local, multilabel)
 | /dev/ada1p4 on /var (ufs, local, soft-updates)
 | /dev/ada1p5 on /usr (ufs, local, soft-updates)
 |
 | 14:25 [2] (3) "autofs" root@thompson# mkdir /tmp/automounted /tmp/manual
 |
 | 14:25 [2] (4) "autofs" root@thompson# mount -t nullfs -o ro /usr/src /tmp/manual
 |
 | 14:25 [2] (5) "autofs" root@thompson# mount -t nullfs -o ro,automounted /usr/src /tmp/automounted/
 |
 | 14:26 [2] (6) "autofs" root@thompson# df
 | Filesystem        1K-blocks     Used      Avail Capacity  Mounted on
 | /dev/ada1p2         5061628   707264    3949436    15%    /
 | devfs                     1        1          0   100%    /dev
 | /dev/ada1p4         5061628   535004    4121696    11%    /var
 | /dev/ada1p5       978973296 21689420  878966016     2%    /usr
 | /usr/src          978973296 21689420  878966016     2%    /tmp/manual
 | /usr/src          978973296 21689420  878966016     2%    /tmp/automounted
 |
 | 14:26 [2] (7) "autofs" root@thompson# mount
 | /dev/ada1p2 on / (ufs, local)
 | devfs on /dev (devfs, local, multilabel)
 | /dev/ada1p4 on /var (ufs, local, soft-updates)
 | /dev/ada1p5 on /usr (ufs, local, soft-updates)
 | /usr/src on /tmp/manual (nullfs, local, read-only)
 | /usr/src on /tmp/automounted (nullfs, local, read-only, automounted)
 |
 | 14:26 [2] (8) "autofs" root@thompson# ./a.out
 | skipping /, not automounted
 | skipping /dev, not automounted
 | skipping /var, not automounted
 | skipping /usr, not automounted
 | skipping /tmp/manual, not automounted
 | skipping /tmp/automounted, not automounted
 |
 | 14:26 [2] (9) "autofs" root@thompson# ./a.out x
 | skipping /, not automounted
 | skipping /dev, not automounted
 | skipping /var, not automounted
 | skipping /usr, not automounted
 | skipping /tmp/manual, not automounted
 | /tmp/automounted IS automounted!!!!!!!!!
Comment 1 Jamie Landeg-Jones 2018-01-02 23:19:59 UTC
The referenced PR is bug #195161 : [autofs] automounted directories not being unmounted
Comment 2 commit-hook freebsd_committer 2018-01-10 17:51:09 UTC
A commit references this bug:

Author: trasz
Date: Wed Jan 10 17:51:02 UTC 2018
New revision: 327777
URL: https://svnweb.freebsd.org/changeset/base/327777

Log:
  Make nullfs properly report MNT_AUTOMOUNTED set on the nullfs mount itself,
  instead of copying from the underlying filesystem.

  PR:		224851
  Reported by:	Jamie Landeg-Jones <jamie at dyslexicfish.net>
  Tested by:	Jamie Landeg-Jones <jamie at dyslexicfish.net>
  MFC after:	2 weeks

Changes:
  head/sys/fs/nullfs/null_vfsops.c
Comment 3 commit-hook freebsd_committer 2018-04-16 17:12:27 UTC
A commit references this bug:

Author: trasz
Date: Mon Apr 16 17:12:19 UTC 2018
New revision: 332613
URL: https://svnweb.freebsd.org/changeset/base/332613

Log:
  MFC r327777:

  Make nullfs properly report MNT_AUTOMOUNTED set on the nullfs mount itself,
  instead of copying from the underlying filesystem.

  PR:		224851

Changes:
_U  stable/11/
  stable/11/sys/fs/nullfs/null_vfsops.c