Blame README.active-restart

Packit 8480eb
Packit 8480eb
The problem
Packit 8480eb
-----------
Packit 8480eb
Packit 8480eb
The initial release of autofs version 5 used the "umount -l" (lazy
Packit 8480eb
umount) to clear stale mounts at startup so that new mounts could
Packit 8480eb
be made with a clean slate. This proved to be a bad choice because
Packit 8480eb
the lazy umount removes the mount from the kernel mount tree. While
Packit 8480eb
the mount itself persists (invisibe to further VFS lookups) until
Packit 8480eb
the mount isn't busy anymore the kernel function d_path(), used to
Packit 8480eb
calculate the path from the mount point to the root, isn't able to
Packit 8480eb
perform its function any more. This leads to things that use d_path(),
Packit 8480eb
such as /bin/pwd, the contents of the link /proc/<pid>/cwd, and so on.
Packit 8480eb
Packit 8480eb
The actual problem with autofs is that it can't re-connect to existing
Packit 8480eb
mounts. Immediately one thinks of just adding the ability to remount
Packit 8480eb
the autofs file system would solve it, but that can't work. This is
Packit 8480eb
because autofs direct mounts and the implementation of "on demand mount
Packit 8480eb
and expire" of nested mount trees i(multi-mounts) have the file system
Packit 8480eb
mounted directly on top of the mount trigger directory.
Packit 8480eb
Packit 8480eb
For example, there are two types of automount maps, direct (in the kernel
Packit 8480eb
module source you will see a third type called an offset, which is just
Packit 8480eb
a direct mount in disguise) and indirect.
Packit 8480eb
Packit 8480eb
Here is a master map with direct and indirect map entries:
Packit 8480eb
Packit 8480eb
/-      /etc/auto.direct
Packit 8480eb
/test   /etc/auto.indirect
Packit 8480eb
Packit 8480eb
and the corresponding map files:
Packit 8480eb
Packit 8480eb
/etc/auto.direct:
Packit 8480eb
Packit 8480eb
/automount/dparse/g6  budgie:/autofs/export1
Packit 8480eb
/automount/dparse/g1  shark:/autofs/export1
Packit 8480eb
and so on.
Packit 8480eb
Packit 8480eb
/etc/auto.indirect:
Packit 8480eb
Packit 8480eb
g1    shark:/autofs/export1
Packit 8480eb
g6    budgie:/autofs/export1
Packit 8480eb
and so on.
Packit 8480eb
Packit 8480eb
For the above indirect map an autofs file system is mounted on /test and
Packit 8480eb
mounts are triggered for each sub-directory key. So we see a mount of
Packit 8480eb
shark:/autofs/export1 on /test/g1, for example.
Packit 8480eb
Packit 8480eb
The way that direct mounts are handled is by making an autofs mount on
Packit 8480eb
each full path, such as /automount/dparse/g1, and using it as a mount
Packit 8480eb
trigger. So when we walk on the path we mount shark:/autofs/export1 "on
Packit 8480eb
top of this mount point".
Packit 8480eb
Packit 8480eb
But, each entry in direct and indirect maps can have offsets (making
Packit 8480eb
them multi-mount map entries).
Packit 8480eb
Packit 8480eb
For example, an indirect mount map entry could also be:
Packit 8480eb
Packit 8480eb
g1  \
Packit 8480eb
   /        shark:/autofs/export5/testing/test \
Packit 8480eb
   /s1      shark:/autofs/export/testing/test/s1 \
Packit 8480eb
   /s2      shark:/autofs/export5/testing/test/s2 \
Packit 8480eb
   /s1/ss1  shark:/autofs/export1 \
Packit 8480eb
   /s2/ss2  shark:/autofs/export2
Packit 8480eb
Packit 8480eb
and a similarly a direct mount map entry could also be:
Packit 8480eb
Packit 8480eb
/automount/dparse/g1 \
Packit 8480eb
    /       shark:/autofs/export5/testing/test \
Packit 8480eb
    /s1     shark:/autofs/export/testing/test/s1 \
Packit 8480eb
    /s2     shark:/autofs/export5/testing/test/s2 \
Packit 8480eb
    /s1/ss1 shark:/autofs/export2 \
Packit 8480eb
    /s2/ss2 shark:/autofs/export2
Packit 8480eb
Packit 8480eb
One of the issues with version 4 of autofs was that, when mounting an
Packit 8480eb
entry with a large number of offsets, possibly with nesting, we needed
Packit 8480eb
to mount and umount all of the offsets as a single unit. Not really a
Packit 8480eb
problem, except for people with a large number of offsets in map entries.
Packit 8480eb
This mechanism is used for the well known "hosts" map and we have seen
Packit 8480eb
cases (in 2.4) where the available number of mounts are exhausted or
Packit 8480eb
where the number of privileged ports available is exhausted.
Packit 8480eb
Packit 8480eb
In version 5 we mount only as we go down the tree of offsets and
Packit 8480eb
similarly for expiring them which resolves the above problem. There is
Packit 8480eb
somewhat more detail to the implementation but it isn't needed for the
Packit 8480eb
sake of the problem explanation. The one important detail is that these
Packit 8480eb
offsets are implemented using the same mechanism as the direct mounts
Packit 8480eb
above and so the autofs mount points can be covered by another mount.
Packit 8480eb
Packit 8480eb
To be able to restart autofs leaving existing direct, indirect and
Packit 8480eb
offset mounts in place we need to be able to obtain a file handle
Packit 8480eb
for these potentially covered autofs mount points. To do this the
Packit 8480eb
autofs ioctl control implementation has been re-implemented,
Packit 8480eb
providing the same functions as the existing ioctl interface and
Packit 8480eb
new operations to the ability to open a file handle on a covered
Packit 8480eb
autofs mount point.
Packit 8480eb
Packit 8480eb
In order to utilize the new interface both kernel and user space
Packit 8480eb
changes (included in this release) are needed. The default install
Packit 8480eb
of autofs won't use the new interface unless it is enabled in the
Packit 8480eb
configuration. This can be done by setting "USE_MISC_DEVICE" to "yes"
Packit 8480eb
in the autofs configuration. In addition, if selinux is being used,
Packit 8480eb
it will likely need to allow operations on the autofs device file
Packit 8480eb
or be set to permissive mode.
Packit 8480eb
Packit 8480eb
Patches for several recent kernel that don't have the implementation
Packit 8480eb
can be found in the patches directory. They have "dev-ioctl" in their
Packit 8480eb
name. Note that, to use these patches, you should be using a kernel
Packit 8480eb
patched with all the current autofs bug fixes since, apart from porobably
Packit 8480eb
not working, the patch probably won't apply either. The bug fix patches
Packit 8480eb
can also be found in the patches directory and they have "v5-update" in
Packit 8480eb
their names.
Packit 8480eb
Packit 8480eb
Ian