reexport.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. Reexporting NFS filesystems
  2. ===========================
  3. Overview
  4. --------
  5. It is possible to reexport an NFS filesystem over NFS. However, this
  6. feature comes with a number of limitations. Before trying it, we
  7. recommend some careful research to determine whether it will work for
  8. your purposes.
  9. A discussion of current known limitations follows.
  10. "fsid=" required, crossmnt broken
  11. ---------------------------------
  12. We require the "fsid=" export option on any reexport of an NFS
  13. filesystem. You can use "uuidgen -r" to generate a unique argument.
  14. The "crossmnt" export does not propagate "fsid=", so it will not allow
  15. traversing into further nfs filesystems; if you wish to export nfs
  16. filesystems mounted under the exported filesystem, you'll need to export
  17. them explicitly, assigning each its own unique "fsid= option.
  18. Reboot recovery
  19. ---------------
  20. The NFS protocol's normal reboot recovery mechanisms don't work for the
  21. case when the reexport server reboots. Clients will lose any locks
  22. they held before the reboot, and further IO will result in errors.
  23. Closing and reopening files should clear the errors.
  24. Filehandle limits
  25. -----------------
  26. If the original server uses an X byte filehandle for a given object, the
  27. reexport server's filehandle for the reexported object will be X+22
  28. bytes, rounded up to the nearest multiple of four bytes.
  29. The result must fit into the RFC-mandated filehandle size limits:
  30. +-------+-----------+
  31. | NFSv2 | 32 bytes |
  32. +-------+-----------+
  33. | NFSv3 | 64 bytes |
  34. +-------+-----------+
  35. | NFSv4 | 128 bytes |
  36. +-------+-----------+
  37. So, for example, you will only be able to reexport a filesystem over
  38. NFSv2 if the original server gives you filehandles that fit in 10
  39. bytes--which is unlikely.
  40. In general there's no way to know the maximum filehandle size given out
  41. by an NFS server without asking the server vendor.
  42. But the following table gives a few examples. The first column is the
  43. typical length of the filehandle from a Linux server exporting the given
  44. filesystem, the second is the length after that nfs export is reexported
  45. by another Linux host:
  46. +--------+-------------------+----------------+
  47. | | filehandle length | after reexport |
  48. +========+===================+================+
  49. | ext4: | 28 bytes | 52 bytes |
  50. +--------+-------------------+----------------+
  51. | xfs: | 32 bytes | 56 bytes |
  52. +--------+-------------------+----------------+
  53. | btrfs: | 40 bytes | 64 bytes |
  54. +--------+-------------------+----------------+
  55. All will therefore fit in an NFSv3 or NFSv4 filehandle after reexport,
  56. but none are reexportable over NFSv2.
  57. Linux server filehandles are a bit more complicated than this, though;
  58. for example:
  59. - The (non-default) "subtreecheck" export option generally
  60. requires another 4 to 8 bytes in the filehandle.
  61. - If you export a subdirectory of a filesystem (instead of
  62. exporting the filesystem root), that also usually adds 4 to 8
  63. bytes.
  64. - If you export over NFSv2, knfsd usually uses a shorter
  65. filesystem identifier that saves 8 bytes.
  66. - The root directory of an export uses a filehandle that is
  67. shorter.
  68. As you can see, the 128-byte NFSv4 filehandle is large enough that
  69. you're unlikely to have trouble using NFSv4 to reexport any filesystem
  70. exported from a Linux server. In general, if the original server is
  71. something that also supports NFSv3, you're *probably* OK. Re-exporting
  72. over NFSv3 may be dicier, and reexporting over NFSv2 will probably
  73. never work.
  74. For more details of Linux filehandle structure, the best reference is
  75. the source code and comments; see in particular:
  76. - include/linux/exportfs.h:enum fid_type
  77. - include/uapi/linux/nfsd/nfsfh.h:struct nfs_fhbase_new
  78. - fs/nfsd/nfsfh.c:set_version_and_fsid_type
  79. - fs/nfs/export.c:nfs_encode_fh
  80. Open DENY bits ignored
  81. ----------------------
  82. NFS since NFSv4 supports ALLOW and DENY bits taken from Windows, which
  83. allow you, for example, to open a file in a mode which forbids other
  84. read opens or write opens. The Linux client doesn't use them, and the
  85. server's support has always been incomplete: they are enforced only
  86. against other NFS users, not against processes accessing the exported
  87. filesystem locally. A reexport server will also not pass them along to
  88. the original server, so they will not be enforced between clients of
  89. different reexport servers.