| 1 |
|
| 2 |
The problem |
| 3 |
----------- |
| 4 |
|
| 5 |
The initial release of autofs version 5 used the "umount -l" (lazy |
| 6 |
umount) to clear stale mounts at startup so that new mounts could |
| 7 |
be made with a clean slate. This proved to be a bad choice because |
| 8 |
the lazy umount removes the mount from the kernel mount tree. While |
| 9 |
the mount itself persists (invisibe to further VFS lookups) until |
| 10 |
the mount isn't busy anymore the kernel function d_path(), used to |
| 11 |
calculate the path from the mount point to the root, isn't able to |
| 12 |
perform its function any more. This leads to things that use d_path(), |
| 13 |
such as /bin/pwd, the contents of the link /proc/<pid>/cwd, and so on. |
| 14 |
|
| 15 |
The actual problem with autofs is that it can't re-connect to existing |
| 16 |
mounts. Immediately one thinks of just adding the ability to remount |
| 17 |
the autofs file system would solve it, but that can't work. This is |
| 18 |
because autofs direct mounts and the implementation of "on demand mount |
| 19 |
and expire" of nested mount trees i(multi-mounts) have the file system |
| 20 |
mounted directly on top of the mount trigger directory. |
| 21 |
|
| 22 |
For example, there are two types of automount maps, direct (in the kernel |
| 23 |
module source you will see a third type called an offset, which is just |
| 24 |
a direct mount in disguise) and indirect. |
| 25 |
|
| 26 |
Here is a master map with direct and indirect map entries: |
| 27 |
|
| 28 |
/- /etc/auto.direct |
| 29 |
/test /etc/auto.indirect |
| 30 |
|
| 31 |
and the corresponding map files: |
| 32 |
|
| 33 |
/etc/auto.direct: |
| 34 |
|
| 35 |
/automount/dparse/g6 budgie:/autofs/export1 |
| 36 |
/automount/dparse/g1 shark:/autofs/export1 |
| 37 |
and so on. |
| 38 |
|
| 39 |
/etc/auto.indirect: |
| 40 |
|
| 41 |
g1 shark:/autofs/export1 |
| 42 |
g6 budgie:/autofs/export1 |
| 43 |
and so on. |
| 44 |
|
| 45 |
For the above indirect map an autofs file system is mounted on /test and |
| 46 |
mounts are triggered for each sub-directory key. So we see a mount of |
| 47 |
shark:/autofs/export1 on /test/g1, for example. |
| 48 |
|
| 49 |
The way that direct mounts are handled is by making an autofs mount on |
| 50 |
each full path, such as /automount/dparse/g1, and using it as a mount |
| 51 |
trigger. So when we walk on the path we mount shark:/autofs/export1 "on |
| 52 |
top of this mount point". |
| 53 |
|
| 54 |
But, each entry in direct and indirect maps can have offsets (making |
| 55 |
them multi-mount map entries). |
| 56 |
|
| 57 |
For example, an indirect mount map entry could also be: |
| 58 |
|
| 59 |
g1 \ |
| 60 |
/ shark:/autofs/export5/testing/test \ |
| 61 |
/s1 shark:/autofs/export/testing/test/s1 \ |
| 62 |
/s2 shark:/autofs/export5/testing/test/s2 \ |
| 63 |
/s1/ss1 shark:/autofs/export1 \ |
| 64 |
/s2/ss2 shark:/autofs/export2 |
| 65 |
|
| 66 |
and a similarly a direct mount map entry could also be: |
| 67 |
|
| 68 |
/automount/dparse/g1 \ |
| 69 |
/ shark:/autofs/export5/testing/test \ |
| 70 |
/s1 shark:/autofs/export/testing/test/s1 \ |
| 71 |
/s2 shark:/autofs/export5/testing/test/s2 \ |
| 72 |
/s1/ss1 shark:/autofs/export2 \ |
| 73 |
/s2/ss2 shark:/autofs/export2 |
| 74 |
|
| 75 |
One of the issues with version 4 of autofs was that, when mounting an |
| 76 |
entry with a large number of offsets, possibly with nesting, we needed |
| 77 |
to mount and umount all of the offsets as a single unit. Not really a |
| 78 |
problem, except for people with a large number of offsets in map entries. |
| 79 |
This mechanism is used for the well known "hosts" map and we have seen |
| 80 |
cases (in 2.4) where the available number of mounts are exhausted or |
| 81 |
where the number of privileged ports available is exhausted. |
| 82 |
|
| 83 |
In version 5 we mount only as we go down the tree of offsets and |
| 84 |
similarly for expiring them which resolves the above problem. There is |
| 85 |
somewhat more detail to the implementation but it isn't needed for the |
| 86 |
sake of the problem explanation. The one important detail is that these |
| 87 |
offsets are implemented using the same mechanism as the direct mounts |
| 88 |
above and so the autofs mount points can be covered by another mount. |
| 89 |
|
| 90 |
To be able to restart autofs leaving existing direct, indirect and |
| 91 |
offset mounts in place we need to be able to obtain a file handle |
| 92 |
for these potentially covered autofs mount points. To do this the |
| 93 |
autofs ioctl control implementation has been re-implemented, |
| 94 |
providing the same functions as the existing ioctl interface and |
| 95 |
new operations to the ability to open a file handle on a covered |
| 96 |
autofs mount point. |
| 97 |
|
| 98 |
In order to utilize the new interface both kernel and user space |
| 99 |
changes (included in this release) are needed. The default install |
| 100 |
of autofs won't use the new interface unless it is enabled in the |
| 101 |
configuration. This can be done by setting "USE_MISC_DEVICE" to "yes" |
| 102 |
in the autofs configuration. In addition, if selinux is being used, |
| 103 |
it will likely need to allow operations on the autofs device file |
| 104 |
or be set to permissive mode. |
| 105 |
|
| 106 |
Patches for several recent kernel that don't have the implementation |
| 107 |
can be found in the patches directory. They have "dev-ioctl" in their |
| 108 |
name. Note that, to use these patches, you should be using a kernel |
| 109 |
patched with all the current autofs bug fixes since, apart from porobably |
| 110 |
not working, the patch probably won't apply either. The bug fix patches |
| 111 |
can also be found in the patches directory and they have "v5-update" in |
| 112 |
their names. |
| 113 |
|
| 114 |
Ian |