view Side-By-Side changes
INTERNET-DRAFT B. Callaghan Document:draft-ietf-nfsv4-00.txtdraft-ietf-nfsv4-01.txt M. Eisler D. Robinson R. Thurlow Sun MicrosystemsJuneD. Noveck Network Appliance September 1999 NFS version 4 Status of this Memo This document is an Internet-Draft and is in full conformance with all provisions of Section 10 of RFC2026. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet- Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet- Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. Abstract NFS version 4 is a distributed file system protocol which owes heritage to NFS versions 2 [RFC1094] and 3 [RFC1813]. Unlike earlier versions, NFS version 4 supports traditional file access while integrating support for file locking and the mount protocol. In addition, support for strong security (and its negotiation), compound operations, and internationlization have been added. Of course, attention has been applied to making NFS version 4 operate well in an Internet environment. Expires:December 1999March 2000 [Page 1] Draft Protocol Specification NFS version 4JuneSeptember 1999 Copyright Copyright (C) The Internet Society (1999). All Rights Reserved. Key Words The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119. Expires:December 1999March 2000 [Page 2] Draft Protocol Specification NFS version 4JuneSeptember 1999 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . .67 2. RPC and Security Flavor . . . . . . . . . . . . . . . . . .78 2.1. Ports and Transports . . . . . . . . . . . . . . . . . . .78 2.2. Security Flavors . . . . . . . . . . . . . . . . . . . . .78 2.2.1. Security mechanisms for NFS version 4 . . . . . . . . .78 2.2.1.1. Kerberos V5 as security triple . . . . . . . . . . . .78 2.2.1.2. <another security triple> . . . . . . . . . . . . . .89 2.3. Security Negotiation . . . . . . . . . . . . . . . . . . .89 2.3.1. Security Error . . . . . . . . . . . . . . . . . . . .. 810 2.3.2. SECINFO . . . . . . . . . . . . . . . . . . . . . . .. 910 3. File handles . . . . . . . . . . . . . . . . . . . . . . .1011 3.1. Obtaining the First File Handle . . . . . . . . . . . .1011 3.1.1. Root File Handle . . . . . . . . . . . . . . . . . . .1011 3.1.2. Public File Handle . . . . . . . . . . . . . . . . . .1112 3.2. File Handle Types . . . . . . . . . . . . . . . . . . .1112 3.2.1. General Properties of a File Handle . . . . . . . . . 12 3.2.2. Persistent File Handle . . . . . . . . . . . . . . . .1213 3.2.3. Volatile File Handle . . . . . . . . . . . . . . . . . 13 3.2.4. One Method of Constructing a Volatile File Handle . .1415 3.3. Client Recovery from File Handle Expiration . . . . . . 15 4. Basic Data Types . . . . . . . . . . . . . . . . . . . . .1617 5. File Attributes . . . . . . . . . . . . . . . . . . . . .1819 5.1. Mandatory Attributes . . . . . . . . . . . . . . . . . .1920 5.2. Recommended Attributes . . . . . . . . . . . . . . . . .1920 5.3. Named Attributes . . . . . . . . . . . . . . . . . . . . 20 5.4. Mandatory Attributes - Definitions . . . . . . . . . . .2022 5.5. Recommended Attributes - Definitions . . . . . . . . . .2225 5.6. Interpreting owner and owner_group . . . . . . . . . . . 30 6. Filesystem Migration and Replication . . . . . . . . . . . 31 6.1. Replication . . . . . . . . . . . . . . . . . . . . . . 31 6.2. Migration . . . . . . . . . . . . . . . . . . . . . . . 31 6.3. Interpretation of the fs_locations Attribute . . . . . . 32 6.4. Filehandle Recovery for Migration or Replication . . . . 33 7. NFS Server Namespace . . . . . . . . . . . . . . . . . . .28 6.1.34 7.1. Server Exports . . . . . . . . . . . . . . . . . . . . .28 6.2.34 7.2. Browsing Exports . . . . . . . . . . . . . . . . . . . .28 6.3.34 7.3. Server Pseudo File-System . . . . . . . . . . . . . . .29 6.4.35 7.4. Multiple Roots . . . . . . . . . . . . . . . . . . . . .29 6.5.35 7.5. Filehandle Volatility . . . . . . . . . . . . . . . . .29 6.6.35 7.6. Exported Root . . . . . . . . . . . . . . . . . . . . .29 6.7.36 7.7. Mount Point Crossing . . . . . . . . . . . . . . . . . .30 6.8.36 7.8. Security Policy and Namespace Presentation . . . . . . . 37 7.9. Summary . . . . . . . . . . . . . . . . . . . . . . . .30 7.37 8. File Locking . . . . . . . . . . . . . . . . . . . . . . .31 7.1.38 8.1. Definitions . . . . . . . . . . . . . . . . . . . . . .31 7.2.38 8.2. Locking . . . . . . . . . . . . . . . . . . . . . . . .32 7.2.1.39 Expires: March 2000 [Page 3] Draft Protocol Specification NFS version 4 September 1999 8.2.1. Client ID . . . . . . . . . . . . . . . . . . . . . .32 7.2.2.39 8.2.2. nfs_lockowner and stateiddefinitionDefinition . . . . . . . . .34 7.2.3.41 8.2.3. Use of the stateid . . . . . . . . . . . . . . . . . .34 7.2.4.41 8.2.4. Sequencing oflock requestsLock Requests . . . . . . . . . . . . .35 7.3.42 8.3. BlockinglocksLocks . . . . . . . . . . . . . . . . . . . . .35 7.4.42 8.4. LeaserenewalRenewal . . . . . . . . . . . . . . . . . . . . .36 7.5.43 8.5. CrashrecoveryRecovery . . . . . . . . . . . . . . . . . . . . .36 Expires: December 1999 [Page 3] Draft Protocol Specification NFS version 4 June 1999 7.6.43 8.5.1. Client Failure and Recovery . . . . . . . . . . . . . 43 8.5.2. Serverrevocation of locksFailure and Recovery . . . . . . . . . . . . . 44 8.5.3. Network Partitions and Recovery . .37 7.7. Share Reservations. . . . . . . . . 44 8.6. Server Revocation of Locks . . . . . . . . . .38 7.8. OPEN/CLOSE procedures. . . . . 45 8.7. Share Reservations . . . . . . . . . . . .38 8. Defined Error Numbers. . . . . . . 46 8.8. OPEN/CLOSE Procedures . . . . . . . . . . .40. . . . . . 47 9.NFS Version 4 RequestsClient-Side Caching . . . . . . . . . . . . . . . . . .45. 48 9.1.Compound ProcedurePerformance Challenges for Client-Side Caching . . . . . 48 9.2. Proxy Caching . . . . . . . . . . . . . .45 9.2. Evaluation of a Compound Request. . . . . . . 49 9.3. Delegation and Callbacks . . . . .45 10. NFS Version 4 Procedures. . . . . . . . . . . 50 9.3.1. Delegation Recovery . . . . .47 10.1. Procedure 0: NULL - No Operation. . . . . . . . . . .47 10.2. Procedure 1: COMPOUND - Compound Operations. 51 9.4. Data Caching . . . . .48 10.3. Procedure 2: ACCESS - Check Access Permission. . . . .50 10.4. Procedure 3: CLOSE - Close File. . . . . . . . . . . . 5310.5. Procedure 4: COMMIT - Commit Cached9.4.1. Data Caching and OPENs . . . . . . .55 10.6. Procedure 5: CREATE - Create a Non-Regular File Object 58 10.7. Procedure 6: GETATTR - Get Attributes. . . . . . . . .62 10.8. Procedure 7: GETFH - Get Current Filehandle53 9.4.2. Data Caching and File Locking . . . . . .64 10.9. Procedure 8: LINK - Create Link to a. . . . . . 54 9.4.3. Data Caching and Mandatory File Locking . . . . . . .66 10.10. Procedure 9: LOCK - Create Lock55 9.4.4. Data Caching and File Identity . . . . . . . . . . .68 10.11. Procedure 10: LOCKT - Test For Lock. 56 9.5. Open Delegation . . . . . . . .70 10.12. Procedure 11: LOCKU - Unlock File. . . . . . . . . .72 10.13. Procedure 12: LOOKUP - Lookup Filename. . 57 9.5.1. Open Delegation and Data Caching . . . . . .74 10.14. Procedure 13: LOOKUPP - Lookup Parent Directory. . .77 10.15. Procedure 14: NVERIFY - Verify Difference in Attributes 79 10.16. Procedure 15: OPEN -. . 59 9.5.2. Opena RegularDelegation and File Locks . . . . . . .81 10.17. Procedure 16: OPENATTR - Open Named Attribute Directory 86 10.18. Procedure 17: PUTFH - Set Current Filehandle. . . . .88 10.19. Procedure 18: PUTPUBFH - Set Public Filehandle60 9.5.3. Recall of Open Delegation . . . .89 10.20. Procedure 19: PUTROOTFH - Set Root Filehandle. . . .90 10.21. Procedure 20: READ - Read from File. . . . . . 60 9.5.4. Delegation Revocation . . .91 10.22. Procedure 21: READDIR - Read Directory. . . . . . . .94 10.23. Procedure 22: READLINK - Read Symbolic Link. . . . .98 10.24. Procedure 23: REMOVE - Remove Filesystem Object63 9.6. Data Caching and Revocation . . .100 10.25. Procedure 24: RENAME - Rename Directory Entry. . . .102 10.26. Procedure 25: RENEW - Renew a Lease. . . . . . . 63 9.6.1. Revocation Recovery for Write Open Delegation . .105 10.27. Procedure 25: RESTOREFH - Restore Saved Filehandle. .106 10.28. Procedure 27: SAVEFH - Save Current Filehandle63 9.7. Attribute Caching . . . .108 10.29. Procedure 28: SECINFO - Obtain Available Security. .109 10.30. Procedure 29: SETATTR - Set Attributes. . . . . . . .111 10.31. Procedure 30: SETCLIENTID - Negotiated Clientid. . .114 10.32. Procedure 31: VERIFY - Verify Same Attributes. . 64 9.8. Name Caching . .116 10.33. Procedure 32: WRITE - Write to File. . . . . . . . .118 11. Locking notes. . . . . . . . . . . 65 9.9. Directory Caching . . . . . . . . . . .123 11.1. Short and long leases. . . . . . . . 66 10. Defined Error Numbers . . . . . . . . .123 11.2. Clocks and leases. . . . . . . . . 68 11. NFS Version 4 Requests . . . . . . . . . .123 11.3. Locks and lease times. . . . . . . 73 11.1. Compound Procedure . . . . . . . . . .123 11.4. Locking of directories and other meta-files. . . . . .124 11.5. Proxy servers and leases. . 73 11.2. Evaluation of a Compound Request . . . . . . . . . . . 73 12. NFS Version 4 Procedures . .124 11.6. Locking and the new latency. . . . . . . . . . . . . .124 Expires: December 1999 [Page 4] Draft Protocol Specification NFS version 4 June 1999 12. Internationalization75 12.1. Procedure 0: NULL - No Operation . . . . . . . . . . . 75 12.2. Procedure 1: COMPOUND - Compound Operations . . . . . . 76 12.2.1. Operation 2: ACCESS - Check Access Rights .125 12.1. Universal Versus Local Character Sets. . . . . 78 12.2.2. Operation 3: CLOSE - Close File . . . .125 12.2. Overview of Universal Character Set Standards. . . . .126 12.3. Difficulties with UCS-4, UCS-2, Unicode. . 82 12.2.3. Operation 4: COMMIT - Commit Cached Data . . . . . .127 12.4. UTF-8 and its solutions84 12.2.4. Operation 5: CREATE - Create a Non-Regular File Object 87 12.2.5. Operation 6: DELEGPURGE - Purge Delegations Awaiting Recovery . . . . . . . . . . . . . . . .128 13. Security Considerations. . . . . . 91 12.2.6. Operation 7: DELEGRETURN - Return Delegation . . . . 92 12.2.7. Operation 8: GETATTR - Get Attributes . . . . . . .129 14.. 93 Expires: March 2000 [Page 4] Draft Protocol Specification NFSVersionversion 4RPC definition fileSeptember 1999 12.2.8. Operation 9: GETFH - Get Current Filehandle . . . . . 95 12.2.9. Operation 10: LINK - Create Link to a File . . . . . 97 12.2.10. Operation 11: LOCK - Create Lock . .130 15. Bibliography. . . . . . . . 99 12.2.11. Operation 12: LOCKT - Test For Lock . . . . . . . . 101 12.2.12. Operation 13: LOCKU - Unlock File . . . . . .151 16. Authors and Contributors. . . 103 12.2.13. Operation 14: LOOKUP - Lookup Filename . . . . . . . 105 12.2.14. Operation 15: LOOKUPP - Lookup Parent Directory . . 108 12.2.15. Operation 16: NVERIFY - Verify Difference in Attributes . . . .155 16.1. Contributors. . . . . . . . . . . . . . . . . 110 12.2.16. Operation 17: OPEN - Open a Regular File . . . .155 16.2. Editor's Address. . 112 12.2.17. Operation 18: OPENATTR - Open Named Attribute Directory . . . . . . . . . . . . . . . . . . .155 16.3. Authors' Addresses. . 120 12.2.18. Operation 19: PUTFH - Set Current Filehandle . . . . 122 12.2.19. Operation 20: PUTPUBFH - Set Public Filehandle . . . 124 12.2.20. Operation 21: PUTROOTFH - Set Root Filehandle . . . 125 12.2.21. Operation 22: READ - Read from File . . . . . . . .155 17. Full Copyright Statement126 12.2.22. Operation 23: READDIR - Read Directory . . . . . . . 129 12.2.23. Operation 24: READLINK - Read Symbolic Link . . . . 133 12.2.24. Operation 25: REMOVE - Remove Filesystem Object . . 135 12.2.25. Operation 26: RENAME - Rename Directory Entry . . .157 Expires: December 1999 [Page 5] Draft Protocol Specification NFS version 4 June 1999 1. Introduction NFS version 4 is137 12.2.26. Operation 27: RENEW - Renew afurther revision of the NFS protocol defined already by versions 2 [RFC1094] and 3 [RFC1813]. It retains theLease . . . . . . . . 140 12.2.27. Operation 28: RESTOREFH - Restore Saved Filehandle . 141 12.2.28. Operation 29: SAVEFH - Save Current Filehandle . . . 143 12.2.29. Operation 30: SECINFO - Obtain Available Security . 145 12.2.30. Operation 31: SETATTR - Set Attributes . . . . . . . 147 12.2.31. Operation 32: SETCLIENTID - Negotiated Clientid . . 150 12.2.32. Operation 33: VERIFY - Verify Same Attributes . . . 152 12.2.33. Operation 34: WRITE - Write to File . . . . . . . . 154 13. NFS Version 4 Callback Procedures . . . . . . . . . . . . 159 13.1. Procedure 0: CB_NULL - No Operation . . . . . . . . . . 159 13.2. Procedure 1: CB_COMPOUND - Compound Operations . . . . 160 13.2.1. Procedure 2: CB_GETATTR - Get Attributes . . . . . . 162 13.2.2. Procedure 3: CB_RECALL - Recall an Open Delegation . 164 14. Locking notes . . . . . . . . . . . . . . . . . . . . . . 166 14.1. Short and long leases . . . . . . . . . . . . . . . . . 166 14.2. Clocks and leases . . . . . . . . . . . . . . . . . . . 166 14.3. Locks and lease times . . . . . . . . . . . . . . . . . 166 14.4. Locking of directories and other meta-files . . . . . . 167 14.5. Proxy servers and leases . . . . . . . . . . . . . . . 167 14.6. Locking and the new latency . . . . . . . . . . . . . . 167 15. Internationalization . . . . . . . . . . . . . . . . . . 168 15.1. Universal Versus Local Character Sets . . . . . . . . . 168 15.2. Overview of Universal Character Set Standards . . . . . 169 15.3. Difficulties with UCS-4, UCS-2, Unicode . . . . . . . . 170 15.4. UTF-8 and its solutions . . . . . . . . . . . . . . . . 171 16. Security Considerations . . . . . . . . . . . . . . . . . 172 17. NFS Version 4 RPC definition file . . . . . . . . . . . . 173 18. Bibliography . . . . . . . . . . . . . . . . . . . . . . 200 Expires: March 2000 [Page 5] Draft Protocol Specification NFS version 4 September 1999 19. Authors and Contributors . . . . . . . . . . . . . . . . 204 19.1. Contributors . . . . . . . . . . . . . . . . . . . . . 204 19.2. Editor's Address . . . . . . . . . . . . . . . . . . . 204 19.3. Authors' Addresses . . . . . . . . . . . . . . . . . . 204 20. Full Copyright Statement . . . . . . . . . . . . . . . . 206 Expires: March 2000 [Page 6] Draft Protocol Specification NFS version 4 September 1999 1. Introduction NFS version 4 is a further revision of the NFS protocol defined already by versions 2 [RFC1094] and 3 [RFC1813]. It retains the essential characteristics of previousversions: stateless designversions: design for easy recovery, independent of transport protocols, operating systems and filesystems, simplicity, and good performance. The NFS version 4 revision has the following goals: o Improved access and good performance on the Internet. The protocol is designed to transit firewalls easily, perform well where latency is high and bandwidth is low, and scale to very large numbers of clients per server. o Strong security with negotiation built into the protocol. The protocol builds on the work of the ONCRPC working group in supporting the RPCSEC_GSS protocol. Additionally NFS version 4 provides a mechanism to allow clients and servers to negotiate security and require clients and servers to support a minimal set of security schemes. o Good cross-platform interoperability. The protocol features a filesystem model that provides a useful, common set of features that does not unduly favor one filesystem or operating system over another. o Designed for protocol extensions. The protocol is designed to accept standard extensions that do not compromise backward compatibility. Expires: March 2000 [Page 7] Draft Protocol Specification NFS version 4 September 1999 2. RPC and Security Flavor The NFS version 4 protocol is a Remote Procedure Call (RPC) application that uses RPC version 2 and the corresponding eXternal Data Representation (XDR) as defined in [RFC1831] and [RFC1832]. The RPCSEC_GSS security flavor as defined in [RFC2203] MUST be used as the mechanism to deliver stronger security to NFS version 4. 2.1. Ports and Transports Historically, NFS version 2 and version 3 servers have resided on UDP/TCP port 2049. Port 2049 is a IANA registered port number for NFS and therefore will continue to be used for NFS version 4. Using the well known port for NFS services means the NFS client will not need to use the RPC binding protocols as described in [RFC1833]; this will allow NFS to transit firewalls. The NFS server SHOULD offer its RPC service via TCP as the primary transport. The server SHOULD also provide UDP for RPC service. The NFS client SHOULD also have a preference for TCP usage but may supply a mechanism to override TCP in favor of UDP as the RPC transport. 2.2. Security Flavors Traditional RPC implementations have included AUTH_NONE, AUTH_SYS, AUTH_DH, and AUTH_KRB4 as security flavors. With [RFC2203] an additional security flavor of RPCSEC_GSS has been introduced which uses the functionality of GSS-API [RFC2078]. This allows for the use of varying security mechanisms by the RPC layer without the additional implementation overhead of adding RPC security flavors. For NFS version 4, the RPCSEC_GSS security flavor MUST be used to enable the mandatory security mechanism. The flavors AUTH_NONE, AUTH_SYS, and AUTH_DH MAY be implemented as well. 2.2.1. Security mechanisms for NFS version 4 The use of RPCSEC_GSS requires selection of: mechanism, quality of protection, and service (authentication, integrity, privacy). The remainder of this document will refer to these three parameters of the RPCSEC_GSS security as the security triple. 2.2.1.1. Kerberos V5 as security triple The Kerberos V5 GSS-API mechanism as described in [RFC1964] MUST be implemented and provide the following security triples. columns: Expires: March 2000 [Page 8] Draft Protocol Specification NFS version 4 September 1999 1 == number of pseudo flavor 2 == name of pseudo flavor 3 == mechanism's OID 4 == mechanism's algorithm(s) 5 == RPCSEC_GSS service 1 2 3 4 5 ----------------------------------------------------------------------- 390003 krb5 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_none 390004 krb5i 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_integrity 390005 krb5p 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_privacy for integrity, and 56 bit DES for privacy. Note that the pseudo flavor is presented here as a mapping aid to the implementor. Because this NFS protocol includes a method to negotiate security and it understands the GSS-API mechanism, the pseudo flavor is not needed. The pseudo flavor is needed for NFS version 3 since the security negotiation is done via the MOUNT protocol. For a discussion of NFS' use of RPCSEC_GSS and Kerberos V5, please see [RFC2623]. 2.2.1.2. <another security triple> Another GSS-API mechanism will need to be specified here along with the corresponding security triple(s). 2.3. Security Negotiation With the NFS version 4 server potentially offering multiple security mechanisms, the client will need a way to determine or negotiate which mechanism is to be used for its communication with the server. The NFS server may have multiple points within its file system name space that are available for use by NFS clients. In turn the NFS server may be configured such that each of these entry points may have different or multiple security mechanisms in use. The security negotiation between client and server must be done with a secure channel to eliminate the possibility of a third party intercepting the negotiation sequence and forcing the client and server to choose a lower level of security than required/desired. Expires: March 2000 [Page 9] Draft Protocol Specification NFS version 4 September 1999 2.3.1. Security Error Based on the assumption that each NFS version 4 client and server must support a minimum set of security (i.e. Kerberos-V5 under RPCSEC_GSS, <ed: add other>), the NFS client will start its communication with the server with one of the minimal security triples. During communication with the server, the client may receive an NFS error of NFS4ERR_WRONGSEC. This error allows the server to notify the client that the security triple currently being used is not appropriate for access to the server's file system resources. The client is then responsible for determining what security triples are available at the server and choose one which is appropriate for the client. 2.3.2. SECINFO The new procedure SECINFO (see SECINFO procedure definition) will allow the client to determine, on a per filehandle basis, what security triple is to be used for server access. In general, the client will not have to use the SECINFO procedure except during initial communication with the server or when the client crosses policy boundaries at the server. It could happen that the server's policies change during the client's interaction therefore forcing the client to negotiate a new security triple. Expires: March 2000 [Page 10] Draft Protocol Specification NFS version 4 September 1999 3. File handles The file handle in the NFS protocol is a per server unique identifier for a file system object. The contents of the file handle are opaque to the client. Therefore, the server is responsible for translating the file handle to an internal representation of the file system object. Since the file handle is the client's reference to an object and the client may cache this reference, the server should not reuse a file handle for another file system object. If the server needs to reuse a file handle value, the time elapsed before reuse SHOULD be large enough that it is likely the client no longer has a cached copy of the reused file handle value. 3.1. Obtaining the First File Handle The procedures of the NFS protocol are defined in terms of one or more file handles. Therefore, the client needs a file handle to initiate communication with the server. With NFS version 2 [RFC1094] and NFS version 3 [RFC1813], there exists an ancillary protocol to obtain this first file handle. The MOUNT protocol, RPC program number 100005, provides the mechanism of translating a string based file system path name to a file handle which can then be used by the NFS protocols. The MOUNT protocol has deficiencies in the area of security and use via firewalls. This is one reason that the use of the public file handle was introduced [RFC2054] [RFC2055]. With the use of public file handle in combination with the LOOKUP procedure in NFS version 2 and 3, it has been demonstrated that the MOUNT protocol is unnecessary for viable interaction between NFS client and server. Therefore, NFS version 4 will not use an ancillary protocol for translation from string based path names to a file handle. Two special file handles will be used as starting points for the NFS client. 3.1.1. Root File Handle The first of the special file handles is the ROOT file handle. The ROOT file handle is the "conceptual" root of the file system name space at the NFS server. The client uses or starts with the ROOT file handle by employing the PUTROOTFH procedure. The PUTROOTFH procedure instructs the server to set the "current" file handle to the ROOT of the server's file tree. Once this PUTROOTFH procedure is used, the client can then traverse the entirety of the server's file tree with the LOOKUP procedure. A complete discussion of the server name space is in section 7, "NFS Server Name Space". Expires: March 2000 [Page 11] Draft Protocol Specification NFS version 4 September 1999 3.1.2. Public File Handle The second special file handle is the PUBLIC file handle. Unlike the ROOT file handle, the PUBLIC file handle may be bound or represent an arbitrary file system object at the server. The server is responsible for this binding. It may be that the PUBLIC file handle and the ROOT file handle refer to the same file system object. However, it is up to the administrative software at the server and the policies of the server administrator to define the binding of the PUBLIC file handle and server file system object. The client may not make any assumptions about this binding. 3.2. File Handle Types In NFS version 2 and 3, there was one type of file handle with a single set of semantics. NFS version 4 introduces a new type of file handle in an attempt to accommodate certain server environments. The first type of file handle is 'persistent'. The semantics of a persistent file handle are the same as the file handles of NFS version 2 and 3. The second or new type of file handle is the 'volatile' file handle. The volatile file handle type is being introduced to address server functionality or implementation issues which prevent correct or feasible implementation of a persistent file handle. Some server environments do not provide a file system level invariant that can be used to construct a persistent file handle. The underlying server file system may not provide the invariant or the server's file system APIs may not provide access to the needed invariant. Volatile file handles may ease the implementation of server functionality such as hierarchical storage management or file system reorganization or migration. However, the volatile file handle increases the implementation burden for the client but this increased burden is deemed acceptable based on the overall gains achieved by the protocol. Since the client will have different paths of logic to handle persistent and volatile file handles, a file attribute is defined which may be used by the client to determine the file handle types being returned by the server. 3.2.1. General Properties of a File Handle The file handle contains all the information the server needs to distinguish an individual file. To the client, the file handle is opaque. The client stores file handles for use in a later request and Expires: March 2000 [Page 12] Draft Protocol Specification NFS version 4 September 1999 can compare two file handles from the same server for equality by doing a byte-by-byte comparison, but MUST NOT otherwise interpret the contents of file handles. If two file handles from the same server are equal, they MUST refer to the same file, but if they are not equal, no conclusions can be drawn. Servers SHOULD try to maintain a one-to-one correspondence between file handles and files but this is not required. Clients MUST only use file handle comparisons only to improve performance, not for correct behavior. As an example, in the case that two different path names when traversed at the server terminate at the same file system object, the server SHOULD return the same file handle for each path. This can occur if a hard link is used to create two file names which refer to the same underlying file object and associated data. For example, if paths /a/b/c and /a/d/c refer to the same file, the server SHOULD return the same file handle for both path names traversals. 3.2.2. Persistent File Handle A persistent file handle is defined as having a persistent value for the lifetime of the file system object to which it refers. Once the server creates the file handle for a file system object, the server MUST return the same file handle for the object for the lifetime of the object. If the server restarts or reboots, or the filesystem is migrated, the NFS server must honor and present the same file handle value as it did in the server's previous instantiation. The persistent file handle will be become stale or invalid when the file system object is removed. When the server is presented with a persistent file handle that refers to a deleted object, it MUST return an error of NFS4ERR_STALE. A file handle may become stale when the file system containing the object is no longer available. The file system may become unavailable if it exists on removable media and the media is no longer available at the server or the file system in whole has been destroyed or the file system has simply been removed from the server's name space (i.e. unmounted in a Unix environment). 3.2.3. Volatile File Handle A volatile file handle does not share the same longevity attributes of the persistent file handle. The server may determine that a volatile file handle is no longer valid at many different points in time. If the server can definitively determine that a volatile file handle refers to an object that has been removed, the server should return NFS4ERR_STALE to the client (as is the case for persistent Expires: March 2000 [Page 13] Draft Protocol Specification NFS version 4 September 1999 file handles). In all other cases where the server determines that a volatile file handle can no longer be used, it should return an error of NFS4ERR_EXPIRED. The following table shows the most common points at which a volatile file handle may expire. This table represents the view from the client's perspective and as such provides columns for when the file may be open or closed by the client. Server Provides Persistent or Volatile File Handle File Open File Closed ___________________________________________________________________ Restart of Server (note 4) P / V P / V Filesystem Migration (note 5) P / V P / V SHARE/LOCK recovery P / V N/A (note 1) Client RENAMEs object P / V P / V Client RENAMEs path to object P / V P / V Other client RENAMEs object P / V P / V Other client RENAMEs path to object P / V P / V Client REMOVEs object P / V (note 2) P / V Other client REMOVEs object P / V N/A (note 3) Note 1 If the file is not open, persistence of the file handle is not applicable for the recovery of SHARE/LOCK. Note 2 With NFS version 2 and 3, when the client removes a file it has open it follows the convention of RENAMEing the file to '.nfsXXXX' until the file is closed. At this point the REMOVE is done at the server. If this same model is used for v4 then this entry will be 'N/A'. Note 3 If the file is not open by the client, then it should not expect any cached file handle to be valid. Note 4 The restart of the NFS server signifies when the operating system or NFS software is (re)started. This also includes High Availability configurations where a separate operating system instantiation acquires ownership of the file system resources and network resources (i.e. disks and IP addresses). Expires: March 2000 [Page 14] Draft Protocol Specification NFS version 4 September 1999 Note 5 Filesystem migration may occur in response to an unresponsive server or when the current server indicates that a filesystem has moved by returning NFS4ERR_MOVED. In both cases, the attribute fs_locations designates the new server location for the filesystem. 3.2.4. One Method of Constructing a Volatile File Handle As mentioned, in some instances a file handle is stale (no longer valid, perhaps because the file was removed from the server), or it is expired (the underlying file is valid, but since the file handle is volatile, it may have expired). Thus the server needs to be able to return NFS4ERR_STALE in the former case, and NFS4ERR_FHEXPIRED in the latter case. This can be done by careful construction of the volatile file handle. One possible implementation follows. A volatile file handle, while opaque to the client could contain: [volatile bit = 1 | server boot time | slot | generation number] o slot is an index in the server volatile file handle table o generation number is the generation number for the table entry/slot If the server boot time is less than the current server boot time, return NFS4ERR_FHEXPIRED. If slot is out of range, return NFS4ERR_BADHANDLE. If the generation number does not match, return NFS4ERR_BADHANDLE. When the server reboots, the table is gone (it is volatile). If volatile bit is 0, then it is a persistent file handle with a different structure following it. 3.3. Client Recovery from File Handle Expiration With the introduction of the volatile file handle, the client must take on additional responsibility so that it may prepare itself to recover from the expiration of a volatile file handle. If the server returns persistent file handles, the client does not need these additional steps. For volatile file handles, most commonly the client will need to store the component names leading up to and including the file system Expires: March 2000 [Page 15] Draft Protocol Specification NFS version 4 September 1999 object in question. With these names, the client should be able to recover by finding a file handle in the name space that is still available or by starting at the root of the server's file system name space. If the expired file handle refers to an object that has been removed from the file system, obviously the client will not be able to recover from the expired file handle. It is also possible that the expired file handle refers to a file that has been renamed. If the file was renamed by another client, again it is possible that the original client will not be able to recover. However, in the case that the client itself is renaming the file and the file is open, it is possible that the client may be able to recover. The client can determine the new path name based on the processing of the rename request. The client can then regenerate the new file handle based on the new path name. The client could also use the compound operation mechanism to construct a set of operations like: RENAME A B LOOKUP B GETFH Expires: March 2000 [Page 16] Draft Protocol Specification NFS version 4 September 1999 4. Basic Data Types Arguments and results from operations will be described in terms of basic XDR types defined in [RFC1832]. The following data types will be defined in terms of basic XDR types: filehandle: opaque <128> An NFS version 4 filehandle. A filehandle with zero length is recognized as a "public" filehandle. utf8string: opaque <> A counted array of octets that contains a UTF-8 string. Note: Section 11, Internationalization, covers the rational of using UTF-8. bitmap: uint32 <> A counted array of 32 bit integers used to contain bit values. The position of the integer in the array that contains bit n can be computed from the expression (n / 32) and its bit within that integer is (n mod 32). 0 1 +-----------+-----------+-----------+-- | count | 31 .. 0 | 63 .. 32 | +-----------+-----------+-----------+-- createverf: opaque<8> Verify used for exclusive create semantics nfstime4 struct nfstime4 { int64_t seconds; uint32_t nseconds; } The nfstime4 structure gives the number of seconds and nanoseconds since midnight or 0 hour January 1, 1970 Coordinated Universal Time (UTC). Values greater than zero for the seconds field denote dates after the 0 hour January 1, 1970. Values less than zero for the seconds field denote dates before the 0 hour January 1, 1970. In both cases, the nseconds field is to be added to the seconds field for the final time representation. For example, if the time to be represented is one-half second Expires: March 2000 [Page 17] Draft Protocol Specification NFS version 4 September 1999 before 0 hour January 1, 1970, the seconds field would have a value of negative one (-1) and the nseconds fields would have a value of one-half second (500000000). Values greater than 999,999,999 for nseconds are considered invalid. This data type is used to pass time and date information. A server converts to and from local time when processing time values, preserving as much accuracy as possible. If the precision of timestamps stored for a file system object is less than defined, loss of precision can occur. An adjunct time maintenance protocol is recommended to reduce client and server time skew. specdata4 struct specdata4 { uint32_t specdata1; uint32_t specdata2; } This data type represents additional information for the device file types NFCHR and NFBLK. Expires: March 2000 [Page 18] Draft Protocol Specification NFS version 4 September 1999 5. File Attributes To meet the NFS Version 4 requirements of extensibility and increased interoperability with non-Unix platforms, attributes must be handled in a more flexible manner. The NFS Version 3 fattr3 structure contained a fixed list of attributes that not all clients and servers are able to support or care about, which cannot be extended as new needs arise, and which provides no way to indicate non-support. With NFS Version 4, the client will be able to ask what attributes the server supports, and will be able to request only those attributes in which it is interested. To this end, attributes will be divided into three groups: mandatory, recommended and named. Both mandatory and recommended attributes are supported in the NFS V4 protocol by a specific and well-defined encoding, and are identified by number. They are requested by setting a bit in the bit vector sent in the GETATTR request; the server response includes a bit vector to list what attributes were returned in response. New mandatory or recommended attributes may be added to the NFS protocol between revisions by publishing a standards-track RFC which allocates a new attribute number value and defines the encoding for the attribute. Named attributes are accessed by the new OPENATTR operation, which accesses a hidden directory of attributes associated with a filesystem object. OPENATTR takes a filehandle for the object and returns the filehandle for the attribute hierarchy, which is a directory object accessible by LOOKUP or READDIR, and which contains files whose names represent the named attributes and whose data bytes are the value of the attribute. For example: LOOKUP "foo" ; look up file GETATTR attrbits OPENATTR ; access foo's named attributes LOOKUP "x11icon" ; look up specific attribute READ 0,4096 ; read stream of bytes Named attributes are intended primarily for data needed by applications rather than by an NFS client implementation per se; NFS implementors are strongly encouraged to define their new attributes as recommended attributes by bringing them to the working group. The set of attributes which are classified as mandatory is deliberately small, since servers must do whatever it takes to support them. The recommended attributes may be unsupported, though a server should support as many as it can. Attributes are deemed Expires: March 2000 [Page 19] Draft Protocol Specification NFS version 4 September 1999 mandatory if the data is both needed by a large number of clients and is not otherwise reasonably computable by the client when support is not provided on the server. 5.1. Mandatory Attributes These MUST be supported by every NFS Version 4 client and server in order to ensure a minimum level of interoperability. The server must store and return these attributes, and the client must be able to function with an attribute set limited to these attributes, though some operations may be impaired or limited in some ways in this case. A client may ask for any of these attributes to be returned by setting a bit in the GETATTR request, and the server must return their value. 5.2. Recommended Attributes These attributes are understood well enough to warrant support in the NFS Version 4 protocol, though they may not be supported on all clients and servers. A client may ask for any of these attributes to be returned by setting a bit in the GETATTR request, but must be able to deal with not receiving them. A client may ask for the set of attributes the server supports and should not request attributes the server does not support. A server should be tolerant of requests for unsupported attributes, and simply not return them, rather than considering the request an error. It is expected that servers will support all attributes they comfortably can, and only fail to support attributes which are difficult to support in their operating environments. A server should provide attributes whenever they don't have to "tell lies" to the client. For example, a file modification time should be either an accurate time or should not be supported by the server. This will not always be comfortable to clients but it seems that the client has a better ability to fabricate or construct an attribute or do without. Most attributes from NFS V3's FSINFO, FSSTAT and PATHCONF procedures have been added as recommended attributes, so that filesystem info may be collected via the filehandle of any object the filesystem. This renders those procedures unnecessary in NFS V4. 5.3. Named Attributes These attributes are not supported by direct encoding in the NFS Version 4 protocol but are accessed by string names rather than numbers and correspond to an uninterpreted stream of bytes which are Expires: March 2000 [Page 20] Draft Protocol Specification NFS version 4 September 1999 stored with the filesystem object. The namespace for these attributes may be accessed by using the OPENATTR operation to get a filehandle for a virtual "attribute directory" and using READDIR and LOOKUP operations on this filehandle. Named attributes may then be examined or changed by normal READ and WRITE and CREATE operations on the filehandles returned from READDIR and LOOKUP. Named attributes may have attributes, for example, a security label may have access control information in its own right. It is recommended that servers support arbitrary named attributes. A client should not depend on the ability to store any named attributes in the server's filesystem. If a server does support named attributes, a client which is also able to handle them should be able to copy a file's data and meta-data with complete transparency from one location to another; this would imply that there should be no attribute names which will be considered illegal by the server. Names of attributes will not be controlled by a standards body. However, vendors and application writers are encouraged to register attribute names and the interpretation and semantics of the stream of bytes via informational RFC so that vendors may interoperate where common interests exist. Expires: March 2000 [Page 21] Draft Protocol Specification NFS version 4 September 1999 5.4. Mandatory Attributes - Definitions Name # DataType Access Description ___________________________________________________________________ supp_attr 0 bitmap READ The bit vector which would retrieve all mandatory and recommended attributes which may be requested for this object. The client must ask this question to request correct attributes. object_type 1 nfs4_ftype READ The type of the object (file, directory, symlink) The client cannot handle object correctly without type. persistent_fh 2 boolean READ Is the filehandle for this object persistent? Server should know if the filehandles being provided are persistent or not. If the server is not able to make this determination, then it can choose volatile or non-persistent. Expires: March 2000 [Page 22] Draft Protocol Specification NFS version 4 September 1999 change 3 uint64 READ A value created by the server that the client can use to determine if a file data, directory contents or attributes have been modified. The server can just return the file mtime in this field though if a more precise value exists then it can be substituted, for instance, a sequence number. Necessary for any useful caching, likely to be available. object_size 4 uint64 R/W The size of the object in bytes. Could be very expensive to derive, likely to be available. link_support 5 boolean READ Does the object's filesystem supports hard links? Server can easily determine if links are supported. symlink_support 6 boolean READ Does the object's filesystem supports symbolic links? Server can easily determine if links are supported. named_attr 7 boolean READ Does this object have named attributes? Expires: March 2000 [Page 23] Draft Protocol Specification NFS version 4 September 1999 fsid 8 fsid4 READ Unique filesystem identifier for the filesystem holding this object. fsid contains major and minor components each of which are uint64. unique_handles 9 boolean READ Are two distinct filehandles guaranteed to refer to two different file system objects? lease_time 10 uint32 READ Duration of leases at server in seconds. Expires: March 2000 [Page 24] Draft Protocol Specification NFS version 4 September 1999 5.5. Recommended Attributes - Definitions Name # Data Type Access Description _____________________________________________________________________ ACL 11 nfsacl4 R/W The access control list for the object. [The nature and format of ACLs is still to be determined.] archive 12 boolean R/W Whether or not this file has been archived since the time of last modification (deprecated in favor of backup_time). cansettime 13 boolean READ Whether or not this object's filesystem can fill in the times on a SETATTR request without an explicit time. case_insensitive 14 boolean READ Are filename comparisons on this filesystem case insensitive? case_preserving 15 boolean READ Is filename case on this filesystem preserved? chown_restricted 16 boolean READ Will a request to change ownership be honored? filehandle 17 nfs4_fh READ The filehandle of this object (primarily for readdir requests). Expires: March 2000 [Page 25] Draft Protocol Specification NFS version 4 September 1999 fileid 18 uint64 READ A number uniquely identifying the file within the filesystem. files_avail 19 uint64 READ File slots available to this user on the filesystem containing this object - this should be the smallest relevant limit. files_free 20 uint64 READ Free file slots on the filesystem containing this object - this should be the smallest relevant limit. files_total 21 uint64 READ Total file slots on the filesystem containing this object. fs_locations 22 fs_locations READ Locations where this filesystem may be found. If the server returns NFS4ERR_MOVED as an error, this attribute must be supported. hidden 23 boolean R/W Is file considered hidden? homogeneous 24 boolean READ Whether or not this object's filesystem is homogeneous, i.e. whether pathconf is the same for all filesystem objects. maxfilesize 25 uint64 READ Maximum supported file size for the filesystem of this object. Expires: March 2000 [Page 26] Draft Protocol Specification NFS version 4 September 1999 maxlink 26 uint32 READ Maximum number of links for this object. maxname 27 uint32 READ Maximum filename size supported for this object. maxread 28 uint64 READ Maximum read size supported for this object. maxwrite 29 uint64 READ Maximum write size supported for this object. This attribute SHOULD be supported if the file is writable. Lack of this attribute can lead to the client either wasting bandwidth or not receiving the best performance. mime_type 30 utf8<> R/W MIME body type/subtype of this object. mode 31 uint32 R/W Unix-style permission bits for this object (deprecated in favor of ACLs) no_trunc 32 boolean READ If a name longer than name_max is used, will an error be returned or will the name be truncated? numlinks 33 uint32 READ Number of links to this object. owner 34 utf8<> R/W The string name of the owner of this object. Expires: March 2000 [Page 27] Draft Protocol Specification NFS version 4 September 1999 owner_group 35 utf8<> R/W The string name of the group of the owner of this object. quota_hard 36 uint64 READ Number of bytes of disk space beyond which the server will decline to allocate new space. quota_soft 37 uint64 READ Number of bytes of disk space at which the client may choose to warn the user about limited space. quota_used 38 uint64 READ Number of bytes of disk space occupied by the owner of this object on this filesystem. rawdev 39 specdata4 READ Raw device identifier. space_avail 40 uint64 READ Disk space in bytes available to this user on the filesystem containing this object - this should be the smallest relevant limit. space_free 41 uint64 READ Free disk space in bytes on the filesystem containing this object - this should be the smallest relevant limit. space_total 42 uint64 READ Total disk space in bytes on the filesystem containing this object. Expires: March 2000 [Page 28] Draft Protocol Specification NFS version 4 September 1999 space_used 43 uint64 READ Number of filesystem bytes allocated to this object. system 44 boolean R/W Whether or not this file is a system file. time_access 45 nfstime4 R/W The time of last access to the object. time_backup 46 nfstime4 R/W The time of last backup of the object. time_create 47 nfstime4 R/W The time of creation of the object. This attribute does not have any relation to the traditional Unix file attribute time'. time_delta 48 nfstime4 READ Smallest useful server time granularity. time_metadata 49 nfstime4 R/W The time of last meta-data modification of the object. time_modify 50 nfstime4 R/W The time since the epoch of last modification to the object. version 51 utf8<> R/W Version number of this document. volatility 52 nfstime4 READ Approximate time until next expected change on this filesystem, as a measure of volatility. Expires: March 2000 [Page 29] Draft Protocol Specification NFS version 4 September 1999 5.6. Interpreting owner and owner_group The recommended attributes "owner" and "owner_group" are represented in terms of a UTF-8 string. To avoid a representation that is tied to a particular underlying implementation at the client or server, the use of the UTF-8 string has been chosen. Note that section 6.1 of [RFC2624] provides additional rationale. It is expected that the client and server will have their own local representation of owner and owner_group that is used for local storage or presentation to the end user. Therefore, it is expected that the when these attributes are transferred between the client and server that the local representation is translated to a syntax of the form "user@dns_domain". This will allow for a client and server that do not use the same local representation the ability to translate to a common syntax that can be interpreted by both. The translation is not specified as part of the protocol. This allows various solutions to be employed. For example, a local translation table may be consulted that maps between a numeric id to the user@dns_domain syntax. A name service may also be used to accomplish the translation. The 'dns_domain' portion of the owner string is meant to be a DNS domain name. For example, user@ietf.org. In the case where there is no translation available to the client or server, the attribute value must be constructed without the '@'. Therefore, the absence of the @ from the owner or owner_group attribute signifies that no translation was available and the receiver of the attribute should not place any special meaning with the attribute value. Even though the attribute value can not be translated, it may still be useful. In the case of a client, the attribute string may be used for local display of ownership. Expires: March 2000 [Page 30] Draft Protocol Specification NFS version 4 September 1999 6. Filesystem Migration and Replication With the use of the recommended attribute "fs_locations", the NFS version 4 server has a method of providing filesystem migration or replication services. For the purposes of migration and replication, a filesystem will be defined as all files that share a given fsid (major and minor values are the same). The fs_locations attribute provides a list of filesystem locations. These locations are specified by providing the server name (either DNS domain or IP address) and the path name representing the root of the filesystem. Depending on the type of service being provided, the list will provide a new or alternate locations for the filesystem. The client will use this information to redirect its requests to the new server. 6.1. Replication It is expected that filesystem replication will be used in the case of read-only data. Typically, the filesystem will be replicated amongst two or more servers. The fs_locations attribute will provide the list of these locations to the client. On first access of the filesystem, the client should obtain the value of the fs_locations attribute. If, in the future, the client finds the server unresponsive, the client may attempt to use another server specified by fs_locations. If applicable, the client must take the appropriate steps to recover valid filehandles from the new server. This is described in more detail in the following sections. 6.2. Migration Filesystem migration is used to move a filesystem from one server to another. Migration is typically used for a filesystem that is writable and has a single copy. The expected use of migration is for load balancing or general resource reallocation. The protocol does not specify how the filesystem will be moved between servers. This server-to-server transfer mechanism is left to the server implementor. However, the method used to communicate the migration event between client and server is specified here. Once the servers participating in the migration have completed the move of the filesystem, the error NFS4ERR_MOVED will be returned for subsequent requests received by the original server. The NFS4ERR_MOVED error is returned for all operations except GETATTR. Expires: March 2000 [Page 31] Draft Protocol Specification NFS version 4 September 1999 Upon receiving the NFS4ERR_MOVED error, the client will obtain the value of the fs_locations attribute. The client will then use the contents of the attribute to redirect its requests to the specified server. To facilitate the use of GETATTR operations such as PUTFH must also be accepted by the server for the migrated filesystem's filehandles. Note that if the server returns NFS4ERR_MOVED, the server MUST support the fs_locations attribute. If the client requests more attributes than fs_locations, the server may return fs_locations only. This is to be expected since the server has migrated the filesystem and may not have a method of obtaining additional attribute data. The server implementor needs to be careful in developing a migration solution. The server must consider all of the state information clients may have outstanding at the server. This includes but is not limited to locking/share state, delegation state, and asynchronous file writes which are represented by WRITE and COMMIT verifiers. The server should strive to minimize the impact on its clients during and after the migration process. 6.3. Interpretation of the fs_locations Attribute The fs_location attribute is structured in the following way: struct fs_location { utf8string server<>; pathname4 rootpath; }; struct fs_locations { pathname4 fs_root; fs_location locations<>; }; The fs_location struct is used to represent the location of a filesystem by providing a server name and the path to the root of the filesystem. For a multi-homed server or a set of servers that use the same rootpath, an array of server names may be provided. An entry in the server array is an UTF8 string and represents one of a traditional DNS host name, IPv4 address, or IPv6 address. It is not a requirement that all servers that share the same rootpath be listed in one fs_location struct. The array of server names is provided for convenience. Servers that share the same rootpath may also be listed in separate fs_location entries in the fs_locations attribute. The fs_locations struct and attribute then contains an array of Expires: March 2000 [Page 32] Draft Protocol Specification NFS version 4 September 1999 locations. Since the namespace of each server may be constructed differently, the "fs_root" field is provided. The path represented by fs_root represents the location of the filesystem in the server's namespace. Therefore, the fs_root path is only associated with the server from which the fs_locations attribute was obtained. The fs_root path is meant to aid the client in locating the filesystem at the various servers listed. As an example, there is a replicated file system located at two servers (servA and servB). At servA the filesystem is located at path "/a/b/c". At servB the filesystem is located at path "/x/y/z". In this example the client accesses the filesystem first at servA with a multi-component lookup path of "/a/b/c/d". Since the client used a multi-component lookup to obtain the filehandle at "/a/b/c/d", it is unaware that the filesystem's root is located in servA's namespace at "/a/b/c". When the client switches to servB, it will need to determine that the directory it first referenced at servA is now represented by the path "/x/y/z/d" on servB. To facilitate this, the fs_locations attribute provided by servA would have a fs_root value of "/a/b/c" and two entries in fs_location. One entry in fs_location will be for itself (servA) and the other will be for servB with a path of "/x/y/z". With this information, the client is able to substitute "/x/y/z" for the "/a/b/c" at the beginning of its access path and construct "/x/y/z/d" to use for the new server. 6.4. Filehandle Recovery for Migration or Replication Filehandles for filesystems that are replicated or migrated have the same semantics as for filesystems that are not replicated or migrated. For example, if a filesystem has persistent filehandles and it is migrated to another server, the filehandle values for the filesystem will be valid at the new server. The same is true for a filesystem which is made up of volatile filehandles. In fact, in this case the client should expect that the new server will return NFS4ERR_EXPIRED when old filehandles are presented; the client will need to recover the filehandles appropriately. Expires: March 2000 [Page 33] Draft Protocol Specification NFS version 4 September 1999 7. NFS Server Namespace 7.1. Server Exports On a UNIX server the name-space describes all the files reachable by pathnames under the root directory "/". On a Windows NT server the name-space constitutes all the files on disks named by mapped disk letters. NFS server administrators rarely make the entire server's file-system name-space available to NFS clients. Typically, pieces of the name-space are made available via an "export" feature. In previous versions of NFS, the root file-handle for each export is obtained through the MOUNT protocol; the client sends a string that identifies the export of name-space and the server returns the root file-handle for it. The MOUNT protocol supports an EXPORTS procedure that will enumerate the server's exports. 7.2. Browsing Exports The NFS version 4 protocol provides a root file-handle that clients can use to obtain file-handles for these exports via a multi- component LOOKUP. A common user experience is to use a graphical user interface (perhaps a file "Open" dialog window) to find a file via progressive browsing through a directory tree. The client must be able to move from one export to another export via single-component, progressive LOOKUP operations. This style of browsing is not well supported by NFS version 2 and 3 protocols. The client expects all LOOKUP operations to remain within a single server file-system, i.e. the device attribute will not change. This prevents a client from taking name-space paths that span exports. An automounter on the client can obtain a snapshot of the server's name-space using the EXPORTS procedure of the MOUNT protocol. If it understands the server's pathname syntax, it can create an image of the server's name-space on the client. The parts of the name-space that are not exported by the server are filled in with a "pseudo file-system" that allows the user to browse from one mounted file- system to another. There is a drawback to this representation of the server's name-space on the client: it is static. If the server administrator adds a new export the client will be unaware of it. Expires: March 2000 [Page 34] Draft Protocol Specification NFS version 4 September 1999 7.3. Server Pseudo File-System NFS version 4 servers avoid this name-space inconsistency by presenting all the exports within the framework of a single server name-space. An NFS version 4 client uses LOOKUP and READDIR operations to browse seamlessly from one export to another. Portions of the server name-space that are not exported are bridged via a "pseudo file-system" that provides a view of exported directories only. A pseudo file-system has a unique fsid and behaves like a normal, read-only file-system. Based on the construction of the server's name space, it is possible that multiple pseudo filesystems may exist. For example, /a pseudo filesystem /a/b real filesystem /a/b/c pseudo filesystem /a/b/c/d real filesystem Need to discuss the ramifications of multiple pseudo filesystems. 7.4. Multiple Roots DOS, Windows 95, 98 and NT are sometimes described as having "multiple roots". File-Systems are commonly represented as disk letters. MacOS represents file-systems as top-level names. NFS version 4 servers for these platforms can construct a pseudo file- system above these root names so that disk letters or volume names are simply directory names in the pseudo-root. 7.5. Filehandle Volatility The nature of the server's pseudo file-system is that it is a logical representation of file-system(s) available from the server. Therefore, the pseudo file-system is most likely constructed dynamically when the NFS version 4 is first instantiated. It is expected the pseudo file-system may not have an on-disk counterpart from which persistent filehandles could be constructed. Even though it is preferable that the server provide persistent filehandles for the pseudo file-system, the NFS client should expect that pseudo file-system file-handles are volatile. This can be confirmed by checking the associated "persistent_fh" attribute for those Expires: March 2000 [Page 35] Draft Protocol Specification NFS version 4 September 1999 filehandles in question. If the filehandles are volatile, the NFS client must be prepared to recover a filehandle value (i.e. with a v4 multi-component LOOKUP) when receiving an error of NFS4ERR_FHEXPIRED. 7.6. Exported Root If the server's root file-system is exported, it might be easy to conclude that a pseudo-file-system is not needed. This would be wrong. Assume the following file-systems on a server: / disk1 (exported) /a disk2 (not exported) /a/b disk3 (exported) Because disk2 is not exported, disk3 cannot be reached with simple LOOKUPs. The server must bridge the gap with a pseudo-file-system. 7.7. Mount Point Crossing The server file-system environment may be constructed in such a way that one file-system contains a directory which is 'covered' or mounted upon by a second file-system. For example: /a/b (file system 1) /a/b/c/d (file system 2) The pseudo file-system for this server may be constructed to look like: / (place holder/not exported) /a/b (file system 1) /a/b/c/d (file system 2) It is the server's responsibility to present the pseudo file-system that is complete to the client. If the client sends a lookup request for the path "/a/b/c/d", the server's response is the filehandle of the file system "/a/b/c/d". In previous versions of NFS, the server would respond with the directory "/a/b/d/d" within the file-system "/a/b". The NFS client will be able to determine if it crosses a server mount point by a change in the value of the "fsid" attribute. Expires: March 2000 [Page 36] Draft Protocol Specification NFS version 4 September 1999 7.8. Security Policy and Namespace Presentation The application of the server's security policy needs to be carefully considered by the implementor. One may choose to limit the viewability of portions of the pseudo file-system based on the server's perception of the client's ability to authenticate itself properly. However with the support of multiple security mechanisms and the ability to negotiate the appropriate use of these mechanisms, the server is unable to properly determine if a client will be able to authenticate itself. If, based on its policies, the server chooses to limit the contents of the pseudo file-system, the server may effectively hide file-systems from a client that may otherwise have legitimate access. 7.9. Summary NFS version 4 provides LOOKUP and READDIR operations foreasy recovery, independentbrowsing of NFS file-systems. These operations are also used to browse server exports. A v4 server supports export browsing by including exported directories in a pseudo-file-system. A browsing client can cross seamlessly between a pseudo-file-system and a real, exported file- system. Clients must support volatile filehandles and recognize mount point crossing of server file-systems. Expires: March 2000 [Page 37] Draft Protocol Specification NFS version 4 September 1999 8. File Locking Integrating locking into NFS necessarily causes it to be state-full, with the invasive nature of "share" file locks it becomes substantially more dependent on state than the traditional combination oftransport protocols, operating systemsNFS andfilesystems, simplicity,NLM [XNFS]. There are three components to making this state manageable: o Clear division between client andgood performance. The NFS version 4 revision has the following goals:server oImproved accessAbility to reliably detect inconsistency in state between client andgood performance onserver o Simple and robust recovery mechanisms In this model, theInternet.server owns the state information. Theprotocolclient communicates its view of this state to the server as needed. The client isdesignedalso able totransit firewalls easily, perform well where latencydetect inconsistent state before modifying a file. To support Windows "share" locks, it ishigh and bandwidthnecessary to atomically open or create files. Having a separate share/unshare operation will not allow correct implementation of the Windows OpenFile API. In order to correctly implement share semantics, the existing mechanisms used when a file islow, and scaleopened or created (LOOKUP, CREATE, ACCESS) need tovery large numbersbe replaced. NFS V4 will have an OPEN procedure that subsumes the functionality ofclients per server. o Strong security with negotiation built intoLOOKUP, CREATE, and ACCESS. However, because many operations require a file handle, theprotocol. The protocol buildstraditional LOOKUP is preserved to map a file name to file handle without establishing state on theworkserver. Policy of granting access or modifying files is managed by theONCRPC working group in supportingserver based on theRPCSEC_GSS protocol. Additionally NFS version 4 provides a mechanism to allow clients and servers to negotiate security and require clients and serversclient's state. It is believed that these mechanisms can implement policy ranging from advisory only locking tosupportfull mandatory locking. While ACCESS is just aminimal setsubset ofsecurity schemes. o Good cross-platform interoperability. The protocol featuresOPEN, the ACCESS procedure is maintained as afilesystem modellighter weight mechanism. 8.1. Definitions Lock The term "lock" will be used to refer to both record (byte-range) locks as well as file (share) locks unless specifically stated otherwise. Client Throughout this proposal the term "client" is used to indicate the entity thatprovidesmaintains auseful, commonset offeatures that does not unduly favorlocks on behalf of onefilesystemoroperating system over another. o Designed for protocol extensions.more applications. Theprotocolclient isdesigned to accept standard extensions that do not compromise backward compatibility.responsible for crash recovery of those locks it manages. Multiple clients may share the same transport and multiple clients may exist Expires:December 1999March 2000 [Page6]38] Draft Protocol Specification NFS version 4JuneSeptember 19992. RPC and Security Flavor The NFS version 4 protocol is a Remote Procedure Call (RPC) application that uses RPC version 2 and the corresponding eXternal Data Representation (XDR) as defined in [RFC1831] and [RFC1832]. The RPCSEC_GSS security flavor as defined in [RFC2203] MUST be used as the mechanism to deliver stronger security to NFS version 4. 2.1. Ports and Transports Historically, NFS version 2 and version 3 servers have residedonUDP/TCP port 2049. Port 2049 is a IANA registered port number for NFS and therefore will continuethe same network node. Clientid A 64-bit quantity returned by a server that uniquely corresponds tobe used for NFS version 4. Usinga client supplied Verifier and ID. Lease An interval of time defined by thewell known portserver forNFS services meanswhich theNFSclientwill not need to useis irrevokeably granted a lock. At theRPC binding protocols as described in [RFC1833]; this will allow NFS to transit firewalls.end of a lease period the lock may be revoked if the lease has not been extended. TheNFSlock must be revoked if a conflicting lock has been granted after the lease interval. All leases granted by a serverSHOULD offer its RPC service via TCP ashave the same fixed interval. Stateid A 64-bit quantity returned by a server that uniquely defines the locking state granted by theprimary transport. TheserverSHOULD also provide UDPforRPC service. The NFS client SHOULD also haveapreferencespecific lock owner forTCP usage but may supplyamechanism to override TCP in favorspecific file. A stateid composed ofUDP as the RPC transport. 2.2. Security Flavors Traditional RPC implementationsall bits 0 or all bits 1 haveincluded AUTH_NONE, AUTH_SYS, AUTH_DH,special meaning andAUTH_KRB4 as security flavors. With [RFC2203] an additional security flavor of RPCSEC_GSS has been introduced which uses the functionality of GSS-API [RFC2078]. This allows for the use of varying security mechanismsare reserved. Verifier A 32-bit quantity generated by theRPC layer without the additional implementation overhead of adding RPC security flavors. For NFS version 4,client that theRPCSEC_GSS security flavor MUST be usedserver can use toenabledetermine if themandatory security mechanism. The flavors AUTH_NONE, AUTH_SYS,client has restarted andAUTH_DH MAY be implemented as well. 2.2.1. Security mechanisms for NFS version 4 The use of RPCSEC_GSS requires selection of: mechanism, quality of protection,lost all previous lock state. 8.2. Locking It is assumed that manipulating a lock is rare when compared to I/O operations. It is also assumed that crashes andservice (authentication, integrity, privacy). The remainder of this document will refernetwork partitions are relatively rare. Therefore it is important that I/O operations have a light weight mechanism tothese three parameters of the RPCSEC_GSS security asindicate if they possess a held lock. A lock request contains thesecurity triple. 2.2.1.1. Kerberos V5 as security triple The Kerberos V5 GSS-API mechanism as described in [RFC1964] MUST be implementedheavy weight information required to establish a lock andprovideuniquely define the lock owner. The followingsecurity triples. columns: Expires: December 1999 [Page 7] Draft Protocol Specification NFS version 4 June 1999 1 == number of pseudo flavor 2 == name of pseudo flavor 3 == mechanism's OID 4 == mechanism's algorithm(s) 5 == RPCSEC_GSS service 1 2 3 4 5 ----------------------------------------------------------------------- 390003 krb5 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_none 390004 krb5i 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_integrity 390005 krb5p 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_privacy for integrity, and 56 bit DES for privacy. This section will be expanded to includesections describe thepertinent detailstransition fromdraft-ietf-nfsv4-nfssec-00.txt. 2.2.1.2. <another security triple> Another GSS-API mechanism will need to be specified here along withthecorresponding security triple(s). 2.3. Security Negotiation Withheavy weight information to theNFS version 4eventual stateid used for most client and serverpotentially offering multiple security mechanisms,locking and lease interactions. 8.2.1. Client ID For each LOCK request, the clientwill needmust identify itself to the server. This is done in such a way as todetermine or negotiate which mechanismallow for correct lock identification and crash recovery. Client identification is accomplished with two values. o A verifier that is used to detect client reboots. o A variable length opaque array to uniquely define a client. For an operating system this may beused for its communication with the server. Thea fully qualified host Expires: March 2000 [Page 39] Draft Protocol Specification NFSserver may have multiple points within its file systemversion 4 September 1999 namespace that are availableor IP address, and foruse by NFS clients. In turn thea user level NFSserver may be configured such that each of these entry pointsclient it mayhave differentadditionally contain a process id ormultiple security mechanisms in use.other unique sequence. Thesecurity negotiation between client and server must be done withdata structure for the Client ID would then appear as: struct nfs_client_id { opaque verifier[4]; opaque id<>; } It is possible through the mis-configuration of asecure channel to eliminateclient or thepossibilityexistence of athird party interceptingrogue client that two clients end up using thenegotiation sequence and forcingsame nfs_client_id. This situation is avoided by 'negotiating' the nfs_client_id between client and serverto choose a lower level of security than required/desired. 2.3.1. Security Error Based onwith theassumption that each NFS version 4 client and server must support a minimum setuse ofsecurity (i.e. Kerberos-V5 under RPCSEC_GSS, <ed: add other>),theNFS client will start its communication withSETCLIENTID. The following describes theserver with onetwo scenarios of negotiation. 1 Client has never connected to theminimal security Expires: December 1999 [Page 8] Draft Protocol Specification NFS version 4 June 1999 triples. During communication with the server,server In this case the clientmay receivegenerates anNFS error of NFS4ERR_WRONGSEC. This error allowsnfs_client_id and unless another client has the same nfs_client_id.id field, the server accepts the request. The server also records the principal (or principal tonotifyuid mapping) from theclientcredential in the RPC request that contains thesecurity triple currently being used is not appropriate for accessnfs_client_id negotiation request. Two clients might still use the same nfs_client_id.id due to perhaps configuration error (say a High Availability configuration where theserver's file system resources. The clientnfs_client_id.id isthen responsible for determining what security triples are available atderived from theserverethernet controller address andchoose one which is appropriate forboth systems have theclient. 2.3.2. SECINFO The new procedure SECINFO (see SECINFO procedure definition) will allowsame address). In this case, nfs4err can be a switched union that returns in addition to NFS4ERR_CLID_INUSE, the network address (the rpcbind netid and universal address) of the clientto determine, on a per filehandle basis, what security triplethat is using the id. 2 Client is re-connecting tobe used forthe serveraccess.after a client reboot Ingeneral,this case, the client still generates an nfs_client_id but the nfs_client_id.id field willnot havebe the same as the nfs_client_id.id generated prior to reboot. If the server finds that the principal/uid is equal tousetheSECINFO procedure except during initial communicationpreviously "registered" nfs_client_id.id, then locks associated with theserver or whenold nfs_client_id are immediately released. If the principal/uid is not equal, then this is a rogue clientcrosses policy boundaries at the server. It could happen that the server's policies change duringand theclient's interaction therefore forcingrequest is returned in error. For more discussion of crash recovery semantics, see theclient to negotiate a new security triple.section on "Crash Recovery" Expires:December 1999March 2000 [Page9]40] Draft Protocol Specification NFS version 4JuneSeptember 19993. File handles The file handle in the NFS protocolIn both cases, upon success, NFS4_OK isa perreturned. To help reduce the amount of data transferred on OPEN and LOCK, the server will also return a uniqueidentifier for64-bit clientid value that is afile system object. The contents of the file handle are opaqueshort hand reference to the nfs_client_id values presented by the client.Therefore,From this point forward, theserver is responsible for translatingclient can use thefile handleclientid toan internal representation of the file system object. Since the file handle is the client's referencerefer toan objectitself. 8.2.2. nfs_lockowner andthe client may cache this reference, the server should not reusestateid Definition When requesting afile handle for another file system object. Iflock, theserver needsclient must present toreuse a file handle value, the time elapsed before reuse SHOULD be large enough that it is likelytheclient no longer has a cached copy ofserver thereused file handle value. 3.1. Obtainingclientid and an identifier for theFirst File Handle The proceduresowner of theNFS protocolrequested lock. These two fields aredefined in terms of one or more file handles. Therefore, the client needs a file handlereferred toinitiate communication withas theserver. With NFS version 2 [RFC1094]nfs_lockowner andNFS version 3 [RFC1813], there exists an ancillary protocol to obtain this first file handle. The MOUNT protocol, RPC program number 100005, providesthemechanismdefinition oftranslating a string based file system path name to a file handle which can then be usedthose fields are: o A clientid returned by theNFS protocols. The MOUNT protocol has deficiencies in the area of security and use via firewalls. This is one reason that the useserver as part of thepublic file handle was introduced [RFC2054] [RFC2055]. With theclients use ofpublic file handle in combination withtheLOOKUPSETCLIENTID procedurein NFS version 2 and 3, it has been demonstrated that the MOUNT protocol is unnecessary for viable interaction between NFS client and server. Therefore, NFS version 4 will not use an ancillary protocol for translation from string based path nameso A variable length opaque array used to uniquely define the owner of afile handle. Two special file handles will be used as starting points forlock managed by theNFSclient.3.1.1. Root File Handle The first ofThis may be a thread id, process id, or other unique value. When thespecial file handles isserver grants theROOT file handle. The ROOT file handle does not havelock it responds with aspecial file handle valueunique 64-bit stateid. The stateid is used asdoesa short hand reference to the nfs_lockowner, since thepublic file handle. The ROOT file handle isserver will be maintaining the"conceptual" rootcorrespondence between them. 8.2.3. Use of thefile system name space atstateid All I/O requests contain a stateid. If theNFS server. The client uses or starts withnfs_lockowner performs I/O on a range of bytes within a locked range, theROOT file handlestateid returned byemploying the PUTROOTFH procedure. The PUTROOTFH procedure instructsthe server must be used tosetindicate the"current" file handle toappropriate lock (record or share) is held. If no state is established by theROOTclient, either record lock or share lock, a stateid ofthe server's file tree. Once this PUTROOTFH procedureall bits 0 isused,used. If no conflicting locks are held on theclient can then traversefile, theentirety ofserver may grant theserver's file treeI/O request. If a conflict with an explicit lock occurs, theLOOKUP procedure.request is failed (NFS4ERR_LOCKED). This allows "mandatory locking" to be implemented. A stateid of all bits 1 allows read requests to bypass locking checks at the server. However, write requests with stateid with bits all 1 does not bypass file locking requirements. An explicit lock may not be granted while an I/O operation with conflicting implicit locking is being performed. Expires:December 1999March 2000 [Page10]41] Draft Protocol Specification NFS version 4JuneSeptember 1999complete discussionThe byte range ofthe server name spacea lock isin section 6, "NFS Server Name Space". 3.1.2. Public File Handle Unlike the root file handle, the public file handleindivisible. A range may be locked, unlocked, or changed between read and write but may not have subranges unlocked or changed between read and write. This isrepresentedthe semantics provided by Win32 but only areserved or special valuesubset of thefile handle. NFS version 4 defines the file handle as a variable length arraysemantics provided by Unix. It is expected that Unix clients can more easily simulate modifying subranges than Win32 servers adding this feature. 8.2.4. Sequencing ofbytes (see section 4, "Basic Data Types"). The public file handleLock Requests Locking is different than most NFS operations as it requires "at- most-one" semantics that are not provided by ONC RPC. In the'zero' file handleface of retransmission orin other wordsreordering, lock or unlock requests must have afile handle withwell defined and consistent behavior. To accomplish this each lock request contains aarray length of zero. Again unlike the root file handle, the public file handle may be bound or represent an arbitrary file system object at the server.sequence number that is a monotonically increasing integer. Different nfs_lockowners have different sequences. The serveris responsible for this binding. It may be thatmaintains thepublic file handlelast sequence number (L) received and theroot file handle refer to the same file system object. However,response that was returned. If a request with a previous sequence number (r < L) is received it isup to the administrative software at the server and the policies of the server administrator to define the binding of public file handle and server file system object. The client may not make any assumptions about this binding. 3.2. File Handle Types In NFS version 2 and 3, theresilently ignored as its response must have been received before the last request (L) wasone type of file handle with a single set of semantics. NFS version 4 introducessent. If anew type of file handle in an attempt to accommodate certain server environments. The first typeduplicate offile handlelast request (r == L) is'persistent'. The semantics ofreceived, the stored response is returned. If apersistent file handlerequest beyond the next sequence (r == L + 2) is received it is silently ignored. Sequences are reinitialized whenever thesame asclient verifier changes. 8.3. Blocking Locks Some clients require thefile handlessupport ofNFS version 2 and 3.blocking locks. Thesecond or new type of file handle iscurrent proposal lacks a call-back mechanism, similar to NLM, to notify a client when the'volatile' file handle. The volatile file handle type is being introducedlock has been granted. Clients have no choice but toaddress server functionality or implementation issuescontinually poll for the lock, whichprevent correct or feasible implementation of a persistent file handle. Some server environments do not providepresents afile system level invariant that can befairness problem. Two new lock types are added, READW and WRITEW used toconstructindicate to the server that the client is requesting apersistent file handle.blocking lock. Theunderlyingserverfile system may not provideshould maintain an ordered list of pending blocking locks. When theinvariant orconflicting lock is released, theserver's file system APIsserver maynot provide access towait theneeded invariant. Volatile file handles may easelease period for theimplementation of server functionality such as hierarchical storage management or file system reorganization or migration. However,first client to re-request thevolatile file handle increaseslock. After theimplementation burden forlease period expires the next waiting clientbut this increased burdenrequest isdeemed acceptable based on the overall gains achieved byallowed theprotocol. Sincelock. Clients are required to poll at an interval sufficiently small that it is likely to acquire theclient will have different paths of logiclock in a timely manner. The server is not required tohandle persistent and volatile file handles,maintain afile attributelist of pending blocked locks as it isdefinedused to increase fairness and not correct operation. Because of the unordered nature of crash recovery, storing of lock state to stable storage would be required to guarantee ordered granting of blocking locks. Expires:December 1999March 2000 [Page11]42] Draft Protocol Specification NFS version 4JuneSeptember 1999which8.4. Lease Renewal The purpose of a lease is to allow a server to remove stale locks that are held by a client that has crashed or is otherwise unreachable. It is not a mechanism for cache consistency and lease renewals may not beused bydenied if theclient to determinelease interval has not expired. Any I/O request that has been made with a valid stateid is a positive indication that thefile handle typesclient is still alive and locks are beingreturned by the server. 3.2.1. General Propertiesmaintained. This becomes an implicit renewal ofa File Handle The file handle contains alltheinformationlease. In theserver needs to distinguish an individual file. Tocase no I/O has been performed within theclient,lease interval, a lease can be renewed by having thefile handle is opaque. Theclientstores file handles for use inissue alater request and can compare two file handles fromzero length READ. Because thesame servernfs_lockowner contains a unique client value, any stateid forequality by doingabyte-by-byte comparison, but MUST NOT otherwise interpret the contents of file handles. If two file handles fromclient will renew all leases for locks held with the sameserver are equal, they MUST refer toclient field. This will allow very low overhead lease renewal that scales extremely well. In thesame file, but if they are not equal,typical case, noconclusions can be drawn. Servers SHOULD try to maintain a one-to-one correspondence between file handlesextra RPC calls are needed andfiles but this is not required. Clients MUST only use file handle comparisons only to improve performance, not for correct behavior. As an example,in the worst casethat two different path names when traversed at the server terminate at the same file system object,one RPC is required every lease period regardless of theserver SHOULD returnnumber of locks held by thesame file handle for each path. This can occur if a hard linkclient. 8.5. Crash Recovery The important requirement in crash recovery isused to create two file names which refer tothat both thesame underlying file object and associated data. For example, if paths /a/b/cclient and/a/d/c refer to the same file,the serverSHOULD returnknow when thesame file handle for both path names traversals. 3.2.2. Persistent File Handle A persistent file handleother has failed. Additionally it isdefined as havingrequired that apersistent value for the lifetimeclient sees a consistent view of data across server reboots. All I/O operations that may have been queued within thefile system object to which it refers. Onceclient or network buffers must wait until theserver createsclient has successfully recovered thefile handle for a file system object,locks protecting theserver MUST returnI/O operations. 8.5.1. Client Failure and Recovery In thesame file handle forevent that a client fails, theobject forserver may recover thelifetime ofclient's locks when theobject.associated leases have expired. Conflicting locks from another client may only be granted after this lease expiration. If theserver restartsclient is able to restart orreboots,reinitialize within theNFS server must honor and presentlease period thesame file handle value as it didclient may be forced to wait the remainder of the lease period before obtaining new locks. To minimize client delay upon restart, lock requests contain a verifier field in theserver's previous instantiation. The persistent file handlelock_owner. This verifier is part of the initial SETCLIENTID call made by the client. Since the verifier will bebecome stale or invalid whenchanged by thefile system object is removed. Whenclient upon each initialization, the serveris presented withcan compare apersistent file handle that refersnew verifier toa deleted object, it MUST return an error of NFS4ERR_STALE. A file handle may become stale whenthefile system containingtheobject is no longer available. The file system may become unavailable if it exists on removable mediaverifier associated with currently held locks and determine that they do not match. This signifies themedia is no longer available atclient's new instantiation and loss of locking state. As a result, the serveror the file system in whole has been destroyed or the file system has simply been removed fromis free to release all locks held which are associated with theserver's name space (i.e. unmounted in a Unix environment).old verifier. Expires:December 1999March 2000 [Page12]43] Draft Protocol Specification NFS version 4JuneSeptember 19993.2.3. Volatile File Handle A volatile file handle does not shareFor secure environments, a change in thesame longevity attributesverifier must only cause the release of locks associated with thepersistent file handle. The server may determine that a volatile file handleauthenticated requester. This isno longerrequired to prevent a rogue entity from freeing otherwise validat many different points in time.locks. Note that the verifier must have the same uniqueness properties of the COMMIT verifier. 8.5.2. Server Failure and Recovery If the servercan definitively determine that a volatile file handle refers to an object that has been removed,fails and loses locking state, the servershould return NFS4ERR_STALEmust wait the lease period before granting any new locks or allowing any I/O. An I/O request during the grace period with a stale stateid will fail with NFS4ERR_GRACE. To recover the lock and associate state, the client will reissue the lock request with reclaim set to TRUE. Upon receiving a successful reply and associated stateid, the client(as ismay reissue thecase for persistent file handles). In all other cases whereI/O request with theserver determines thatnew stateid. Any time avolatile file handle can no longer be used, it should returnclient receives an NFS4ERR_GRACE error, the client must assume that all locking state associated with the server returning the errorof NFS4ERR_EXPIRED.has been lost. Thefollowing table showsclient should start recovering all outstanding locks upon receiving NFS4ERR_GRACE. If themost common points at whichserver receives avolatile file handle may expire. This table represents the view fromlock request during its grace period that does not have reclaim set to TRUE, theclient's perspective and as such provides columns for whenserver must return NFS4ERR_GRACE. This error return will trigger thefile may be open or closedclient to recover all of its locking state by reclaiming locks. A lock request outside theclient. Server Provides Persistent or Volatile File Handle File Open File Closed ___________________________________________________________________ Restart of Server (note 4) P / V P / V Fileset Migration (note 5) P / V P / V SHARE/LOCK recovery P / V N/A (note 1) Client RENAMEs object P / V P / V Client RENAMEs path to object P / V P / V Other client RENAMEs object P / V P / V Other client RENAMEs pathserver's grace period with reclaim set toobject P / V P / V Client REMOVEs object P / V (note 2) P / V Other client REMOVEs object P / V N/A (note 3) Note 1TRUE can only succeed if the server can guarantee that no conflicting lock or I/O request has been granted since reboot. 8.5.3. Network Partitions and Recovery If thefile is not open, persistenceduration of a network partition is greater than the lease period provided by the server, thefile handle isserver will have notapplicable forreceived a lease renewal from therecovery of SHARE/LOCK. Note 2 With NFS version 2 and 3, whenclient. If this occurs, theclient removesserver may free all locks held for the client. As afile it has open it followsresult, all stateids held by theconvention of RENAMEingclient will become invalid. Once thefileclient is able to'.nfsXXXX' untilreach thefile is closed. At this pointserver after such a network partition, all I/O submitted by theREMOVE is done atclient with theserver. Ifnow invalid stateids will fail with the server returning the error NFS4ERR_EXPIRED. Once thissame modelerror isused for v4 then this entryreceived, the client willbe 'N/A'. Note 3 Ifsuitably notify thefile is not open byapplication that held theclient, then it should not expect any cached file handlelock. As a courtesy tobe valid.the client or optimization, the server may continue to hold locks on behalf of a client for which recent communication has extended beyond the lease period. If the server receives a lock or I/O request that conflicts with one of these courtesy locks, the Expires:December 1999March 2000 [Page13]44] Draft Protocol Specification NFS version 4JuneSeptember 1999Note 4 The restartserver must free the courtesy lock and grant the new request. In the event of a network partition with a duration extending beyond the expiration of a client's leases, theNFSserversignifies whenMUST employ a method of recording this fact in its stable storage. Conflicting locks requests from another client may be serviced after theoperating systemlease expiration. There are various scenarios involving server failure after such an event that require the storage of these lease expirations orNFS softwarenetwork partitions. One scenario is(re)started. This also includes High Availability configurations whereas follows: A client holds aseparate operating system instantiation acquires ownership oflock at thefile system resourcesserver and encounters a networkresources (i.e. diskspartition andIP addresses). Note 5 Fileset migration occurs whenis unable to renew the associated lease. A second client obtains a conflicting lock and then frees the lock. After the unlock request by the second client, theownership of file system resources are transfered from oneserverto another without a transfer of ownership ofreboots or reinitializes. Once the server recovers, the networkresources. Sopartition heals and the original client attempts to reclaim the original lock. In thisdiffers fromscenario and without any state information, theHigh Availability scenario. This also includesserver will allow themove of a file system resources withinreclaim and the client will be in an inconsistent state because thesameserversuch thator thefsid value is different. The fileset migration entry is a place holder until a file set migration proposalclient hasbeen fully evaluated and decided upon. 3.2.4. One Methodno knowledge ofConstructing a Volatile File Handle As mentioned,the conflicting lock. The server may choose to store this lease expiration or network partitioning state insome instancesafile handle is stale (no longer valid, perhaps becauseway that will only identify thefile was removed fromclient as a whole. Note that this may potentially lead to lock reclaims being denied unnecessarily because of a mix of conflicting and non- conflicting locks. The server may also choose to store information about each lock that has an expired lease with an associated conflicting lock. The choice of theserver), or itamount and type of state information that isexpired (the underlying filestored isvalid, but sinceleft to thefile handle is volatile, it may have expired). Thusimplementor. In any case, the serverneeds to be ablemust have enough state information toreturn NFS4ERR_STALE in the former case,enable correct recovery from multiple partitions andNFS4ERR_EXPIRED inmultiple server failures. 8.6. Server Revocation of Locks At any point, thelatter case. Thisserver canbe donerevoke locks held bycareful construction ofa client and thevolatile file handle. One possible implementation follows. A volatile file handle, while opaque toclient must be prepared for this event. When the clientcould contain: [volatile bit = 1 | server boot time | slot | generation number] o slot is an index indetects that its locks have been or may have been revoked, theserver volatile file handle table o generation numberclient isthe generation numberresponsible for validating thetable entry/slot Ifstate information between itself and theserver boot time is less thanserver. Validating locking state for thecurrent server boot time, return NFS4ERR_EXPIRED. If slot is outclient means that it must verify or reclaim state for each lock currently held. The first instance ofrange, return NFS4ERR_EXPIRED. Iflock revocation is upon server reboot or re- initialization. In this instance thegeneration number does not match, return NFS4ERR_EXPIRED. Whenclient will receive an error or NFS4ERR_GRACE and theserver reboots,client will proceed with normal crash recovery as described in thetable is gone (it is volatile).previous section. Expires:December 1999March 2000 [Page14]45] Draft Protocol Specification NFS version 4JuneSeptember 1999If volatile bitThe second lock revocation event can occur as a result of administrative intervention within the lease period. While this is0, thenconsidered a rare event, it is possible that the server's administrator has decided to release or revoke apersistent file handle withparticular lock held by the client. As adifferent structure following it. 3.3. Client Recovery from File Handle Expiration Withresult of revocation, theintroductionclient will receive an error of NFS4ERR_EXPIRED and thevolatile file handle,error is received within the lease period for the lock. In this instance the clientmust take on additional responsibility somay assume thatitonly the lock_owner's locks have been lost. The client notifies the lock holder appropriately. The client mayprepare itself to recover fromnot assume theexpiration oflease period has been renewed as avolatile file handle. Ifresult of failed operation. The third lock revocation event is theserverinability to renew the lease period. While this isreturn persistent file handles,considered a rare or unusual event, the clientdoes not need these additional steps. For volatile file handles, most commonlymust be prepared to recover. Both the server and client willneedbe able tostoredetect thecomponent names leading upfailure to renew the lease andincludingare capable of recovering without data corruption. For thefile system object in question. With these names,server, it tracks theclient should be able to recover by finding a file handle inlast renewal event serviced for thename space that is still available or by starting atclient and knows when theroot oflease will expire. Similarly, theserver's file system name space. Ifclient must track operations which will renew theexpired file handle referslease period and is able toan objectdetermine lease period expiration. When the client determines that the lease period hasbeen removed fromexpired, thefile system, obviouslyclient must mark all locks held for the associated lease as "unvalidated". This means the clientwill not be ablehas been unable torecover fromre-establish or confirm theexpired file handle. It is also possible thatappropriate lock state with the server. As described in the previous section on crash recovery, there are scenarios in which the server may grant conflicting locks after the lease period has expiredfile handle, refers tofor afileclient. Once the lease period has expired, the client must validate each lock it has held to ensure that a conflicting lock has not beenrenamed.granted. The client may accomplish this task by issuing an I/O request, either a pending I/O or zero length read. If thefile was renamed by another client, again itresponse to the request ispossible thatsuccess, theoriginalclientwill not be able to recover. However, inhas validated thecase thatlock and re-established theclientappropriate state between itself and the server. If the I/O request isrenamingnot successful, thefilelock was revoked by the server and thefileclient must notify the owner. 8.7. Share Reservations A share reservation isopen, ita mechanism to control access to a file. It ispossible that thea separate and independent mechanism from record locking. When a clientmay be ableopens a file, it issues an OPEN request torecover. The client can determinethenew path name based onserver specifying theprocessingtype of access required (READ, WRITE, or BOTH) and therename request. The client can then regeneratetype of access to deny others (deny NONE, READ, WRITE, or BOTH). If thenew file handle based onOPEN fails thenew path name. Theclientcould also usewill fail thecompound operation mechanism to construct a setapplications open request. Pseudo-code definition ofoperations like: RENAME A B LOOKUP B GETFHthe semantics: Expires:December 1999March 2000 [Page15]46] Draft Protocol Specification NFS version 4JuneSeptember 19994. Basic Data Types Arguments and results from operations will be described in terms of basic XDR types defined in [RFC1832]. The following data types will be defined in terms of basic XDR types: filehandle: opaque <128> An NFS version 4 filehandle. A filehandle with zero length is recognized as a "public" filehandle. utf8string: opaque <> A counted array of octets that containsif ((request.access & file_state.deny)) || (request.deny & file_state.access)) return (NFS4ERR_DENIED) 8.8. OPEN/CLOSE Procedures To provide correct share semantics, aUTF-8 string. Note: Section 11, Internationalization, coversclient MUST use therational of using UTF-8. bitmap: uint32 <> A counted array of 32 bit integers usedOPEN procedure tocontain bit values. The positionobtain the initial file handle and indicate the desired access and what if any access to deny. Even if the client intends to use a stateid of all 0's or all 1's, it must still obtain theinteger infilehandle for thearray that contains bit n can be computed fromregular file with theexpression (n / 32) and its bit withinOPEN procedure. For clients thatinteger is (n mod 32). 0 1 +-----------+-----------+-----------+-- | count | 31 .. 0 | 63 .. 32 | +-----------+-----------+-----------+-- createverf: opaque<8> Verify useddo not have a deny mode built into their open API, deny equal to NONE should be used. The OPEN procedure with the CREATE flag, also subsumes the CREATE procedure forexclusiveregular files as used in previous versions of NFS, allowing a create with a share to be done atomicly. Will expand on create semanticsnfstime4 struct nfstime4 { int64_t seconds; uint32_t nseconds; }here. Thenfstime4 structure givesCLOSE procedure removes all share locks held by thenumberlock_owner on that file. If record locks are held they should be explicitly unlocked. Some servers may not support the CLOSE ofsecondsa file that still has record locks held; if so, CLOSE will fail andnanoseconds since midnight or 0 hour January 1, 1970 Coordinated Universal Time (UTC). Values greater than zero for the seconds field denote dates after the 0 hour January 1, 1970. Values less than zero for the seconds field denote dates beforereturn an error. The LOOKUP procedure is preserved and will return a file handle without establishing any lock state on the0 hour January 1, 1970. In both cases,server. Without a valid stateid, thenseconds field is to be added toserver will assume theseconds field forclient has thefinal time representation.least access. For example,if the time toa file opened with deny READ/WRITE cannot berepresented is one-half secondaccessed using a file handle obtained through LOOKUP. Expires:December 1999March 2000 [Page16]47] Draft Protocol Specification NFS version 4JuneSeptember 1999before 0 hour January 1, 1970, the seconds field would have a value9. Client-Side Caching Client-side caching ofnegative one (-1)data, of file attributes, andthe nseconds fields would haveof file names is essential to providing good performance in NFS. Providing dis- tributed cache-coherence is avaluedifficult problem and previous versions ofone-half second (500000000). Values greater than 999,999,999NFS have not attempted it. Instead, several client implementation techniques have been used to reduce the problems that lack of co- herence poses fornseconds are considered invalid. This data typeusers. These techniques have not been clearly defined by earlier specifications and it is often unclear what is valid or invalid client behavior. NFS version 4 uses many techniques similar to those that have been used in previous versions of NFS. It does not provide distributed cache coherence, but it defines a more limited set of caching guarantees topass timeallow locks anddate information. A server convertsshare reservation toandbe used without destructive interference fromlocal time when processing time values, preserving as much accuracy as possible. Ifclient-side caching. In addition, version 4 introduces a delegation mechanism which allows many decisions normally made by theprecisionserver to be made locally by clients. This provides efficient support oftimestamps storedthe common cases where sharing is infrequent or where sharing is read-only. 9.1. Performance Challenges for Client-Side Caching Caching techniques used in previous versions of NFS have been successful in providing good performance. However, several scala- bility challenges can arise when those techniques are used with very large numbers of clients, particularly when those clients are geographically distributed, increasing the latency for cache revalidation requests. When latencies are large, repeated cache validation requests at open time, which NFS-v2 and NFS-v3 clients typically do, can have serious performance drawbacks. A common case is one in which a filesystem objectisless than defined, loss of precision can occur. An adjunct time maintenance protocolonly accessed by a single client. Sharing is infrequent. In this case, repeated reference to the server to find that no conflicts exist, is expensive. A better option isrecommendedtoreduceallow a client repeatedly opening a file to do so without reference to the server, until potentially conflicting operations from another client actually occur. A similar situation arises in connection with file locking. Sending file lock and unlock requests to the servertime skew. specdata4 struct specdata4 { uint32_t specdata1; uint32_t specdata2; } Thisas well as the I/O requests necessary to make datatype represents additional information forcaching consistent with thedevice file types NFCHRlocking semantics (see the section "Data Caching andNFBLK.File Locking") can severely limit performance. When locking is used to provide pro- Expires:December 1999March 2000 [Page17]48] Draft Protocol Specification NFS version 4JuneSeptember 19995. File Attributes To meettection against infrequent conflicts, a large penalty will be paid, which may discourage the use of locking. In NFS Version4 requirements of extensibility and increased interoperability with non-Unix platforms, attributes must4, more aggressive caching strategies are designed: o To behandled incompatible with amore flexible manner. Thelarge range of server semantics. o Provide the same caching benefits as previous versions of NFSVersion 3 fattr3 structure containedwhen unable to provide the more aggressive model. o Requirements for aggressive caching are organized so that afixed listlarge portion ofattributes thatthe benefit can be obtained even when not allclients and servers are able to support or care about, which cannot be extended as new needs crop up, and which provides no way to indicate non-support. With NFS Version 4,of theclient willrequirements can beable to ask what attributesmet. The appropriate requirements for the serversupports, and will be able to request only those attributes in which it is interested. To this end, attributes will be divided into three groups: mandatory, recommended and named. Both mandatory and recommended attributesaresupporteddiscussed inthe NFS V4 protocol by alater sections in which specificand well-defined encoding, and are identified by number. Theyforms of caching arerequested by setting a bit in the bit vector sent indealt with. (see Section "Open Delegation"). NOTE: [[This discussion of proxy caching assumes that theGETATTR request;a proxy server appears to the (real) serverresponse includesas an ordinary client. Should there be abit vector to list what attributes were returned in response. New mandatory or recommended attributes mayproposal for non-transparent proxy server support (Mike Eisler's proxy model 2), this can beadded to the NFS protocol between revisions by publishingmodified.]] 9.2. Proxy Caching Proxy caching is astandards-track RFC which allocatesuseful technique to reduce latency and avoid server overload when anew attributelarge numbervalue and defines the encoding for the attribute. Named attributes are accessedof geographically distributed clients share data. The proxy cache allows many requests to be satisfied bythe new OPENATTR operation, which accessesahidden directory of attributeslocal server, reducing bandwidth and latencies associated witha filesystem object. OPENATTR takes a filehandle for the object and returns the filehandle for the attribute hierarchy, which is a directory object accessible by LOOKUP or READDIR, and which contains files whose names represent the named attributes and whose data bytes are the value ofaccessing theattribute. For example: LOOKUP "foo" ; look up file GETATTR attrbits OPENATTR ; access foo's named attributes LOOKUP "x11icon" ; look up specific attribute READ 0,4096 ; read stream of bytes Named attributes are intended primarily for data needed by applications rather than by an NFS client implementation per se;primary server. If NFSimplementors are strongly encouragedversion 4 were todefine their new attributes as recommended attributes by bringing themlimit itself to theworking group. The setcaching approaches used in NFS v2 and NFS v3, a large number ofattributesthe requests whichare classified as mandatory is deliberately small, since servers must do whatever it takes to support them. The recommended attributes may be unsupported, thougha proxy servershould support as many as it can. Attributes are deemedwould receive would result in corresponding requests to the distant server: o All OPEN and CLOSE requests o WRITE requests necessary to flush out dirty data before all file close operations. o All LOCK and UNLOCK requests. Expires:December 1999March 2000 [Page18]49] Draft Protocol Specification NFS version 4JuneSeptember 1999mandatory ifo READ and WRITE requests which must go to thedataserver because locks are held or being released. o All directory modification requests (e.g. CREATE, REMOVE, etc.) o All SETATTR requests o Many other requests because of cache entry staleness Maintaining distributed caches allowing authoritative decisions to be made locally isboth needed bydifficult, in the general case. However, there are many situations in which access patterns allow such decisions to be delegated opportunistically to particular clients (such as proxy servers) avoiding alarge numbergreat deal ofclients andunnecessary communication. This isnot otherwise reasonably computable by the clientof particular importance whensupport is not provided on the server. 5.1. Mandatory Attributes These MUST be supported by every NFS Version 4 clientscaling to very large numbers of clients. 9.3. Delegation and Callbacks Recallable delegation of serverin orderresponsibilities for a file toensureaminimum levelclient (which may include proxy servers) improves performance by avoiding repeated requests to the server in the absence ofinteroperability. Theinterclient conflict. A servermust store and return these attributes, andrecalls delegated responsibilities, using a callback rpc from the server to the client, when another clientmust be ableengages in sharing of a delegated file. A delegation is passed from the server tofunction with an attribute set limitedthe client, specifying the object for which the delegation is being done and type of delegation. There are different types of delegations but each contains a stateid tothese attributes, though somebe used to represent the delegation when performing operations that depend on the delegation. This stateid is similar to those associated with locks and share reservations but differs in that the stateid for a delegation is associated with a clientid and may beimpaired or limited in some ways in this case.used on behalf of all the nfs_lockowner's for the given client. A delegation is made to the client as a whole and not to any specific process within it. Because callback rpc's mayasknot work in all environments (due to firewalls, foranyexample), correct operation does not depend on them. Preliminary testing ofthese attributes to be returnedcallback functionality bysettingmeans of abit inCB_NULL request determines whether callbacks can be supported. The CB_NULL request checks theGETATTR request, andcontinuity of the callback path. A servermust return their value. 5.2. Recommended Attributes These attributes are understood well enoughmakes a preliminary assessment of callback availability towarrant support ina given client and avoids delegating responsibilities until it has determined that callbacks are supported. Because client requests for delegation are always conditional upon the absence of conflicting access, clients Expires: March 2000 [Page 50] Draft Protocol Specification NFSVersionversion 4protocol, though they maySeptember 1999 can not assume that a request for delegation will besupported ongranted, and must always be prepared for denial. Once granted, a delegation behaves in most ways like a lock. There is an associated lease that is subject to renewal together with allclients and servers. A client may ask for anyofthese attributes to be returnedthe other leases held bysettingthat client. Unlike locks, abit inrequest to a delegated file from a second client will cause theGETATTR request, but must be ableserver todeal with not receiving them. Arecall a delegation through a callback. On recall, the clientmay ask forholding theset of attributesdelegation must flush modified state (such as modified data) to the serversupportsandshould not request attributesreturn theserver doesdelegation. The conflicting request will notsupport. A server shouldbetolerant of requests for unsupported attributes, and simply not return them, rather than consideringresponded to until therequest an error. Itrecall isexpected that servers will support all attributes they comfortably can,complete, either by the return of the delegation or by the server timing out the recall andonly failrevoking the delegation. Following recall, the server has the information necessary tosupport attributes which are difficultgrant or deny second client's request. Since recalling a delegation may involve the flushing of substantial state tosupport in their operating environments. Athe server, the server shouldprovide attributes whenever they don't have to "tell lies"allow a time to complete theclient. For example,recall substantially longer than for afile modificationtypical single RPC. The server may also extend the timeshould be either an accurateallowed if it can determine that state is being diligently flushed by the client. However, the timeorto complete the recall should not besupported byunbounded. For example, when responsibility to mediate opens on a given file is delegated to a client (see theserver. Thissection "Open Delegation"), the server will notalways be comfortable to clients but it seems thatknow what opens are in effect on the clienthas a better ability to fabricate or construct an attribute or do without. Most attributes from NFS V3's FSINFO, FSSTATandPATHCONF procedures have been added as recommended attributes, so that filesystem info maythus will becollected viaunable to determine whether thefilehandle ofaccess and deny state for the file allows anyobjectparticular open until thefilesystem. This renders those procedures unnecessarydelegation has been returned. Client failure or a network partition can result inNFS V4. Iffailure to respond to a recall callback. The serversupports any per-filesystem attributes, it must supportwill revoke thefsid attribute so thatdelegation, rendering any modified state still on the clientmay always determine when filesystemsuseless. 9.3.1. Delegation Recovery There arecrossed sothree situations thatit can work correctly with these attributes.delegation recovery must deal with: o Client reboot o Server reboot o Network partition (full or callback-only) Expires:December 1999March 2000 [Page19]51] Draft Protocol Specification NFS version 4JuneSeptember 19995.3. Named Attributes These attributes are not supported by direct encoding inIn theNFS Version 4 protocol but are accessed by string names rather than numbers and correspond to an uninterpreted streameven ofbytes which are stored with the filesystem object. The namespace for these attributes may be accessed by using the OPENATTR operation to get a filehandle for a virtual "attribute directory" and using READDIR and LOOKUP operations on this filehandle. Named attributes may then be examined or changed by normal READ and WRITE and CREATE operations on the filehandles returned from READDIR and LOOKUP. Named attributes may have attributes, for example,asecurity label may have access control information in its own right. It is recommended that servers support arbitrary named attributes. Aclientshould not depend onreboot, theabilityfailure tostore any named attributesrenew leases will result in theserver's filesystem. If a server does support named attributes,revocation of record locks and share reservations. Delegations, however, may treated aclient which is also able to handle them shouldbit differently. Because data associated with some delegations may beablewritten tocopy a file's datastable storage on the client andmeta-data with complete transparency from one locationbecause a delegation held by a proxy server may be further delegated toanother; this would imply thatits client in turn whereupon the proxy server may reboot, thereshouldwill beno attribute namessituations in which delegations will need to beconsidered illegal byre-established after a client (which includes a proxy server) reboots. To accommodate such situations, theserver. Names of attributes will not be controlled byserver may, after leases expire, force requests that conflict with existing delegations to wait for astandards body. However, vendors and application writers are encouragedlonger period of time. This is consistent with the fact that recall, including the time necessary to flush modified state toregister attribute names andtheinterpretationserver andsemantics ofreturn thestream of bytes via informational RFC so that vendorsdelegation, mayinteroperate where common interests exist. 5.4. Mandatory Attributes - Definitions Name # DataType Access Description __________________________________________________________________ supp_attr 0 bitmap READ The bit vector whichtake significant time. This longer interval wouldretrieve all mandatory and recommended attributesallow clients whichmay be requested for this object. The client must ask this questionreboot to consult stable storage and requestcorrect attributes. Expires: December 1999 [Page 20] Draft Protocol Specification NFS version 4 June 1999 object_type 1 nfs4_ftype READ Thethe reclamation of delegations which have not been timed out using this longer interval. For open delegations, such delegations are reclaimed using OPEN with a claim type of CLAIM_DELEGATE_PREV. (See theobject (file, directory, symlink) The client cannot handle object correctly without type. persistent_fh 2 boolean READ Is the filehandleSections on "Data Caching and Revocation" and "Procedure 17: OPEN" forthis object persistent? Server should know ifdiscussion of open delegation and thefile handles being provided are persistent or not. Ifdetails of OPEN respectively). When the server reboots, delegations are reclaimed (using OPEN with CLAIM_DELEGATE_PREV) in a similar fashion to record locks and share reservations. However, there is a slight semantic difference. Normally, the server decides that a delegation should notable to makebe granted, it performs the requested action (e.g. OPEN) without granting any delegation. When thisdetermination, thenhappens as part of reclaim, the server grants the delegation but marks itcan choose volatile or non-persistent. change 3 uint64 READ A value createdspecially so that the client treats the delegation as having been granted but recalled by the server so that it then has theclient can useduty todetermine if a file data, directory contents or attributes have been modified. Thewrite all modified state to the servercan justand then return thefile mtime in this field though ifdelegation. This handling of delegation reclaim reconciles three principles of NFS Version 4: o That upon reclaim, amore precise value exists thenclient faithfully reporting resources assigned to itcan be substituted, forby an earlier server instance,a sequence number. Necessary for any useful caching, likely tomust beavailable. object_size 4 uint64 R/W The size ofgranted those resources. o That theobject in bytes. Couldserver has untrammeled authority to determine whether delegations are to bevery expensivegranted and, once granted, whether they are toderive, likelybe continued. o That the use of callbacks is not to be depended upon until the client has proved its ability tobe available.receive them. Expires:December 1999March 2000 [Page21]52] Draft Protocol Specification NFS version 4JuneSeptember 1999link_support 5 boolean READ DoesWhen a network partition occurs, delegations, like locks and share reservations will be subject to freeing when theobject's filesystem supports hard links? Server can easily determine if links are supported. symlink_support 6 boolean READ Doeslease renewal period expires, although theobject's filesystem supports symbolic links? Server can easily determine if linksserver will normally extend the period in which conflicting requests aresupported. named_attr 7 boolean READ Does this object have named attributes? fsid.major 8 uint64 READ Unique filesystem identifier forheld off in thefilesystem holding this object. fsid.minor 9 uint64 READ Unique filesystem identifier withincase of delegations. Eventually, however, thefsid.major filesystem identifier foroccurrence of a conflicting request from another client will cause revocation of thefilesystem holding this object. 5.5. Recommended Attributes - Definitions Name # Data Type Access Description ___________________________________________________________________ ACL 10 nfsacl4 R/W The access control list fordelegation. A blockage of theobject. [The naturecallback (e.g. by later network configuration change) will have the same effect. A recall request will fail andformatrevocation ofACLs is still to be determined.] Expires: December 1999 [Page 22] Draft Protocol Specification NFS version 4 June 1999 archive 11 boolean R/W Whether or not this file has been archived sincethetimedelegation will result. A client normally finds out about revocation oflast modification (deprecateda delegation when it uses a stateid associated with a delegation and receives the error NFS4ERR_EXPIRED. It also may find out about delegation revocation after a client reboot when it attempts to reclaim a delegation and receives that same error. Note that infavorthe case ofbackup_time). cansettime 12 boolean READ Whether or not this object's filesystem can fill ina revoked write open delegation, there are issues because data may have been modified by thetimes onclient whose delegation is revoked and separately by other clients. See the section "Revocation Recovery for Write Open Delegation" for aSETATTR request without an explicit time. case_insensitive 13 boolean READ Are filename comparisons on this filesystem case insensitive? case_preserving 14 boolean READ Is filenamediscussion of such issues. Note also that when delegations are revoked information about the revoked delegation will be written by the server to stable storage (as described in section 7.5) to deal with the caseon this filesystem preserved? chown_restricted 15 boolean READ Willin which arequestserver reboots after revoking a delegation but before revoked delegate find out about the revocation. 9.4. Data Caching When programs share access to a set of files they need tochange ownershipbehonored? filehandle 16 nfs4_fh READ The filehandleimplemented so as to take account ofthis object (primarily for readdir requests). fileid 17 uint64 READ A number uniquely identifyingthefile withinpossibility of conflicting access by another program. This is true whether thefilesystem. files_avail 18 uint64 READ File slots available to this userprograms in question are on different hosts or reside on thefilesystem containing this object - this shouldsame host. Share reservations and record locks are the facilities that NFS v4 provides to allow programs to co-ordinate access by providing mutual exclusion facilities. NFS v4 data caching must be implemented so that it does not vitiate thesmallest relevant limit. files_free 19 uint64 READ Free file slots onassumptions that those using these facilities depend on. 9.4.1. Data Caching and OPENs In order to avoid invalidating thefilesystem containing this object - thissharing assumptions that applications rely on, NFS v4 clients should not provide cached data to applications or modify it on behalf of an application when it would not bethe smallest relevant limit.valid to obtain/modify that same data via a READ or WRITE rpc. Expires:December 1999March 2000 [Page23]53] Draft Protocol Specification NFS version 4JuneSeptember 1999files_total 20 uint64 READ Total file slotsFurther, in the absence of open delegation (see the Section "Open delegation"), two further rules apply. These rules are obeyed in practice by many NFS v2 and NFS v3 clients. o The first rule is that cached data present on a client must be revalidated after doing an OPEN, to make sure that the data for thefilesystem containing this object. hidden 21 boolean R/W Isfileconsidered hidden? homogeneous 22 boolean READ Whether or not this object's filesystem is homogeneous, i.e. whether pathconfin question, is still validly reflected in the client's cache. This must be done at least when a client open includes DENY=WRITE or BOTH, terminating a period in which other clients may have had the opportunity to open thesame for all filesystem objects. maxfilesize 23 uint64 READ Maximum supportedfilesizewith WRITE access. Clients may choose to do the revalidation more often (i.e. on opens specifying DENY=NONE) to parallel NFS v3 practice for thefilesystembenefit of users assuming thisobject. maxlink 24 uint32 READ Maximum numberdegree oflinks for this object. maxname 25 uint32 READ Maximum filename size supported for this object. maxread 26 uint64 READ Maximum read size supported for this object. maxwrite 27 uint64 READ Maximum write size supportedcache revalidation. o The second rule, complementary to the first, is that modified data must be flushed to the server before closing a file opened for write. If thisobject.rule is not adhered to, the revalidation done after client OPEN's cannot achieve its purpose. Thisattribute SHOULDdata must besupported ifcommitted to stable storage before the CLOSE is done since retransmission of the data after a server reboot might not be possible, once the file iswritable. Lackclosed. 9.4.2. Data Caching and File Locking When users do not use share reservations to exclude inconsistent access, but use file locking instead, there is an analogous set ofthis attribute can leadconstraints that apply totheclienteither wasting bandwidth or not receivingside data caching. These rules are effective only if file locking is used in a way which is congruent with thebest performance. mime_type 28 utf8<> R/W MIME body type/subtypeactual IO operations being done, as opposed to being used in a purely conventional way. For example, it is possible to manipulate a 2MB file, dividing the file into two 1MB regions, and using a lock for write on byte 0 of the file to represent the right to do IO to the first region and a lock for write to byte 1 of the file to represent the right to do IO on the second region. As long as all applications manipulating the file obey thisobject. Expires: December 1999convention, they will work on a local file system, but they may not work on NFS v4 unless clients refrain from data caching. The first rule is that when a client locks a region, it must revalidate its data cache if it has any cached data in the region newly locked and invalidate it if the change attribute shows that the file may have been written since that data was obtained. (A client might choose to invalidate all of non-modified cached data that it has, but invalidating all of the data in the newly locked region is necessary for correct operation). Expires: March 2000 [Page24]54] Draft Protocol Specification NFS version 4JuneSeptember 1999mode 29 uint32 R/W Unix-style permission bitsThe second rule is that before releasing a write lock forthis object (deprecated in favor of ACLs) no_trunc 30 boolean READ Ifaname longer than name_max is used, will an errorregion, all modified data for that region must bereturned or willflushed to thename be truncated? numlinks 31 uint32 READ Number of linksserver (although not necessarily to disk). Note that flushing data tothis object. owner 32 utf8<> R/W The string name oftheowner of this object. owner_group 33 utf8<> R/W The string nameserver and the invalidation of cached data must reflect thegroupactual byte ranges locked or unlocked. Rounding these up or down to reflect client cache block boundaries will cause problems if not carefully done. For example, writing a modified block when only half of that block is within an area being unlocked may cause invalid modification to theownerregion outside the unlocked area which may be part of a region locked by another client. Clients can avoid thisobject. quota_hard 34 uint64 READ Number of bytessituation by synchronously performing portions ofdisk space beyondwrite operations that overlap that portion (initial or final) that is not a full block. Similarly, invalidating a locked area which is not an integral number of full buffer blocks would require theserver will declineclient toallocate new space. quota_soft 35 uint64 READ Number of bytes of disk space atread one or two partial blocks from the server if the revalidation procedure shows that the data which the client possesses maychoosenot be valid. Writes required towarn the user about limited space. quota_used 36 uint64 READ Number of bytes of disk space occupiedflush data before unlocking must be done to stable storage, either by doing synchronous writes or a COMMIT as part of theownerflush operation. The is so because retransmission ofthis object on this filesystem. rawdev 37 specdata4 READ Raw device identifier. Expires: December 1999 [Page 25] Draft Protocol Specification NFS version 4 June 1999 space_avail 38 uint64 READ Disk spacethe modified data after a server reboot might conflict with a lock held by another client. Clients may choose to accommodate programs using record locking inbytes availablenon-standard ways (e.g. using a record lock as a global semaphore), by flushing tothis user onthefilesystem containing this object - this should beserver more data upon an UNLOCK than is covered by thesmallest relevant limit. space_free 39 uint64 READ Free disk spacelocked range, possibly including modified data inbytes on the filesystem containing this object - this should be the smallest relevant limit. space_total 40 uint64 READ Total disk spaceother files. Any client doing so must ensure that for any file inbytes on the filesystem containing this object. space_used 41 uint64 READ Numberwhich all data written is to properly locked areas, no piece offilesystem bytes allocateddata be written tothis object. system 42 boolean R/W Whether orthe server which is notthiswithin the locked area. 9.4.3. Data Caching and Mandatory File Locking Client side data caching needs to respect mandatory file locking when this isa system file. time_access 43 nfstime4 R/Win effect. Thetimepresence oflast access tomandatory file locking for a given file is indicated in the result flags for an OPEN. When there is a read or write for a file for which mandatory locking is in effect, theobject. time_backup 44 nfstime4 R/W The time of last backup ofclient must check if it holds an appropriate lock for theobject. time_create 45 nfstime4 R/W The time of creationrange of bytes being read or written. If it does, it may satisfy theobject. This attribute does not haverequest using client side caching, just as for anyrelation to the traditional Unix file attribute 'ctime'other read or'change time'. time_delta 46 nfstime4 READ Smallest useful server time granularity. time_metadata 47 nfstime4 R/W The time of last meta-data modification of the object. Expires: December 1999 [Page 26] Draft Protocol Specification NFS version 4 June 1999 time_modify 48 nfstime4 R/W The time sincewrite. If such a lock is not held, theepoch of last modificationread or write cannot be satisfied by caching but must be sent to theobject. version 49 utf8<> R/W Version number of this document. volatility 50 nfstime4 READ Approximate time until next expected change on this filesystem, asserver. When ameasure of volatility.request partially overlaps a locked area, the request should be broken up into multiple pieces with each region (locked or not) treated Expires:December 1999March 2000 [Page27]55] Draft Protocol Specification NFS version 4JuneSeptember 19996. NFS Server Namespace 6.1. Server Exports On a UNIX server the name-space describes all the files reachable by pathnames underappropriately. 9.4.4. Data Caching and File Identity When clients cache data, data needs to organized according to theroot directory "/". On a Windows NT serverthename-space constitutes allfile system object to which thefiles on disks named by mapped disk letters.data belongs. For NFSserver administrators rarely makev3 clients, theentire server's file-system name-space availabletypical practice has been toNFS clients. Typically, pieces of the name-space are made available via an "export" feature. The root filehandle for each export is obtained through the MOUNT protocol; the client sends a stringassume (for this purpose) thatidentifiesdistinct handles represent distinct filesystem objects (even though in some unusual cases this has not been theexport of name-spacecase) andthe server returns the root filehandle for it. The MOUNT protocol supports an EXPORTS procedurethatwill enumeratetheserver's exports. 6.2. Browsing Exports Thedata cache may be maintained on the this basis. In NFSversion 4 protocol providesv4, we have the prospect (due to pathname based handles) of more significant deviations from aroot filehandle thatone-filehandle-per-object model. This requires some method by which clientscan use to obtainmay reliably determine whether two filehandlesfor these exports via a multi-component LOOKUP. A common user experience isdesignate the same object. If they were touse a graphical user interface (perhaps a file "Open" dialog window)simply assume that all distinct filehandles denoted distinct objects and proceeded tofind a file via progressive browsing through a directory tree. Thedo data caching on that basis, caching inconsistencies would arise between the distinct clientmustside objects which mapped to the same server side object. While it is true that such inconsistencies would beablesimilar tomovethose typically seen by programs running on multiple clients (apart fromone export to another export via single-component, progressive LOOKUP operations. This style of browsing isthis issue), these inconsistencies would notwell supported bybe expected an NFSversion 2 and 3 protocols. The client expects all LOOKUP operations to remain within a single server file-system, i.e. the device attribute willv3 clients notchange. This preventssharing files with any other client. The appearance of such inconsistencies would be aclientdefinite problem inhibiting transition fromtaking name-space paths that span exports. An automounter on theNFS v3 to NFS v4 and so must be avoided. The following procedure allows an NFS v4 clientcan obtain a snapshot of the server's name-space usingto determine (for theEXPORTS procedurepurposes of data caching) whether two distinct filehandles denote theMOUNT protocol.same server side object: o Ifit understandsGETATTR directed to theserver's pathname syntax, it can create an imagetwo handles in question have different values ofthe server's name-spacefsid.major or fsid.minor, then they are distinct objects. o If GETATTR for any file on theclient. The parts offsid (major and minor) to which thename-space that are not exported bytwo handles belong and unique_handles is TRUE, then theservertwo objects arefilled in with a "pseudo file-system" that allows the userdistinct. o If GETATTR directed tobrowse fromthe two handles does not return the fileid attribute for onemounted file- system to another. There is a drawback to this representationor both of theserver's name-space onhandles, then theclient:itis static. Ifcannot be determined whether theserver administrator adds a new exporttwo objects are the same and so operations which depend on that knowledge (e.g. clientwillside data caching) cannot beunaware of it.done reliably. o If the two GETATTR's return different values for the fileid Expires:December 1999March 2000 [Page28]56] Draft Protocol Specification NFS version 4JuneSeptember 19996.3. Server Pseudo File-System NFS version 4 servers avoid this name-space inconsistency by presenting all the exports withinattribute, then they are distinct objects. o Otherwise they are theframework ofsame object. 9.5. Open Delegation When asingle server name-space. An NFS version 4 client uses LOOKUP and READDIR operations to browse seamlessly from one export to another. Portions offile is being opened, the servername-space that are not exported are bridged via a "pseudo file-system" that provides a view onlymay delegate further handling ofexported directories. The pseudo file-system has a unique fsid and behaves like a normal, read-only file-system. 6.4. Multiple Roots DOS, Windows 95, 98opens andNT are sometimes described as having "multiple roots". File-Systems are commonly represented as disk letters. MacOS represents file-systems as top-level names. NFS version 4 serverscloses forthese platforms can construct a pseudo file- system above these root names sothatdisk letters or volume names are simply directory names in the pseudo-root. 6.5. Filehandle Volatility The nature offile to theserver's pseudo file-systemopening client. Any such delegation is recallable, since the circumstances that occasioned itisare subject to change. In particular, the server may receive alogical representation of file-system(s) availableconflicting OPEN from another client, which obliges it to recall theserver. Therefore, the pseudo file-system is most likely constructed dynamically whendelegation before deciding whether theNFS version 4 is first instantiated. ItOPEN may be granted. Granting a delegation request isexpectedup to thepseudo file-systemserver and it may deny all such requests. The following is a typical set of conditions that servers might use in deciding whether open should be delegated: o The client must be able to respond to callbacks (as evidenced by responding to previous CB_NULL requests). o The client must not havean on-disk counterpart from which persistent filehandles couldfailed to respond properly to previous recalls. o There must be no current open conflicting with the requested delegation. o There should be no current delegation that conflicts with the delegation being requested. o The probability of future conflicting open requests should beconstructed. Even though it is preferable thatlow based on the recent history of the file. o The existence of any serverprovide persistent filehandles forspecific semantics of OPEN/CLOSE that would make thepseudo file-system,required handling incompatible with theNFS client should expectprescribed handling thatpseudo file-system file-handles are volatile. This can be confirmed by checking the associated "persistent_fh" attribute for those filehandles in question. Ifthefilehandlesdelegated client would apply (see below). There arevolatile, the NFStwo types of open delegations, read and write. A read open delegation allows a clientmust be preparedtorecover a filehandle value (i.e. with a v4 multi-component LOOKUP) when receiving an error of NFS4ERR_FHEXPIRED. 6.6. Exported Root If the server's root file-system is exported, it might be easyhandle, on its own, requests toconclude thatopen apseudo-file-system isfile for reading that do notneeded. This woulddeny read access to others. Multiple read open delegations may bewrong. Assumeoutstanding simultaneously and do not conflict. A write open delegation allows thefollowing file-systemsclient to handle on its own all opens. Only one write open delegation may exist for aserver: / disk1 (exported) /a disk2 (not exported)given file at a given time and it is inconsistent with any read open Expires:December 1999March 2000 [Page29]57] Draft Protocol Specification NFS version 4JuneSeptember 1999/a/b disk3 (exported) Because disk2 isdelegations. When a client has a read open delegation, it may notexported, disk3 cannot be reached with simple LOOKUPs. The server must bridgemake any changes to thegap withcontents or attributes of the file but it is assured that no other client may do so. When apseudo-file-system. 6.7. Mount Point Crossing The server file-system environmentclient has a write open delegation it mayconstructedmodify the file data as it wishes secure insuch a waythe knowledge thatone file-system containsno other client is accessing the file's data. The client holding adirectorywrite delegation may only affect file attributes whichis 'covered' or mounted upon byare intimately connected with the file data: length, modify_time, change. When asecond file-system. For example: /a/b (file system 1) /a/b/c/d (file system 2) The pseudo file-system for thisclient has an open delegation, it does not send OPEN's, or CLOSE's to the servermaybut updates the appropriate status internally. For a read open delegation, opens that cannot beconstructedhandled locally (opens for write or that deny read access) must go tolook like: / (place holder/not exported) /a/b (file system 1) /a/b/c/d (file system 2) Itthe server. When an open delegation is requested and granted, theserver's responsibilityresponse topresentthepseudo file-system that is complete toOPEN contains an open delegation structure which specifies, theclient. Iftype of delegation (read or write), space limitation information to control flushing of data on close (write open delegation only, see theclient sendsSection "Open Delegation and Data Caching"), an nfsacl4 specifying read and write permissions and alookup request for the path "/a/b/c/d",stateid to represent theserver's responsedelegation when doing IO. This stateid is separate and distinct from thefilehandle ofstateid for thefile system "/a/b/c/d". In previous versions of NFS,OPEN proper, which, unlike theserver would responddelegation stateid, is associated withthe directory "/a/b/d/d" within the file-system "/a/b". The NFS clienta particular nfs_lockowner, and willbe ablecontinue todeterminebe valid after the delegation is recalled, ifit crossesthe file remains open. When an internal request (or aserver mount pointrequest by one of achangeproxy server's clients) is made to open a file when open delegation is in effect, it will be accepted or rejected solely on thevaluebasis of the"fsid" attribute. 6.8. Summary NFS version 4 provides LOOKUP and READDIR operationsfollowing conditions. Any requirement forbrowsing of NFS file-systems. These operations are also usedother checks tobrowse server exports. A v4 server supports export browsingbe made byincluding exported directoriesthe delegate, should result ina pseudo-file-system. A browsing clientopen delegation being denied so that the checks cancross seamlessly between a pseudo-file-systembe made by the server itself. o The access anda real, exported file- system. Clients must support volatile filehandlesdeny bits for the request andrecognize mount point crossing of server file-systems.the file as described in Section 7.7, Share reservations o The read and write permissions as determined below. The nfsacl4 passed with delegation can be used to avoid frequent ACCESS calls. The permission check should be as follows: o If the nfsacl4 indicates that the open may be done, then it should be granted, without reference to the server. Expires:December 1999March 2000 [Page30]58] Draft Protocol Specification NFS version 4JuneSeptember 19997. File Locking Integrating locking into NFS necessarily causes it too If the nfsacl4 indicates that the open may not bestate-full, withdone, then an ACCESS request must be made to theinvasive nature of "share" file locks it becomes substantiallyserver to obtain the definitive answer. The server may thus return an nfsacl4 that is moredependent on staterestrictive than thetraditional combinationactual ACL ofNFS and NLM [XNFS]. There are three componentsthe file, including one that specifies denial of all access. Note that some common practices like mapping root tomaking this state manageable: o Clear division between client and server o Abilitynobody may make it incorrect toreliably detect inconsistencysend the actual ACL of the file instate between client and server o Simple and robust recovery mechanisms In this model,some cases. The use of delegation together with various other forms of caching creates the possibility that no serverownsauthentication will ever be performed on a given user since all of his requests might be satisfied locally. Where thestate information. Theclientcommunicates its viewis depending ofthis state tothe serveras needed.for authentication, it should make sure that some authentication (via an ACCESS call) happens for each user, even if an ACCESS call would not otherwise be required. Theclientserver may enforce frequent authentication by returning an nfsacl4 denying all access with every open delegation. 9.5.1. Open Delegation and Data Caching Open delegation allows much of the message overhead associated with opening and close files to be eliminated. This is alsoable to detect inconsistent state before modifyingthe case for afile. To support Windows "share" locks, it is necessaryproxy server toatomicallywhich an openor create files. Having a separate share/unshare operation willdelegation was made but which did notallow correct implementation ofpass theWindows OpenFile API.delegation on. Inorder to correctly implement share semantics, the existing mechanisms usedeither case, an open whena file is opened or created (LOOKUP, CREATE, ACCESS) need to be replaced. NFS V4 will haveanOPEN procedureopen delegation was in effect would not require thatsubsumesa validation message be sent to thefunctionalityserver. The continued endurance ofLOOKUP, CREATE,the read-open- delegation provides a guarantee that no open for write andACCESS. However, because many operations requirethus no write has occurred. Similarly, when closing a filehandle, the traditional LOOKUPopened for write, if write open delegation ispreservedin effect, the data written does not have tomap a file namebe flushed tofile handle without establishing state ontheserver. Policyserver until the open delegation is recalled. The continued endurance ofgranting accessthe open delegation provides a guarantee that no open and thus no read ormodifying files is managedwrite has been done by another client. For theserver based onpurposes of open delegation, IO done without an OPEN (via special stateid's consisting of all zero bits or all one bits) are treated as theclient's state. It is believed that these mechanisms can implement policy ranging from advisory only locking to full mandatory locking. While ACCESS is justfunctional equivalent of asubsetcorresponding type of open. Thus, such READ's or WRITE's done by another client need will provoke recall ofOPEN, the ACCESS procedure is maintained asalighter weight mechanism. 7.1. Definitions Lock The term "lock"write open delegation, willbe used to referany such WRITE will provoke recall of a read open delegation. In order toboth record (byte-range) locks as well as file (share) locks unless specifically stated otherwise. Client Throughout this proposalmaintain current semantics in which theterm "client" is usednon-availability of storage toindicate the entity that maintainshold aset of locks on behalf of one or more applications. Thefile written by an NFS client isresponsible for crash recovery of those locks it manages. Multiple clients may share the same transport and multiple clients may existguaranteed to Expires:December 1999March 2000 [Page31]59] Draft Protocol Specification NFS version 4JuneSeptember 1999onbe determined at or before thesame network node. Clientid A 64-bit quantity returnedassociated close operation, the avoidance bya server that uniquely corresponds to athe clientsupplied Verifier and ID. Lease An intervaloftime defined bythe requirement to flush data to the serverforon close, is limited to cases in which the clientis irrevokeably granted a lock. Atand server together can determine in advance that theendrequired space will be available. The server specifies one of alease periodnumber of limiting conditions, either a limit on thelock may be revoked ifsize of thelease has not been extended. The lock must be revoked iffile or aconflicting lock has been granted afterlimit on thelease interval. All leases granted bynumber of modified blocks using aserver have the same fixed interval. Stateid A 64-bit quantity returnedblocksize supplied bya server that uniquely definesthelocking state granted byserver. Based on implementation experience, changes in theserver for a specific lock owner for a specific file. A stateid composedform ofall bits 0these conditions may be made orall bits 1 have special meaning and are reserved. Verifier A 32-bit quantity generated bynew types of limiting conditions defined. Whatever theclient thatform of condition used, it us up to the servercan usetodetermine if the client has restarted and lost all previous lock state. 7.2. Locking It is assumedensure thatmanipulatingany set of writes, no matter how arranged that meets the specified condition will ever encounter alock is rarelack of disk space availability whencomparedthe modified data is allowed toI/O operations. Itremain on the client unflushed to the server past the point of close. The server must make sure that the maximum possible amount of storage isalso assumedreserved so thatcrashesall outstanding delegations together meet that condition, andnetwork partitions are relatively rare. Thereforeto recall delegations appropriately to maintain that invariant. When a server implements quotas, it should also be careful that it does not invalidate its quota invariants when granting write open delegation. When a user isimportant that I/O operations havenear alight weight mechanismquota limit, this may result in write open delegations granted with very restrictive space limitation conditions or those which always force modified data to be flushed toindicate if they possess a held lock. A lock request containstheheavy weight information requiredserver on close. When authentication considerations make flushing of modified data toestablish a lock and uniquely definethelock owner. The following sections describeserver after thetransition fromclose problematic (after theheavy weight information tolast close, theeventual stateid used for most client and server lockinguser may have logged off andlease interactions. 7.2.1. Client ID For each LOCK request,unexpired local credentials may not exist), the clientmust identify itselfmay need to take special care to ensure that local unexpired credentials will in fact be available, either by tracking theserver. This is doneexpiration time of credentials and flushing data well insuch a way asadvance of their expiration, or by making private copies of credentials toallow for correct lock identificationassure their availability when needed. 9.5.2. Open Delegation andcrash recovery. Client identification is accomplished with two values. o A verifier that is used to detectFile Locks When a clientreboots. o A variable length opaque array to uniquely defineholds aclient. For an operating system this maywrite-open-delegation, lock operations, including those required by mandatory file locking are performed locally since the delegation implies that there can be no conflicting locks. On afully qualified hostsimilar basis, all of the revalidations that would normally be associated with obtaining locks and the flushing of data which would attend the releasing of locks for write need not be done. 9.5.3. Recall of Open Delegation Expires:December 1999March 2000 [Page32]60] Draft Protocol Specification NFS version 4JuneSeptember 1999name or IP address, and for a user level NFS client it may additionally contain a process id or other unique sequence. The data structure for the Client ID would then appear as: struct nfs_client_id { opaque verifier[4]; opaque id<>; }: It is possible through the mis-configuration of a client or the existence of a rogue client that two clients end up using the same nfs_client_id. This situation is avoided by 'negotiating' the nfs_client_id between client and server with the use of the SETCLIENTID.The followingdescribes the two scenariosevents necessitate recall ofnegotiation. 1 Client has never connected to the server In this case the client generatesannfs_client_id and unlessopen delegation: o Potentially conflicting OPEN request (or IO done with "special" stateid) o SETATTR issued by another clienthas the same nfs_client_id.id field, the server accepts the request. The server also records the principal (or principal to uid mapping) fromo REMOVE request for thecredentialfile inthe RPCquestion o RENAME requestthat containsfor thenfs_client_id negotiation request. Two clients might still usefile in question as either source or target of thesame nfs_client_id.id due to perhaps configuration error (say a High Availability configuration whereRENAME NOTE: [[The following are necessary unless thenfs_client_id.idspec isderived from the ethernet controller addresscleaned up to disallow LOCK's andboth systems have the same address). In this case, nfs4err can beIO operations without aswitched union that returnscorresponding OPEN.]] o LOCK request by another client. o IO operation done with "special" stateid by another client. Whether a RENAME of a directory inadditionthe path leading toNFS4ERR_CLID_IN_USE,thenetwork address (the rpcbind netid and universal address)file results in recall of an open delegation depends on the semantics of theclientserver file system. If that filesystem denies such RENAME's when a file isusingopen, theid. 2 Client is re-connectingrecall must be performed to determine whether the file in question is, in fact, open. In addition to the situations above, the serveraftermay choose to recall open delegations at any time if resource constraints make it advisable to do so. Clients should always be prepared for the possibility of recall. Special handling is needed for aclient rebootGETATTR which occurs when a write open delegation is in effect. In this case, the clientstill generates an nfs_client_id butholding thenfs_client_id.id field willdelegation needs to be interrogated, using a CB_GETATTR callback, if thesame as the nfs_client_id.id generated prior to reboot. IfGETATTR attribute bits include any of theserver findsattributes thatthe principal/uid is equala write open delegate may modify (length, modify time, change). When a client receives a recall for an open delegation, it needs to update state on thepreviously "registered" nfs_client_id.id, then locks associated with the old nfs_client_id are immediately released. Ifserver before returning theprincipal/uid is not equal, then this isdelegation. These same updates must be done whenever arogueclientand the request is returned in error. For more discussionchooses to return a delegation voluntarily. The following items ofcrash recovery semantics, see the section on "Crash Recovery"state need to be dealt with: Expires:December 1999March 2000 [Page33]61] Draft Protocol Specification NFS version 4JuneSeptember 1999In both cases, upon success, NFS4_OK is returned. To help reduceo If the open file associated with theamount of data transferred onOPENand LOCK,which delivered theserver will also return a unique 64-bit clientid value thatdelegation to the client is no longer open, then ashort hand referenceCLOSE must be done to thenfs_client_id values presented by the client. Fromserver, if thispoint forward,has not been done previously. o If there are other opens extant for that file, then OPEN operations must be done to update theclient can useserver and obtain theclientidstateid's torefer to itself. 7.2.2. nfs_lockowner andbe used subsequently, given that the delegation stateiddefinition When requestingwill no longer be valid. Such OPEN's are done using alock,claim type of CLAIM_DELEGATE_CUR so that theclient must presentdelegation stateid can be presented to the server to establish theclientid and an identifier for the owner ofclient's right to perform this OPEN. (See therequested lock. These two fieldssection "Procedure 17: OPEN" for details). o If there arereferredlocks which have been granted (write open delegation case only), then these need to be performed toasthenfs_lockowner andserver. In thedefinitioncase ofthose fields are: o A clientid returned bya write open delegation, if theserver as part offile in question is not opened for write at theclients usetime of recall, then any modified data for theSETCLIENTID procedure o A variable length opaque array usedfile needs touniquely define the owner of a lock managed by the client. This maybea thread id, process id, or other unique value. When the server grants the lock it responds with a unique 64-bit stateid. The stateid is used as a short hand referenceflushed to thenfs_lockowner, sinceserver, as it would have been flushed when theserver will be maintainingfile was closed, had thecorrespondence between them. 7.2.3. Usewrite open delegation not been in effect. The possibility of truncation on thestateid All I/O requests contain a stateid. Ifclient means that thenfs_lockowner performs I/O on a range of bytes withinfollowing needs to be done: o If alocked range,file truncate has been done on thestateid returned byclient (as part of an OPEN UNCHECKED, for example), and this has not yet been propagated to the server (it must beusedbefore allowing any new data to be written toindicate the appropriate lock (record or share) is held. If no state is established bytheclient, either record lock or share lock, a stateidserver), it must be done as part ofall bits 0 is used. If no conflicting locks are held on the file, the server may grantrecall, again before writing modified data to theI/O request. If a conflict with an explicit lock occurs,server. o Any modified data for therequest is failed (NFS4ERR_LOCKED). This allows "mandatory locking"file needs to beimplemented. A stateid of all bits 1 allows read requestsflushed tobypass locking checks atthe the server.However,In the case of writerequests with stateid with bits all 1 does not bypassopen delegation, file locking imposes some additional requirements.An explicitThe flushing of any modified data in any area for which a write lockmay not be grantedwas released whilean I/O operation with conflicting implicitthe write open delegation was in effect is what is required to precisely maintain the associated invariant. However, because the write open delegation implies no other locking by other clients, a simpler implementation isbeing performed.to flush all modified data for the file (as described just above) if any write lock has been released while the write open delegation was in effect. Expires:December 1999March 2000 [Page34]62] Draft Protocol Specification NFS version 4JuneSeptember 1999The byte range of9.5.4. Delegation Revocation When alockdelegation isindivisible. A range mayrevoked, if there are associated opens on the client, the processes holding these opens need to belocked, unlocked,notified, normally by returning errors whenever IO operations orchanged between read and write buta close is attempted on that open file. When an open delegation is revoked, if no opens are present on the client, then no error needs to be reported, unless there is modified data present on the client. In this case, the user will have to be notified, since there may nothave subranges unlocked or changed between readbe an active application to get an error status. (See the section "Revocation Recovery for Write Open Delegation" for more details). 9.6. Data Caching andwrite. This isRevocation When locks (including delegations) are revoked, thesemantics provided by Win32 but only a subsetassumptions upon which successful caching depend, are no longer guaranteed. Therefore the client, in addition to notifying the owner of a record lock or share reservation, and processes holding opens for thesemantics provided by Unix. It is expected that Unix clients can more easily simulate modifying subranges than Win32 servers adding this feature. 7.2.4. Sequencingdelegation, needs to remove all data for the file from its cache. In the case of modified data, it must be removed from the client's cache without being written to the server. Notification to the lockrequests Locking is different than most NFSowner will in many cases consist of simply returning an error on the next (and all subsequent) IO to the open file or on the close. Where the client API make such notification impossible (because errors for certain operations may not be returned), more drastic action such asit requires "at- most-one" semanticssignals or process termination may be appropriate since an invariant that an application depends on may be violated. Depending on how errors arenot provided by ONC RPC. Intypically treated on thefaceclient operating system, further levels ofretransmission or reordering, lock or unlock requests must have a well definednotification including logging, console messages, andconsistent behavior. To accomplish this each lock request containsGUI pop-up's may be in order. 9.6.1. Revocation Recovery for Write Open Delegation Revocation recovery for asequence numberwrite open delegation poses the issue in that there may be modified data in the client cache while the file isa monotonically increasing integer. Different nfs_lockowners have different sequences. Thenot open. In this situation, any client which does not flush modified data to the servermaintainson each close must make sure that thelast sequence number (L) received anduser receives appropriate notification of theresponse that was returned.failure. Since such situations may require human action to correct problems, notification schemes in which the appropriate user or administrator is notified Expires: March 2000 [Page 63] Draft Protocol Specification NFS version 4 September 1999 may be necessary. Logging and console messages are typical examples. Ifa request with a previous sequence number (r < L)there isreceivedmodified data on the client, itis silently ignored as its responsemusthave been received beforenot be flushed normally to thelast request (L) was sent. Ifserver. A client may attempt to provide aduplicatecopy oflast request (r == L) is received,thestored response is returned. Iffile data as modified during the delegation under arequest beyonddifferent name, to ease recovery. Unless thenext sequence (r == L + 2) is received it is silently ignored. Sequences are reinitialized wheneverclient can determine that the file was has not modified by any other client, this technique is limited to situations in which a clientverifier changes. 7.3. Blocking locks Some clients requirehas a complete cached copy of thesupportfile in question. Use ofblocking locks. The current proposal lackssuch acall-back mechanism, similar to NLM,technique may be limited tonotifyfiles under aclientcertain size or may only be used when sufficient disk space is guaranteed available within the target file system and when thelockclient hasbeen granted. Clients have no choice butsufficient buffering resources tocontinually poll forkeep thelock, which presents a fairness problem. Two new lock typescached copy available until it is properly stored to the target file system. 9.7. Attribute Caching First note that when attributes areadded, READWdiscussed here, extended or named attributes are not included. Individual named attributes are analogous to files andWRITEW usedcaching of the data for these needs toindicatebe handled just as data caching is for ordinary files. Similarly, LOOKUP results from an OPENATTR directory are to be cached on the same basis as any other pathnames and similarly for directory contents. Clients may cache file attributes obtained from the server and use them to avoid subsequent GETATTR requests. Such caching is write through in thatthe clientmodification to file attributes isrequesting a blocking lock. Thealways done by means of requests to the server and shouldmaintain an ordered list of pending blocking locks. Whennot be done locally and cached, theconflicting lock is released,exception being modifications to attributes that are intimately connected with data caching. Thus, extending a file by writing data to theserver may waitlocal data cache is reflected immediately in thelease period forlength as seen on thefirstclientto re-requestwithout this change being immediately reflected on thelock. Afterserver. Normally such changes are not propagated directly to thelease period expiresserver, but when thenext waiting client requestmodified data isallowedflushed to thelock. Clientsserver, analogous attribute changes arerequired to poll at an interval sufficiently small that itmade on the server. When open delegation islikelyin effect, the modified attributes may be returned toacquirethelockserver in the response to atimely manner.CB_RECALL call. Theserverresult of local caching of attributes is that the attribute caches maintained on individual clients will notrequired to maintainbe coherent. Changes made in one order on the server may be seen in alist of pending blocked locks as it is used to increase fairnessdifferent order on one client and in a third order on a different client. Given that typical file API's do notcorrect operation. Because ofprovide means to atomically modify or interrogate attributes for multiple files at theunordered nature of crash recovery, storingsame time, the undesirable effects oflock state to stable storage would be required to guarantee ordered grantingthese incoherencies have proved manageable, if the following rules, derived from the practice ofblocking locks.Expires:December 1999March 2000 [Page35]64] Draft Protocol Specification NFS version 4JuneSeptember 19997.4. Lease renewal The purpose of a lease is to allow a server to remove stale locks thatNFSv3 implementations areheld by a client that has crashed or is otherwise unreachable. It is not a mechanismfollowed: o All attributes forcache consistency and lease renewals may not be denied if the lease interval has not expired. Any I/O request that has been made withavalid stateid isgiven file (per-fsid attributes excepted) are cached as apositive indicationunit so thatthe client is still alive and locks are being maintained. This becomes an implicit renewal of the lease. In the casenoI/O has been performednon-serializability can arise within thelease interval,context of aleasesingle file. o A bound is maintained on how long a client cache entry can berenewed by having the client issue a zero length READ. Becausekept without being refreshed from thenfs_lockowner contains a unique client value,server. o When performing anystateid for a client will renew all leases for locks held with the same client field. This will allow very low overhead lease renewal that scales extremely well. In the typical case, no extra RPC calls are needed and in the worst case one RPC is required every lease period regardless of the number of locks held by the client. 7.5. Crash recovery The important requirement in crash recovery isoperation thatboth the client and the server know whenchanges attributes on theother has failed. Additionally it is required that a client sees a consistent view of data across server reboots. I/Oserver, including directory operations thatmay have been queued within the client or network buffers, cannot complete until after the client has successfully recovered the lock protectingdue so indirectly, updated attributes would be fetched as part of theI/O operation. Ifassociated rpc, using aclient fails, the server only needs to wait the lease period to allow conflicting locks. If the client reinitializes withinGETATTR following thelease period, it may be forced to waitoperation in question, which theremainderresults of theperiod before resuming service. To minimize this delay, lock requests contain a verifier field inGETATTR used to update thelock_owner,client's attribute cache. Note that if theserver receives a verifier field that does not matchfull set of attributes to be cached is requested by READDIR, theexisting verifier,results can be cached by theserver knows thatclient on the same basis as attributes obtained GETATTR. A clienthas lost all lock state and locks heldmay validate its cached version of attributes for a file by fetching only the change attribute and assuming thatclient that do not matchif thecurrent verifier may be released. In a secure environment, achangeinattribute has theverifier must only causesame value as it did when thelocks held byattributes were cached, then no attributes have changed, with theauthenticated requester topossible exception of access_time. 9.8. Name Caching The results of LOOKUP and READDIR operations may bereleased in ordercached toprevent a rogue user from freeing otherwise valid locks. The verifier must haveavoid thesame uniqueness propertiescost of subsequent LOOKUP operations. Just as in theCOMMIT verifier. If the server fails and loses locking state,case attribute caching, inconsistencies may arise among theserver must waitvarious client caches. To mitigate thelease period before granting any new locks or allowing any I/O. An I/O request duringeffects of these inconsistencies, given thegrace period with an invalid stateid will fail with NFS4ERR_GRACE,context of typical file API's, theclient will reissuefollowing rules should be adhered to: o The results of unsuccessful LOOKUP's should not cached, unless they are specifically reverified at thelock request with reclaim set to TRUE, and upon receivingpoint of use. o A bound is maintained on how long asuccessful reply, the I/O mayclient name cache entry can bereissued withkept without verifying that thenew stateid. Any timeentry in question has not been made invalid by aclient receives andirectory change operation performed by another client. Expires:December 1999March 2000 [Page36]65] Draft Protocol Specification NFS version 4JuneSeptember 1999NFS4ERR_GRACE error it should start recovering all outstanding locks. A lock request during the grace period without reclaim set will also result inWhen aNFS4ERR_GRACE, triggering theclientrecovery processing. A lock request outside the grace period with reclaim set will succeed only if the server can guarantee that no conflicting lock or I/O request has been granted since reboot. In the case of a network partition longer than the lease period, the server will haveis notreceived an implicit lease renewal and may free all locks heldmaking changes to a directory forthe client, thus invalidating any stateid held by the client. Subsequent reconnection will cause I/O with invalid stateidwhich there exist name cache entries, it needs tofail with NFS4ERR_EXPIRED, the client will suitably notify the application holding the lock.periodically fetch attributes for that directory to make sure that it is not changing. Afterthe lease perioddetermining that no change that hasexpiredoccurred, theserverexpiration time for the associated name cache entries mayoptionally continuebe updated toholdbe thelocks forcurrent time plus theclient. In this case, ifname cache staleness bound. When aconflicting lock or I/O requestclient isreceived, the lock must be freedmaking changes toallow the clienta given directory, it needs todetect possible corruption. Whendetermine whether thereis a network partitionhave been changes made to the directory by other clients. It does this using the change attribute as reported before and after thelease expires,directory operation in theserver must recordassociated wcc4_info returned onstable storagethat operation. When theclient information relating to those leases. Thisserver is able to report these values atomically with respect topreventthecase where another client obtainsdirectory operation, which theconflicting lock, freesserver indicates in thelock, andwcc4_info, comparison of theserver reboots. Afterpre-operation change value with theserver recoverschange value which theoriginalclientmay recoverhas in his cache determines whether there has been a change by another client, necessitating a purge of name cache associated with thenetwork partition and attempt to reclaimdirectory. If there has been no such change, thelock. Without any state to indicate that a conflicting may have occurred,name cache can be updated on the clientcould get in an inconsistent state. Storing justto reflect theclient information isdirectory operation and theminimal state necessary to detect this condition, but could lead to losing locks unnecessarily. However this is consideredassociated timeout extended. The post-operation change value needs to bea very rare event, and a sophisticated server could store more state completely eliminate any unnecessary locks being lost. 7.6. Server revocation of locks The server can revokesaved as thelocks heldbasis for future wcc4_info comparisons. Name caching requires that the client revalidate cached data by comparing the change attribute for aclient at any time,directory when theclient detects revocation it must ensure its state matchesname item was cached. This requires thatof the server. If locks are revoked due to a server reboot,any changes in theclient will receivecontents of aNFS4ERR_GRACE and normal crash recovery described above willdirectory beperformed. The server may revokevisible as alock withinchanged value for thelease period, this is consideredchange attribute of the directory. Proper use of wcc4_info, when arare event likelyclient makes a change tobe initiated only byahuman (as part of an administration task). The client may assumedirectory, requires thatonlyreporting of thefile that causedpre-operation and post-operation change attribute values are in fact atomic with theNFS4ERR_EXPIREDactual directory change. When the server cannot reliably report before and after values atomically with respect tobe returned has lostthelock_owner's locksdirectory operation, the server indicates that in the wcc4_info andnotifiestheholder appropriately. Theclientcanshould not assume that other clients have not changed thelease period has been renewed.directory. 9.9. Directory Caching Theclient not being ableresults of READDIR operations may be used torenewavoid subsequent READDIR operations. Just as in thelease period is a relatively rarecases of attribute andunusual state. Both sides will detectname caching, thisstate and can recover without data corruption. Themay result in inconsistencies among the various client caches. To mitigate the effects of these inconsistencies, given the context of typical file API's, the following rules should be adhered to: o Cached READDIR information for a directory which is not obtained in a single READDIR operation mustmark all locks heldalways be a consistent Expires:December 1999March 2000 [Page37]66] Draft Protocol Specification NFS version 4JuneSeptember 1999as "invalidated" and then must issue an I/O request, either a pending I/O or zero length read to revalidate the lock. If the response is success the lock is upgraded to valid, otherwise it was revoked by the server and the owner is notified. 7.7. Share Reservations A share reservation is a mechanism to control access to a file. It is a separate and independent mechanism from record locking. When a client opens a file, it issues an OPEN request to the server specifying the typesnapshot ofaccess required (READ, WRITE, or BOTH)directory contents as evidenced by a GETATTR before the first and after thetypelast ofaccess to deny others (deny NONE, READ, WRITE, or BOTH). IfREADDIR's which contribute. o A bound is maintained on theOPEN failsamount of time that a directory cache entry may be kept on the clientwill failwithout revalidation. The revalidation technique parallels that discussed in theapplications open request. Pseudo-code definitioncase of name caching. When thesemantics: if ((request.access & file_state.deny)) || (request.deny & file_state.access)) return (NFS4ERR_DENIED) Old DOS applications specify shares in compatibility mode. Microsoft has indicated inclient is not changing theWin32 specification that it will be deprecateddirectory inthe future and recommendsquestion, checking thatdeny NONE be used. This specification doesthe directory has notsupport compatibility mode. 7.8. OPEN/CLOSE procedures To provide correct share semantics,changed (by using GETATTR to obtain the change attribute) is adequate to extend the lifetime of the cache entry. When a clientMUSTis modifying the directory, it needs to use theOPEN procedurewcc4_info data toobtaindetermine whether there are other clients who are modifying theinitial file handle and indicatedirectory, allowing it to update thedesired access and what if any accessdirectory cache todeny. Evenreflect its own changes if it is the only clientintends to use a stateid of all 0's or all 1's, it must still obtainmaking modifications. Directory caching requires that thefilehandle forclient revalidate cached data by comparing theregular file withchange attribute for a directory when theOPEN procedure. For clientsdirectory data was cached. This requires thatdo not haveany changes in the contents of adeny mode built into their open API, deny equal to NONE shoulddirectory beused. The OPEN procedure withvisible as a changed value for theCREATE flag, also subsumeschange attribute of theCREATE procedure for regular files as used in previous versionsdirectory. Proper use ofNFS, allowingwcc4_info, when acreate withclient makes asharechange tobe done atomicly. Will expand on create semantics here. The CLOSE procedure removes all share locks held by the lock_owner on that file. If record locks are held they should be explicitly Expires: December 1999 [Page 38] Draft Protocol Specification NFS version 4 June 1999 unlocked. Some servers may not support the CLOSE ofafiledirectory, require thatstill has record locks held; if so, CLOSE will failreporting of the pre-operation andreturn an error. The LOOKUP procedure is preservedpost-operation change attribute values are in fact atomic with the actual directory change. When the server cannot reliably report before andwill return a file handle without establishing any lock state onafter values atomically with respect to theserver. Without a valid stateid,directory operation, the serverwill assumeindicates that in the wcc4_info and the clienthasshould not assume that other clients have not changed theleast access. For example, a file opened with deny READ/WRITE cannot be accessed using a file handle obtained through LOOKUP.directory. Expires:December 1999March 2000 [Page39]67] Draft Protocol Specification NFS version 4JuneSeptember 19998.10. Defined Error Numbers NFS error numbers are assigned to failed operations within a compound request. A compound request contains a number of NFS operations that have their results encoded in sequence in a compound reply. The results of successful operations will consist of an NFS4_OK status followed by the encoded results of the operation. If an NFS operation fails, an error status will be entered in the reply and the compound request will be terminated. A description of each defined error follows: NFS4_OK Indicates the operation completed successfully. NFS4ERR_PERM Not owner. The operation was not allowed because the caller is either not a privileged user (root) or not the owner of the target of the operation. NFS4ERR_NOENT No such file or directory. The file or directory name specified does not exist. NFS4ERR_IO I/O error. A hard error (for example, a disk error) occurred while processing the requested operation. NFS4ERR_NXIO I/O error. No such device or address. NFS4ERR_ACCES Permission denied. The caller does not have the correct permission to perform the requested operation. Contrast this with NFS4ERR_PERM, which restricts itself to owner or privileged user permission failures. NFS4ERR_EXIST File exists. The file specified already exists. NFS4ERR_XDEV Attempt to do a cross-device hard link. NFS4ERR_NODEV No such device. Expires:December 1999March 2000 [Page40]68] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_NOTDIR Not a directory. The caller specified a non- directory in a directory operation. NFS4ERR_ISDIR Is a directory. The caller specified a directory in a non-directory operation. NFS4ERR_INVAL Invalid argument or unsupported argument for an operation. Two examples are attempting a READLINK on an object other than a symbolic link or attempting to SETATTR a time field on a server that does not support this operation. NFS4ERR_FBIG File too large. The operation would have caused a file to grow beyond the server's limit. NFS4ERR_NOSPC No space left on device. The operation would have caused the server's file system to exceed its limit. NFS4ERR_ROFS Read-only file system. A modifying operation was attempted on a read-only file system. NFS4ERR_MLINK Too many hard links. NFS4ERR_NAMETOOLONG The filename in an operation was too long. NFS4ERR_NOTEMPTY An attempt was made to remove a directory that was not empty. NFS4ERR_DQUOT Resource (quota) hard limit exceeded. The user's resource limit on the server has been exceeded. NFS4ERR_STALE Invalid file handle. The file handle given in the arguments was invalid. The file referred to by that file handle no longer exists or access to it has been revoked. Expires:December 1999March 2000 [Page41]69] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_BADHANDLE Illegal NFS file handle. The file handle failed internal consistency checks. NFS4ERR_NOT_SYNC Update synchronization mismatch was detected during a SETATTR operation. NFS4ERR_BAD_COOKIE READDIR cookie is stale. NFS4ERR_NOTSUPP Operation is not supported. NFS4ERR_TOOSMALL Buffer or request is too small. NFS4ERR_SERVERFAULT An error occurred on the server which does not map to any of the legal NFS version 4 protocol error values. The client should translate this into an appropriate error. UNIX clients may choose to translate this to EIO. NFS4ERR_BADTYPE An attempt was made to create an object of a type not supported by the server. NFS4ERR_JUKEBOX The server initiated the request, but was not able to complete it in a timely fashion. The client should wait and then try the request with a new RPC transaction ID. For example, this error should be returned from a server that supports hierarchical storage and receives a request to process a file that has been migrated. In this case, the server should start the immigration process and respond to client with this error. NFS4ERR_SAME Returned if an NVERIFY operation shows that no attributes have changed. NFS4ERR_DENIED An attempt to lock a file is denied. Since this may be a temporary condition, the client is encouraged to retry the lock request (with exponential backoff of timeout) until the lock Expires:December 1999March 2000 [Page42]70] Draft Protocol Specification NFS version 4JuneSeptember 1999 is accepted. NFS4ERR_EXPIRED A lease has expired that is being used in the current procedure. NFS4ERR_LOCKED A read or write operation was attempted on a locked file. NFS4ERR_GRACE The server is in its recovery or grace period which should match the lease period of the server. NFS4ERR_FHEXPIRED The file handle provided is volatile and has expired at the server. The client should attempt to recover the new file handle by traversing the server's file system name space. The file handle may have expired because the server has restarted, the file system object has been removed, or the file handle has been flushed from the server's internal mappings. NOTE: This error definition will need to be crisp and match the section describing the volatile file handles. NFS4ERR_SHARE_DENIED An attempt to OPEN a file with a share reservation has failed because of a share conflict. NFS4ERR_SAME This error is returned by the NVERIFY operation to signify that the attributes compared were the same as provided in the client's request. NFS4ERR_WRONGSEC The security mechanism being used by the client for the procedure does not match the server's security policy. The client should change the security mechanism being used and retry the operation. NFS4ERR_CLID_INUSE The SETCLIENTID procedure has found that a Expires:December 1999March 2000 [Page43]71] Draft Protocol Specification NFS version 4JuneSeptember 1999 client id is already in use by another client. NFS4ERR_RESOURCE For the processing of the COMPOUND procedure, the server may exhaust available resources and can not continue processing procedures within the COMPOUND operation. This error will be returned from the server in those instances of resource exhaustion related to theprocessingprocessing of the COMPOUND procedure. NFS4ERR_MOVED The filesystem which contains the current filehandle object has been relocated or migrated to another server. The client may obtain the new filesystem location by obtaining the "fs_locations" attribute for the current filehandle. For further discussion, refer to the section "Filesystem Migration or Relocation". NFS4ERR_NOFILEHANDLE The logical current file handle value has not been set properly. This may be a result ofthea malformed COMPOUNDprocedure.operation (i.e. no PUTFH or PUTROOTFH before an operation that requires the current file handle be set). Expires:December 1999March 2000 [Page44]72] Draft Protocol Specification NFS version 4JuneSeptember 19999.11. NFS Version 4 Requests For the NFS program, version 4, there are two traditional RPC procedures: NULL and COMPOUND. All otherproceduresoperations for NFS version 4 are defined in normal XDR/RPC syntax and semantics except that theseproceduresoperations are encapsulated within the COMPOUND request. This requires that the client combine one or more NFSv4proceduresoperations into a single request.9.1.The NFS4_CALLBACK program is used to provide server to client signaling and is constructed in a similar fashion as the NFS program. The procedures CB_NULL and CB_COMPOUND are defined in the same way as NULL and COMPOUND are within the NFS program. The CB_COMPOUND request also encapsulates the remaining operations of the NFS4_CALLBACK program. 11.1. Compound Procedure These compound requests provide the opportunity for better performance on high latency networks. The client can avoid cumulative latency of multiple RPCs by combining multiple dependent operations into a single compound request. A compound op may provide for protocol simplification by allowing the client to combine basic procedures into a single request that is customized for the client's environment. The basics of the COMPOUND procedures construction is: +-----------+-----------+-----------+-- | op + args | op + args | op + args | +-----------+-----------+-----------+-- and the reply looks like this: +----------------+----------------+----------------+-- | code + results | code + results | code + results | +----------------+----------------+----------------+-- Where "code" is an indication of the success or failure of the operation including the opcode itself.9.2.11.2. Evaluation of a Compound Request The server will process the COMPOUND procedure by evaluating each of theproceduresoperations within the COMPOUND request in order. Each componentprocedure orExpires: March 2000 [Page 73] Draft Protocol Specification NFS version 4 September 1999 operation consists of a 32 bit operation code, followed by the argument of length determined by the type of operation. The results of each operation are encoded in sequence into a reply buffer. The results of each operation are preceded by the opcode and a status code (normally zero). If an operation results in a non-zero status code, the status will be encoded and evaluation of the compound sequence will halt and the reply will be returned.Expires: December 1999 [Page 45] Draft Protocol Specification NFS version 4 June 1999There are no atomicity requirements for the procedures contained within the COMPOUND procedure. Theproceduresoperations being evaluated as part of a COMPOUND request mayand more than likely willbe evaluated simultaneously with other COMPOUND requests that the server receives. It is the client's responsibility for recovering from any partially completed compound request. Each operation assumes a "current" filehandle that is available as part of the execution context of the compound request. Operations may set, change, or return this filehandle. Expires:December 1999March 2000 [Page46]74] Draft Protocol Specification NFS version 4JuneSeptember 199910.12. NFS Version 4 Procedures10.1.12.1. Procedure 0: NULL - No Operation SYNOPSIS <null> ARGUMENT void; RESULT void; DESCRIPTION Standard ONCRPC NULL procedure. Void argument, void response. ERRORS None. Expires:December 1999March 2000 [Page47]75] Draft Protocol Specification NFS version 4JuneSeptember 199910.2.12.2. Procedure 1: COMPOUND - Compound Operations SYNOPSIS compoundargs -> compoundres ARGUMENT union opunion switch (unsigned opcode) { case <OPCODE>: <argument>; ... }; struct op { opunion ops; }; struct COMPOUND4args { utf8string tag; op oplist<>; }; RESULT structCOMPOUND4resokCOMPOUND4res { nfsstat4 status; utf8string tag; resultdata data<>; };union COMPOUND4res switch (nfsstat4 status){ case NFS4_OK: COMPOUND4resok resok4; default: void; };DESCRIPTION The COMPOUND procedure is used to combine one or more of the NFS procedures into a single RPC request. The main NFS RPC program has two main procedures: NULL and COMPOUND. All other procedures use the COMPOUND procedure as a wrapper.Expires: December 1999 [Page 48] Draft Protocol Specification NFS version 4 June 1999In the processing of the COMPOUND procedure, the server may find that it does not have the available resources to execute any or all of the procedures within the COMPOUND sequence. In this case, the error NFS4ERR_RESOURCE will be returned for the particular procedure within the COMPOUND operation where the resource exhaustion occurred. This assume that all previous procedures Expires: March 2000 [Page 76] Draft Protocol Specification NFS version 4 September 1999 within the COMPOUND sequence have been evaluated successfully. IMPLEMENTATION The COMPOUND procedure is used to combine individual procedures into a single RPC request. The server interprets each of the procedures in turn. If a procedure is executed by the server and the status of that procedure is NFS4_OK, then the next procedure in the COMPOUND procedure is executed. The server continues this process until there are no more procedures to be executed or one of the procedures has a status value other than NFS4_OK. Note that the definition of the "tag" in both the request and response are left to the implementor. It may be used to summarize the content of the compound request for the benefit of packet sniffers and engineers debugging implementations. ERRORS NFS4ERR_RESOURCE Expires:December 1999March 2000 [Page49]77] Draft Protocol Specification NFS version 4JuneSeptember 199910.3. Procedure12.2.1. Operation 2: ACCESS - Check AccessPermissionRights SYNOPSIS (cfh),permbitsaccessreq ->permbitssupported, accessrights ARGUMENT constACCESS4_READ=ACCESS4_READ = 0x0001; constACCESS4_LOOKUP=ACCESS4_LOOKUP = 0x0002; constACCESS4_MODIFY=ACCESS4_MODIFY = 0x0004; constACCESS4_EXTEND=ACCESS4_EXTEND = 0x0008; constACCESS4_DELETE=ACCESS4_DELETE = 0x0010; constACCESS4_EXECUTE=ACCESS4_EXECUTE = 0x0020; struct ACCESS4args { /* CURRENT_FH: object */uint32_taccess;uint32_t access; }; RESULT struct ACCESS4resok {uint32_taccess;uint32_t supported; uint32_t access; }; union ACCESS4res switch (nfsstat4 status) { case NFS4_OK:ACCESS4resokresok;ACCESS4resok resok; default: void; }; DESCRIPTION ACCESS determines the access rights that a user, as identified by the credentials in the request, has with respect to a file system object. The client encodes the set ofpermissionsaccess rights that are to be checked in a bit mask. The server checks the permissions encoded in the bit mask.AIf a status of NFS4_OK isreturned along with areturned, two bitmask encoded with the permissions that the client is allowed.masks Expires:December 1999March 2000 [Page50]78] Draft Protocol Specification NFS version 4JuneSeptember 1999 are included in the response. The first represents the access rights for which the server can verify reliably for the user. The second represents the access rights available to the user for the filehandle provided. The results of this procedure are necessarily advisory in nature. That is, a return status of NFS4_OK and the appropriate bit set in the bit mask does not imply that such access will be allowed to the file system object in the future, as access rights can be revoked by the server at any time. The following access permissions may be requested: ACCESS_READ: bit 1 Read data from file or read a directory.ACCESS_MODIFY: bit 2 Rewrite existing file data or modify existing directory entries.ACCESS_LOOKUP: bit32 Look up a name in a directory (no meaning for non-directory objects). ACCESS_MODIFY: bit 3 Rewrite existing file data or modify existing directory entries. ACCESS_EXTEND: bit 4 Write new data or add directory entries. ACCESS_DELETE: bit 5 Delete an existing directory entry. ACCESS_EXECUTE: bit 6 Execute file (no meaning for a directory).The server must return an error if the any access permission cannot be determined.IMPLEMENTATION In general, it is not sufficient for the client to attempt to deduce access permissions by inspecting the uid, gid, and mode fields in the file attributes, since the server may perform uid or gid mapping or enforce additional access control restrictions. It is also possible that the NFS version 4 protocol server may not be in the same ID space as the NFS version 4 protocol client. In these cases (and perhaps others), the NFS version 4 protocol client can not reliably perform an access check with only current file attributes. In the NFS version 2 protocol, the only reliable way to determine whether an operation was allowed was to try it and see if it succeeded or failed. Using the ACCESS procedure in the NFS version 4 protocol, the client can ask the server to indicate whether or Expires: March 2000 [Page 79] Draft Protocol Specification NFS version 4 September 1999 not one or more classes of operations are permitted. The ACCESS operation is provided to allow clients to check before doing aExpires: December 1999 [Page 51] Draft Protocol Specification NFS version 4 June 1999series of operations. This is useful in operating systems (such as UNIX) where permission checking is done only when a directory is opened. This procedure is also invoked by NFS client access procedure (called possibly through access(2)). The intent is to make the behavior of opening a remote file more consistent with the behavior of opening a local file. For NFS version 4, the use of the ACCESS procedure when opening a regular file is deprecated in favor of using OPEN. The information returned by the server in response to an ACCESS call is not permanent. It was correct at the exact time that the server performed the checks, but not necessarily afterwards. The server can revoke access permission at any time. The NFS version 4 protocol client should use the effective credentials of the user to build the authentication information in the ACCESS request used to determine access rights. It is the effective user and group credentials that are used in subsequent read and write operations. Many implementations do not directly support the ACCESS_DELETE permission. Operating systems like UNIX will ignore the ACCESS_DELETE bit if set on an access request on a non-directory object. In these systems, delete permission on a file is determined by the access permissions on the directory in which the file resides, instead of being determined by the permissions of the file itself.Thus,Therefore thebitmask returnedfor such a requestenumerating which access rights can be determined will have the ACCESS_DELETEbitvalue set to0, indicating that0. This indicates to the clientdoes not have this permission.that the server was unable to check that particular access right. The ACCESS_DELETE bit in the access mask returned will then be ignored by the client. ERRORS NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_SERVERFAULT NFS4ERR_STALE NFS4ERR_BADHANDLE Expires: March 2000 [Page 80] Draft Protocol Specification NFS version 4 September 1999 NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page52]81] Draft Protocol Specification NFS version 4JuneSeptember 199910.4. Procedure12.2.2. Operation 3: CLOSE - Close File SYNOPSIS (cfh), stateid -> stateid ARGUMENT struct CLOSE4args {stateid4stateid;stateid4 stateid; }; RESULT union CLOSE4res switch (nfsstat4 status) { case NFS4_OK:stateid4stateid;stateid4 stateid; default: void; }; DESCRIPTION The CLOSE procedure notifies the server that all share reservations corresponding to the client supplied stateid should be released. IMPLEMENTATION Share reservations for the matching stateid will be released on successful completion of the CLOSE procedure. ERRORS NFS4ERR_INVAL NFS4ERR_STALE NFS4ERR_BADHANDLE Expires:December 1999March 2000 [Page53]82] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_SERVERFAULT NFS4ERR_EXPIRED NFS4ERR_GRACE NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page54]83] Draft Protocol Specification NFS version 4JuneSeptember 199910.5. Procedure12.2.3. Operation 4: COMMIT - Commit Cached Data SYNOPSIS (cfh), offset, count -> verifier ARGUMENT struct COMMIT4args { /* CURRENT_FH: file */offset4offset; count4count;offset4 offset; count4 count; }; RESULT struct COMMIT4resok {writeverf4verf;writeverf4 verf; }; union COMMIT4res switch (nfsstat4 status) { case NFS4_OK:COMMIT4resokresok4;COMMIT4resok resok4; default: void; }; DESCRIPTION The COMMIT procedure forces or flushes data to stable storage that was previously written with a WRITE operation which had the stable field set to UNSTABLE4. The offset provided by the client represents the position within the file at which the flush is to begin. An offset value of 0 (zero) means to flush data starting at the beginning of the file. The count as provided by the client is the number of bytes of data to flush. If count is 0 (zero), a flush from offset to the end of file is done. The server returns a write verifier upon successful completion of the COMMIT. The write verifier is used by the client to determine if the server has restarted or rebooted between the initial Expires:December 1999March 2000 [Page55]84] Draft Protocol Specification NFS version 4JuneSeptember 1999 WRITE(s) and the COMMIT. The client does this by comparing the write verifier returned from the initial writes and the verifier returned by the COMMIT procedure. The server must vary the value of the write verifier at each server event that may lead to a loss of uncommitted data. Most commonly this occurs when the server is rebooted; however, other events at the server may result in uncommitted data loss as well. IMPLEMENTATION The COMMIT procedure is similar in operation and semantics to the POSIX fsync(2) system call that synchronizes a file's state with the disk (file data and metadata is flushed to disk or stable storage). COMMIT performs the same operation for a client, flushing any unsynchronized data and metadata on the server to the server's disk or stable storage for the specified file. Like fsync(2), it may be that there is some modified data or no modified data to synchronize. The data may have been synchronized by the server's normal periodic buffer synchronization activity. COMMIT should return NFS4_OK, unless there has been an unexpected error. COMMIT differs from fsync(2) in that it is possible for the client to flush a range of the file (most likely triggered by a buffer- reclamation scheme on the client before file has been completely written). The server implementation of COMMIT is reasonably simple. If the server receives a full file COMMIT request, that is starting at offset 0 and count 0, it should do the equivalent of fsync()'ing the file. Otherwise, it should arrange to have the cached data in the range specified by offset and count to be flushed to stable storage. In both cases, any metadata associated with the file must be flushed to stable storage before returning. It is not an error for there to be nothing to flush on the server. This means that the data and metadata that needed to be flushed have already been flushed or lost during the last server failure. The client implementation of COMMIT is a little more complex. There are two reasons for wanting to commit a client buffer to stable storage. The first is that the client wants to reuse a buffer. In this case, the offset and count of the buffer are sent to the server in the COMMIT request. The server then flushes any cached data based on the offset and count, and flushes any metadata associated with the file. It then returns the status of the flush and the write verifier. The other reason for the client to generate a COMMIT is for a full file flush, such as may be done at Expires:December 1999March 2000 [Page56]85] Draft Protocol Specification NFS version 4JuneSeptember 1999 close. In this case, the client would gather all of the buffers for this file that contain uncommitted data, do the COMMIT operation with an offset of 0 and count of 0, and then free all of those buffers. Any other dirty buffers would be sent to the server in the normal fashion. After a buffer is written by the client with stable parameter set to UNSTABLE, the buffer must be considered as modified by the client until the buffer has either been flushed via a COMMIT operation or written via a WRITE operation with stable parameter set to FILE_SYNC or DATA_SYNC. This is done to prevent the buffer from being freed and reused before the data can be flushed to stable storage on the server. When a response comes back from either a WRITE or a COMMIT operation and it contains a write verifier that is different than previously returned by the server, the client will need to retransmit all of the buffers containing uncommitted cached data to the server. How this is to be done is up to the implementor. If there is only one buffer of interest, then it should probably be sent back over in a WRITE request with the appropriate stable parameter. If there is more than one buffer, it might be worthwhile retransmitting all of the buffers in WRITE requests with the stable parameter set to UNSTABLE and then retransmitting the COMMIT operation to flush all of the data on the server to stable storage. The timing of these retransmissions is left to the implementor. The above description applies to page-cache-based systems as well as buffer-cache-based systems. In those systems, the virtual memory system will need to be modified instead of the buffer cache. ERRORS NFS4ERR_IO NFS4ERR_LOCKED NFS4ERR_SERVERFAULT NFS4ERR_MOVED Expires:December 1999March 2000 [Page57]86] Draft Protocol Specification NFS version 4JuneSeptember 199910.6. Procedure12.2.4. Operation 5: CREATE - Create a Non-Regular File Object SYNOPSIS (cfh), name, type, how ->(cfh)(cfh), change_info ARGUMENT struct CREATE4args { /* CURRENT_FH: directory for creation */filename4objname; fattr4_typetype; createhow4createhow;component4 objname; fattr4_type type; createhow4 createhow; }; RESULT struct change_info4 { bool atomic; fattr4_change before; fattr4_change after; }; struct CREATE4resok { change_info4 cinfo; }; union CREATE4res switch (nfsstat4 status) {nfsstat4status;case NFS4_OK: CREATE4resok resok4; default: void; }; DESCRIPTION The CREATE procedure creates an non-regular file object in a directory with a given name. The OPEN procedure MUST be used to create a regular file. The need for exclusive create semantics for non-regular Expires: March 2000 [Page 87] Draft Protocol Specification NFS version 4 September 1999 files needs to be decided upon and decisions about storage location of the verifier will need to be determined as well. The objtype determines the type of object to be created: directory, symlink, etc. The how union may have a value of UNCHECKED, GUARDED, and EXCLUSIVE. UNCHECKED means that the object should be created without checking for the existence of a duplicate object in the same directory. In this case, attrbits and attrvals describe the initial attributes for the file object. GUARDED specifies that the server should check for the presence of a duplicate object before performing the create and should fail the request with NFS4ERR_EXIST if a duplicate object exists. If the object does not exist, the request isExpires: December 1999 [Page 58] Draft Protocol Specification NFS version 4 June 1999performed as described for UNCHECKED. EXCLUSIVE specifies that the server is to follow exclusive creation semantics, using the verifier to ensure exclusive creation of the target. No attributes may be provided in this case, since the server may use the target object meta-data to store the verifier. For the directory where the new file object was created, the server returns change_info4 information in cinfo. With the atomic field of the change_info4 struct, the server will indicate if the before and after change attributes were obtained atomically with respect to the file object creation. The current filehandle is replaced by that of the new object. IMPLEMENTATION The CREATE procedure carries support for EXCLUSIVE create forward from NFS version 3. As in NFS version 3, this mechanism provides reliable exclusive creation. Exclusive create is invoked when the how parameter is EXCLUSIVE. In this case, the client provides a verifier that can reasonably be expected to be unique. A combination of a client identifier, perhaps the client network address, and a unique number generated by the client, perhaps the RPC transaction identifier, may be appropriate. If the object does not exist, the server creates the object and stores the verifier in stable storage. For file systems that do not provide a mechanism for the storage of arbitrary file attributes, the server may use one or more elements of the object meta-data to store the verifier. The verifier must be stored in stable storage to prevent erroneous failure on retransmission of the request. It is assumed that an exclusive create is being performed because exclusive semantics are critical to the application. Because of the Expires: March 2000 [Page 88] Draft Protocol Specification NFS version 4 September 1999 expected usage, exclusive CREATE does not rely solely on the normally volatile duplicate request cache for storage of the verifier. The duplicate request cache in volatile storage does not survive a crash and may actually flush on a long network partition, opening failure windows. In the UNIX local file system environment, the expected storage location for the verifier on creation is the meta-data (time stamps) of the object. For this reason, an exclusive object create may not include initial attributes because the server would have nowhere to store the verifier. If the server can not support these exclusive create semantics, possibly because of the requirement to commit the verifier to stable storage, it should fail the CREATE request with the error, NFS4ERR_NOTSUPP. During an exclusive CREATE request, if the object already exists, the server reconstructs the object's verifier and compares it with the verifier in the request. If they match, the server treats the request as a success. The request is presumed to be a duplicate of an earlier, successful request for which the reply was lost and that the server duplicate request cache mechanism did not detect.Expires: December 1999 [Page 59] Draft Protocol Specification NFS version 4 June 1999If the verifiers do not match, the request is rejected with the status, NFS4ERR_EXIST. Once the client has performed a successful exclusive create, it must issue a SETATTR to set the correct object attributes. Until it does so, it should not rely upon any of the object attributes, since the server implementation may need to overload object meta- data to store the verifier. Use of the GUARDED attribute does not provide exactly-once semantics. In particular, if a reply is lost and the server does not detect the retransmission of the request, the procedure can fail with NFS4ERR_EXIST, even though the create was performed successfully. Note: 1. Need to determine an initial set of attributes that must be set, and a set of attributes that can optionally be set, on a per-filetype basis. For instance, if the filetype is a NF4BLK then the device attributes must be set. 2. Need to consider the symbolic link path as an "attribute". No need for a READLINK op Expires: March 2000 [Page 89] Draft Protocol Specification NFS version 4 September 1999 if this is so. Similarly, a filehandle could be defined as an attribute for LINK. ERRORS NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_EXIST NFS4ERR_NOTDIR NFS4ERR_INVAL NFS4ERR_NOSPC NFS4ERR_ROFS NFS4ERR_NAMETOOLONG NFS4ERR_DQUOT NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page60]90] Draft Protocol Specification NFS version 4JuneSeptember 1999NFS4ERR_NAMETOOLONG NFS4ERR_DQUOT NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC12.2.5. Operation 6: DELEGPURGE - Purge Delegations Awaiting Recovery SYNOPSIS clientid -> ARGUMENT struct DELEGPURGE4args { clientid4 clientid; }; RESULT struct DELEGPURGE4res { nfsstat4 status; }; DESCRIPTION Purges all of the delegations awaiting recovery for a given client. This is useful for clients which do not commit delegation information to stable storage to indicate that conflicting requests need not be held up awaiting recovery of delegation information. This operation should also be used by clients which do have delegation information on stable storage after doing all of delegation recovery that is needed. Using DELEGPURGE will prevent any delegations which were made by the server but were not sent to the client and committed to stable storage from holding up other clients making conflicting requests. ERRORS <TBD> Expires:DecemberMarch 2000 [Page 91] Draft Protocol Specification NFS version 4 September 1999 12.2.6. Operation 7: DELEGRETURN - Return Delegation SYNOPSIS stateid -> ARGUMENT struct DELEGRETURN4args { stateid4 stateid; }; RESULT struct DELEGRETURN4res { nfsstat4 status; }; DESCRIPTION Returns the delegation represented by the given stateid ERRORS <TBD> Expires: March 2000 [Page61]92] Draft Protocol Specification NFS version 4JuneSeptember 199910.7. Procedure 6:12.2.7. Operation 8: GETATTR - Get Attributes SYNOPSIS (cfh), attrbits -> attrbits, attrvals ARGUMENT struct GETATTR4args { /* CURRENT_FH: directory or file */ bitmap4 attr_request; }; RESULT struct GETATTR4resok { fattr4 obj_attributes; }; union GETATTR4res switch (nfsstat4 status) { case NFS4_OK:GETATTR4resokresok4;GETATTR4resok resok4; default: void; }; DESCRIPTION The GETATTR procedure will obtain attributes from the server. The client sets a bit in the bitmap argument for each attribute value that it would like the server to return. The server returns an attribute bitmap that indicates the attribute values for which it was able to return, followed by the attribute values ordered lowest attribute number first. The server must return a value for each attribute that the client requests if the attribute is supported by the server. If the server does not support an attribute or cannot approximate a useful value then it must not return the attribute value and must not set the attribute bit in the result bitmap. The server must return an error if it supports an attribute but cannot obtain its value. In that case no attribute values will be returned. Expires:December 1999March 2000 [Page62]93] Draft Protocol Specification NFS version 4JuneSeptember 1999 All servers must support attribute 0 (zero) which is a bitmap of all supported attributes for the filesystem object. IMPLEMENTATION ERRORS NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_INVAL NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_SERVERFAULT NFS4ERR_JUKEBOX NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page63]94] Draft Protocol Specification NFS version 4JuneSeptember 199910.8. Procedure 7:12.2.8. Operation 9: GETFH - Get Current Filehandle SYNOPSIS (cfh) -> filehandle ARGUMENT /* CURRENT_FH: */ void; RESULT struct GETFH4resok { nfs4_fh object; }; union GETFH4res switch (nfsstat4 status) { case NFS4_OK:GETFH4resokresok4;GETFH4resok resok4; default: void; }; DESCRIPTION Returns the current filehandle. Operations that change the current filehandle like LOOKUP or CREATE to not automatically return the new filehandle as a result. For instance, if a client needs to lookup a directory entry and obtain its filehandle then the following request is needed. 1: PUTFH (directory filehandle) 2: LOOKUP (entry name) 3: GETFH IMPLEMENTATION Expires:December 1999March 2000 [Page64]95] Draft Protocol Specification NFS version 4JuneSeptember 1999 ERRORS NFS4ERR_BADHANDLE NFS4ERR_FHEXPIRED NFS4ERR_MOVED NFS4ERR_NOFILEHANDLE NFS4ERR_SERVERFAULT NFS4ERR_STALE NFS4ERR_WRONGSEC Expires:December 1999March 2000 [Page65]96] Draft Protocol Specification NFS version 4JuneSeptember 199910.9. Procedure 8:12.2.9. Operation 10: LINK - Create Link to a File SYNOPSIS (cfh), directory, newname ->(cfh)(cfh), change_info ARGUMENT struct LINK4args { /* CURRENT_FH: file */ nfs4_fh dir;filename4component4 newname; }; RESULT struct LINK4resok { change_info4 cinfo; }; union LINK4res switch (nfsstat4 status) {nfsstat4status;case NFS4_OK: LINK4resok resok4; default: void; }; DESCRIPTION The LINK procedure creates an additional newname for the file with the current filehandle in thenewdirectorydirdir. The current file handle andlink.dirthe directory must resideonwithin the same file systemandon the server. For the directory, the server returns change_info4 information in cinfo. With the atomic field of the change_info4 struct, the server will indicate if the before and after change attributes were obtained atomically with respect to the link creation. IMPLEMENTATION Expires: March 2000 [Page 97] Draft Protocol Specification NFS version 4 September 1999 Changes to any property of the hard-linked files are reflected in all of the linked files. When a hard link is made to a file, the attributes for the file should have a value for nlink that is one greater than the value before the LINK. The comments under RENAME regarding object and target residing on the same file system apply here as well. The comments regarding the target name applies as well. ERRORS NFS4ERR_IOExpires: December 1999 [Page 66] Draft Protocol Specification NFS version 4 June 1999NFS4ERR_ACCES NFS4ERR_EXIST NFS4ERR_XDEV NFS4ERR_NOTDIR NFS4ERR_INVAL NFS4ERR_NOSPC NFS4ERR_ROFS NFS4ERR_MLINK NFS4ERR_NAMETOOLONG NFS4ERR_DQUOT NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page67]98] Draft Protocol Specification NFS version 4JuneSeptember 199910.10. Procedure 9:12.2.10. Operation 11: LOCK - Create Lock SYNOPSIS (cfh) type, seqid, reclaim, owner, offset, length -> stateid, access ARGUMENTstruct lockown { clientid4clientid; opaqueowner<>; }; union nfs_lockowner switch (stateid4 stateid) { case 0: lockownident; default: void; };enum nfs4_lock_type { READ_LT = 1, WRITE_LT = 2, READW_LT =3,/*3, /* blocking read */ WRITEW_LT =4/*4 /* blocking write */ }; struct LOCK4args { /* CURRENT_FH: file */nfs4_lock_typetype; seqid4seqid; boolreclaim; nfs_lockownerowner; offset4offset; length4length;nfs4_lock_type type; seqid4 seqid; bool reclaim; stateid4 stateid; offset4 offset; length4 length; }; RESULT struct lockres {stateid4stateid; int32_taccess;stateid4 stateid; int32_t access; };Expires: December 1999 [Page 68] Draft Protocol Specification NFS version 4 June 1999union LOCK4res switch (nfsstat4 status) { case NFS4_OK:lockresresult;lockres result; default: void; }; DESCRIPTION Expires: March 2000 [Page 99] Draft Protocol Specification NFS version 4 September 1999 The LOCK procedure requests a record lock for the byte range specified by the offset and length parameters. The lock type is also specified to be one of the nfs4_lock_types. If this is a reclaim request, the reclaim parameter will be TRUE; IMPLEMENTATION The File Locking section contains a full description of this and the other file locking procedures. ERRORS NFS4ERR_ACCES NFS4ERR_ISDIR NFS4ERR_INVAL NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_SERVERFAULT NFS4ERR_GRACE NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page69]100] Draft Protocol Specification NFS version 4JuneSeptember 199910.11. Procedure 10:12.2.11. Operation 12: LOCKT - Test For Lock SYNOPSIS (cfh) type, seqid, reclaim, owner, offset, length -> {void, NFS4ERR_DENIED -> owner} ARGUMENT struct LOCK4args { /* CURRENT_FH: file */nfs4_lock_typetype; seqid4seqid; boolreclaim; nfs_lockownerowner; offset4offset; length4length;nfs4_lock_type type; seqid4 seqid; bool reclaim; nfs_lockowner owner; offset4 offset; length4 length; }; RESULT union LOCKT4res switch (nfsstat4 status) { case NFS4ERR_DENIED:nfs_lockownerowner;nfs_lockowner owner; case NFS4_OK: void; default: void; }; DESCRIPTION The LOCKT procedure tests the lock as specified in the argument. The owner of the lock is returned in the event it is currently being held; if no lock is held, nothing other than NFS4_OK is returned. IMPLEMENTATION The File Locking section contains a full description of this and the other file locking procedures. Expires:December 1999March 2000 [Page70]101] Draft Protocol Specification NFS version 4JuneSeptember 1999 ERRORS NFS4ERR_ACCES NFS4ERR_ISDIR NFS4ERR_INVAL NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_SERVERFAULT NFS4ERR_DENIED NFS4ERR_GRACE NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page71]102] Draft Protocol Specification NFS version 4JuneSeptember 199910.12. Procedure 11:12.2.12. Operation 13: LOCKU - Unlock File SYNOPSIS (cfh) type, seqid, reclaim, owner, offset, length -> stateid ARGUMENT struct LOCK4args { /* CURRENT_FH: file */nfs4_lock_typetype; seqid4seqid; boolreclaim; nfs_lockownerowner; offset4offset; length4length;nfs4_lock_type type; seqid4 seqid; bool reclaim; nfs_lockowner owner; offset4 offset; length4 length; }; RESULT union LOCKU4res switch (nfsstat4 status) {caseNFS4_OK: stateid4stateid_ok;case NFS4_OK: stateid4 stateid_ok; default:stateid4stateid_oth;stateid4 stateid_oth; }; DESCRIPTION The LOCKU procedure unlocks the record lock specified by the parameters. IMPLEMENTATION The File Locking section contains a full description of this and the other file locking procedures. ERRORS NFS4ERR_ACCES Expires:December 1999March 2000 [Page72]103] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_ISDIR NFS4ERR_INVAL NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_SERVERFAULT NFS4ERR_GRACE NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page73]104] Draft Protocol Specification NFS version 4JuneSeptember 199910.13. Procedure 12:12.2.13. Operation 14: LOOKUP - Lookup Filename SYNOPSIS (cfh), filenames -> (cfh) ARGUMENT struct LOOKUP4args { /* CURRENT_FH: directory */filename4 filenames<>;pathname4 path; }; RESULT struct LOOKUP4res { /* CURRENT_FH: object */nfsstat4status;nfsstat4 status; }; DESCRIPTION The current filehandle is assumed to refer to a directory. LOOKUP evaluates the pathname contained in the array of names and obtains a new current filehandle from the final name. All but the final name in the list must be the names of directories. If the pathname cannot be evaluated either because a component doesn't exist or because the client doesn't have permission to evaluate a component of the path, then an error will be returned and the current filehandle will be unchanged. IMPLEMENTATION If the client prefers a partial evaluation of the path then a sequence of LOOKUP operations can be substituted e.g. 1. PUTFH (directory filehandle) 2. LOOKUP "pub" "foo" "bar" 3. GETFH Expires:December 1999March 2000 [Page74]105] Draft Protocol Specification NFS version 4JuneSeptember 1999 or 1. PUTFH (directory filehandle) 2. LOOKUP "pub" 3. GETFH 4. LOOKUP "foo" 5. GETFH 6. LOOKUP "bar" 7. GETFH NFS version 4 servers depart from the semantics of previous NFS versions in allowing LOOKUP requests to cross mountpoints on the server. The client can detect a mountpoint crossing by comparing the fsid attribute of the directory with the fsid attribute of the directory looked up. If the fsids are different then the new directory is a server mountpoint. Unix clients that detect a mountpoint crossing will need to mount the server's filesystem. Servers that limit NFS access to "shares" or "exported" filesystems should provide a pseudo-filesystem into which the exported filesystems can be integrated, so that clients can browse the server's namespace. The clients view of a pseudo filesystem will be limited to paths that lead to exported filesystems. Note: previous versions of the protocol assigned special semantics to the names "." and "..". NFS version 4 assigns no special semantics to these names. The LOOKUPP operator must be used to lookup a parent directory. Note that this procedure does not follow symbolic links. The client is responsible for all parsing of filenames including filenames that are modified by symbolic links encountered during the lookup process. ERRORS NFS4ERR_NOENT NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_NOTDIR NFS4ERR_INVAL NFS4ERR_NAMETOOLONG Expires:December 1999March 2000 [Page75]106] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_STALE NFS4ERR_SERVERFAULT NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page76]107] Draft Protocol Specification NFS version 4JuneSeptember 199910.14. Procedure 13:12.2.14. Operation 15: LOOKUPP - Lookup Parent Directory SYNOPSIS (cfh) -> (cfh) ARGUMENT /* CURRENT_FH: object */ void; RESULT struct LOOKUPP4res { /* CURRENT_FH: directory */nfsstat4status;nfsstat4 status; }; DESCRIPTION The current filehandle is assumed to refer to a directory. LOOKUPP assigns the filehandle for its parent directory to be the current filehandle. If there is no parent directory an ENOENT error must be returned. Therefore, ENOENT will be returned by the server when the current filehandle is at the root or top of the server's file tree. IMPLEMENTATION As for LOOKUP, LOOKUPP will also cross mountpoints. ERRORS NFS4ERR_NOENT NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_INVALNFS4ERR_STALEExpires:December 1999March 2000 [Page77]108] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_STALE NFS4ERR_SERVERFAULT NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page78]109] Draft Protocol Specification NFS version 4JuneSeptember 199910.15. Procedure 14:12.2.15. Operation 16: NVERIFY - Verify Difference in Attributes SYNOPSIS (cfh), attrbits, attrvals -> - ARGUMENT struct NVERIFY4args { /* CURRENT_FH: object */ bitmap4 attr_request; fattr4 obj_attributes; }; RESULT struct NVERIFY4res {nfsstat4status;nfsstat4 status; }; DESCRIPTION This operation is used to prefix a sequence of operations to be performed if one or more attributes have changed on some filesystem object. If all the attributes match then the error NFS4ERR_SAME must be returned. IMPLEMENTATION This operation is useful as a cache validation operator. If the object to which the attributes belong has changed then the following operations may obtain new data associated with that object. For instance, to check if a file has been changed and obtain new data if it has: 1. PUTFH (public) 2. LOOKUP "pub" "foo" "bar" 3. NVERIFY attrbits attrs 4. READ 0 32767 Expires:December 1999March 2000 [Page79]110] Draft Protocol Specification NFS version 4JuneSeptember 1999 ERRORS NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_SERVERFAULT NFS4ERR_FHEXPIRED NFS4ERR_SAME NFS4ERR_MOVED Expires:December 1999March 2000 [Page80]111] Draft Protocol Specification NFS version 4JuneSeptember 199910.16. Procedure 15:12.2.16. Operation 17: OPEN - Open a Regular File SYNOPSIS (cfh),file,claim, openhow, owner, seqid,reclaim,access, deny -> (cfh), stateid,accessrflags, access, delegation ARGUMENT struct OPEN4args {open_nameorfh file;open_claim4 claim; openflag openhow; nfs_lockowner owner; seqid4 seqid;bool reclaim;int32_t access; int32_t deny; };union open_nameoffh switch (bool reclaim_fh) { case FALSE: /* CURRENT_FH: directory */ filename4 filenames<>; case TRUE: /* CURRENT_FH: file on reclaim */ void; };enum createmode4 { UNCHECKED = 0, GUARDED = 1, EXCLUSIVE = 2 }; union createhow4 switch (createmode4 mode) { case UNCHECKED: case GUARDED: fattr4 createattrs; case EXCLUSIVE: createverf4 verf; }; enum opentype4 {OPEN4_NOCREATE0, OPEN4_CREATE1OPEN4_NOCREATE 0, OPEN4_CREATE 1 }; union openflag switch (opentype4 opentype) { case OPEN4_CREATE: createhow4 how; default: void; }; /* * Access and Deny constants for open argument */ Expires:DecemberMarch 2000 [Page 112] Draft Protocol Specification NFS version 4 September 1999 const OPEN4_ACCESS_READ = 0x0001; const OPEN4_ACCESS_WRITE= 0x0002; const OPEN4_ACCESS_BOTH = 0x0003; const OPEN4_DENY_NONE = 0x0000; const OPEN4_DENY_READ = 0x0001; const OPEN4_DENY_WRITE = 0x0002; const OPEN4_DENY_BOTH = 0x0003; enum open_delegation_type4 { OPEN_DELEGATE_NONE = 0, OPEN_DELEGATE_READ = 1, OPEN_DELEGATE_WRITE = 2 }; enum open_claim_type4 { CLAIM_NULL = 0, CLAIM_PREVIOUS = 1, CLAIM_DELEGATE_CUR = 2, CLAIM_DELEGATE_PREV = 3 }; struct open_claim_delegate_cur { pathname4 file; stateid4 delegate_stateid; }; union open_claim4 switch (open_claim_type4 claim) { /* * No special rights to file. Ordinary OPEN of the specified file. */ case CLAIM_NULL: /* CURRENT_FH: directory */ pathname4 file; /* * Right to the file established by an open previous to server * reboot. File identified by filehandle obtained at that time * rather than by name. */ case CLAIM_PREVIOUS: /* CURRENT_FH: file being reclaimed */ int32_t delegate_type; /* * Right to file based on a delegation granted by the server. * File is specified by name. */ Expires: March 2000 [Page 113] Draft Protocol Specification NFS version 4 September 1999 case CLAIM_DELEGATE_CUR: /* CURRENT_FH: directory */ open_claim_delegate_cur delegate_cur_info; /* Right to file based on a delegation granted to a previous boot * instance of the client. File is specified by name. */ case CLAIM_DELEGATE_PREV: /* CURRENT_FH: directory */ pathname4 file_delegate_prev; }; RESULT /* * Result flags */ /* Mandatory locking is in effect for this file. */ const OPEN4_RESULT_MLOCK = 0x0001; struct open_read_delegation4 { stateid4 stateid; /* Stateid for delegation*/ bool recall; /* Pre-recalled flag for delegations obtained by reclaim (CLAIM_PREVIOUS) */ nfsacl4 permissions; /* Defines users who don't need an ACCESS call to open for read */ }; struct open_write_delegation4 { stateid4 stateid; /* Stateid for delegation be flushed to the server on close. */ bool recall; /* Pre-recalled flag for delegations obtained by reclaim (CLAIM_PREVIOUS) */ nfs_space_limit4 space_limit; /* Defines condition that the client must check to determine whether the file needs to be flushed to the server on close. */ nfsacl4 permissions; /* Defines users who don't Expires: March 2000 [Page81]114] Draft Protocol Specification NFS version 4JuneSeptember 1999 need an ACCESS call as part of a delegated open. */ }; unionopenflagopen_delegation4 switch(opentype4 opentype)(open_delegation_type4 delegation_type) { caseOPEN4_CREATE: createhow4how; default:OPEN_DELEGATE_NONE: void; case OPEN_DELEGATE_READ: OPEN4readDelegation read; case OPEN_DELEGATE_WRITE: OPEN4writeDelegation write; }; struct OPEN4resok { stateid4 stateid; /* Stateid for open */ uint32_t rflags; /* Result flags */ int32_t access; /**Accessand Deny constants forgranted */ open_delegation4 delegation; /* Info on any openargumentdelegation */const OPEN4_ACCESS_READ = 0x0001; const OPEN4_ACCESS_WRITE= 0x0002; const OPEN4_ACCESS_BOTH = 0x0003; const OPEN4_DENY_NONE = 0x0000; const OPEN4_DENY_READ = 0x0001; const OPEN4_DENY_WRITE = 0x0002; const OPEN4_DENY_BOTH = 0x0003; RESULT}; union OPEN4res switch (nfsstat4 status) { case NFS4_OK: /* CURRENT_FH: opened file */LOCK4resresok;OPEN4resok result; default: void; }; DESCRIPTION The OPEN procedure creates and/or opens a regular file in a directory with the provided name. If the file does not exist at the server and creation is desired, specification of the method of creation is provided by the openhow parameter. The client has the choice of three creation methods: UNCHECKED, GUARDED, or EXCLUSIVE. UNCHECKED means that the file should be created without checking for the existence of a duplicate object in the same directory. For this type of create, createattrs specifies the initial set of attributes for the file (NOTE: need to define exactly which attributes should be set and if the file exists, should the attributes be modified if the file exists). If GUARDED is specified, the server checks for the presence of a duplicate object Expires:December 1999March 2000 [Page82]115] Draft Protocol Specification NFS version 4JuneSeptember 1999 by name before performing the create. If a duplicate exists, an error of NFS4ERR_EXIST is returned as the status. If the object does not exist, the request is performed as described for UNCHECKED. EXCLUSIVE specifies that the server is to follow exclusive creation semantics, using the verifier to ensure exclusive creation of the target. The server should check for the presence of a duplicate object by name. If the object does not exist, the server creates the object and stores the verifier with the object. If the object does exist and the stored verifier matches the client provided verifier, the server uses the existing object as the newly created object. If the stored verifier does not match, then an error of NFS4ERR_EXIST is returned. No attributes may be provided in this case, since the server may use an attribute of the target object to store the verifier. (NOTE: does a specific attribute need to be specified for storage of verifier ) Upon successful creation, the current filehandle is replaced by that of the new object. The OPEN procedure provides for DOS SHARE capability with the use of the access and deny fields of the OPEN arguments. The client specifies at OPEN the required access and deny modes. For clients that do not directly support SHAREs (i.e. Unix), the expected deny value is DENY_NONE. In the case that there is a existing SHARE reservation that conflicts with the OPEN request, the server returns the error NFS4ERR_DENIED. For a complete SHARE request, the client must provide values for the owner and seqid fields for the OPEN argument. For additional discussion of SHARE semantics see the section on 'Share Reservations'. In the case that the client is recovering state from a server failure, the reclaim field of the OPEN argument isuseused to signify that the request is meant to reclaim state previously held. Thefile"claim" field of the OPEN argumentallows the clientis used to specifyan open by name or by filehandle. The filehandle MAY onlythe file to bespecified inopened and thecase thatstate information which theOPENclient claims to possess. There are four basic claim types which cover the various situations for an OPEN. They are as follows: CLAIM_NULL For the client, this is areclaim request. Itnew OPEN request and there isexpected that ifno previous state associate with the file for the client. Expires: March 2000 [Page 116] Draft Protocol Specification NFS version 4 September 1999 CLAIM_PREVIOUS The client is claiming basic OPEN state for a file that was held previous to a server reboot. Generally used when a server isprovidingreturning persistentfilehandles,file handles; the clientwillmay not have the filenames savedname torequest areclaim the OPEN. CLAIM_DELEGATE_CUR The client is claiming a delegation for OPEN as granted byname.the server. Generally this is done as part of recalling a delegation. CLAIM_DELEGATE_PREV The client is claiming a delegation granted to a previous client instance; used after the client reboots. Fornon-reclaimOPEN requests whose claim type is other than CLAIM_PREVIOUS (i.e. requests other than those devoted to reclaiming opens after a server reboot) that reach the server during its grace or lease expiration period, the server returns an error of NFS4ERR_GRACE.Expires: December 1999 [Page 83] Draft Protocol Specification NFS version 4 June 1999For any OPEN request, the server may return an open delegation, which allows further opens and closes to be handled locally on the client as described in the section Open Delegation. Note that delegation is up to the server to decide. The client should never assume that delegation will or will not be granted in a particular instance. It should always be prepared for either case. A partial exception is the reclaim (CLAIM_PREVIOUS) case, in which a delegation type is claimed. In this case, delegation will always be granted, although the server may specify an immediate recall in the delegation structure. IMPLEMENTATION The OPEN procedure contains support for EXCLUSIVE create. The mechanism is similar to the support in NFS version 3 [RFC1813]. As in NFS version 3, this mechanism provides reliable exclusive creation. Exclusive create is invoked when the how parameter is EXCLUSIVE. In this case, the client provides a verifier that can reasonably be expected to be unique. A combination of a client identifier, perhaps the client network address, and a unique number generated by the client, perhaps the RPC transaction identifier, may be appropriate. If the object does not exist, the server creates the object and Expires: March 2000 [Page 117] Draft Protocol Specification NFS version 4 September 1999 stores the verifier in stable storage. For file systems that do not provide a mechanism for the storage of arbitrary file attributes, the server may use one or more elements of the object meta-data to store the verifier. The verifier must be stored in stable storage to prevent erroneous failure on retransmission of the request. It is assumed that an exclusive create is being performed because exclusive semantics are critical to the application. Because of the expected usage, exclusive CREATE does not rely solely on the normally volatile duplicate request cache for storage of the verifier. The duplicate request cache in volatile storage does not survive a crash and may actually flush on a long network partition, opening failure windows. In the UNIX local file system environment, the expected storage location for the verifier on creation is the meta-data (time stamps) of the object. For this reason, an exclusive object create may not include initial attributes because the server would have nowhere to store the verifier. If the server can not support these exclusive create semantics, possibly because of the requirement to commit the verifier to stable storage, it should fail the OPEN request with the error, NFS4ERR_NOTSUPP. During an exclusive CREATE request, if the object already exists, the server reconstructs the object's verifier and compares it with the verifier in the request. If they match, the server treats the request as a success. The request is presumed to be a duplicate of an earlier, successful request for which the reply was lost and that the server duplicate request cache mechanism did not detect. If the verifiers do not match, the request is rejected with the status, NFS4ERR_EXIST. Once the client has performed a successful exclusive create, it must issue a SETATTR to set the correct object attributes. Until it does so, it should not rely upon any of the object attributes,Expires: December 1999 [Page 84] Draft Protocol Specification NFS version 4 June 1999since the server implementation may need to overload object meta- data to store the verifier. The subsequent SETATTR must not occur in the same COMPOUND request as the OPEN. This separation will guarantee that the exclusive create mechanism will continue to function properly in the face of retransmission of the request. Use of the GUARDED attribute does not provide exactly-once semantics. In particular, if a reply is lost and the server does not detect the retransmission of the request, the procedure can fail with NFS4ERR_EXIST, even though the create was performed successfully. For SHARE reservations, the client must specify a value for access Expires: March 2000 [Page 118] Draft Protocol Specification NFS version 4 September 1999 that is one of READ, WRITE, or BOTH. For deny, the client must specify one of NONE, READ, WRITE, or BOTH. If the client fails to do this, the server must return NFS4ERR_INVAL. The OPEN call ERRORS NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_EXIST NFS4ERR_NOTDIR NFS4ERR_NOSPC NFS4ERR_ROFS NFS4ERR_NAMETOOLONG NFS4ERR_DQUOT NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_SHARE_DENIED NFS4ERR_GRACE NFS4ERR_MOVED Expires:December 1999March 2000 [Page85]119] Draft Protocol Specification NFS version 4JuneSeptember 199910.17. Procedure 16:12.2.17. Operation 18: OPENATTR - Open Named Attribute Directory SYNOPSIS (cfh) -> (cfh) ARGUMENT /* CURRENT_FH: file or directory */ void; RESULT struct OPENATTR4res { /* CURRENT_FH: name attr directory*/nfsstat4status;nfsstat4 status; }; DESCRIPTION The OPENATTR procedure is used to obtain the filehandle of the named attribute directory associated with the current filehandle. The result of the OPENATTR will be a filehandle of type NF4ATTRDIR. From this filehandle, READDIR and LOOKUP procedures can be used to obtain filehandles for the various named attributes associated with the original file system object. Filehandles returned within the named attribute directory will have a type of NF4NAMEDATTR. IMPLEMENTATION If the server does not support named attributes for the current filehandle, an error of NFS4ERR_NOTSUPP will be returned to the client. ERRORS NFS4ERR_NOENT NFS4ERR_IO Expires:December 1999March 2000 [Page86]120] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_ACCES NFS4ERR_INVAL NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_JUKEBOX NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page87]121] Draft Protocol Specification NFS version 4JuneSeptember 199910.18. Procedure 17:12.2.18. Operation 19: PUTFH - Set Current Filehandle SYNOPSIS filehandle -> (cfh) ARGUMENT struct PUTFH4args { nfs4_fh object; }; RESULT struct PUTFH4res { /* CURRENT_FH: */nfsstat4status;nfsstat4 status; }; DESCRIPTION Replaces the current filehandle with the filehandle provided as an argument. IMPLEMENTATION Commonly used as the first operator in any NFS request to set the context for following operations. ERRORS NFS4ERR_BADHANDLE NFS4ERR_FHEXPIRED NFS4ERR_MOVED NFS4ERR_SERVERFAULTNFS4ERR_WRONGSECExpires:DecemberMarch 2000 [Page 122] Draft Protocol Specification NFS version 4 September 1999 NFS4ERR_STALE NFS4ERR_WRONGSEC Expires: March 2000 [Page88]123] Draft Protocol Specification NFS version 4JuneSeptember 199910.19. Procedure 18:12.2.19. Operation 20: PUTPUBFH - Set Public Filehandle SYNOPSIS - -> (cfh) ARGUMENT void; RESULT struct PUTPUBFH4res { /* CURRENT_FH: root fh */nfsstat4status;nfsstat4 status; }; DESCRIPTION Replaces the current filehandle with the filehandle that represents the public filehandle of the server's namespace. This filehandle may be different from the "root" filehandle which may be associated with some other directory on the server. IMPLEMENTATION Used as the first operator in any NFS request to set the context for following operations. ERRORS NFS4ERR_SERVERFAULT NFS4ERR_WRONGSEC Expires:December 1999March 2000 [Page89]124] Draft Protocol Specification NFS version 4JuneSeptember 199910.20. Procedure 19:12.2.20. Operation 21: PUTROOTFH - Set Root Filehandle SYNOPSIS - -> (cfh) ARGUMENT void; RESULT struct PUTROOTFH4res { /* CURRENT_FH: root fh */nfsstat4status;nfsstat4 status; }; DESCRIPTION Replaces the current filehandle with the filehandle that represents the root of the server's namespace. From this filehandle a LOOKUP operation can locate any other filehandle on the server. This filehandle may be different from the "public" filehandle which may be associated with some other directory on the server. IMPLEMENTATION Commonly used as the first operator in any NFS request to set the context for following operations. ERRORS NFS4ERR_SERVERFAULT NFS4ERR_WRONTSEC Expires:December 1999March 2000 [Page90]125] Draft Protocol Specification NFS version 4JuneSeptember 199910.21. Procedure 20:12.2.21. Operation 22: READ - Read from File SYNOPSIS (cfh), offset, count, stateid -> eof, data ARGUMENT struct READ4args { /* CURRENT_FH: file */stateid4stateid; offset4offset; count4count;stateid4 stateid; offset4 offset; count4 count; }; RESULT struct READ4resok {booleof; opaquedata<>;bool eof; opaque data<>; }; union READ4res switch (nfsstat4 status) { case NFS4_OK:READ4resokresok4;READ4resok resok4; default: void; }; DESCRIPTION The READ procedure reads data from the regular file identified by the current filehandle. The client provides an offset of where the READ is to start and a count of how many bytes are to be read. An offset of 0 (zero) means to read data starting at the beginning of the file. If offset is greater than or equal to the size of the file, the status, NFS4_OK, is returned with a data length set to 0 (zero) and eof set to TRUE. The READ is subject to access permissions checking. If the client specifies a count value of 0 (zero), the READ Expires:December 1999March 2000 [Page91]126] Draft Protocol Specification NFS version 4JuneSeptember 1999 succeeds and returns 0 (zero) bytes of data again subject to access permissions checking. The server may choose to return fewer bytes than specified by the client. The client needs to check for this condition and handle the condition appropriately. The stateid value for a READ request represents a value returned from a previous record lock or share reservation request. Used by the server to verify that the associated lock is still valid and to update lease timeouts for the client. If the read ended at the end-of-file (formally, in a correctly formed READ request, if offset + count is equal to the size of the file), eof is returned as TRUE; otherwise it is FALSE. A successful READ of an empty file will always return eof as TRUE. IMPLEMENTATION It is possible for the server to return fewer than count bytes of data. If the server returns less than the count requested and eof set to FALSE, the client should issue another READ to get the remaining data. A server may return less data than requested under several circumstances. The file may have been truncated by another client or perhaps on the server itself, changing the file size from what the requesting client believes to be the case. This would reduce the actual amount of data available to the client. It is possible that the server may back off the transfer size and reduce the read request return. Server resource exhaustion may also occur necessitating a smaller read return. If the file is locked the server will return an NFS4ERR_LOCKED error. Since the lock may be of short duration, the client may choose to retransmit the READ request (with exponential backoff) until the operation succeeds. ERRORS NFS4ERR_IO NFS4ERR_NXIO NFS4ERR_ACCES NFS4ERR_INVAL NFS4ERR_STALE Expires:December 1999March 2000 [Page92]127] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_BADHANDLE NFS4ERR_SERVERFAULT NFS4ERR_DENIED NFS4ERR_JUKEBOX NFS4ERR_EXPIRED NFS4ERR_LOCKED NFS4ERR_GRACE NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page93]128] Draft Protocol Specification NFS version 4JuneSeptember 199910.22. Procedure 21:12.2.22. Operation 23: READDIR - Read Directory SYNOPSIS (cfh), cookie, dircount, maxcount, attrbits -> { cookie, filename, attrbits, attributes } ARGUMENT struct READDIR4args { /* CURRENT_FH: directory */nfs_cookie4cookie; count4dircount; count4maxcount; bitmap4attr_request;nfs_cookie4 cookie; count4 dircount; count4 maxcount; bitmap4 attr_request; }; RESULT struct entry4 {nfs_cookie4cookie; filename4name; fattr4attrs; entry4*nextentry;nfs_cookie4 cookie; component4 name; fattr4 attrs; entry4 *nextentry; }; struct dirlist4 {entry4*entries; booleof;entry4 *entries; bool eof; }; struct READDIR4resok {dirlist4reply;dirlist4 reply; }; union READDIR4res switch (nfsstat4 status) { case NFS4_OK:READDIR4resokresok4;READDIR4resok resok4; default: void; }; Expires:December 1999March 2000 [Page94]129] Draft Protocol Specification NFS version 4JuneSeptember 1999 DESCRIPTION The READDIR procedure retrieves a variable number of entries from a file system directory and returns complete information about each entry along with information to allow the client to request additional directory entries in a subsequent READDIR. The arguments contain a cookie value that represents where the READDIR should start within the directory. A value of 0 (zero) for the cookie is used to start reading at the beginning of the directory. For subsequent READDIR requests, the client specifies a cookie value that is provided by the server on a previous READDIR request. The dircount portion of the argument is the maximum number of bytes of directory information that should be returned. This value does not include the size of attributes or filehandle values that may be returned in the result. The maxcount value of the argument specifies the maximum number of bytes for the result. This maximum size represents all of the data being returned and includes the XDR overhead. The server may return less data. Finally, attrbits represents the list of attributes the client wants returned for each directory entry supplied by the server. On successful return, the server's response will provide a list of directory entries. Each of these entries contains the name of the directory entry, a cookie value for that entry and the associated attributes as requested. The cookie value is only meaningful to the server and is used as a "bookmark" for the directory entry. As mentioned, this cookie is used by the client for subsequent READDIR operations so that it may continue reading a directory. The cookie is similar in concept to a READ offset but should not be interpreted as such by the client. Ideally, the cookie value should not change if the directory is modified. IMPLEMENTATION Issues that need to be understood for this procedure include increased cache flushing activity on the client (as new file handles are returned with names which are entered into caches) and over-the-wire overhead versus expected subsequent LOOKUP and GETATTR elimination. The dircount and maxcount fields are included as an optimization. Expires:December 1999March 2000 [Page95]130] Draft Protocol Specification NFS version 4JuneSeptember 1999 Consider a READDIR call on a UNIX operating system implementation for 1048 bytes; the reply does not contain many entries because of the overhead due to attributes and file handles. An alternative is to issue a READDIR call for 8192 bytes and then only use the first 1048 bytes of directory information. However, the server doesn't know that all that is needed is 1048 bytes of directory information (as would be returned by READDIR). It sees the 8192 byte request and issues a VOP_READDIR for 8192 bytes. It then steps through all of those directory entries, obtaining attributes and file handles for each entry. When it encodes the result, the server only encodes until it gets 8192 bytes of results which include the attributes and file handles. Thus, it has done a larger VOP_READDIR and many more attribute fetches than it needed to. The ratio of the directory entry size to the size of the attributes plus the size of the file handle is usually at least 8 to 1. The server has done much more work than it needed to. The solution to this problem is for the client to provide two counts to the server. The first is the number of bytes of directory information that the client really wants, dircount. The second is the maximum number of bytes in the result, including the attributes and file handles, maxcount. Thus, the server will issue a VOP_READDIR for only the number of bytes that the client really wants to get, not an inflated number. This should help to reduce the size of VOP_READDIR requests on the server, thus reducing the amount of work done there, and to reduce the number of VOP_LOOKUP, VOP_GETATTR, and other calls done by the server to construct attributes and file handles. ERRORS NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_NOTDIR NFS4ERR_INVAL NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_BAD_COOKIE NFS4ERR_TOOSMALL Expires:December 1999March 2000 [Page96]131] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_JUKEBOX NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page97]132] Draft Protocol Specification NFS version 4JuneSeptember 199910.23. Procedure 22:12.2.23. Operation 24: READLINK - Read Symbolic Link SYNOPSIS (cfh) -> linktext ARGUMENT /* CURRENT_FH: symlink */ void; RESULT struct READLINK4resok {linktext4link;linktext4 link; }; union READLINK4res switch (nfsstat4 status) { case NFS4_OK:READLINK4resokresok4;READLINK4resok resok4; default: void; }; DESCRIPTION READLINK reads the data associated with a symbolic link. The data is a UTF-8 string that is opaque to the server. That is, whether created by an NFS client or created locally on the server, the data in a symbolic link is not interpreted when created, but is simply stored. IMPLEMENTATION A symbolic link is nominally a pointer to another file. The data is not necessarily interpreted by the server, just stored in the file. It is possible for a client implementation to store a path name that is not meaningful to the server operating system in a symbolic link. A READLINK operation returns the data to the client for interpretation. If different implementations want to share access to symbolic links, then they must agree on the Expires:December 1999March 2000 [Page98]133] Draft Protocol Specification NFS version 4JuneSeptember 1999 interpretation of the data in the symbolic link. The READLINK operation is only allowed on objects of type, NF4LNK. The server should return the error, NFS4ERR_INVAL, if the object is not of type, NF4LNK. ERRORS NFS4ERR_IO NFS4ERR_INVAL NFS4ERR_ACCES NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_JUKEBOX NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page99]134] Draft Protocol Specification NFS version 4JuneSeptember 199910.24. Procedure 23:12.2.24. Operation 25: REMOVE - Remove Filesystem Object SYNOPSIS (cfh), filename ->-change_info ARGUMENT struct REMOVE4args { /* CURRENT_FH: directory */filename4target;component4 target; }; RESULT struct REMOVE4resok { change_info4 cinfo; } union REMOVE4res switch (nfsstat4 status) {nfsstat4status; };case NFS4_OK: REMOVE4resok resok4; default: void; } DESCRIPTION The REMOVE procecure removes (deletes) a directory entry named by filename from the directory corresponding to the current filehandle. If the entry in the directory was the last reference to the corresponding file system object, the object may be destroyed. For the directory where the filename was removed, the server returns change_info4 information in cinfo. With the atomic field of the change_info4 struct, the server will indicate if the before and after change attributes were obtained atomically with respect to the removal. Expires: March 2000 [Page 135] Draft Protocol Specification NFS version 4 September 1999 IMPLEMENTATION NFS versions 2 and 3 required a different operator RMDIR for directory removal. NFS version 4 REMOVE can be used to delete any directory entry independent of its filetype. The concept of last reference is server specific. However, if the nlink field in the previous attributes of the object had the value 1, the client should not rely on referring to the object via a file handle. Likewise, the client should not rely on the resources (disk space, directory entry, and so on.) formerly associated with the object becoming immediately available. Thus, if a client needs to be able to continue to access a file after using REMOVE to remove it, the client should take steps to make sure that the file willExpires: December 1999 [Page 100] Draft Protocol Specification NFS version 4 June 1999still be accessible. The usual mechanism used is to use RENAME to rename the file from its old name to a new hidden name. ERRORS NFS4ERR_NOENT NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_NOTDIR NFS4ERR_ROFS NFS4ERR_NAMETOOLONG NFS4ERR_NOTEMPTY NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page101]136] Draft Protocol Specification NFS version 4JuneSeptember 199910.25. Procedure 24:12.2.25. Operation 26: RENAME - Rename Directory Entry SYNOPSIS (cfh), oldname, newdir, newname ->-source_change_info, target_change_info ARGUMENT struct RENAME4args { /* CURRENT_FH: source directory */filename4oldname; nfs4_fhnewdir; filename4newname;component4 oldname; nfs4_fh newdir; component4 newname; }; RESULT struct RENAME4resok { change_info4 source_cinfo; change_info4 target_cinfo; }; union RENAME4res switch (nfsstat4 status) {nfsstat4status;case NFS4_OK: RENAME4resok resok4; default: void; }; DESCRIPTION RENAME renames the object identified by oldname in the directory corresponding to the current filehandle to newname in directory newdir. The operation is required to be atomic to the client. Source and target directories must reside on the same file system on the server. If the directory, newdir, already contains an entry with the name, newname, the source object must be compatible with the target: either both are non-directories or both are directories and the target must be empty. If compatible, the existing target is removed Expires: March 2000 [Page 137] Draft Protocol Specification NFS version 4 September 1999 before the rename occurs. If they are not compatible or if the target is a directory but not empty, the server should return the error, NFS4ERR_EXIST. If oldname and newname both refer to the same file (they might be hard links of each other), then RENAME should perform no action and return success. For both directories involved in the RENAME, the server returns change_info4 information. With the atomic field of the change_info4 struct, the server will indicate if the before and after change attributes were obtained atomically with respect to the rename. IMPLEMENTATION The RENAME operation must be atomic to the client. The statement "source and target directories must reside on the same file systemExpires: December 1999 [Page 102] Draft Protocol Specification NFS version 4 June 1999on the server" means that the fsid fields in the attributes for the directories are the same. If they reside on different file systems, the error, NFS4ERR_XDEV, is returned. Even though the operation is atomic, the status, NFS4ERR_MLINK, may be returned if the server used a "unlink/link/unlink" sequence internally. A file handle may or may not become stale on a rename. However, server implementors are strongly encouraged to attempt to keep file handles from becoming stale in this fashion. On some servers, the filenames, "." and "..", are illegal as either oldname or newname. In addition, neither oldname nor newname can be an alias for the source directory. These servers will return the error, NFS4ERR_INVAL, in these cases.If oldname and newname both refer to the same file (they might be hard links of each other), then RENAME should perform no action and return success.ERRORS NFS4ERR_NOENT NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_EXIST NFS4ERR_XDEVNFS4ERR_NOTDIR NFS4ERR_ISDIR NFS4ERR_INVAL NFS4ERR_NOSPC NFS4ERR_ROFS NFS4ERR_MLINK NFS4ERR_NAMETOOLONG NFS4ERR_NOTEMPTYExpires:December 1999March 2000 [Page103]138] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_NOTDIR NFS4ERR_ISDIR NFS4ERR_INVAL NFS4ERR_NOSPC NFS4ERR_ROFS NFS4ERR_MLINK NFS4ERR_NAMETOOLONG NFS4ERR_NOTEMPTY NFS4ERR_DQUOT NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page104]139] Draft Protocol Specification NFS version 4JuneSeptember 199910.26. Procedure 25:12.2.26. Operation 27: RENEW - Renew a Lease SYNOPSIS stateid -> () ARGUMENT struct RENEW4args {stateid4stateid;stateid4 stateid; }; RESULT struct RENEW4res {nfsstat4status;nfsstat4 status; }; DESCRIPTION The RENEW procedure is used by the client to renew leases which it currently holds at a server. The processing the RENEW request, the server renews all leases associated with the client. The associated leases are determined by the client id provided via the SETCLIENTID procedure. IMPLEMENTATION ERRORS NFS4ERR_SERVERFAULT NFS4ERR_EXPIRED NFS4ERR_GRACE NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page105]140] Draft Protocol Specification NFS version 4JuneSeptember 199910.27. Procedure 25:12.2.27. Operation 28: RESTOREFH - Restore Saved Filehandle SYNOPSIS (sfh) -> (cfh) ARGUMENT /* SAVED_FH: */ void; RESULT struct RESTOREFH4res { /* CURRENT_FH: value of saved fh */nfsstat4status;nfsstat4 status; }; DESCRIPTION Set the current filehandle to the value in the saved filehandle. If there is no saved filehandle then return an error NFS4ERR_INVAL. IMPLEMENTATION Procedures like OPEN and LOOKUP use the current filehandle to represent a directory and replace it with a new filehandle. Assuming the previous filehandle was saved with a SAVEFH operator, the previous filehandle can be restored as the current filehandle. This is commonly used to obtain post-operation attributes for the directory, e.g. 1. PUTFH (directory filehandle) 2. SAVEFH 3. GETATTR attrbits (pre-op dir attrs) 4. CREATE optbits "foo" attrs 5. GETATTR attrbits (file attributes) 6. RESTOREFH 7. GETATTR attrbits (post-op dir attrs) Expires:December 1999March 2000 [Page106]141] Draft Protocol Specification NFS version 4JuneSeptember 1999 ERRORSNFS4ERR_INVAL NFS4ERR_STALENFS4ERR_BADHANDLENFS4ERR_SERVERFAULTNFS4ERR_FHEXPIRED NFS4ERR_MOVED NFS4ERR_NOFILEHANDLE NFS4ERR_SERVERFAULT NFS4ERR_STALE NFS4ERR_WRONGSEC Expires:December 1999March 2000 [Page107]142] Draft Protocol Specification NFS version 4JuneSeptember 199910.28. Procedure 27:12.2.28. Operation 29: SAVEFH - Save Current Filehandle SYNOPSIS (cfh) -> (sfh) ARGUMENT /* CURRENT_FH: */ void; RESULT struct SAVEFH4res { /* SAVED_FH: value of current fh */nfsstat4status;nfsstat4 status; }; DESCRIPTION Save the current filehandle. If a previous filehandle was saved then it is no longer accessible. The saved filehandle can be restored as the current filehandle with the RESTOREFH operator. IMPLEMENTATION ERRORSNFS4ERR_INVAL NFS4ERR_STALENFS4ERR_BADHANDLENFS4ERR_SERVERFAULTNFS4ERR_FHEXPIREDNFS4ERR_WRONGSECNFS4ERR_MOVED NFS4ERR_NOFILEHANDLE NFS4ERR_SERVERFAULT NFS4ERR_STALE Expires:DecemberMarch 2000 [Page 143] Draft Protocol Specification NFS version 4 September 1999 NFS4ERR_WRONGSEC Expires: March 2000 [Page108]144] Draft Protocol Specification NFS version 4JuneSeptember 199910.29. Procedure 28:12.2.29. Operation 30: SECINFO - Obtain Available Security SYNOPSIS (cfh), filename -> { secinfo } ARGUMENT struct SECINFO4args { /* CURRENT_FH: */filename4name;component4 name; }; RESULT structrpc_flavor_inforpcsec_gss_info {sec_oid4oid; qop4qop;sec_oid4 oid; qop4 qop; rpc_gss_svc_t service; }; struct secinfo4 {rpc_flavor4flavor; rpc_flavor_info *flavor_info; secinfo4*nextentry;unsigned int flavor; opaque flavor_info<>; /* null for AUTH_SYS, AUTH_NONE; contains rpcsec_gss_info for RPCSEC_GSS. */ }; struct SECINFO4resok {secinfo4reply;secinfo4 reply<>; }; union SECINFO4res switch (nfsstat4 status) { case NFS4_OK:SECINFO4resokresok4;SECINFO4resok resok4; default: void; }; DESCRIPTION Expires: March 2000 [Page 145] Draft Protocol Specification NFS version 4 September 1999 The SECINFO procedure is used by the client to obtain a list ofExpires: December 1999 [Page 109] Draft Protocol Specification NFS version 4 June 1999valid RPC authentication flavors for a specific file handle, file name pair. The result will contain an array which represents the security mechanisms available. The array entries are represented by the secinfo4 structure. The field 'flavor' will contain a value of AUTH_NONE, AUTH_SYS (as defined in [RFC1831]), or RPCSEC_GSS (as defined in [RFC2203]). For the flavors, AUTH_NONE,AUTH_SYS, AUTH_DH,andAUTH_KRB4AUTH_SYS no additional security information is returned. For a return value ofAUTH_RPCSEC_GSS,RPCSEC_GSS, a security triple is returned that contains the mechanism object id (as defined in [RFC2078]), the quality of protection (as defined in[RFC 2078])[RFC2078]) and the service type (as defined in [RFC2203]). It is possible for SECINFO to return multiple entries with flavor equal toAUTH_RPCSEC_GSSRPCSEC_GSS with different security triple values. IMPLEMENTATION The SECINFO procedure is expected to be used by the NFS client when the error value of NFS4ERR_WRONGSEC is returned from another NFS procedure. This signifies to the client that the server's security policy is different from what the client is currently using. At this point, the client is expected to obtain a list of possible security flavors and choose what best suits its policies. ERRORS NFS4ERR_SERVERFAULT NFS4ERR_MOVED Expires:December 1999March 2000 [Page110]146] Draft Protocol Specification NFS version 4JuneSeptember 199910.30. Procedure 29:12.2.30. Operation 31: SETATTR - Set Attributes SYNOPSIS (cfh), attrbits, attrvals -> - ARGUMENT struct SETATTR4args { /* CURRENT_FH: target object */ stateid4 stateid; fattr4 obj_attributes; }; RESULT struct SETATTR4res {nfsstat4status;nfsstat4 status; }; DESCRIPTION The SETATTR Procedure changes one or more of the attributes of a file system object. The new attributes are specified with a bitmap and the attributes that follow the bitmap in bit order. The stateid is necessary for SETATTR's that change the size of file (modify the attribute object_size). This stateid represents a record lock, share reservation, or delegation which must be valid for the SETATTR to modify the file data. IMPLEMENTATION The file size attribute is used to request changes to the size of a file. A value of 0 (zero) causes the file to be truncated, a value less than the current size of the file causes data from new size to the end of the file to be discarded, and a size greater than the current size of the file causes logically zeroed data bytes to be added to the end of the file. Servers are free to implement this using holes or actual zero data bytes. Clients should not make any Expires: March 2000 [Page 147] Draft Protocol Specification NFS version 4 September 1999 assumptions regarding a server's implementation of this feature, beyond that the bytes returned will be zeroed. Servers must support extending the file size via SETATTR. SETATTR is not guaranteed atomic. A failed SETATTR may partially change a file's attributes.Expires: December 1999 [Page 111] Draft Protocol Specification NFS version 4 June 1999Changing the size of a file with SETATTR indirectly changes the time_modify. A client must account for this as size changes can result in data deletion. If server and client times differ, programs that compare client time to file times can break. A time maintenance protocol should be used to limit client/server time skew. If the server cannot successfully set all the attributes it must return an NFS4ERR_INVAL error. If the server can only support 32 bit offsets and sizes, a SETATTR request to set the size of a file to larger than can be represented in 32 bits will be rejected with this same error. ERRORS NFS4ERR_PERM NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_INVAL NFS4ERR_FBIG NFS4ERR_NOSPC NFS4ERR_ROFS NFS4ERR_DQUOT NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULTNFS4ERR_JUKEBOX NFS4ERR_DENIED NFS4ERR_GRACE NFS4ERR_FHEXPIREDExpires:December 1999March 2000 [Page112]148] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_JUKEBOX NFS4ERR_DENIED NFS4ERR_GRACE NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires:December 1999March 2000 [Page113]149] Draft Protocol Specification NFS version 4JuneSeptember 199910.31. Procedure 30:12.2.31. Operation 32: SETCLIENTID - Negotiated Clientid SYNOPSIS verifier, client -> clientid ARGUMENT struct cid { opaqueverifier<4>;verifier[4]; opaque id<>; }; union nfs_client_id switch (clientid4 clientid) { case 0:cidident;cid ident; default: void; }; struct SETCLIENTID4args {seqid4seqid; nfs_client_idclient;seqid4 seqid; nfs_client_id client; }; RESULT union SETCLIENTID4res switch (nfsstat4 status) { case NFS4_OK:clientid4clientid;clientid4 clientid; default: void; }; DESCRIPTION The SETCLIENTID procedure introduces the ability of the client to notify the server of its intention to use a particular client identifier and verifier pair. Upon successful completion the server will return a clientid which is used in subsequent file locking requests. Expires:December 1999March 2000 [Page114]150] Draft Protocol Specification NFS version 4JuneSeptember 1999 IMPLEMENTATION The server takes the verifier and client identification supplied and search for a match of the client identification. If no match is found the server saves the principal/uid information along with the verifier and client identification and returns a unique clientid that is used as a short hand reference to the supplied information. If the server find matching client identification and a corresponding match in principal/uid, the server releases all locking state for the client and returns a new clientid. ERRORS NFS4ERR_INVAL NFS4ERR_SERVERFAULT NFS4ERR_CLID_INUSE Expires:December 1999March 2000 [Page115]151] Draft Protocol Specification NFS version 4JuneSeptember 199910.32. Procedure 31:12.2.32. Operation 33: VERIFY - Verify Same Attributes SYNOPSIS (cfh), attrbits, attrvals -> - ARGUMENT struct VERIFY4args { /* CURRENT_FH: object */ bitmap4 attr_request; fattr4 obj_attributes; }; RESULT struct VERIFY4res {nfsstat4status;nfsstat4 status; }; DESCRIPTION The VERIFY procedure is used to verify that attributes have a value assumed by the client before proceeding with following operations in the compound request. For instance, a VERIFY can be used to make sure that the file size has not changed for an append-mode write: 1. PUTFH 0x0123456 2. VERIFY attrbits attrs 3. WRITE 450328 4096 If the attributes are not as expected, then the request fails and the data is not appended to the file. IMPLEMENTATION ERRORS Expires:December 1999March 2000 [Page116]152] Draft Protocol Specification NFS version 4JuneSeptember 1999 NFS4ERR_ACCES NFS4ERR_INVAL NFS4ERR_STALE NFS4ERR_BADHANDLE NFS4ERR_NOTSUPP NFS4ERR_SERVERFAULT NFS4ERR_JUKEBOX NFS4ERR_FHEXPIRED NFS4ERR_MOVED Expires:December 1999March 2000 [Page117]153] Draft Protocol Specification NFS version 4JuneSeptember 199910.33. Procedure 32:12.2.33. Operation 34: WRITE - Write to File SYNOPSIS (cfh), offset, count, stability, stateid, data -> count, committed, verifier ARGUMENT enum stable_how4 { UNSTABLE4 = 0, DATA_SYNC4 = 1, FILE_SYNC4 = 2 }; struct WRITE4args { /* CURRENT_FH: file */stateid4stateid; offset4offset; count4count; stable_how4stable; opaquedata<>;stateid4 stateid; offset4 offset; count4 count; stable_how4 stable; opaque data<>; }; RESULT struct WRITE4resok {count4count; stable_how4committed; writeverf4verf;count4 count; stable_how4 committed; writeverf4 verf; }; union WRITE4res switch (nfsstat4 status) { case NFS4_OK:WRITE4resokresok4;WRITE4resok resok4; default: void; }; DESCRIPTION The WRITE procedure is used to write data to aregular file. Theregular file. The Expires: March 2000 [Page 154] Draft Protocol Specification NFS version 4 September 1999 target file is specified by the current filehandle. The offset specifies the offset where the data should be written. An offset of 0 (zero) specifies that the write should start at the beginning of the file. The count represents the number of bytes of data that are to be written. If the count is 0 (zero), the WRITE will succeed and return a count of 0 (zero) subject to permissions checking. The server may choose to write fewer bytes than requested by the client. Part of the write request is a specification of how the write is to be performed. The client specifies with the stable parameter the method of how the data is to be processed by the server. If stable is FILE_SYNC, the server must commit the data written plus all file system metadata to stable storage before returning results. This corresponds to the NFS version 2 protocol semantics. Any other behavior constitutes a protocol violation. If stable is DATA_SYNC, then the server must commit all of the data to stable storage and enough of the metadata to retrieve the data before returning. The server implementor is free to implement DATA_SYNC in the same fashion as FILE_SYNC, but with a possible performance drop. If stable is UNSTABLE, the server is free to commit any part of the data and the metadata to stable storage, including all or none, before returning a reply to the client. There is no guarantee whether or when any uncommitted data will subsequently be committed to stable storage. The only guarantees made by the server are that it will not destroy any data without changing the value of verf and that it will not commit the data and metadata at a level less than that requested by the client. The stateid returned from a previous record lock or share reservation request is provided as part of the argument. The stateid is used by the server to verify that the associated lock is still valid and to update lease timeouts for the client. Upon successful completion, the following results are returned. The count result is the number of bytes of data written to the file. The server may write fewer bytes than requested. If so, the actual number of bytes written starting at location, offset, is returned. The server also returns an indication of the level of commitment of the data and metadata via committed. If the server committed all data and metadata to stable storage, committed should be set to FILE_SYNC. If the level of commitment was at least as strong as DATA_SYNC, then committed should be set to DATA_SYNC. Otherwise, committed must be returned as UNSTABLE. If stable was FILE_SYNC, then committed must also be FILE_SYNC: anything else constitutes a protocol violation. If stable was DATA_SYNC, then committed may be Expires:December 1999March 2000 [Page118]155] Draft Protocol Specification NFS version 4JuneSeptember 1999target fileFILE_SYNC or DATA_SYNC: anything else constitutes a protocol violation. If stable was UNSTABLE, then committed may be either FILE_SYNC, DATA_SYNC, or UNSTABLE. The final portion of the result isspecified bythecurrent filehandle.write verifier, verf. Theoffset specifieswrite verifier is a cookie that theoffset whereclient can use to determine whether thedata shouldserver has changed state between a call to WRITE and a subsequent call to either WRITE or COMMIT. This cookie must bewritten. An offsetconsistent during a single instance of0 (zero) specifies that the write should start atthebeginningNFS version 4 protocol service and must be unique between instances of thefile. The count represents the number of bytes ofNFS version 4 protocol server, where uncommitted datathat are tomay bewritten.lost. If a client writes data to thecount is 0 (zero),server with theWRITE will succeedstable argument set to UNSTABLE andreturnthe reply yields acountcommitted response of0 (zero) subjectDATA_SYNC or UNSTABLE, the client will follow up some time in the future with a COMMIT operation topermissions checking. Thesynchronize outstanding asynchronous data and metadata with the server's stable storage, barring client error. It is possible that due to client crash or other error that a subsequent COMMIT will not be received by the server. IMPLEMENTATION It is possible for the servermay chooseto write fewerbytesthanrequested by the client. Partcount bytes of data. In this case, the server should not return an error unless no data was written at all. If the server writes less than count bytes, the client should issue another WRITE to writerequestthe remaining data. It is assumed that the act of writing data to aspecificationfile will cause the time_modified ofhowthewrite isfile to beperformed. The client specifies with the stable parameterupdated. However, themethodtime_modified ofhowthedata is tofile should not beprocessed bychanged unless theserver. If stable is FILE_SYNC,contents of theserver must commitfile are changed. Thus, a WRITE request with count set to 0 should not cause the time_modified of thedata written plus allfilesystem metadatato be updated. The definition of stable storagebefore returning results.has been historically a point of contention. The following expected properties of stable storage may help in resolving design issues in the implementation. Stable storage is persistent storage that survives: 1. Repeated power failures. 2. Hardware failures (of any board, power supply, etc.). 3. Repeated software crashes, including reboot cycle. Thiscorresponds todefinition does not address failure of the stable storage module itself. Expires: March 2000 [Page 156] Draft Protocol Specification NFS version2 protocol semantics. Any other behavior constitutes4 September 1999 The verifier, is defined to allow a client to detect different instances of an NFS version 4 protocolviolation. If stable is DATA_SYNC, then theservermust commit all of theover which cached, uncommitted datato stable storage and enough ofmay be lost. In themetadata to retrievemost likely case, thedata before returning. Theverifier allows the client to detect serverimplementorreboots. This information isfree to implement DATA_SYNC inrequired so that thesame fashion as FILE_SYNC, but with a possible performance drop.client can safely determine whether the server could have lost cached data. Ifstable is UNSTABLE,the serveris free to commit any part offails unexpectedly and the client has uncommitted dataandfrom previous WRITE requests (done with themetadata tostablestorage, including all or none, before returning a replyargument set to UNSTABLE and in which theclient. There is no guarantee whether or when any uncommitted data will subsequently beresult committed was returned as UNSTABLE as well) it may not have flushed cached data to stable storage. Theonly guarantees made by the server are that it will not destroy any data without changing the valueburden ofverfrecovery is on the client andthat itthe client willnot commitneed to retransmit the dataand metadata at a level less thanto the server. A suggested verifier would be to use the time thatrequested bytheclient. The stateid returned from a previous record lockserver was booted orshare reservation request is provided as part oftheargument. The stateid is used bytime the server was last started (if restarting the server without a reboot results in lost buffers). The committed field in the results allows the client toverify thatdo more effective caching. If theassociated lockserver isstill valid andcommitting all WRITE requests toupdate lease timeouts forstable storage, then it should return with committed set to FILE_SYNC, regardless of theclient. Upon successful completion,value of thefollowing results are returned.stable field in the arguments. A server that uses an NVRAM accelerator may choose to implement this policy. Thecount result isclient can use this to increase thenumber of byteseffectiveness of the cache by discarding cached datawritten tothat has already been committed on thefile. The serverserver. Some implementations maywrite fewer bytes than requested. If so, the actual numberreturn NFS4ERR_NOSPC instead ofbytes written starting at location, offset,NFS4ERR_DQUOT when a user's quota isreturned.exceeded. ERRORS NFS4ERR_IO NFS4ERR_ACCES NFS4ERR_INVAL NFS4ERR_FBIG NFS4ERR_NOSPC NFS4ERR_ROFS NFS4ERR_DQUOT NFS4ERR_STALE Expires: March 2000 [Page 157] Draft Protocol Specification NFS version 4 September 1999 NFS4ERR_BADHANDLE NFS4ERR_SERVERFAULT NFS4ERR_JUKEBOX NFS4ERR_LOCKED NFS4ERR_GRACE NFS4ERR_FHEXPIRED NFS4ERR_WRONGSEC NFS4ERR_MOVED Expires: March 2000 [Page 158] Draft Protocol Specification NFS version 4 September 1999 13. NFS Version 4 Callback Procedures Theserver also returns an indication ofprocedures used for callbacks are defined in thelevel of commitment offollowing sections. In thedata and metadata via committed. Ifinterest of clarity, theserver committed all dataterms "client" andmetadata to stable storage, committed should be set"server" refer toFILE_SYNC. IfNFS clients and servers, despite thelevelfact that for an individual callback RPC, the sense ofcommitment was at least as strong as DATA_SYNC, then committed should be set to DATA_SYNC. Otherwise, committed must be returned as UNSTABLE. If stable was FILE_SYNC, then committed must also be FILE_SYNC: anything else constitutes a protocol violation. If stable was DATA_SYNC, then committed maythese terms would be precisely the opposite. 13.1. Procedure 0: CB_NULL - No Operation SYNOPSIS <null> ARGUMENT void; RESULT void; DESCRIPTION Standard ONCRPC NULL procedure. Void argument, void response. ERRORS None. Expires:DecemberMarch 2000 [Page 159] Draft Protocol Specification NFS version 4 September 1999 13.2. Procedure 1: CB_COMPOUND - Compound Operations SYNOPSIS compoundargs -> compoundres ARGUMENT union cb_opunion switch (unsigned opcode) { case <OPCODE>: <argument>; ... }; struct cb_op { cb_opunion ops; }; struct CB_COMPOUND4args { utf8string tag; cb_op oplist<>; }; RESULT union cb_resultdata switch (unsigned resop){ case <OPCODE: <result>; ... }; struct CB_COMPOUND4res { nfsstat4 status; utf8string tag; cb_resultdata data<>; }; union opunion switch (unsigned opcode) { case <OPCODE>: <argument>; ... }; struct op { opunion ops; }; struct COMPOUND4args { Expires: March 2000 [Page119]160] Draft Protocol Specification NFS version 4JuneSeptember 1999FILE_SYNC or DATA_SYNC: anything else constitutes a protocol violation. If stable was UNSTABLE, then committed may be either FILE_SYNC, DATA_SYNC, or UNSTABLE. The final portion of the result is the write verifier, verf.utf8string tag; op oplist<>; }; DESCRIPTION Thewrite verifierCB_COMPOUND procedure isa cookie that the client can useused todetermine whethercombine one or more of theserver has changed state betweencallback procedures into acall to WRITEsingle RPC request. The main callback RPC program has two main procedures: CB_NULL and CB_COMPOUND. All other procedures use the CB_COMPOUND procedure as asubsequent call to either WRITE or COMMIT. This cookie must be consistent during a single instance ofwrapper. In theNFS version 4 protocol service and must be unique between instancesprocessing of theNFS version 4 protocol server, where uncommitted data may be lost. If a client writes data toCB_COMPOUND procedure, the serverwithmay find that it does not have thestable argument setavailable resources toUNSTABLE and the reply yields a committed response of DATA_SYNCexecute any orUNSTABLE,all of theclient will follow up some time inprocedures within thefuture with a COMMIT operation to synchronize outstanding asynchronous data and metadata withCB_COMPOUND sequence. In this case, theserver's stable storage, barring client error. It is possible that due to client crash or othererrorthat a subsequent COMMITNFS4ERR_RESOURCE willnotbereceived byreturned for theserver.particular procedure within the CB_COMPOUND operation where the resource exhaustion occurred. This assumes that all previous procedures within the CB_COMPOUND sequence have been evaluated successfully. IMPLEMENTATIONItThe CB_COMPOUND procedure ispossible for the serverused towrite fewer than count bytescombine individual procedures into a single RPC request. The server interprets each ofdata. In this case,theserver should not return an error unless no data was written at all.procedures in turn. If a procedure is executed by the serverwrites less than count bytes, the client should issue another WRITE to write the remaining data. It is assumed thatand theactstatus ofwriting data to a file will causethat procedure is NFS4_OK, then thetime_modified ofnext procedure in thefileCB_COMPOUND procedure is executed. The server continues this process until there are no more procedures to beupdated. However,executed or one of the procedures has a status value other than NFS4_OK. ERRORS NFS4ERR_RESOURCE Expires: March 2000 [Page 161] Draft Protocol Specification NFS version 4 September 1999 13.2.1. Procedure 2: CB_GETATTR - Get Attributes SYNOPSIS fh, attrbits -> attrbits, attrvals ARGUMENT struct CB_GETATTR4args { nfs_fh4 fh; bitmap4 attr_request; }; RESULT struct CB_GETATTR4resok { fattr4 obj_attributes; }; union CB_GETATTR4res switch (nfsstat4 status) { case NFS4_OK: CB_GETATTR4resok resok4; default: void; }; DESCRIPTION CB_GETATTR is used to obtain thetime_modified ofattributes modified by an open delegate to allow the server to respond to GETATTR requests for a fileshould not be changed unlesswhich is thecontentssubject of an open delegation. IMPLEMENTATION The client returns attrbits and thefile are changed. Thus, a WRITE request with count set to 0 should not cause the time_modified ofassociated attribute values only for attributes that it may change (change, time_modify, object_size). It may further limit thefileresponse tobe updated. The definition of stable storageattributes that it hasbeen historically a point of contention. The following expected properties of stable storage may help in resolving design issuesin fact changed during theimplementation. Stable storage is persistent storage that survives: 1. Repeated power failures. 2. Hardware failures (of any board, power supply, etc.). 3. Repeated software crashes, including reboot cycle. This definition does not address failurescope of thestable storage module itself.delegation. Expires:December 1999March 2000 [Page120]162] Draft Protocol Specification NFS version 4JuneSeptember 1999The verifier, is defined to allow a client to detect different instances of anERRORS <TBD> Expires: March 2000 [Page 163] Draft Protocol Specification NFS version 4protocol server over which cached, uncommitted data may be lost. In the most likely case, the verifier allows the client to detect server reboots. This informationSeptember 1999 13.2.2. Procedure 3: CB_RECALL - Recall an Open Delegation SYNOPSIS stateid, truncate, fh ARGUMENT struct CB_RECALL4args { stateid4 stateid; bool truncate; nfs_fh4 fh; }; RESULT struct CB_RECALL4res { nfsstat4 status; }; DESCRIPTION CB_RECALL isrequired so that the client can safely determine whether the server could have lost cached data. If the server fails unexpectedly and the client has uncommitted data from previous WRITE requests (done with the stable argument setused toUNSTABLE and in which