]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: ignore autofs mount table entries
authorIan Kent <raven@themaw.net>
Mon, 12 Oct 2020 19:40:01 +0000 (15:40 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Mon, 12 Oct 2020 19:40:01 +0000 (15:40 -0400)
Some of the xfsprogs utilities read the mount table via. getmntent(3).

The mount table may contain (almost always these days since /etc/mtab is
symlinked to /proc/self/mounts) autofs mount entries. During processing
of the mount table entries statfs(2) can be called on mount point paths
which will trigger an automount if those entries are direct or offset
autofs mount triggers (indirect autofs mounts aren't affected).

This can be a problem when there are a lot of autofs direct or offset
mounts because real mounts will be triggered when statfs(2) is called.
This can be particularly bad if the triggered mounts are NFS mounts and
the server is unavailable leading to lengthy boot times or worse.

Simply ignoring autofs mount entries during getmentent(3) traversals
avoids the statfs() call that triggers these mounts. If there are
automounted mounts (real mounts) at the time of reading the mount table
these will still be seen in the list so they will be included if that
actually matters to the reader.

Recent glibc getmntent(3) can ignore autofs mounts but that requires the
autofs user to configure autofs to use the "ignore" pseudo mount option
for autofs mounts. But this isn't yet the autofs default (to prevent
unexpected side effects) so that can't be used.

The autofs direct and offset automount triggers are pseudo file system
mounts and are more or less useless in terms on file system information
so excluding them doesn't sacrifice useful file system information
either.

Consequently excluding autofs mounts shouldn't have any adverse side
effects.

Changes since v1:
- drop hunk from fsr/xfs_fsr.c.

Signed-off-by: Ian Kent <raven@themaw.net>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libfrog/linux.c
libfrog/paths.c

index 40a839d18e4f30a898e88248658fd3dbf1e45828..a45d99ab5bbe1481f0e088c4d4adffbd32fda3d2 100644 (file)
@@ -73,6 +73,8 @@ platform_check_mount(char *name, char *block, struct stat *s, int flags)
         * servers.  So first, a simple check: does the "dev" start with "/" ?
         */
        while ((mnt = getmntent(f)) != NULL) {
+               if (!strcmp(mnt->mnt_type, "autofs"))
+                       continue;
                if (mnt->mnt_fsname[0] != '/')
                        continue;
                if (stat(mnt->mnt_dir, &mst) < 0)
index 327372237dd337cf54e662f6b2b227d0543fa1dc..d6793764298eaa9fa251d1dd543b10b18933ff61 100644 (file)
@@ -389,6 +389,8 @@ fs_table_initialise_mounts(
                        return errno;
 
        while ((mnt = getmntent(mtp)) != NULL) {
+               if (!strcmp(mnt->mnt_type, "autofs"))
+                       continue;
                if (!realpath(mnt->mnt_dir, rmnt_dir))
                        continue;
                if (!realpath(mnt->mnt_fsname, rmnt_fsname))