0001 ==========
0002 NFS Client
0003 ==========
0004
0005 The NFS client
0006 ==============
0007
0008 The NFS version 2 protocol was first documented in RFC1094 (March 1989).
0009 Since then two more major releases of NFS have been published, with NFSv3
0010 being documented in RFC1813 (June 1995), and NFSv4 in RFC3530 (April
0011 2003).
0012
0013 The Linux NFS client currently supports all the above published versions,
0014 and work is in progress on adding support for minor version 1 of the NFSv4
0015 protocol.
0016
0017 The purpose of this document is to provide information on some of the
0018 special features of the NFS client that can be configured by system
0019 administrators.
0020
0021
0022 The nfs4_unique_id parameter
0023 ============================
0024
0025 NFSv4 requires clients to identify themselves to servers with a unique
0026 string. File open and lock state shared between one client and one server
0027 is associated with this identity. To support robust NFSv4 state recovery
0028 and transparent state migration, this identity string must not change
0029 across client reboots.
0030
0031 Without any other intervention, the Linux client uses a string that contains
0032 the local system's node name. System administrators, however, often do not
0033 take care to ensure that node names are fully qualified and do not change
0034 over the lifetime of a client system. Node names can have other
0035 administrative requirements that require particular behavior that does not
0036 work well as part of an nfs_client_id4 string.
0037
0038 The nfs.nfs4_unique_id boot parameter specifies a unique string that can be
0039 used together with a system's node name when an NFS client identifies itself to
0040 a server. Thus, if the system's node name is not unique, its
0041 nfs.nfs4_unique_id can help prevent collisions with other clients.
0042
0043 The nfs.nfs4_unique_id string is typically a UUID, though it can contain
0044 anything that is believed to be unique across all NFS clients. An
0045 nfs4_unique_id string should be chosen when a client system is installed,
0046 just as a system's root file system gets a fresh UUID in its label at
0047 install time.
0048
0049 The string should remain fixed for the lifetime of the client. It can be
0050 changed safely if care is taken that the client shuts down cleanly and all
0051 outstanding NFSv4 state has expired, to prevent loss of NFSv4 state.
0052
0053 This string can be stored in an NFS client's grub.conf, or it can be provided
0054 via a net boot facility such as PXE. It may also be specified as an nfs.ko
0055 module parameter.
0056
0057 This uniquifier string will be the same for all NFS clients running in
0058 containers unless it is overridden by a value written to
0059 /sys/fs/nfs/net/nfs_client/identifier which will be local to the network
0060 namespace of the process which writes.
0061
0062
0063 The DNS resolver
0064 ================
0065
0066 NFSv4 allows for one server to refer the NFS client to data that has been
0067 migrated onto another server by means of the special "fs_locations"
0068 attribute. See `RFC3530 Section 6: Filesystem Migration and Replication`_ and
0069 `Implementation Guide for Referrals in NFSv4`_.
0070
0071 .. _RFC3530 Section 6\: Filesystem Migration and Replication: https://tools.ietf.org/html/rfc3530#section-6
0072 .. _Implementation Guide for Referrals in NFSv4: https://tools.ietf.org/html/draft-ietf-nfsv4-referrals-00
0073
0074 The fs_locations information can take the form of either an ip address and
0075 a path, or a DNS hostname and a path. The latter requires the NFS client to
0076 do a DNS lookup in order to mount the new volume, and hence the need for an
0077 upcall to allow userland to provide this service.
0078
0079 Assuming that the user has the 'rpc_pipefs' filesystem mounted in the usual
0080 /var/lib/nfs/rpc_pipefs, the upcall consists of the following steps:
0081
0082 (1) The process checks the dns_resolve cache to see if it contains a
0083 valid entry. If so, it returns that entry and exits.
0084
0085 (2) If no valid entry exists, the helper script '/sbin/nfs_cache_getent'
0086 (may be changed using the 'nfs.cache_getent' kernel boot parameter)
0087 is run, with two arguments:
0088 - the cache name, "dns_resolve"
0089 - the hostname to resolve
0090
0091 (3) After looking up the corresponding ip address, the helper script
0092 writes the result into the rpc_pipefs pseudo-file
0093 '/var/lib/nfs/rpc_pipefs/cache/dns_resolve/channel'
0094 in the following (text) format:
0095
0096 "<ip address> <hostname> <ttl>\n"
0097
0098 Where <ip address> is in the usual IPv4 (123.456.78.90) or IPv6
0099 (ffee:ddcc:bbaa:9988:7766:5544:3322:1100, ffee::1100, ...) format.
0100 <hostname> is identical to the second argument of the helper
0101 script, and <ttl> is the 'time to live' of this cache entry (in
0102 units of seconds).
0103
0104 .. note::
0105 If <ip address> is invalid, say the string "0", then a negative
0106 entry is created, which will cause the kernel to treat the hostname
0107 as having no valid DNS translation.
0108
0109
0110
0111
0112 A basic sample /sbin/nfs_cache_getent
0113 =====================================
0114 .. code-block:: sh
0115
0116 #!/bin/bash
0117 #
0118 ttl=600
0119 #
0120 cut=/usr/bin/cut
0121 getent=/usr/bin/getent
0122 rpc_pipefs=/var/lib/nfs/rpc_pipefs
0123 #
0124 die()
0125 {
0126 echo "Usage: $0 cache_name entry_name"
0127 exit 1
0128 }
0129
0130 [ $# -lt 2 ] && die
0131 cachename="$1"
0132 cache_path=${rpc_pipefs}/cache/${cachename}/channel
0133
0134 case "${cachename}" in
0135 dns_resolve)
0136 name="$2"
0137 result="$(${getent} hosts ${name} | ${cut} -f1 -d\ )"
0138 [ -z "${result}" ] && result="0"
0139 ;;
0140 *)
0141 die
0142 ;;
0143 esac
0144 echo "${result} ${name} ${ttl}" >${cache_path}