|
| 1 | +# Auto Re-export |
| 2 | + |
| 3 | +With older kernel versions all re-exported filesystems had to be explicitly re-exported. This limitation existed because each re-export required an explicit FSID. |
| 4 | + |
| 5 | +As of kernel 6.1 a new auto re-export feature was added; made possible by the addition of the new `fsidd` service that can automatically assign an FSID to an export when required. |
| 6 | + |
| 7 | +Auto re-export is useful in the following conditions: |
| 8 | + |
| 9 | +* The source server has nested mounts on separate filesystems (FSIDs). |
| 10 | + |
| 11 | + This will depend upon the implementation of the source NFS server. For example, NetApp Junctions are presented as separate filesystems and operate similar to Linux NFS' `nohide`/`crossmnt` option. Other NFS servers such as Isilon OneFS present nested volumes as if they were a single filesystem. |
| 12 | + |
| 13 | +* The source server uses `crossmnt`/`nohide` (or similar) and you already use it with the clients. For example, when using NetApp Junctions. |
| 14 | + |
| 15 | +* The source server has a large number of nested mounts (over 1,000) making it impractical or impossible to explicitly re-export every mount. |
| 16 | + |
| 17 | +## Example |
| 18 | + |
| 19 | +Assume the source server is exporting the following nested mounts: |
| 20 | + |
| 21 | +```text |
| 22 | +/dev/sda1 on /files |
| 23 | +/dev/sda2 on /files/archive |
| 24 | +``` |
| 25 | + |
| 26 | +With auto re-export enabled the proxy server only needs to explicitly export `/files`. When a client tries to access `/files/archive` the proxy will detect the change in file system, automatically re-export `/files/archive` using the FSID service to allocate a unique FSID to the export. |
| 27 | + |
| 28 | +In NFS v4, this style of nested mount is directly supported by the NFS protocol. In NFS v3 this style of re-export relies on the `crossmnt` or `nohide` flags. There are some caveats that come with `crossmnt` or `nohide`, see `man exports.5` for more details. |
| 29 | + |
| 30 | +## NFS protocol versions |
| 31 | + |
| 32 | +### NFS version 3 |
| 33 | + |
| 34 | +NFS version 3 does not directly support nested volumes. Officially clients have to use the mount protocol to explicitly mount nested volumes. |
| 35 | + |
| 36 | +Some NFS servers, including the Linux Kernel NFS server (knfsd), support a non-standard option that allows clients to see the nested volume without first mounting the volume. The Linux NFS client then detects the change in FSID and automatically mounts the nested volume. |
| 37 | + |
| 38 | +On Linux this option is `nohide`/`crossmnt`. This can cause issues with NFS clients that do not support this, see `man exports.5` for details. |
| 39 | + |
| 40 | +If the source server does not support an equivalent of `nohide` then auto re-export might not work. In this case the knfsd proxy will only see an empty directory instead of the nested volume. |
| 41 | + |
| 42 | +For NFS v3 all root volumes still need to be explicitly re-exported. If you have a large number of root volumes consider mounting using NFS v4 instead. |
| 43 | + |
| 44 | +### NFS version 4 |
| 45 | + |
| 46 | +The NFS v4 protocol was updated to directly support nested volumes. Under the NFS v4 protocol all exported volumes are considered to be nested volumes of a pseudo-root volume. |
| 47 | + |
| 48 | +Because NFS v4 directly supports nested volumes the `nohide`/`crossmnt` issues of NFS v3 do not apply. However, the knfsd proxy still has to assign an FSID for each nested volume; either explicitly or by using auto re-export. |
| 49 | + |
| 50 | +If you connect to the source server using NFS v4 you can re-export the pseudo-root path `/` with auto re-export enabled to automatically re-export every export. |
| 51 | + |
| 52 | +**NOTE:** When using NFS v4, it is recommended that you use NFS v4.1 or greater. NFS v4.1 has many improvements to fix limitations of the NFS v4.0 protocol. |
| 53 | + |
| 54 | +## Configuration |
| 55 | + |
| 56 | +Use of an FSID service to automatically allocate FSIDs for exports is required when using auto re-export. An `FSID_MODE="external"` is recommended so that all the knfsd proxy instances in the cluster use the same FSID number for each export. |
| 57 | + |
| 58 | +```terraform |
| 59 | +module "nfs_proxy" { |
| 60 | +
|
| 61 | + source = "github.com/GoogleCloudPlatform/knfsd-cache-utils//deployment/terraform-module-knfsd?ref=v1.0.0-beta4" |
| 62 | +
|
| 63 | + # Include your standard KNFSD configuration, this example only shows the |
| 64 | + # configuration values specific to the auto re-export feature. |
| 65 | +
|
| 66 | + # Explicitly re-export only the root volumes from the source server. |
| 67 | + # Not using auto-discovery such as EXPORT_HOST_AUTO_DETECT to avoid |
| 68 | + # explicitly re-exporting nested volumes. |
| 69 | + EXPORT_MAP = "10.0.5.5;/remoteexport;/remoteexport" |
| 70 | +
|
| 71 | + # Enable the auto re-export feature |
| 72 | + AUTO_REEXPORT = true |
| 73 | +
|
| 74 | + # Store FSID mappings in an external database so that all knfsd proxy |
| 75 | + # instances in the cluster allocate the same FSID to each export. |
| 76 | + FSID_MODE = "external" |
| 77 | +
|
| 78 | + # If possible, use an NFS v4 protocol version for the proxy clients as |
| 79 | + # the NFS v4 protocol has direct support nested volumes. |
| 80 | + DISABLED_NFS_VERSIONS = "3,4.0,4.2" |
| 81 | +} |
| 82 | +``` |
0 commit comments