idnits 2.17.1 draft-ietf-nfsv4-rfc3530bis-12.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- == There are 2 instances of lines with non-RFC2606-compliant FQDNs in the document. -- The abstract seems to indicate that this document obsoletes RFC1813, but the header doesn't have an 'Obsoletes:' line to match this. -- The abstract seems to indicate that this document obsoletes RFC3530, but the header doesn't have an 'Obsoletes:' line to match this. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 940 has weird spacing: '...al_must ser...' == Line 1038 has weird spacing: '...ned int cb_...' == Line 1254 has weird spacing: '...otiated rpc_g...' == Line 1255 has weird spacing: '...otiated rpc_g...' == Line 1256 has weird spacing: '...otiated rpc_g...' == (19 more instances...) -- The exact meaning of the all-uppercase expression 'MAY NOT' is not defined in RFC 2119. If it is intended as a requirements expression, it should be rewritten using one of the combinations defined in RFC 2119; otherwise it should not be all-uppercase. == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: The server can specify a root path by setting an array of zero path components. Other than this special case, the server MUST not present empty path components to the client. == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: A problem exists if a client allows an open owner to have state on multiple filesystems on a server. If one of those filesystems is migrated, what happens to the sequence numbers? A client can avoid such a situation with the stipulation that any client which supports migration MUST ensure that any open owner is confined to a single filesystem. If the server finds itself migrating open owners that span multiple filesystems, then it MUST not migrate the state for the conflicting open owners on the non-migrated filesystems; instead it MUST return NFS4ERR_STALE_STATEID if the client tries to use those stateids. == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: As a courtesy to the client or as an 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 server MUST free the courtesy lock and grant the new request. If the server runs out of resources, it MAY free all courtesy locks. I.e., the client MUST not make an assumption that the server has issued courtesy locks. == The expression 'MAY NOT', while looking like RFC 2119 requirements text, is not defined in RFC 2119, and should not be used. Consider using 'MUST NOT' instead (if that is what you mean). Found 'MAY NOT' in this paragraph: The current lock has been revoked during the partition and the server did not reboot. Other locks MAY still be renewed. The client MAY NOT want to do a SETCLIENTID and instead SHOULD probe via a RENEW call. == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'SHOULD not' in this paragraph: If a COMPOUND contains an OPEN which establishes a OPEN_DELEGATE_WRITE delegation, then a subsequent GETATTR inside that COMPOUND SHOULD not result in a CB_GETATTR to the client. The server SHOULD understand the GETATTR to be for the same client ID and avoid querying the client, which will not be able to respond. This sequence of OPEN, GETATTR SHOULD be understood as an atomic retrieval of the initial size and change attribute. Further, the client SHOULD NOT construct a COMPOUND which mixes operations for different client IDs. == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (April 08, 2011) is 4766 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Possible downref: Non-RFC (?) normative reference: ref. '1' == Outdated reference: A later version (-24) exists of draft-ietf-nfsv4-rfc3530bis-dot-x-02 -- Possible downref: Non-RFC (?) normative reference: ref. '7' ** Obsolete normative reference: RFC 3454 (ref. '9') (Obsoleted by RFC 7564) -- Obsolete informational reference (is this intentional?): RFC 3530 (ref. '11') (Obsoleted by RFC 7530) -- Obsolete informational reference (is this intentional?): RFC 3010 (ref. '12') (Obsoleted by RFC 3530) -- Obsolete informational reference (is this intentional?): RFC 2373 (ref. '18') (Obsoleted by RFC 3513) -- Obsolete informational reference (is this intentional?): RFC 5661 (ref. '31') (Obsoleted by RFC 8881) -- Obsolete informational reference (is this intentional?): RFC 793 (ref. '33') (Obsoleted by RFC 9293) -- Obsolete informational reference (is this intentional?): RFC 5226 (ref. '41') (Obsoleted by RFC 8126) Summary: 1 error (**), 0 flaws (~~), 15 warnings (==), 13 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 NFSv4 T. Haynes, Ed. 3 Internet-Draft NetApp 4 Intended status: Standards Track D. Noveck, Ed. 5 Expires: October 10, 2011 EMC 6 April 08, 2011 8 Network File System (NFS) Version 4 Protocol 9 draft-ietf-nfsv4-rfc3530bis-12.txt 11 Abstract 13 The Network File System (NFS) version 4 is a distributed filesystem 14 protocol which owes heritage to NFS protocol version 2, RFC 1094, and 15 version 3, RFC 1813. Unlike earlier versions, the NFS version 4 16 protocol supports traditional file access while integrating support 17 for file locking and the mount protocol. In addition, support for 18 strong security (and its negotiation), compound operations, client 19 caching, and internationalization have been added. Of course, 20 attention has been applied to making NFS version 4 operate well in an 21 Internet environment. 23 This document, together with the companion XDR description document, 24 replaces RFC 3530 as the definition of the NFS version 4 protocol. 26 Requirements Language 28 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 29 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 30 document are to be interpreted as described in RFC 2119 [1]. 32 Status of this Memo 34 This Internet-Draft is submitted in full conformance with the 35 provisions of BCP 78 and BCP 79. 37 Internet-Drafts are working documents of the Internet Engineering 38 Task Force (IETF). Note that other groups may also distribute 39 working documents as Internet-Drafts. The list of current Internet- 40 Drafts is at http://datatracker.ietf.org/drafts/current/. 42 Internet-Drafts are draft documents valid for a maximum of six months 43 and may be updated, replaced, or obsoleted by other documents at any 44 time. It is inappropriate to use Internet-Drafts as reference 45 material or to cite them other than as "work in progress." 47 This Internet-Draft will expire on October 10, 2011. 49 Copyright Notice 51 Copyright (c) 2011 IETF Trust and the persons identified as the 52 document authors. All rights reserved. 54 This document is subject to BCP 78 and the IETF Trust's Legal 55 Provisions Relating to IETF Documents 56 (http://trustee.ietf.org/license-info) in effect on the date of 57 publication of this document. Please review these documents 58 carefully, as they describe your rights and restrictions with respect 59 to this document. Code Components extracted from this document must 60 include Simplified BSD License text as described in Section 4.e of 61 the Trust Legal Provisions and are provided without warranty as 62 described in the Simplified BSD License. 64 This document may contain material from IETF Documents or IETF 65 Contributions published or made publicly available before November 66 10, 2008. The person(s) controlling the copyright in some of this 67 material may not have granted the IETF Trust the right to allow 68 modifications of such material outside the IETF Standards Process. 69 Without obtaining an adequate license from the person(s) controlling 70 the copyright in such materials, this document may not be modified 71 outside the IETF Standards Process, and derivative works of it may 72 not be created outside the IETF Standards Process, except to format 73 it for publication as an RFC or to translate it into languages other 74 than English. 76 Table of Contents 78 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 9 79 1.1. Changes since RFC 3530 . . . . . . . . . . . . . . . . . 9 80 1.2. Changes since RFC 3010 . . . . . . . . . . . . . . . . . 10 81 1.3. NFS Version 4 Goals . . . . . . . . . . . . . . . . . . 11 82 1.4. Inconsistencies of this Document with the companion 83 document NFS Version 4 Protocol . . . . . . . . . . . . 11 84 1.5. Overview of NFSv4 Features . . . . . . . . . . . . . . . 12 85 1.5.1. RPC and Security . . . . . . . . . . . . . . . . . . 12 86 1.5.2. Procedure and Operation Structure . . . . . . . . . 12 87 1.5.3. Filesystem Model . . . . . . . . . . . . . . . . . . 13 88 1.5.4. OPEN and CLOSE . . . . . . . . . . . . . . . . . . . 15 89 1.5.5. File Locking . . . . . . . . . . . . . . . . . . . . 15 90 1.5.6. Client Caching and Delegation . . . . . . . . . . . 15 91 1.6. General Definitions . . . . . . . . . . . . . . . . . . 16 92 2. Protocol Data Types . . . . . . . . . . . . . . . . . . . . . 18 93 2.1. Basic Data Types . . . . . . . . . . . . . . . . . . . . 18 94 2.2. Structured Data Types . . . . . . . . . . . . . . . . . 20 95 3. RPC and Security Flavor . . . . . . . . . . . . . . . . . . . 25 96 3.1. Ports and Transports . . . . . . . . . . . . . . . . . . 25 97 3.1.1. Client Retransmission Behavior . . . . . . . . . . . 26 98 3.2. Security Flavors . . . . . . . . . . . . . . . . . . . . 27 99 3.2.1. Security mechanisms for NFSv4 . . . . . . . . . . . 27 100 3.3. Security Negotiation . . . . . . . . . . . . . . . . . . 29 101 3.3.1. SECINFO . . . . . . . . . . . . . . . . . . . . . . 30 102 3.3.2. Security Error . . . . . . . . . . . . . . . . . . . 30 103 3.3.3. Callback RPC Authentication . . . . . . . . . . . . 30 104 4. Filehandles . . . . . . . . . . . . . . . . . . . . . . . . . 32 105 4.1. Obtaining the First Filehandle . . . . . . . . . . . . . 32 106 4.1.1. Root Filehandle . . . . . . . . . . . . . . . . . . 33 107 4.1.2. Public Filehandle . . . . . . . . . . . . . . . . . 33 108 4.2. Filehandle Types . . . . . . . . . . . . . . . . . . . . 33 109 4.2.1. General Properties of a Filehandle . . . . . . . . . 34 110 4.2.2. Persistent Filehandle . . . . . . . . . . . . . . . 34 111 4.2.3. Volatile Filehandle . . . . . . . . . . . . . . . . 35 112 4.2.4. One Method of Constructing a Volatile Filehandle . . 36 113 4.3. Client Recovery from Filehandle Expiration . . . . . . . 36 114 5. File Attributes . . . . . . . . . . . . . . . . . . . . . . . 37 115 5.1. REQUIRED Attributes . . . . . . . . . . . . . . . . . . 38 116 5.2. RECOMMENDED Attributes . . . . . . . . . . . . . . . . . 39 117 5.3. Named Attributes . . . . . . . . . . . . . . . . . . . . 39 118 5.4. Classification of Attributes . . . . . . . . . . . . . . 41 119 5.5. Set-Only and Get-Only Attributes . . . . . . . . . . . . 41 120 5.6. REQUIRED Attributes - List and Definition References . . 42 121 5.7. RECOMMENDED Attributes - List and Definition 122 References . . . . . . . . . . . . . . . . . . . . . . . 43 123 5.8. Attribute Definitions . . . . . . . . . . . . . . . . . 44 124 5.8.1. Definitions of REQUIRED Attributes . . . . . . . . . 44 125 5.8.2. Definitions of Uncategorized RECOMMENDED 126 Attributes . . . . . . . . . . . . . . . . . . . . . 46 127 5.9. Interpreting owner and owner_group . . . . . . . . . . . 52 128 5.10. Character Case Attributes . . . . . . . . . . . . . . . 55 129 6. Access Control Attributes . . . . . . . . . . . . . . . . . . 55 130 6.1. Goals . . . . . . . . . . . . . . . . . . . . . . . . . 55 131 6.2. File Attributes Discussion . . . . . . . . . . . . . . . 56 132 6.2.1. Attribute 12: acl . . . . . . . . . . . . . . . . . 56 133 6.2.2. Attribute 33: mode . . . . . . . . . . . . . . . . . 70 134 6.3. Common Methods . . . . . . . . . . . . . . . . . . . . . 71 135 6.3.1. Interpreting an ACL . . . . . . . . . . . . . . . . 71 136 6.3.2. Computing a Mode Attribute from an ACL . . . . . . . 72 137 6.4. Requirements . . . . . . . . . . . . . . . . . . . . . . 73 138 6.4.1. Setting the mode and/or ACL Attributes . . . . . . . 73 139 6.4.2. Retrieving the mode and/or ACL Attributes . . . . . 75 140 6.4.3. Creating New Objects . . . . . . . . . . . . . . . . 75 141 7. Multi-Server Namespace . . . . . . . . . . . . . . . . . . . 77 142 7.1. Location Attributes . . . . . . . . . . . . . . . . . . 77 143 7.2. File System Presence or Absence . . . . . . . . . . . . 77 144 7.3. Getting Attributes for an Absent File System . . . . . . 78 145 7.3.1. GETATTR Within an Absent File System . . . . . . . . 79 146 7.3.2. READDIR and Absent File Systems . . . . . . . . . . 80 147 7.4. Uses of Location Information . . . . . . . . . . . . . . 80 148 7.4.1. File System Replication . . . . . . . . . . . . . . 81 149 7.4.2. File System Migration . . . . . . . . . . . . . . . 82 150 7.4.3. Referrals . . . . . . . . . . . . . . . . . . . . . 82 151 7.5. Location Entries and Server Identity . . . . . . . . . . 83 152 7.6. Additional Client-Side Considerations . . . . . . . . . 84 153 7.7. Effecting File System Transitions . . . . . . . . . . . 85 154 7.7.1. File System Transitions and Simultaneous Access . . 86 155 7.7.2. Filehandles and File System Transitions . . . . . . 86 156 7.7.3. Fileids and File System Transitions . . . . . . . . 87 157 7.7.4. Fsids and File System Transitions . . . . . . . . . 88 158 7.7.5. The Change Attribute and File System Transitions . . 88 159 7.7.6. Lock State and File System Transitions . . . . . . . 89 160 7.7.7. Write Verifiers and File System Transitions . . . . 91 161 7.7.8. Readdir Cookies and Verifiers and File System 162 Transitions . . . . . . . . . . . . . . . . . . . . 91 163 7.7.9. File System Data and File System Transitions . . . . 91 164 7.8. Effecting File System Referrals . . . . . . . . . . . . 93 165 7.8.1. Referral Example (LOOKUP) . . . . . . . . . . . . . 93 166 7.8.2. Referral Example (READDIR) . . . . . . . . . . . . . 97 167 7.9. The Attribute fs_locations . . . . . . . . . . . . . . . 99 168 7.9.1. Inferring Transition Modes . . . . . . . . . . . . . 101 169 8. NFS Server Name Space . . . . . . . . . . . . . . . . . . . . 102 170 8.1. Server Exports . . . . . . . . . . . . . . . . . . . . . 103 171 8.2. Browsing Exports . . . . . . . . . . . . . . . . . . . . 103 172 8.3. Server Pseudo Filesystem . . . . . . . . . . . . . . . . 103 173 8.4. Multiple Roots . . . . . . . . . . . . . . . . . . . . . 104 174 8.5. Filehandle Volatility . . . . . . . . . . . . . . . . . 104 175 8.6. Exported Root . . . . . . . . . . . . . . . . . . . . . 104 176 8.7. Mount Point Crossing . . . . . . . . . . . . . . . . . . 105 177 8.8. Security Policy and Name Space Presentation . . . . . . 105 178 9. File Locking and Share Reservations . . . . . . . . . . . . . 106 179 9.1. Opens and Byte-Range Locks . . . . . . . . . . . . . . . 107 180 9.1.1. Client ID . . . . . . . . . . . . . . . . . . . . . 107 181 9.1.2. Server Release of Client ID . . . . . . . . . . . . 110 182 9.1.3. Stateid Definition . . . . . . . . . . . . . . . . . 111 183 9.1.4. lock-owner . . . . . . . . . . . . . . . . . . . . . 118 184 9.1.5. Use of the Stateid and Locking . . . . . . . . . . . 119 185 9.1.6. Sequencing of Lock Requests . . . . . . . . . . . . 121 186 9.1.7. Recovery from Replayed Requests . . . . . . . . . . 122 187 9.1.8. Releasing state-owner State . . . . . . . . . . . . 122 188 9.1.9. Use of Open Confirmation . . . . . . . . . . . . . . 123 189 9.2. Lock Ranges . . . . . . . . . . . . . . . . . . . . . . 124 190 9.3. Upgrading and Downgrading Locks . . . . . . . . . . . . 124 191 9.4. Blocking Locks . . . . . . . . . . . . . . . . . . . . . 125 192 9.5. Lease Renewal . . . . . . . . . . . . . . . . . . . . . 125 193 9.6. Crash Recovery . . . . . . . . . . . . . . . . . . . . . 126 194 9.6.1. Client Failure and Recovery . . . . . . . . . . . . 127 195 9.6.2. Server Failure and Recovery . . . . . . . . . . . . 127 196 9.6.3. Network Partitions and Recovery . . . . . . . . . . 129 197 9.7. Recovery from a Lock Request Timeout or Abort . . . . . 135 198 9.8. Server Revocation of Locks . . . . . . . . . . . . . . . 136 199 9.9. Share Reservations . . . . . . . . . . . . . . . . . . . 137 200 9.10. OPEN/CLOSE Operations . . . . . . . . . . . . . . . . . 138 201 9.10.1. Close and Retention of State Information . . . . . . 138 202 9.11. Open Upgrade and Downgrade . . . . . . . . . . . . . . . 139 203 9.12. Short and Long Leases . . . . . . . . . . . . . . . . . 140 204 9.13. Clocks, Propagation Delay, and Calculating Lease 205 Expiration . . . . . . . . . . . . . . . . . . . . . . . 140 206 9.14. Migration, Replication and State . . . . . . . . . . . . 141 207 9.14.1. Migration and State . . . . . . . . . . . . . . . . 141 208 9.14.2. Replication and State . . . . . . . . . . . . . . . 142 209 9.14.3. Notification of Migrated Lease . . . . . . . . . . . 143 210 9.14.4. Migration and the Lease_time Attribute . . . . . . . 143 211 10. Client-Side Caching . . . . . . . . . . . . . . . . . . . . . 144 212 10.1. Performance Challenges for Client-Side Caching . . . . . 145 213 10.2. Delegation and Callbacks . . . . . . . . . . . . . . . . 146 214 10.2.1. Delegation Recovery . . . . . . . . . . . . . . . . 147 215 10.3. Data Caching . . . . . . . . . . . . . . . . . . . . . . 149 216 10.3.1. Data Caching and OPENs . . . . . . . . . . . . . . . 150 217 10.3.2. Data Caching and File Locking . . . . . . . . . . . 151 218 10.3.3. Data Caching and Mandatory File Locking . . . . . . 152 219 10.3.4. Data Caching and File Identity . . . . . . . . . . . 153 221 10.4. Open Delegation . . . . . . . . . . . . . . . . . . . . 154 222 10.4.1. Open Delegation and Data Caching . . . . . . . . . . 156 223 10.4.2. Open Delegation and File Locks . . . . . . . . . . . 157 224 10.4.3. Handling of CB_GETATTR . . . . . . . . . . . . . . . 158 225 10.4.4. Recall of Open Delegation . . . . . . . . . . . . . 161 226 10.4.5. OPEN Delegation Race with CB_RECALL . . . . . . . . 163 227 10.4.6. Clients that Fail to Honor Delegation Recalls . . . 163 228 10.4.7. Delegation Revocation . . . . . . . . . . . . . . . 164 229 10.5. Data Caching and Revocation . . . . . . . . . . . . . . 165 230 10.5.1. Revocation Recovery for Write Open Delegation . . . 165 231 10.6. Attribute Caching . . . . . . . . . . . . . . . . . . . 166 232 10.7. Data and Metadata Caching and Memory Mapped Files . . . 168 233 10.8. Name Caching . . . . . . . . . . . . . . . . . . . . . . 170 234 10.9. Directory Caching . . . . . . . . . . . . . . . . . . . 171 235 11. Minor Versioning . . . . . . . . . . . . . . . . . . . . . . 172 236 12. Internationalization . . . . . . . . . . . . . . . . . . . . 175 237 12.1. Use of UTF-8 . . . . . . . . . . . . . . . . . . . . . . 176 238 12.1.1. Relation to Stringprep . . . . . . . . . . . . . . . 176 239 12.1.2. Normalization, Equivalence, and Confusability . . . 177 240 12.2. String Type Overview . . . . . . . . . . . . . . . . . . 179 241 12.2.1. Overall String Class Divisions . . . . . . . . . . . 180 242 12.2.2. Divisions by Typedef Parent types . . . . . . . . . 181 243 12.2.3. Individual Types and Their Handling . . . . . . . . 181 244 12.3. Errors Related to Strings . . . . . . . . . . . . . . . 183 245 12.4. Types with Pre-processing to Resolve Mixture Issues . . 184 246 12.4.1. Processing of Principal Strings . . . . . . . . . . 184 247 12.4.2. Processing of Server Id Strings . . . . . . . . . . 184 248 12.5. String Types without Internationalization Processing . . 185 249 12.6. Types with Processing Defined by Other Internet Areas . 185 250 12.7. String Types with NFS-specific Processing . . . . . . . 186 251 12.7.1. Handling of File Name Components . . . . . . . . . . 187 252 12.7.2. Processing of Link Text . . . . . . . . . . . . . . 196 253 12.7.3. Processing of Principal Prefixes . . . . . . . . . . 197 254 13. Error Values . . . . . . . . . . . . . . . . . . . . . . . . 198 255 13.1. Error Definitions . . . . . . . . . . . . . . . . . . . 198 256 13.1.1. General Errors . . . . . . . . . . . . . . . . . . . 199 257 13.1.2. Filehandle Errors . . . . . . . . . . . . . . . . . 201 258 13.1.3. Compound Structure Errors . . . . . . . . . . . . . 202 259 13.1.4. File System Errors . . . . . . . . . . . . . . . . . 203 260 13.1.5. State Management Errors . . . . . . . . . . . . . . 205 261 13.1.6. Security Errors . . . . . . . . . . . . . . . . . . 206 262 13.1.7. Name Errors . . . . . . . . . . . . . . . . . . . . 206 263 13.1.8. Locking Errors . . . . . . . . . . . . . . . . . . . 207 264 13.1.9. Reclaim Errors . . . . . . . . . . . . . . . . . . . 208 265 13.1.10. Client Management Errors . . . . . . . . . . . . . . 209 266 13.1.11. Attribute Handling Errors . . . . . . . . . . . . . 209 267 13.2. Operations and their valid errors . . . . . . . . . . . 210 268 13.3. Callback operations and their valid errors . . . . . . . 217 269 13.4. Errors and the operations that use them . . . . . . . . 217 270 14. NFSv4 Requests . . . . . . . . . . . . . . . . . . . . . . . 222 271 14.1. Compound Procedure . . . . . . . . . . . . . . . . . . . 222 272 14.2. Evaluation of a Compound Request . . . . . . . . . . . . 223 273 14.3. Synchronous Modifying Operations . . . . . . . . . . . . 224 274 14.4. Operation Values . . . . . . . . . . . . . . . . . . . . 224 275 15. NFSv4 Procedures . . . . . . . . . . . . . . . . . . . . . . 224 276 15.1. Procedure 0: NULL - No Operation . . . . . . . . . . . . 224 277 15.2. Procedure 1: COMPOUND - Compound Operations . . . . . . 225 278 15.3. Operation 3: ACCESS - Check Access Rights . . . . . . . 230 279 15.4. Operation 4: CLOSE - Close File . . . . . . . . . . . . 233 280 15.5. Operation 5: COMMIT - Commit Cached Data . . . . . . . . 234 281 15.6. Operation 6: CREATE - Create a Non-Regular File Object . 236 282 15.7. Operation 7: DELEGPURGE - Purge Delegations Awaiting 283 Recovery . . . . . . . . . . . . . . . . . . . . . . . . 239 284 15.8. Operation 8: DELEGRETURN - Return Delegation . . . . . . 240 285 15.9. Operation 9: GETATTR - Get Attributes . . . . . . . . . 240 286 15.10. Operation 10: GETFH - Get Current Filehandle . . . . . . 242 287 15.11. Operation 11: LINK - Create Link to a File . . . . . . . 243 288 15.12. Operation 12: LOCK - Create Lock . . . . . . . . . . . . 244 289 15.13. Operation 13: LOCKT - Test For Lock . . . . . . . . . . 248 290 15.14. Operation 14: LOCKU - Unlock File . . . . . . . . . . . 250 291 15.15. Operation 15: LOOKUP - Lookup Filename . . . . . . . . . 251 292 15.16. Operation 16: LOOKUPP - Lookup Parent Directory . . . . 253 293 15.17. Operation 17: NVERIFY - Verify Difference in 294 Attributes . . . . . . . . . . . . . . . . . . . . . . . 253 295 15.18. Operation 18: OPEN - Open a Regular File . . . . . . . . 255 296 15.19. Operation 19: OPENATTR - Open Named Attribute 297 Directory . . . . . . . . . . . . . . . . . . . . . . . 265 298 15.20. Operation 20: OPEN_CONFIRM - Confirm Open . . . . . . . 266 299 15.21. Operation 21: OPEN_DOWNGRADE - Reduce Open File Access . 268 300 15.22. Operation 22: PUTFH - Set Current Filehandle . . . . . . 269 301 15.23. Operation 23: PUTPUBFH - Set Public Filehandle . . . . . 270 302 15.24. Operation 24: PUTROOTFH - Set Root Filehandle . . . . . 271 303 15.25. Operation 25: READ - Read from File . . . . . . . . . . 272 304 15.26. Operation 26: READDIR - Read Directory . . . . . . . . . 274 305 15.27. Operation 27: READLINK - Read Symbolic Link . . . . . . 278 306 15.28. Operation 28: REMOVE - Remove Filesystem Object . . . . 279 307 15.29. Operation 29: RENAME - Rename Directory Entry . . . . . 281 308 15.30. Operation 30: RENEW - Renew a Lease . . . . . . . . . . 283 309 15.31. Operation 31: RESTOREFH - Restore Saved Filehandle . . . 284 310 15.32. Operation 32: SAVEFH - Save Current Filehandle . . . . . 285 311 15.33. Operation 33: SECINFO - Obtain Available Security . . . 285 312 15.34. Operation 34: SETATTR - Set Attributes . . . . . . . . . 288 313 15.35. Operation 35: SETCLIENTID - Negotiate Client ID . . . . 291 314 15.36. Operation 36: SETCLIENTID_CONFIRM - Confirm Client ID . 295 315 15.37. Operation 37: VERIFY - Verify Same Attributes . . . . . 298 316 15.38. Operation 38: WRITE - Write to File . . . . . . . . . . 300 317 15.39. Operation 39: RELEASE_LOCKOWNER - Release Lockowner 318 State . . . . . . . . . . . . . . . . . . . . . . . . . 304 319 15.40. Operation 10044: ILLEGAL - Illegal operation . . . . . . 305 320 16. NFSv4 Callback Procedures . . . . . . . . . . . . . . . . . . 305 321 16.1. Procedure 0: CB_NULL - No Operation . . . . . . . . . . 306 322 16.2. Procedure 1: CB_COMPOUND - Compound Operations . . . . . 306 323 16.2.6. Operation 3: CB_GETATTR - Get Attributes . . . . . . 308 324 16.2.7. Operation 4: CB_RECALL - Recall an Open Delegation . 309 325 16.2.8. Operation 10044: CB_ILLEGAL - Illegal Callback 326 Operation . . . . . . . . . . . . . . . . . . . . . 310 327 17. Security Considerations . . . . . . . . . . . . . . . . . . . 311 328 18. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 312 329 18.1. Named Attribute Definitions . . . . . . . . . . . . . . 312 330 18.1.1. Initial Registry . . . . . . . . . . . . . . . . . . 313 331 18.1.2. Updating Registrations . . . . . . . . . . . . . . . 313 332 18.2. ONC RPC Network Identifiers (netids) . . . . . . . . . . 313 333 18.2.1. Initial Registry . . . . . . . . . . . . . . . . . . 315 334 18.2.2. Updating Registrations . . . . . . . . . . . . . . . 315 335 19. References . . . . . . . . . . . . . . . . . . . . . . . . . 315 336 19.1. Normative References . . . . . . . . . . . . . . . . . . 315 337 19.2. Informative References . . . . . . . . . . . . . . . . . 316 338 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 318 339 Appendix B. RFC Editor Notes . . . . . . . . . . . . . . . . . . 319 340 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 319 342 1. Introduction 344 1.1. Changes since RFC 3530 346 This document, together with the companion XDR description document 347 [2], obsoletes RFC 3530 [11] as the authoritative document describing 348 NFSv4. It does not introduce any over-the-wire protocol changes, in 349 the sense that previously valid requests requests remain valid. 350 However, some requests previously defined as invalid, although not 351 generally rejected, are now explicitly allowed, in that 352 internationalization handling has been generalized and liberalized. 353 The main changes from RFC 3530 are: 355 o The XDR definition has been moved to a companion document [2] 357 o Updates for the latest IETF intellectual property statements 359 o There is a restructured and more complete explanation of multi- 360 server namespace features. In particular, this explanation 361 explicitly describes handling of inter-server referrals, even 362 where neither migration nor replication is involved. 364 o More liberal handling of internationalization for file names and 365 user and group names, with the elimination of restrictions imposed 366 by stringprep, with the recognition that rules for the forms of 367 these name are the province of the receiving entity. 369 o Updating handling of domain names to reflect IDNA. 371 o Restructuring of string types to more appropriately reflect the 372 reality of required string processing. 374 o LIPKEY SPKM/3 has been moved from being REQUIRED to OPTIONAL. 376 o Some clarification on a client re-establishing callback 377 information to the new server if state has been migrated. 379 o A third edge case was added for Courtesy locks and network 380 partitions. 382 o The definition of stateid was strengthened, which had the side 383 effect of introducing a semantic change in a COMPOUND structure 384 having a current stateid and a saved stateid. 386 1.2. Changes since RFC 3010 388 This definition of the NFSv4 protocol replaces or obsoletes the 389 definition present in [12]. While portions of the two documents have 390 remained the same, there have been substantive changes in others. 391 The changes made between [12] and this document represent 392 implementation experience and further review of the protocol. While 393 some modifications were made for ease of implementation or 394 clarification, most updates represent errors or situations where the 395 [12] definition were untenable. 397 The following list is not all inclusive of all changes but presents 398 some of the most notable changes or additions made: 400 o The state model has added an open_owner4 identifier. This was 401 done to accommodate Posix based clients and the model they use for 402 file locking. For Posix clients, an open_owner4 would correspond 403 to a file descriptor potentially shared amongst a set of processes 404 and the lock_owner4 identifier would correspond to a process that 405 is locking a file. 407 o Clarifications and error conditions were added for the handling of 408 the owner and group attributes. Since these attributes are string 409 based (as opposed to the numeric uid/gid of previous versions of 410 NFS), translations may not be available and hence the changes 411 made. 413 o Clarifications for the ACL and mode attributes to address 414 evaluation and partial support. 416 o For identifiers that are defined as XDR opaque, limits were set on 417 their size. 419 o Added the mounted_on_filed attribute to allow Posix clients to 420 correctly construct local mounts. 422 o Modified the SETCLIENTID/SETCLIENTID_CONFIRM operations to deal 423 correctly with confirmation details along with adding the ability 424 to specify new client callback information. Also added 425 clarification of the callback information itself. 427 o Added a new operation RELEASE_LOCKOWNER to enable notifying the 428 server that a lock_owner4 will no longer be used by the client. 430 o RENEW operation changes to identify the client correctly and allow 431 for additional error returns. 433 o Verify error return possibilities for all operations. 435 o Remove use of the pathname4 data type from LOOKUP and OPEN in 436 favor of having the client construct a sequence of LOOKUP 437 operations to achieve the same effect. 439 o Clarification of the internationalization issues and adoption of 440 the new stringprep profile framework. 442 1.3. NFS Version 4 Goals 444 The NFSv4 protocol is a further revision of the NFS protocol defined 445 already by versions 2 [13] and 3 [14]. It retains the essential 446 characteristics of previous versions: design for easy recovery, 447 independent of transport protocols, operating systems and 448 filesystems, simplicity, and good performance. The NFSv4 revision 449 has the following goals: 451 o Improved access and good performance on the Internet. 453 The protocol is designed to transit firewalls easily, perform well 454 where latency is high and bandwidth is low, and scale to very 455 large numbers of clients per server. 457 o Strong security with negotiation built into the protocol. 459 The protocol builds on the work of the ONCRPC working group in 460 supporting the RPCSEC_GSS protocol. Additionally, the NFS version 461 4 protocol provides a mechanism to allow clients and servers the 462 ability to negotiate security and require clients and servers to 463 support a minimal set of security schemes. 465 o Good cross-platform interoperability. 467 The protocol features a filesystem model that provides a useful, 468 common set of features that does not unduly favor one filesystem 469 or operating system over another. 471 o Designed for protocol extensions. 473 The protocol is designed to accept standard extensions that do not 474 compromise backward compatibility. 476 1.4. Inconsistencies of this Document with the companion document NFS 477 Version 4 Protocol 479 [2], NFS Version 4 Protocol, contains the definitions in XDR 480 description language of the constructs used by the protocol. Inside 481 this document, several of the constructs are reproduced for purposes 482 of explanation. The reader is warned of the possibility of errors in 483 the reproduced constructs outside of [2]. For any part of the 484 document that is inconsistent with [2], [2] is to be considered 485 authoritative. 487 1.5. Overview of NFSv4 Features 489 To provide a reasonable context for the reader, the major features of 490 NFSv4 protocol will be reviewed in brief. This will be done to 491 provide an appropriate context for both the reader who is familiar 492 with the previous versions of the NFS protocol and the reader that is 493 new to the NFS protocols. For the reader new to the NFS protocols, 494 there is still a fundamental knowledge that is expected. The reader 495 should be familiar with the XDR and RPC protocols as described in [3] 496 and [15]. A basic knowledge of filesystems and distributed 497 filesystems is expected as well. 499 1.5.1. RPC and Security 501 As with previous versions of NFS, the External Data Representation 502 (XDR) and Remote Procedure Call (RPC) mechanisms used for the NFSv4 503 protocol are those defined in [3] and [15]. To meet end to end 504 security requirements, the RPCSEC_GSS framework [4] will be used to 505 extend the basic RPC security. With the use of RPCSEC_GSS, various 506 mechanisms can be provided to offer authentication, integrity, and 507 privacy to the NFS version 4 protocol. Kerberos V5 will be used as 508 described in [16] to provide one security framework. The LIPKEY GSS- 509 API mechanism described in [5] will be used to provide for the use of 510 user password and server public key by the NFSv4 protocol. With the 511 use of RPCSEC_GSS, other mechanisms may also be specified and used 512 for NFS version 4 security. 514 To enable in-band security negotiation, the NFSv4 protocol has added 515 a new operation which provides the client a method of querying the 516 server about its policies regarding which security mechanisms must be 517 used for access to the server's filesystem resources. With this, the 518 client can securely match the security mechanism that meets the 519 policies specified at both the client and server. 521 1.5.2. Procedure and Operation Structure 523 A significant departure from the previous versions of the NFS 524 protocol is the introduction of the COMPOUND procedure. For the 525 NFSv4 protocol, there are two RPC procedures, NULL and COMPOUND. The 526 COMPOUND procedure is defined in terms of operations and these 527 operations correspond more closely to the traditional NFS procedures. 529 With the use of the COMPOUND procedure, the client is able to build 530 simple or complex requests. These COMPOUND requests allow for a 531 reduction in the number of RPCs needed for logical filesystem 532 operations. For example, without previous contact with a server a 533 client will be able to read data from a file in one request by 534 combining LOOKUP, OPEN, and READ operations in a single COMPOUND RPC. 535 With previous versions of the NFS protocol, this type of single 536 request was not possible. 538 The model used for COMPOUND is very simple. There is no logical OR 539 or ANDing of operations. The operations combined within a COMPOUND 540 request are evaluated in order by the server. Once an operation 541 returns a failing result, the evaluation ends and the results of all 542 evaluated operations are returned to the client. 544 The NFSv4 protocol continues to have the client refer to a file or 545 directory at the server by a "filehandle". The COMPOUND procedure 546 has a method of passing a filehandle from one operation to another 547 within the sequence of operations. There is a concept of a "current 548 filehandle" and "saved filehandle". Most operations use the "current 549 filehandle" as the filesystem object to operate upon. The "saved 550 filehandle" is used as temporary filehandle storage within a COMPOUND 551 procedure as well as an additional operand for certain operations. 553 1.5.3. Filesystem Model 555 The general filesystem model used for the NFSv4 protocol is the same 556 as previous versions. The server filesystem is hierarchical with the 557 regular files contained within being treated as opaque byte streams. 558 In a slight departure, file and directory names are encoded with 559 UTF-8 to deal with the basics of internationalization. 561 The NFSv4 protocol does not require a separate protocol to provide 562 for the initial mapping between path name and filehandle. Instead of 563 using the older MOUNT protocol for this mapping, the server provides 564 a ROOT filehandle that represents the logical root or top of the 565 filesystem tree provided by the server. The server provides multiple 566 filesystems by gluing them together with pseudo filesystems. These 567 pseudo filesystems provide for potential gaps in the path names 568 between real filesystems. 570 1.5.3.1. Filehandle Types 572 In previous versions of the NFS protocol, the filehandle provided by 573 the server was guaranteed to be valid or persistent for the lifetime 574 of the filesystem object to which it referred. For some server 575 implementations, this persistence requirement has been difficult to 576 meet. For the NFSv4 protocol, this requirement has been relaxed by 577 introducing another type of filehandle, volatile. With persistent 578 and volatile filehandle types, the server implementation can match 579 the abilities of the filesystem at the server along with the 580 operating environment. The client will have knowledge of the type of 581 filehandle being provided by the server and can be prepared to deal 582 with the semantics of each. 584 1.5.3.2. Attribute Types 586 The NFSv4 protocol has a rich and extensible file object attribute 587 structure, which is divided into REQUIRED, RECOMMENDED, and named 588 attributes (see Section 5). 590 Several (but not all) of the REQUIRED attributes are derived from the 591 attributes of NFSv3 (see definition of the fattr3 data type in [14]). 592 An example of a REQUIRED attribute is the file object's type 593 (Section 5.8.1.2) so that regular files can be distinguished from 594 directories (also known as folders in some operating environments) 595 and other types of objects. REQUIRED attributes are discussed in 596 Section 5.1. 598 An example of three RECOMMENDED attributes are acl, sacl, and dacl. 599 These attributes define an Access Control List (ACL) on a file object 600 ((Section 6). An ACL provides directory and file access control 601 beyond the model used in NFSv3. The ACL definition allows for 602 specification of specific sets of permissions for individual users 603 and groups. In addition, ACL inheritance allows propagation of 604 access permissions and restriction down a directory tree as file 605 system objects are created. RECOMMENDED attributes are discussed in 606 Section 5.2. 608 A named attribute is an opaque byte stream that is associated with a 609 directory or file and referred to by a string name. Named attributes 610 are meant to be used by client applications as a method to associate 611 application-specific data with a regular file or directory. NFSv4.1 612 modifies named attributes relative to NFSv4.0 by tightening the 613 allowed operations in order to prevent the development of non- 614 interoperable implementations. Named attributes are discussed in 615 Section 5.3. 617 1.5.3.3. Multi-server Namespace 619 NFSv4 contains a number of features to allow implementation of 620 namespaces that cross server boundaries and that allow and facilitate 621 a non-disruptive transfer of support for individual file systems 622 between servers. They are all based upon attributes that allow one 623 file system to specify alternate or new locations for that file 624 system. 626 These attributes may be used together with the concept of absent file 627 systems, which provide specifications for additional locations but no 628 actual file system content. This allows a number of important 629 facilities: 631 o Location attributes may be used with absent file systems to 632 implement referrals whereby one server may direct the client to a 633 file system provided by another server. This allows extensive 634 multi-server namespaces to be constructed. 636 o Location attributes may be provided for present file systems to 637 provide the locations of alternate file system instances or 638 replicas to be used in the event that the current file system 639 instance becomes unavailable. 641 o Location attributes may be provided when a previously present file 642 system becomes absent. This allows non-disruptive migration of 643 file systems to alternate servers. 645 1.5.4. OPEN and CLOSE 647 The NFSv4 protocol introduces OPEN and CLOSE operations. The OPEN 648 operation provides a single point where file lookup, creation, and 649 share semantics can be combined. The CLOSE operation also provides 650 for the release of state accumulated by OPEN. 652 1.5.5. File Locking 654 With the NFSv4 protocol, the support for byte range file locking is 655 part of the NFS protocol. The file locking support is structured so 656 that an RPC callback mechanism is not required. This is a departure 657 from the previous versions of the NFS file locking protocol, Network 658 Lock Manager (NLM). The state associated with file locks is 659 maintained at the server under a lease-based model. The server 660 defines a single lease period for all state held by a NFS client. If 661 the client does not renew its lease within the defined period, all 662 state associated with the client's lease may be released by the 663 server. The client may renew its lease with use of the RENEW 664 operation or implicitly by use of other operations (primarily READ). 666 1.5.6. Client Caching and Delegation 668 The file, attribute, and directory caching for the NFSv4 protocol is 669 similar to previous versions. Attributes and directory information 670 are cached for a duration determined by the client. At the end of a 671 predefined timeout, the client will query the server to see if the 672 related filesystem object has been updated. 674 For file data, the client checks its cache validity when the file is 675 opened. A query is sent to the server to determine if the file has 676 been changed. Based on this information, the client determines if 677 the data cache for the file should kept or released. Also, when the 678 file is closed, any modified data is written to the server. 680 If an application wants to serialize access to file data, file 681 locking of the file data ranges in question should be used. 683 The major addition to NFSv4 in the area of caching is the ability of 684 the server to delegate certain responsibilities to the client. When 685 the server grants a delegation for a file to a client, the client is 686 guaranteed certain semantics with respect to the sharing of that file 687 with other clients. At OPEN, the server may provide the client 688 either a OPEN_DELEGATE_READ or OPEN_DELEGATE_WRITE delegation for the 689 file. If the client is granted a OPEN_DELEGATE_READ delegation, it 690 is assured that no other client has the ability to write to the file 691 for the duration of the delegation. If the client is granted a 692 OPEN_DELEGATE_WRITE delegation, the client is assured that no other 693 client has read or write access to the file. 695 Delegations can be recalled by the server. If another client 696 requests access to the file in such a way that the access conflicts 697 with the granted delegation, the server is able to notify the initial 698 client and recall the delegation. This requires that a callback path 699 exist between the server and client. If this callback path does not 700 exist, then delegations cannot be granted. The essence of a 701 delegation is that it allows the client to locally service operations 702 such as OPEN, CLOSE, LOCK, LOCKU, READ, or WRITE without immediate 703 interaction with the server. 705 1.6. General Definitions 707 The following definitions are provided for the purpose of providing 708 an appropriate context for the reader. 710 Byte: In this document, a byte is an octet, i.e., a datum exactly 8 711 bits in length. 713 Client: The client is the entity that accesses the NFS server's 714 resources. The client may be an application that contains the 715 logic to access the NFS server directly. The client may also be 716 the traditional operating system client that provides remote 717 filesystem services for a set of applications. 719 With reference to byte-range locking, the client is also the 720 entity that maintains a set of locks on behalf of one or more 721 applications. This client is responsible for crash or failure 722 recovery for those locks it manages. 724 Note that multiple clients may share the same transport and 725 connection and multiple clients may exist on the same network 726 node. 728 Client ID: A 64-bit quantity used as a unique, short-hand reference 729 to a client supplied Verifier and ID. The server is responsible 730 for supplying the Client ID. 732 File System: The file system is the collection of objects on a 733 server that share the same fsid attribute (see Section 5.8.1.9). 735 Lease: An interval of time defined by the server for which the 736 client is irrevocably granted a lock. At the end of a lease 737 period the lock may be revoked if the lease has not been extended. 738 The lock must be revoked if a conflicting lock has been granted 739 after the lease interval. 741 All leases granted by a server have the same fixed interval. Note 742 that the fixed interval was chosen to alleviate the expense a 743 server would have in maintaining state about variable length 744 leases across server failures. 746 Lock: The term "lock" is used to refer to both record (byte-range) 747 locks as well as share reservations unless specifically stated 748 otherwise. 750 Server: The "Server" is the entity responsible for coordinating 751 client access to a set of filesystems. 753 Stable Storage: NFSv4 servers must be able to recover without data 754 loss from multiple power failures (including cascading power 755 failures, that is, several power failures in quick succession), 756 operating system failures, and hardware failure of components 757 other than the storage medium itself (for example, disk, 758 nonvolatile RAM). 760 Some examples of stable storage that are allowable for an NFS 761 server include: 763 (1) Media commit of data, that is, the modified data has been 764 successfully written to the disk media, for example, the disk 765 platter. 767 (2) An immediate reply disk drive with battery-backed on-drive 768 intermediate storage or uninterruptible power system (UPS). 770 (3) Server commit of data with battery-backed intermediate 771 storage and recovery software. 773 (4) Cache commit with uninterruptible power system (UPS) and 774 recovery software. 776 Stateid: A stateid is a 128-bit quantity returned by a server that 777 uniquely identifies the open and locking states provided by the 778 server for a specific open-owner or lock-owner/open-owner pair for 779 a specific file and type of lock. 781 Verifier: A 64-bit quantity generated by the client that the server 782 can use to determine if the client has restarted and lost all 783 previous lock state. 785 2. Protocol Data Types 787 The syntax and semantics to describe the data types of the NFS 788 version 4 protocol are defined in the XDR [15] and RPC [3] documents. 789 The next sections build upon the XDR data types to define types and 790 structures specific to this protocol. 792 2.1. Basic Data Types 794 These are the base NFSv4 data types. 796 +----------------+--------------------------------------------------+ 797 | Data Type | Definition | 798 +----------------+--------------------------------------------------+ 799 | int32_t | typedef int int32_t; | 800 | uint32_t | typedef unsigned int uint32_t; | 801 | int64_t | typedef hyper int64_t; | 802 | uint64_t | typedef unsigned hyper uint64_t; | 803 | attrlist4 | typedef opaque attrlist4<>; | 804 | | Used for file/directory attributes. | 805 | bitmap4 | typedef uint32_t bitmap4<>; | 806 | | Used in attribute array encoding. | 807 | changeid4 | typedef uint64_t changeid4; | 808 | | Used in the definition of change_info4. | 809 | clientid4 | typedef uint64_t clientid4; | 810 | | Shorthand reference to client identification. | 811 | count4 | typedef uint32_t count4; | 812 | | Various count parameters (READ, WRITE, COMMIT). | 813 | length4 | typedef uint64_t length4; | 814 | | Describes LOCK lengths. | 815 | mode4 | typedef uint32_t mode4; | 816 | | Mode attribute data type. | 817 | nfs_cookie4 | typedef uint64_t nfs_cookie4; | 818 | | Opaque cookie value for READDIR. | 819 | nfs_fh4 | typedef opaque nfs_fh4; | 820 | | Filehandle definition. | 821 | nfs_ftype4 | enum nfs_ftype4; | 822 | | Various defined file types. | 823 | nfsstat4 | enum nfsstat4; | 824 | | Return value for operations. | 825 | offset4 | typedef uint64_t offset4; | 826 | | Various offset designations (READ, WRITE, LOCK, | 827 | | COMMIT). | 828 | qop4 | typedef uint32_t qop4; | 829 | | Quality of protection designation in SECINFO. | 830 | sec_oid4 | typedef opaque sec_oid4<>; | 831 | | Security Object Identifier. The sec_oid4 data | 832 | | type is not really opaque. Instead it contains | 833 | | an ASN.1 OBJECT IDENTIFIER as used by GSS-API in | 834 | | the mech_type argument to GSS_Init_sec_context. | 835 | | See [6] for details. | 836 | seqid4 | typedef uint32_t seqid4; | 837 | | Sequence identifier used for file locking. | 838 | utf8string | typedef opaque utf8string<>; | 839 | | UTF-8 encoding for strings. | 840 | utf8_should | typedef utf8string utf8_should; | 841 | | String expected to be UTF8 but no validation | 842 | utf8val_should | typedef utf8string utf8val_should; | 843 | | String SHOULD be sent UTF8 and SHOULD be | 844 | | validated | 845 | utf8val_must | typedef utf8string utf8val_must; | 846 | | String MUST be sent UTF8 and MUST be validated | 847 | ascii_must | typedef utf8string ascii_must; | 848 | | String MUST be sent as ASCII and thus is | 849 | | automatically UTF8 | 850 | comptag4 | typedef utf8_should comptag4; | 851 | | Tag should be UTF8 but is not checked | 852 | component4 | typedef utf8val_should component4; | 853 | | Represents path name components. | 854 | linktext4 | typedef utf8val_should linktext4; | 855 | | Symbolic link contents. | 856 | pathname4 | typedef component4 pathname4<>; | 857 | | Represents path name for fs_locations. | 858 | nfs_lockid4 | typedef uint64_t nfs_lockid4; | 859 | verifier4 | typedef opaque verifier4[NFS4_VERIFIER_SIZE]; | 860 | | Verifier used for various operations (COMMIT, | 861 | | CREATE, EXCHANGE_ID, OPEN, READDIR, WRITE) | 862 | | NFS4_VERIFIER_SIZE is defined as 8. | 863 +----------------+--------------------------------------------------+ 865 End of Base Data Types 867 Table 1 869 2.2. Structured Data Types 871 2.2.1. nfstime4 873 struct nfstime4 { 874 int64_t seconds; 875 uint32_t nseconds; 876 }; 878 The nfstime4 structure gives the number of seconds and nanoseconds 879 since midnight or 0 hour January 1, 1970 Coordinated Universal Time 880 (UTC). Values greater than zero for the seconds field denote dates 881 after the 0 hour January 1, 1970. Values less than zero for the 882 seconds field denote dates before the 0 hour January 1, 1970. In 883 both cases, the nseconds field is to be added to the seconds field 884 for the final time representation. For example, if the time to be 885 represented is one-half second before 0 hour January 1, 1970, the 886 seconds field would have a value of negative one (-1) and the 887 nseconds fields would have a value of one-half second (500000000). 888 Values greater than 999,999,999 for nseconds are considered invalid. 890 This data type is used to pass time and date information. A server 891 converts to and from its local representation of time when processing 892 time values, preserving as much accuracy as possible. If the 893 precision of timestamps stored for a filesystem object is less than 894 defined, loss of precision can occur. An adjunct time maintenance 895 protocol is recommended to reduce client and server time skew. 897 2.2.2. time_how4 899 enum time_how4 { 900 SET_TO_SERVER_TIME4 = 0, 901 SET_TO_CLIENT_TIME4 = 1 902 }; 904 2.2.3. settime4 906 union settime4 switch (time_how4 set_it) { 907 case SET_TO_CLIENT_TIME4: 908 nfstime4 time; 909 default: 910 void; 911 }; 913 The above definitions are used as the attribute definitions to set 914 time values. If set_it is SET_TO_SERVER_TIME4, then the server uses 915 its local representation of time for the time value. 917 2.2.4. specdata4 919 struct specdata4 { 920 uint32_t specdata1; /* major device number */ 921 uint32_t specdata2; /* minor device number */ 922 }; 924 This data type represents additional information for the device file 925 types NF4CHR and NF4BLK. 927 2.2.5. fsid4 929 struct fsid4 { 930 uint64_t major; 931 uint64_t minor; 932 }; 934 This type is the filesystem identifier that is used as a mandatory 935 attribute. 937 2.2.6. fs_location4 939 struct fs_location4 { 940 utf8val_must server<>; 941 pathname4 rootpath; 942 }; 944 2.2.7. fs_locations4 946 struct fs_locations4 { 947 pathname4 fs_root; 948 fs_location4 locations<>; 949 }; 951 The fs_location4 and fs_locations4 data types are used for the 952 fs_locations recommended attribute which is used for migration and 953 replication support. 955 2.2.8. fattr4 957 struct fattr4 { 958 bitmap4 attrmask; 959 attrlist4 attr_vals; 960 }; 962 The fattr4 structure is used to represent file and directory 963 attributes. 965 The bitmap is a counted array of 32 bit integers used to contain bit 966 values. The position of the integer in the array that contains bit n 967 can be computed from the expression (n / 32) and its bit within that 968 integer is (n mod 32). 970 0 1 971 +-----------+-----------+-----------+-- 972 | count | 31 .. 0 | 63 .. 32 | 973 +-----------+-----------+-----------+-- 975 2.2.9. change_info4 977 struct change_info4 { 978 bool atomic; 979 changeid4 before; 980 changeid4 after; 981 }; 983 This structure is used with the CREATE, LINK, REMOVE, RENAME 984 operations to let the client know the value of the change attribute 985 for the directory in which the target filesystem object resides. 987 2.2.10. clientaddr4 989 struct clientaddr4 { 990 /* see struct rpcb in RFC 1833 */ 991 string r_netid<>; /* network id */ 992 string r_addr<>; /* universal address */ 993 }; 995 The clientaddr4 structure is used as part of the SETCLIENTID 996 operation to either specify the address of the client that is using a 997 client ID or as part of the callback registration. The r_netid and 998 r_addr fields are specified in [17], but they are underspecified in 1000 [17] as far as what they should look like for specific protocols. 1002 For TCP over IPv4 and for UDP over IPv4, the format of r_addr is the 1003 US-ASCII string: 1005 h1.h2.h3.h4.p1.p2 1007 The prefix, "h1.h2.h3.h4", is the standard textual form for 1008 representing an IPv4 address, which is always four octets long. 1009 Assuming big-endian ordering, h1, h2, h3, and h4, are respectively, 1010 the first through fourth octets each converted to ASCII-decimal. 1011 Assuming big-endian ordering, p1 and p2 are, respectively, the first 1012 and second octets each converted to ASCII-decimal. For example, if a 1013 host, in big-endian order, has an address of 0x0A010307 and there is 1014 a service listening on, in big endian order, port 0x020F (decimal 1015 527), then the complete universal address is "10.1.3.7.2.15". 1017 For TCP over IPv4 the value of r_netid is the string "tcp". For UDP 1018 over IPv4 the value of r_netid is the string "udp". 1020 For TCP over IPv6 and for UDP over IPv6, the format of r_addr is the 1021 US-ASCII string: 1023 x1:x2:x3:x4:x5:x6:x7:x8.p1.p2 1025 The suffix "p1.p2" is the service port, and is computed the same way 1026 as with universal addresses for TCP and UDP over IPv4. The prefix, 1027 "x1:x2:x3:x4:x5:x6:x7:x8", is the standard textual form for 1028 representing an IPv6 address as defined in Section 2.2 of [18]. 1029 Additionally, the two alternative forms specified in Section 2.2 of 1030 [18] are also acceptable. 1032 For TCP over IPv6 the value of r_netid is the string "tcp6". For UDP 1033 over IPv6 the value of r_netid is the string "udp6". 1035 2.2.11. cb_client4 1037 struct cb_client4 { 1038 unsigned int cb_program; 1039 clientaddr4 cb_location; 1040 }; 1042 This structure is used by the client to inform the server of its call 1043 back address; includes the program number and client address. 1045 2.2.12. nfs_client_id4 1047 struct nfs_client_id4 { 1048 verifier4 verifier; 1049 opaque id; 1050 }; 1052 This structure is part of the arguments to the SETCLIENTID operation. 1053 NFS4_OPAQUE_LIMIT is defined as 1024. 1055 2.2.13. open_owner4 1057 struct open_owner4 { 1058 clientid4 clientid; 1059 opaque owner; 1060 }; 1062 This structure is used to identify the owner of open state. 1063 NFS4_OPAQUE_LIMIT is defined as 1024. 1065 2.2.14. lock_owner4 1067 struct lock_owner4 { 1068 clientid4 clientid; 1069 opaque owner; 1070 }; 1072 This structure is used to identify the owner of file locking state. 1073 NFS4_OPAQUE_LIMIT is defined as 1024. 1075 2.2.15. open_to_lock_owner4 1077 struct open_to_lock_owner4 { 1078 seqid4 open_seqid; 1079 stateid4 open_stateid; 1080 seqid4 lock_seqid; 1081 lock_owner4 lock_owner; 1082 }; 1084 This structure is used for the first LOCK operation done for an 1085 open_owner4. It provides both the open_stateid and lock_owner such 1086 that the transition is made from a valid open_stateid sequence to 1087 that of the new lock_stateid sequence. Using this mechanism avoids 1088 the confirmation of the lock_owner/lock_seqid pair since it is tied 1089 to established state in the form of the open_stateid/open_seqid. 1091 2.2.16. stateid4 1093 struct stateid4 { 1094 uint32_t seqid; 1095 opaque other[12]; 1096 }; 1098 This structure is used for the various state sharing mechanisms 1099 between the client and server. For the client, this data structure 1100 is read-only. The starting value of the seqid field is undefined. 1101 The server is required to increment the seqid field monotonically at 1102 each transition of the stateid. This is important since the client 1103 will inspect the seqid in OPEN stateids to determine the order of 1104 OPEN processing done by the server. 1106 3. RPC and Security Flavor 1108 The NFSv4 protocol is a Remote Procedure Call (RPC) application that 1109 uses RPC version 2 and the corresponding eXternal Data Representation 1110 (XDR) as defined in [3] and [15]. The RPCSEC_GSS security flavor as 1111 defined in [4] MUST be used as the mechanism to deliver stronger 1112 security for the NFSv4 protocol. 1114 3.1. Ports and Transports 1116 Historically, NFSv2 and NFSv3 servers have resided on port 2049. The 1117 registered port 2049 [19] for the NFS protocol SHOULD be the default 1118 configuration. Using the registered port for NFS services means the 1119 NFS client will not need to use the RPC binding protocols as 1120 described in [17]; this will allow NFS to transit firewalls. 1122 Where an NFSv4 implementation supports operation over the IP network 1123 protocol, the supported transports between NFS and IP MUST be among 1124 the IETF-approved congestion control transport protocols, which 1125 include TCP and SCTP. To enhance the possibilities for 1126 interoperability, an NFSv4 implementation MUST support operation over 1127 the TCP transport protocol, at least until such time as a standards 1128 track RFC revises this requirement to use a different IETF-approved 1129 congestion control transport protocol. 1131 If TCP is used as the transport, the client and server SHOULD use 1132 persistent connections. This will prevent the weakening of TCP's 1133 congestion control via short lived connections and will improve 1134 performance for the WAN environment by eliminating the need for SYN 1135 handshakes. 1137 As noted in Section 17, the authentication model for NFSv4 has moved 1138 from machine-based to principal-based. However, this modification of 1139 the authentication model does not imply a technical requirement to 1140 move the TCP connection management model from whole machine-based to 1141 one based on a per user model. In particular, NFS over TCP client 1142 implementations have traditionally multiplexed traffic for multiple 1143 users over a common TCP connection between an NFS client and server. 1144 This has been true, regardless whether the NFS client is using 1145 AUTH_SYS, AUTH_DH, RPCSEC_GSS or any other flavor. Similarly, NFS 1146 over TCP server implementations have assumed such a model and thus 1147 scale the implementation of TCP connection management in proportion 1148 to the number of expected client machines. It is intended that NFSv4 1149 will not modify this connection management model. NFSv4 clients that 1150 violate this assumption can expect scaling issues on the server and 1151 hence reduced service. 1153 Note that for various timers, the client and server should avoid 1154 inadvertent synchronization of those timers. For further discussion 1155 of the general issue refer to [20]. 1157 3.1.1. Client Retransmission Behavior 1159 When processing a request received over a reliable transport such as 1160 TCP, the NFSv4 server MUST NOT silently drop the request, except if 1161 the transport connection has been broken. Given such a contract 1162 between NFSv4 clients and servers, clients MUST NOT retry a request 1163 unless one or both of the following are true: 1165 o The transport connection has been broken 1167 o The procedure being retried is the NULL procedure 1169 Since reliable transports, such as TCP, do not always synchronously 1170 inform a peer when the other peer has broken the connection (for 1171 example, when an NFS server reboots), the NFSv4 client may want to 1172 actively "probe" the connection to see if has been broken. Use of 1173 the NULL procedure is one recommended way to do so. So, when a 1174 client experiences a remote procedure call timeout (of some arbitrary 1175 implementation specific amount), rather than retrying the remote 1176 procedure call, it could instead issue a NULL procedure call to the 1177 server. If the server has died, the transport connection break will 1178 eventually be indicated to the NFSv4 client. The client can then 1179 reconnect, and then retry the original request. If the NULL 1180 procedure call gets a response, the connection has not broken. The 1181 client can decide to wait longer for the original request's response, 1182 or it can break the transport connection and reconnect before re- 1183 sending the original request. 1185 For callbacks from the server to the client, the same rules apply, 1186 but the server doing the callback becomes the client, and the client 1187 receiving the callback becomes the server. 1189 3.2. Security Flavors 1191 Traditional RPC implementations have included AUTH_NONE, AUTH_SYS, 1192 AUTH_DH, and AUTH_KRB4 as security flavors. With [4] an additional 1193 security flavor of RPCSEC_GSS has been introduced which uses the 1194 functionality of GSS-API [6]. This allows for the use of various 1195 security mechanisms by the RPC layer without the additional 1196 implementation overhead of adding RPC security flavors. For NFSv4, 1197 the RPCSEC_GSS security flavor MUST be used to enable the mandatory 1198 security mechanism. Other flavors, such as, AUTH_NONE, AUTH_SYS, and 1199 AUTH_DH MAY be implemented as well. 1201 3.2.1. Security mechanisms for NFSv4 1203 The use of RPCSEC_GSS requires selection of: mechanism, quality of 1204 protection, and service (authentication, integrity, privacy). The 1205 remainder of this document will refer to these three parameters of 1206 the RPCSEC_GSS security as the security triple. 1208 3.2.1.1. Kerberos V5 as a security triple 1210 The Kerberos V5 GSS-API mechanism as described in [16] MUST be 1211 implemented and provide the following security triples. 1213 column descriptions: 1215 1 == number of pseudo flavor 1216 2 == name of pseudo flavor 1217 3 == mechanism's OID 1218 4 == mechanism's algorithm(s) 1219 5 == RPCSEC_GSS service 1221 1 2 3 4 5 1222 -------------------------------------------------------------------- 1223 390003 krb5 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_none 1224 390004 krb5i 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_integrity 1225 390005 krb5p 1.2.840.113554.1.2.2 DES MAC MD5 rpc_gss_svc_privacy 1226 for integrity, 1227 and 56 bit DES 1228 for privacy. 1230 Note that the pseudo flavor is presented here as a mapping aid to the 1231 implementor. Because this NFS protocol includes a method to 1232 negotiate security and it understands the GSS-API mechanism, the 1233 pseudo flavor is not needed. The pseudo flavor is needed for NFSv3 1234 since the security negotiation is done via the MOUNT protocol. 1236 For a discussion of NFS' use of RPCSEC_GSS and Kerberos V5, please 1237 see [21]. 1239 Users and implementors are warned that 56 bit DES is no longer 1240 considered state of the art in terms of resistance to brute force 1241 attacks. Once a revision to [16] is available that adds support for 1242 AES, implementors are urged to incorporate AES into their NFSv4 over 1243 Kerberos V5 protocol stacks, and users are similarly urged to migrate 1244 to the use of AES. 1246 3.2.1.2. LIPKEY as a security triple 1248 The LIPKEY GSS-API mechanism as described in [5] MAY be implemented 1249 and provide the following security triples. The definition of the 1250 columns matches those in Section 3.2.1.1. 1252 1 2 3 4 5 1253 -------------------------------------------------------------------- 1254 390006 lipkey 1.3.6.1.5.5.9 negotiated rpc_gss_svc_none 1255 390007 lipkey-i 1.3.6.1.5.5.9 negotiated rpc_gss_svc_integrity 1256 390008 lipkey-p 1.3.6.1.5.5.9 negotiated rpc_gss_svc_privacy 1258 The mechanism algorithm is listed as "negotiated". This is because 1259 LIPKEY is layered on SPKM-3 and in SPKM-3 [5] the confidentiality and 1260 integrity algorithms are negotiated. Since SPKM-3 specifies HMAC-MD5 1261 for integrity as MANDATORY, 128 bit cast5CBC for confidentiality for 1262 privacy as MANDATORY, and further specifies that HMAC-MD5 and 1263 cast5CBC MUST be listed first before weaker algorithms, specifying 1264 "negotiated" in column 4 does not impair interoperability. In the 1265 event an SPKM-3 peer does not support the mandatory algorithms, the 1266 other peer is free to accept or reject the GSS-API context creation. 1268 Because SPKM-3 negotiates the algorithms, subsequent calls to 1269 LIPKEY's GSS_Wrap() and GSS_GetMIC() by RPCSEC_GSS will use a quality 1270 of protection value of 0 (zero). See section 5.2 of [22] for an 1271 explanation. 1273 LIPKEY uses SPKM-3 to create a secure channel in which to pass a user 1274 name and password from the client to the server. Once the user name 1275 and password have been accepted by the server, calls to the LIPKEY 1276 context are redirected to the SPKM-3 context. See [5] for more 1277 details. 1279 3.2.1.3. SPKM-3 as a security triple 1281 The SPKM-3 GSS-API mechanism as described in [5] MAY be implemented 1282 and provide the following security triples. The definition of the 1283 columns matches those in Section 3.2.1.1. 1285 1 2 3 4 5 1286 -------------------------------------------------------------------- 1287 390009 spkm3 1.3.6.1.5.5.1.3 negotiated rpc_gss_svc_none 1288 390010 spkm3i 1.3.6.1.5.5.1.3 negotiated rpc_gss_svc_integrity 1289 390011 spkm3p 1.3.6.1.5.5.1.3 negotiated rpc_gss_svc_privacy 1291 For a discussion as to why the mechanism algorithm is listed as 1292 "negotiated", see Section 3.2.1.2. 1294 Because SPKM-3 negotiates the algorithms, subsequent calls to 1295 SPKM-3's GSS_Wrap() and GSS_GetMIC() by RPCSEC_GSS will use a quality 1296 of protection value of 0 (zero). See section 5.2 of [22] for an 1297 explanation. 1299 Even though LIPKEY is layered over SPKM-3, SPKM-3 is specified as a 1300 mandatory set of triples to handle the situations where the initiator 1301 (the client) is anonymous or where the initiator has its own 1302 certificate. If the initiator is anonymous, there will not be a user 1303 name and password to send to the target (the server). If the 1304 initiator has its own certificate, then using passwords is 1305 superfluous. 1307 3.3. Security Negotiation 1309 With the NFSv4 server potentially offering multiple security 1310 mechanisms, the client needs a method to determine or negotiate which 1311 mechanism is to be used for its communication with the server. The 1312 NFS server may have multiple points within its filesystem name space 1313 that are available for use by NFS clients. In turn the NFS server 1314 may be configured such that each of these entry points may have 1315 different or multiple security mechanisms in use. 1317 The security negotiation between client and server SHOULD be done 1318 with a secure channel to eliminate the possibility of a third party 1319 intercepting the negotiation sequence and forcing the client and 1320 server to choose a lower level of security than required or desired. 1321 See Section 17 for further discussion. 1323 3.3.1. SECINFO 1325 The new SECINFO operation will allow the client to determine, on a 1326 per filehandle basis, what security triple is to be used for server 1327 access. In general, the client will not have to use the SECINFO 1328 operation except during initial communication with the server or when 1329 the client crosses policy boundaries at the server. It is possible 1330 that the server's policies change during the client's interaction 1331 therefore forcing the client to negotiate a new security triple. 1333 3.3.2. Security Error 1335 Based on the assumption that each NFSv4 client and server MUST 1336 support a minimum set of security (i.e., LIPKEY, SPKM-3, and 1337 Kerberos-V5 all under RPCSEC_GSS), the NFS client will start its 1338 communication with the server with one of the minimal security 1339 triples. During communication with the server, the client may 1340 receive an NFS error of NFS4ERR_WRONGSEC. This error allows the 1341 server to notify the client that the security triple currently being 1342 used is not appropriate for access to the server's filesystem 1343 resources. The client is then responsible for determining what 1344 security triples are available at the server and choose one which is 1345 appropriate for the client. See Section 15.33 for further discussion 1346 of how the client will respond to the NFS4ERR_WRONGSEC error and use 1347 SECINFO. 1349 3.3.3. Callback RPC Authentication 1351 Except as noted elsewhere in this section, the callback RPC 1352 (described later) MUST mutually authenticate the NFS server to the 1353 principal that acquired the client ID (also described later), using 1354 the security flavor the original SETCLIENTID operation used. 1356 For AUTH_NONE, there are no principals, so this is a non-issue. 1358 AUTH_SYS has no notions of mutual authentication or a server 1359 principal, so the callback from the server simply uses the AUTH_SYS 1360 credential that the user used when he set up the delegation. 1362 For AUTH_DH, one commonly used convention is that the server uses the 1363 credential corresponding to this AUTH_DH principal: 1365 unix.host@domain 1367 where host and domain are variables corresponding to the name of 1368 server host and directory services domain in which it lives such as a 1369 Network Information System domain or a DNS domain. 1371 Because LIPKEY is layered over SPKM-3, it is permissible for the 1372 server to use SPKM-3 and not LIPKEY for the callback even if the 1373 client used LIPKEY for SETCLIENTID. 1375 Regardless of what security mechanism under RPCSEC_GSS is being used, 1376 the NFS server, MUST identify itself in GSS-API via a 1377 GSS_C_NT_HOSTBASED_SERVICE name type. GSS_C_NT_HOSTBASED_SERVICE 1378 names are of the form: 1380 service@hostname 1382 For NFS, the "service" element is 1384 nfs 1386 Implementations of security mechanisms will convert nfs@hostname to 1387 various different forms. For Kerberos V5 and LIPKEY, the following 1388 form is RECOMMENDED: 1390 nfs/hostname 1392 For Kerberos V5, nfs/hostname would be a server principal in the 1393 Kerberos Key Distribution Center database. This is the same 1394 principal the client acquired a GSS-API context for when it issued 1395 the SETCLIENTID operation, therefore, the realm name for the server 1396 principal must be the same for the callback as it was for the 1397 SETCLIENTID. 1399 For LIPKEY, this would be the username passed to the target (the NFS 1400 version 4 client that receives the callback). 1402 It should be noted that LIPKEY may not work for callbacks, since the 1403 LIPKEY client uses a user id/password. If the NFS client receiving 1404 the callback can authenticate the NFS server's user name/password 1405 pair, and if the user that the NFS server is authenticating to has a 1406 public key certificate, then it works. 1408 In situations where the NFS client uses LIPKEY and uses a per-host 1409 principal for the SETCLIENTID operation, instead of using LIPKEY for 1410 SETCLIENTID, it is RECOMMENDED that SPKM-3 with mutual authentication 1411 be used. This effectively means that the client will use a 1412 certificate to authenticate and identify the initiator to the target 1413 on the NFS server. Using SPKM-3 and not LIPKEY has the following 1414 advantages: 1416 o When the server does a callback, it must authenticate to the 1417 principal used in the SETCLIENTID. Even if LIPKEY is used, 1418 because LIPKEY is layered over SPKM-3, the NFS client will need to 1419 have a certificate that corresponds to the principal used in the 1420 SETCLIENTID operation. From an administrative perspective, having 1421 a user name, password, and certificate for both the client and 1422 server is redundant. 1424 o LIPKEY was intended to minimize additional infrastructure 1425 requirements beyond a certificate for the target, and the 1426 expectation is that existing password infrastructure can be 1427 leveraged for the initiator. In some environments, a per-host 1428 password does not exist yet. If certificates are used for any 1429 per-host principals, then additional password infrastructure is 1430 not needed. 1432 o In cases when a host is both an NFS client and server, it can 1433 share the same per-host certificate. 1435 4. Filehandles 1437 The filehandle in the NFS protocol is a per server unique identifier 1438 for a filesystem object. The contents of the filehandle are opaque 1439 to the client. Therefore, the server is responsible for translating 1440 the filehandle to an internal representation of the filesystem 1441 object. 1443 4.1. Obtaining the First Filehandle 1445 The operations of the NFS protocol are defined in terms of one or 1446 more filehandles. Therefore, the client needs a filehandle to 1447 initiate communication with the server. With the NFSv2 protocol [13] 1448 and the NFSv3 protocol [14], there exists an ancillary protocol to 1449 obtain this first filehandle. The MOUNT protocol, RPC program number 1450 100005, provides the mechanism of translating a string based 1451 filesystem path name to a filehandle which can then be used by the 1452 NFS protocols. 1454 The MOUNT protocol has deficiencies in the area of security and use 1455 via firewalls. This is one reason that the use of the public 1456 filehandle was introduced in [23] and [24]. With the use of the 1457 public filehandle in combination with the LOOKUP operation in the 1458 NFSv2 and NFSv3 protocols, it has been demonstrated that the MOUNT 1459 protocol is unnecessary for viable interaction between NFS client and 1460 server. 1462 Therefore, the NFSv4 protocol will not use an ancillary protocol for 1463 translation from string based path names to a filehandle. Two 1464 special filehandles will be used as starting points for the NFS 1465 client. 1467 4.1.1. Root Filehandle 1469 The first of the special filehandles is the ROOT filehandle. The 1470 ROOT filehandle is the "conceptual" root of the filesystem name space 1471 at the NFS server. The client uses or starts with the ROOT 1472 filehandle by employing the PUTROOTFH operation. The PUTROOTFH 1473 operation instructs the server to set the "current" filehandle to the 1474 ROOT of the server's file tree. Once this PUTROOTFH operation is 1475 used, the client can then traverse the entirety of the server's file 1476 tree with the LOOKUP operation. A complete discussion of the server 1477 name space is in Section 8. 1479 4.1.2. Public Filehandle 1481 The second special filehandle is the PUBLIC filehandle. Unlike the 1482 ROOT filehandle, the PUBLIC filehandle may be bound or represent an 1483 arbitrary filesystem object at the server. The server is responsible 1484 for this binding. It may be that the PUBLIC filehandle and the ROOT 1485 filehandle refer to the same filesystem object. However, it is up to 1486 the administrative software at the server and the policies of the 1487 server administrator to define the binding of the PUBLIC filehandle 1488 and server filesystem object. The client may not make any 1489 assumptions about this binding. The client uses the PUBLIC 1490 filehandle via the PUTPUBFH operation. 1492 4.2. Filehandle Types 1494 In the NFSv2 and NFSv3 protocols, there was one type of filehandle 1495 with a single set of semantics. This type of filehandle is termed 1496 "persistent" in NFS Version 4. The semantics of a persistent 1497 filehandle remain the same as before. A new type of filehandle 1498 introduced in NFS Version 4 is the "volatile" filehandle, which 1499 attempts to accommodate certain server environments. 1501 The volatile filehandle type was introduced to address server 1502 functionality or implementation issues which make correct 1503 implementation of a persistent filehandle infeasible. Some server 1504 environments do not provide a filesystem level invariant that can be 1505 used to construct a persistent filehandle. The underlying server 1506 filesystem may not provide the invariant or the server's filesystem 1507 programming interfaces may not provide access to the needed 1508 invariant. Volatile filehandles may ease the implementation of 1509 server functionality such as hierarchical storage management or 1510 filesystem reorganization or migration. However, the volatile 1511 filehandle increases the implementation burden for the client. 1513 Since the client will need to handle persistent and volatile 1514 filehandles differently, a file attribute is defined which may be 1515 used by the client to determine the filehandle types being returned 1516 by the server. 1518 4.2.1. General Properties of a Filehandle 1520 The filehandle contains all the information the server needs to 1521 distinguish an individual file. To the client, the filehandle is 1522 opaque. The client stores filehandles for use in a later request and 1523 can compare two filehandles from the same server for equality by 1524 doing a byte-by-byte comparison. However, the client MUST NOT 1525 otherwise interpret the contents of filehandles. If two filehandles 1526 from the same server are equal, they MUST refer to the same file. 1527 Servers SHOULD try to maintain a one-to-one correspondence between 1528 filehandles and files but this is not required. Clients MUST use 1529 filehandle comparisons only to improve performance, not for correct 1530 behavior. All clients need to be prepared for situations in which it 1531 cannot be determined whether two filehandles denote the same object 1532 and in such cases, avoid making invalid assumptions which might cause 1533 incorrect behavior. Further discussion of filehandle and attribute 1534 comparison in the context of data caching is presented in 1535 Section 10.3.4. 1537 As an example, in the case that two different path names when 1538 traversed at the server terminate at the same filesystem object, the 1539 server SHOULD return the same filehandle for each path. This can 1540 occur if a hard link is used to create two file names which refer to 1541 the same underlying file object and associated data. For example, if 1542 paths /a/b/c and /a/d/c refer to the same file, the server SHOULD 1543 return the same filehandle for both path names traversals. 1545 4.2.2. Persistent Filehandle 1547 A persistent filehandle is defined as having a fixed value for the 1548 lifetime of the filesystem object to which it refers. Once the 1549 server creates the filehandle for a filesystem object, the server 1550 MUST accept the same filehandle for the object for the lifetime of 1551 the object. If the server restarts or reboots the NFS server must 1552 honor the same filehandle value as it did in the server's previous 1553 instantiation. Similarly, if the filesystem is migrated, the new NFS 1554 server must honor the same filehandle as the old NFS server. 1556 The persistent filehandle will be become stale or invalid when the 1557 filesystem object is removed. When the server is presented with a 1558 persistent filehandle that refers to a deleted object, it MUST return 1559 an error of NFS4ERR_STALE. A filehandle may become stale when the 1560 filesystem containing the object is no longer available. The file 1561 system may become unavailable if it exists on removable media and the 1562 media is no longer available at the server or the filesystem in whole 1563 has been destroyed or the filesystem has simply been removed from the 1564 server's name space (i.e., unmounted in a UNIX environment). 1566 4.2.3. Volatile Filehandle 1568 A volatile filehandle does not share the same longevity 1569 characteristics of a persistent filehandle. The server may determine 1570 that a volatile filehandle is no longer valid at many different 1571 points in time. If the server can definitively determine that a 1572 volatile filehandle refers to an object that has been removed, the 1573 server should return NFS4ERR_STALE to the client (as is the case for 1574 persistent filehandles). In all other cases where the server 1575 determines that a volatile filehandle can no longer be used, it 1576 should return an error of NFS4ERR_FHEXPIRED. 1578 The mandatory attribute "fh_expire_type" is used by the client to 1579 determine what type of filehandle the server is providing for a 1580 particular filesystem. This attribute is a bitmask with the 1581 following values: 1583 FH4_PERSISTENT: The value of FH4_PERSISTENT is used to indicate a 1584 persistent filehandle, which is valid until the object is removed 1585 from the filesystem. The server will not return NFS4ERR_FHEXPIRED 1586 for this filehandle. FH4_PERSISTENT is defined as a value in 1587 which none of the bits specified below are set. 1589 FH4_VOLATILE_ANY: The filehandle may expire at any time, except as 1590 specifically excluded (i.e., FH4_NOEXPIRE_WITH_OPEN). 1592 FH4_NOEXPIRE_WITH_OPEN: May only be set when FH4_VOLATILE_ANY is 1593 set. If this bit is set, then the meaning of FH4_VOLATILE_ANY is 1594 qualified to exclude any expiration of the filehandle when it is 1595 open. 1597 FH4_VOL_MIGRATION: The filehandle will expire as a result of 1598 migration. If FH4_VOLATILE_ANY is set, FH4_VOL_MIGRATION is 1599 redundant. 1601 FH4_VOL_RENAME: The filehandle will expire during rename. This 1602 includes a rename by the requesting client or a rename by any 1603 other client. If FH4_VOLATILE_ANY is set, FH4_VOL_RENAME is 1604 redundant. 1606 Servers which provide volatile filehandles that may expire while open 1607 (i.e., if FH4_VOL_MIGRATION or FH4_VOL_RENAME is set or if 1608 FH4_VOLATILE_ANY is set and FH4_NOEXPIRE_WITH_OPEN not set), should 1609 deny a RENAME or REMOVE that would affect an OPEN file of any of the 1610 components leading to the OPEN file. In addition, the server should 1611 deny all RENAME or REMOVE requests during the grace period upon 1612 server restart. 1614 Note that the bits FH4_VOL_MIGRATION and FH4_VOL_RENAME allow the 1615 client to determine that expiration has occurred whenever a specific 1616 event occurs, without an explicit filehandle expiration error from 1617 the server. FH4_VOLATILE_ANY does not provide this form of 1618 information. In situations where the server will expire many, but 1619 not all filehandles upon migration (e.g., all but those that are 1620 open), FH4_VOLATILE_ANY (in this case with FH4_NOEXPIRE_WITH_OPEN) is 1621 a better choice since the client may not assume that all filehandles 1622 will expire when migration occurs, and it is likely that additional 1623 expirations will occur (as a result of file CLOSE) that are separated 1624 in time from the migration event itself. 1626 4.2.4. One Method of Constructing a Volatile Filehandle 1628 A volatile filehandle, while opaque to the client could contain: 1630 [volatile bit = 1 | server boot time | slot | generation number] 1632 o slot is an index in the server volatile filehandle table 1634 o generation number is the generation number for the table entry/ 1635 slot 1637 When the client presents a volatile filehandle, the server makes the 1638 following checks, which assume that the check for the volatile bit 1639 has passed. If the server boot time is less than the current server 1640 boot time, return NFS4ERR_FHEXPIRED. If slot is out of range, return 1641 NFS4ERR_BADHANDLE. If the generation number does not match, return 1642 NFS4ERR_FHEXPIRED. 1644 When the server reboots, the table is gone (it is volatile). 1646 If volatile bit is 0, then it is a persistent filehandle with a 1647 different structure following it. 1649 4.3. Client Recovery from Filehandle Expiration 1651 If possible, the client SHOULD recover from the receipt of an 1652 NFS4ERR_FHEXPIRED error. The client must take on additional 1653 responsibility so that it may prepare itself to recover from the 1654 expiration of a volatile filehandle. If the server returns 1655 persistent filehandles, the client does not need these additional 1656 steps. 1658 For volatile filehandles, most commonly the client will need to store 1659 the component names leading up to and including the filesystem object 1660 in question. With these names, the client should be able to recover 1661 by finding a filehandle in the name space that is still available or 1662 by starting at the root of the server's filesystem name space. 1664 If the expired filehandle refers to an object that has been removed 1665 from the filesystem, obviously the client will not be able to recover 1666 from the expired filehandle. 1668 It is also possible that the expired filehandle refers to a file that 1669 has been renamed. If the file was renamed by another client, again 1670 it is possible that the original client will not be able to recover. 1671 However, in the case that the client itself is renaming the file and 1672 the file is open, it is possible that the client may be able to 1673 recover. The client can determine the new path name based on the 1674 processing of the rename request. The client can then regenerate the 1675 new filehandle based on the new path name. The client could also use 1676 the compound operation mechanism to construct a set of operations 1677 like: 1679 RENAME A B 1680 LOOKUP B 1681 GETFH 1683 Note that the COMPOUND procedure does not provide atomicity. This 1684 example only reduces the overhead of recovering from an expired 1685 filehandle. 1687 5. File Attributes 1689 To meet the requirements of extensibility and increased 1690 interoperability with non-UNIX platforms, attributes need to be 1691 handled in a flexible manner. The NFSv3 fattr3 structure contains a 1692 fixed list of attributes that not all clients and servers are able to 1693 support or care about. The fattr3 structure cannot be extended as 1694 new needs arise and it provides no way to indicate non-support. With 1695 the NFSv4.0 protocol, the client is able to query what attributes the 1696 server supports and construct requests with only those supported 1697 attributes (or a subset thereof). 1699 To this end, attributes are divided into three groups: REQUIRED, 1700 RECOMMENDED, and named. Both REQUIRED and RECOMMENDED attributes are 1701 supported in the NFSv4.0 protocol by a specific and well-defined 1702 encoding and are identified by number. They are requested by setting 1703 a bit in the bit vector sent in the GETATTR request; the server 1704 response includes a bit vector to list what attributes were returned 1705 in the response. New REQUIRED or RECOMMENDED attributes may be added 1706 to the NFSv4 protocol as part of a new minor version by publishing a 1707 Standards Track RFC which allocates a new attribute number value and 1708 defines the encoding for the attribute. See Section 11 for further 1709 discussion. 1711 Named attributes are accessed by the new OPENATTR operation, which 1712 accesses a hidden directory of attributes associated with a file 1713 system object. OPENATTR takes a filehandle for the object and 1714 returns the filehandle for the attribute hierarchy. The filehandle 1715 for the named attributes is a directory object accessible by LOOKUP 1716 or READDIR and contains files whose names represent the named 1717 attributes and whose data bytes are the value of the attribute. For 1718 example: 1720 +----------+-----------+---------------------------------+ 1721 | LOOKUP | "foo" | ; look up file | 1722 | GETATTR | attrbits | | 1723 | OPENATTR | | ; access foo's named attributes | 1724 | LOOKUP | "x11icon" | ; look up specific attribute | 1725 | READ | 0,4096 | ; read stream of bytes | 1726 +----------+-----------+---------------------------------+ 1728 Named attributes are intended for data needed by applications rather 1729 than by an NFS client implementation. NFS implementors are strongly 1730 encouraged to define their new attributes as RECOMMENDED attributes 1731 by bringing them to the IETF Standards Track process. 1733 The set of attributes that are classified as REQUIRED is deliberately 1734 small since servers need to do whatever it takes to support them. A 1735 server should support as many of the RECOMMENDED attributes as 1736 possible but, by their definition, the server is not required to 1737 support all of them. Attributes are deemed REQUIRED if the data is 1738 both needed by a large number of clients and is not otherwise 1739 reasonably computable by the client when support is not provided on 1740 the server. 1742 Note that the hidden directory returned by OPENATTR is a convenience 1743 for protocol processing. The client should not make any assumptions 1744 about the server's implementation of named attributes and whether or 1745 not the underlying file system at the server has a named attribute 1746 directory. Therefore, operations such as SETATTR and GETATTR on the 1747 named attribute directory are undefined. 1749 5.1. REQUIRED Attributes 1751 These MUST be supported by every NFSv4.0 client and server in order 1752 to ensure a minimum level of interoperability. The server MUST store 1753 and return these attributes, and the client MUST be able to function 1754 with an attribute set limited to these attributes. With just the 1755 REQUIRED attributes some client functionality may be impaired or 1756 limited in some ways. A client may ask for any of these attributes 1757 to be returned by setting a bit in the GETATTR request, and the 1758 server must return their value. 1760 5.2. RECOMMENDED Attributes 1762 These attributes are understood well enough to warrant support in the 1763 NFSv4.0 protocol. However, they may not be supported on all clients 1764 and servers. A client MAY ask for any of these attributes to be 1765 returned by setting a bit in the GETATTR request but must handle the 1766 case where the server does not return them. A client MAY ask for the 1767 set of attributes the server supports and SHOULD NOT request 1768 attributes the server does not support. A server should be tolerant 1769 of requests for unsupported attributes and simply not return them 1770 rather than considering the request an error. It is expected that 1771 servers will support all attributes they comfortably can and only 1772 fail to support attributes that are difficult to support in their 1773 operating environments. A server should provide attributes whenever 1774 they don't have to "tell lies" to the client. For example, a file 1775 modification time should be either an accurate time or should not be 1776 supported by the server. At times this will be difficult for 1777 clients, but a client is better positioned to decide whether and how 1778 to fabricate or construct an attribute or whether to do without the 1779 attribute. 1781 5.3. Named Attributes 1783 These attributes are not supported by direct encoding in the NFSv4 1784 protocol but are accessed by string names rather than numbers and 1785 correspond to an uninterpreted stream of bytes that are stored with 1786 the file system object. The name space for these attributes may be 1787 accessed by using the OPENATTR operation. The OPENATTR operation 1788 returns a filehandle for a virtual "named attribute directory", and 1789 further perusal and modification of the name space may be done using 1790 operations that work on more typical directories. In particular, 1791 READDIR may be used to get a list of such named attributes, and 1792 LOOKUP and OPEN may select a particular attribute. Creation of a new 1793 named attribute may be the result of an OPEN specifying file 1794 creation. 1796 Once an OPEN is done, named attributes may be examined and changed by 1797 normal READ and WRITE operations using the filehandles and stateids 1798 returned by OPEN. 1800 Named attributes and the named attribute directory may have their own 1801 (non-named) attributes. Each of these objects must have all of the 1802 REQUIRED attributes and may have additional RECOMMENDED attributes. 1803 However, the set of attributes for named attributes and the named 1804 attribute directory need not be, and typically will not be, as large 1805 as that for other objects in that file system. 1807 Named attributes and the named attribute directory might be the 1808 target of delegations (in the case of the named attribute directory 1809 these will be directory delegations). However, since granting of 1810 delegations is at the server's discretion, a server need not support 1811 delegations on named attributes or the named attribute directory. 1813 It is RECOMMENDED that servers support arbitrary named attributes. A 1814 client should not depend on the ability to store any named attributes 1815 in the server's file system. If a server does support named 1816 attributes, a client that is also able to handle them should be able 1817 to copy a file's data and metadata with complete transparency from 1818 one location to another; this would imply that names allowed for 1819 regular directory entries are valid for named attribute names as 1820 well. 1822 In NFSv4.0, the structure of named attribute directories is 1823 restricted in a number of ways, in order to prevent the development 1824 of non-interoperable implementations in which some servers support a 1825 fully general hierarchical directory structure for named attributes 1826 while others support a limited but adequate structure for named 1827 attributes. In such an environment, clients or applications might 1828 come to depend on non-portable extensions. The restrictions are: 1830 o CREATE is not allowed in a named attribute directory. Thus, such 1831 objects as symbolic links and special files are not allowed to be 1832 named attributes. Further, directories may not be created in a 1833 named attribute directory, so no hierarchical structure of named 1834 attributes for a single object is allowed. 1836 o If OPENATTR is done on a named attribute directory or on a named 1837 attribute, the server MUST return NFS4ERR_WRONG_TYPE. 1839 o Doing a RENAME of a named attribute to a different named attribute 1840 directory or to an ordinary (i.e., non-named-attribute) directory 1841 is not allowed. 1843 o Creating hard links between named attribute directories or between 1844 named attribute directories and ordinary directories is not 1845 allowed. 1847 Names of attributes will not be controlled by this document or other 1848 IETF Standards Track documents. See Section 18 for further 1849 discussion. 1851 5.4. Classification of Attributes 1853 Each of the REQUIRED and RECOMMENDED attributes can be classified in 1854 one of three categories: per server (i.e., the value of the attribute 1855 will be the same for all file objects that share the same server), 1856 per file system (i.e., the value of the attribute will be the same 1857 for some or all file objects that share the same fsid attribute 1858 (Section 5.8.1.9) and server owner), or per file system object. Note 1859 that it is possible that some per file system attributes may vary 1860 within the file system. Note that it is possible that some per file 1861 system attributes may vary within the file system, depending on the 1862 value of the "homogeneous" (Section 5.8.2.16) attribute. Note that 1863 the attributes time_access_set and time_modify_set are not listed in 1864 this section because they are write-only attributes corresponding to 1865 time_access and time_modify, and are used in a special instance of 1866 SETATTR. 1868 o The per-server attribute is: 1870 lease_time 1872 o The per-file system attributes are: 1874 supported_attrs, fh_expire_type, link_support, symlink_support, 1875 unique_handles, aclsupport, cansettime, case_insensitive, 1876 case_preserving, chown_restricted, files_avail, files_free, 1877 files_total, fs_locations, homogeneous, maxfilesize, maxname, 1878 maxread, maxwrite, no_trunc, space_avail, space_free, 1879 space_total, time_delta, 1881 o The per-file system object attributes are: 1883 type, change, size, named_attr, fsid, rdattr_error, filehandle, 1884 acl, archive, fileid, hidden, maxlink, mimetype, mode, 1885 numlinks, owner, owner_group, rawdev, space_used, system, 1886 time_access, time_backup, time_create, time_metadata, 1887 time_modify, mounted_on_fileid 1889 For quota_avail_hard, quota_avail_soft, and quota_used, see their 1890 definitions below for the appropriate classification. 1892 5.5. Set-Only and Get-Only Attributes 1894 Some REQUIRED and RECOMMENDED attributes are set-only; i.e., they can 1895 be set via SETATTR but not retrieved via GETATTR. Similarly, some 1896 REQUIRED and RECOMMENDED attributes are get-only; i.e., they can be 1897 retrieved via GETATTR but not set via SETATTR. If a client attempts 1898 to set a get-only attribute or get a set-only attribute, the server 1899 MUST return NFS4ERR_INVAL. 1901 5.6. REQUIRED Attributes - List and Definition References 1903 The list of REQUIRED attributes appears in Table 2. The meaning of 1904 the columns of the table are: 1906 o Name: The name of attribute 1908 o Id: The number assigned to the attribute. In the event of 1909 conflicts between the assigned number and [2], the latter is 1910 likely authoritative, but should be resolved with Errata to this 1911 document and/or [2]. See [25] for the Errata process. 1913 o Data Type: The XDR data type of the attribute. 1915 o Acc: Access allowed to the attribute. R means read-only (GETATTR 1916 may retrieve, SETATTR may not set). W means write-only (SETATTR 1917 may set, GETATTR may not retrieve). R W means read/write (GETATTR 1918 may retrieve, SETATTR may set). 1920 o Defined in: The section of this specification that describes the 1921 attribute. 1923 +-----------------+----+------------+-----+------------------+ 1924 | Name | Id | Data Type | Acc | Defined in: | 1925 +-----------------+----+------------+-----+------------------+ 1926 | supported_attrs | 0 | bitmap4 | R | Section 5.8.1.1 | 1927 | type | 1 | nfs_ftype4 | R | Section 5.8.1.2 | 1928 | fh_expire_type | 2 | uint32_t | R | Section 5.8.1.3 | 1929 | change | 3 | uint64_t | R | Section 5.8.1.4 | 1930 | size | 4 | uint64_t | R W | Section 5.8.1.5 | 1931 | link_support | 5 | bool | R | Section 5.8.1.6 | 1932 | symlink_support | 6 | bool | R | Section 5.8.1.7 | 1933 | named_attr | 7 | bool | R | Section 5.8.1.8 | 1934 | fsid | 8 | fsid4 | R | Section 5.8.1.9 | 1935 | unique_handles | 9 | bool | R | Section 5.8.1.10 | 1936 | lease_time | 10 | nfs_lease4 | R | Section 5.8.1.11 | 1937 | rdattr_error | 11 | enum | R | Section 5.8.1.12 | 1938 | filehandle | 19 | nfs_fh4 | R | Section 5.8.1.13 | 1939 +-----------------+----+------------+-----+------------------+ 1941 Table 2 1943 5.7. RECOMMENDED Attributes - List and Definition References 1945 The RECOMMENDED attributes are defined in Table 3. The meanings of 1946 the column headers are the same as Table 2; see Section 5.6 for the 1947 meanings. 1949 +-------------------+----+--------------+-----+------------------+ 1950 | Name | Id | Data Type | Acc | Defined in: | 1951 +-------------------+----+--------------+-----+------------------+ 1952 | acl | 12 | nfsace4<> | R W | Section 6.2.1 | 1953 | aclsupport | 13 | uint32_t | R | Section 6.2.1.2 | 1954 | archive | 14 | bool | R W | Section 5.8.2.1 | 1955 | cansettime | 15 | bool | R | Section 5.8.2.2 | 1956 | case_insensitive | 16 | bool | R | Section 5.8.2.3 | 1957 | case_preserving | 17 | bool | R | Section 5.8.2.4 | 1958 | chown_restricted | 18 | bool | R | Section 5.8.2.5 | 1959 | fileid | 20 | uint64_t | R | Section 5.8.2.6 | 1960 | files_avail | 21 | uint64_t | R | Section 5.8.2.7 | 1961 | files_free | 22 | uint64_t | R | Section 5.8.2.8 | 1962 | files_total | 23 | uint64_t | R | Section 5.8.2.9 | 1963 | fs_locations | 24 | fs_locations | R | Section 5.8.2.10 | 1964 | hidden | 25 | bool | R W | Section 5.8.2.11 | 1965 | homogeneous | 26 | bool | R | Section 5.8.2.12 | 1966 | maxfilesize | 27 | uint64_t | R | Section 5.8.2.13 | 1967 | maxlink | 28 | uint32_t | R | Section 5.8.2.14 | 1968 | maxname | 29 | uint32_t | R | Section 5.8.2.15 | 1969 | maxread | 30 | uint64_t | R | Section 5.8.2.16 | 1970 | maxwrite | 31 | uint64_t | R | Section 5.8.2.17 | 1971 | mimetype | 32 | utf8<> | R W | Section 5.8.2.18 | 1972 | mode | 33 | mode4 | R W | Section 6.2.2 | 1973 | mounted_on_fileid | 55 | uint64_t | R | Section 5.8.2.19 | 1974 | no_trunc | 34 | bool | R | Section 5.8.2.20 | 1975 | numlinks | 35 | uint32_t | R | Section 5.8.2.21 | 1976 | owner | 36 | utf8<> | R W | Section 5.8.2.22 | 1977 | owner_group | 37 | utf8<> | R W | Section 5.8.2.23 | 1978 | quota_avail_hard | 38 | uint64_t | R | Section 5.8.2.24 | 1979 | quota_avail_soft | 39 | uint64_t | R | Section 5.8.2.25 | 1980 | quota_used | 40 | uint64_t | R | Section 5.8.2.26 | 1981 | rawdev | 41 | specdata4 | R | Section 5.8.2.27 | 1982 | space_avail | 42 | uint64_t | R | Section 5.8.2.28 | 1983 | space_free | 43 | uint64_t | R | Section 5.8.2.29 | 1984 | space_total | 44 | uint64_t | R | Section 5.8.2.30 | 1985 | space_used | 45 | uint64_t | R | Section 5.8.2.31 | 1986 | system | 46 | bool | R W | Section 5.8.2.32 | 1987 | time_access | 47 | nfstime4 | R | Section 5.8.2.33 | 1988 | time_access_set | 48 | settime4 | W | Section 5.8.2.34 | 1989 | time_backup | 49 | nfstime4 | R W | Section 5.8.2.35 | 1990 | time_create | 50 | nfstime4 | R W | Section 5.8.2.36 | 1991 | time_delta | 51 | nfstime4 | R | Section 5.8.2.37 | 1992 | time_metadata | 52 | nfstime4 | R | Section 5.8.2.38 | 1993 | time_modify | 53 | nfstime4 | R | Section 5.8.2.39 | 1994 | time_modify_set | 54 | settime4 | W | Section 5.8.2.40 | 1995 +-------------------+----+--------------+-----+------------------+ 1997 Table 3 1999 5.8. Attribute Definitions 2001 5.8.1. Definitions of REQUIRED Attributes 2003 5.8.1.1. Attribute 0: supported_attrs 2005 The bit vector that would retrieve all REQUIRED and RECOMMENDED 2006 attributes that are supported for this object. The scope of this 2007 attribute applies to all objects with a matching fsid. 2009 5.8.1.2. Attribute 1: type 2011 Designates the type of an object in terms of one of a number of 2012 special constants: 2014 o NF4REG designates a regular file. 2016 o NF4DIR designates a directory. 2018 o NF4BLK designates a block device special file. 2020 o NF4CHR designates a character device special file. 2022 o NF4LNK designates a symbolic link. 2024 o NF4SOCK designates a named socket special file. 2026 o NF4FIFO designates a fifo special file. 2028 o NF4ATTRDIR designates a named attribute directory. 2030 o NF4NAMEDATTR designates a named attribute. 2032 Within the explanatory text and operation descriptions, the following 2033 phrases will be used with the meanings given below: 2035 o The phrase "is a directory" means that the object's type attribute 2036 is NF4DIR or NF4ATTRDIR. 2038 o The phrase "is a special file" means that the object's type 2039 attribute is NF4BLK, NF4CHR, NF4SOCK, or NF4FIFO. 2041 o The phrase "is an ordinary file" means that the object's type 2042 attribute is NF4REG or NF4NAMEDATTR. 2044 5.8.1.3. Attribute 2: fh_expire_type 2046 Server uses this to specify filehandle expiration behavior to the 2047 client. See Section 4 for additional description. 2049 5.8.1.4. Attribute 3: change 2051 A value created by the server that the client can use to determine if 2052 file data, directory contents, or attributes of the object have been 2053 modified. The server may return the object's time_metadata attribute 2054 for this attribute's value but only if the file system object cannot 2055 be updated more frequently than the resolution of time_metadata. 2057 5.8.1.5. Attribute 4: size 2059 The size of the object in bytes. 2061 5.8.1.6. Attribute 5: link_support 2063 TRUE, if the object's file system supports hard links. 2065 5.8.1.7. Attribute 6: symlink_support 2067 TRUE, if the object's file system supports symbolic links. 2069 5.8.1.8. Attribute 7: named_attr 2071 TRUE, if this object has named attributes. In other words, object 2072 has a non-empty named attribute directory. 2074 5.8.1.9. Attribute 8: fsid 2076 Unique file system identifier for the file system holding this 2077 object. The fsid attribute has major and minor components, each of 2078 which are of data type uint64_t. 2080 5.8.1.10. Attribute 9: unique_handles 2082 TRUE, if two distinct filehandles are guaranteed to refer to two 2083 different file system objects. 2085 5.8.1.11. Attribute 10: lease_time 2087 Duration of the lease at server in seconds. 2089 5.8.1.12. Attribute 11: rdattr_error 2091 Error returned from an attempt to retrieve attributes during a 2092 READDIR operation. 2094 5.8.1.13. Attribute 19: filehandle 2096 The filehandle of this object (primarily for READDIR requests). 2098 5.8.2. Definitions of Uncategorized RECOMMENDED Attributes 2100 The definitions of most of the RECOMMENDED attributes follow. 2101 Collections that share a common category are defined in other 2102 sections. 2104 5.8.2.1. Attribute 14: archive 2106 TRUE, if this file has been archived since the time of last 2107 modification (deprecated in favor of time_backup). 2109 5.8.2.2. Attribute 15: cansettime 2111 TRUE, if the server is able to change the times for a file system 2112 object as specified in a SETATTR operation. 2114 5.8.2.3. Attribute 16: case_insensitive 2116 TRUE, if file name comparisons on this file system are case 2117 insensitive. 2119 5.8.2.4. Attribute 17: case_preserving 2121 TRUE, if file name case on this file system is preserved. 2123 5.8.2.5. Attribute 18: chown_restricted 2125 If TRUE, the server will reject any request to change either the 2126 owner or the group associated with a file if the caller is not a 2127 privileged user (for example, "root" in UNIX operating environments 2128 or in Windows 2000, the "Take Ownership" privilege). 2130 5.8.2.6. Attribute 20: fileid 2132 A number uniquely identifying the file within the file system. 2134 5.8.2.7. Attribute 21: files_avail 2136 File slots available to this user on the file system containing this 2137 object -- this should be the smallest relevant limit. 2139 5.8.2.8. Attribute 22: files_free 2141 Free file slots on the file system containing this object - this 2142 should be the smallest relevant limit. 2144 5.8.2.9. Attribute 23: files_total 2146 Total file slots on the file system containing this object. 2148 5.8.2.10. Attribute 24: fs_locations 2150 Locations where this file system may be found. If the server returns 2151 NFS4ERR_MOVED as an error, this attribute MUST be supported. 2153 The server can specify a root path by setting an array of zero path 2154 components. Other than this special case, the server MUST not 2155 present empty path components to the client. 2157 5.8.2.11. Attribute 25: hidden 2159 TRUE, if the file is considered hidden with respect to the Windows 2160 API. 2162 5.8.2.12. Attribute 26: homogeneous 2164 TRUE, if this object's file system is homogeneous, i.e., all objects 2165 in the file system (all objects on the server with the same fsid) 2166 have common values for all per-file-system attributes. 2168 5.8.2.13. Attribute 27: maxfilesize 2170 Maximum supported file size for the file system of this object. 2172 5.8.2.14. Attribute 28: maxlink 2174 Maximum number of links for this object. 2176 5.8.2.15. Attribute 29: maxname 2178 Maximum file name size supported for this object. 2180 5.8.2.16. Attribute 30: maxread 2182 Maximum amount of data the READ operation will return for this 2183 object. 2185 5.8.2.17. Attribute 31: maxwrite 2187 Maximum amount of data the WRITE operation will accept for this 2188 object. This attribute SHOULD be supported if the file is writable. 2189 Lack of this attribute can lead to the client either wasting 2190 bandwidth or not receiving the best performance. 2192 5.8.2.18. Attribute 32: mimetype 2194 MIME body type/subtype of this object. 2196 5.8.2.19. Attribute 55: mounted_on_fileid 2198 Like fileid, but if the target filehandle is the root of a file 2199 system, this attribute represents the fileid of the underlying 2200 directory. 2202 UNIX-based operating environments connect a file system into the 2203 namespace by connecting (mounting) the file system onto the existing 2204 file object (the mount point, usually a directory) of an existing 2205 file system. When the mount point's parent directory is read via an 2206 API like readdir(), the return results are directory entries, each 2207 with a component name and a fileid. The fileid of the mount point's 2208 directory entry will be different from the fileid that the stat() 2209 system call returns. The stat() system call is returning the fileid 2210 of the root of the mounted file system, whereas readdir() is 2211 returning the fileid that stat() would have returned before any file 2212 systems were mounted on the mount point. 2214 Unlike NFSv3, NFSv4.0 allows a client's LOOKUP request to cross other 2215 file systems. The client detects the file system crossing whenever 2216 the filehandle argument of LOOKUP has an fsid attribute different 2217 from that of the filehandle returned by LOOKUP. A UNIX-based client 2218 will consider this a "mount point crossing". UNIX has a legacy 2219 scheme for allowing a process to determine its current working 2220 directory. This relies on readdir() of a mount point's parent and 2221 stat() of the mount point returning fileids as previously described. 2222 The mounted_on_fileid attribute corresponds to the fileid that 2223 readdir() would have returned as described previously. 2225 While the NFSv4.0 client could simply fabricate a fileid 2226 corresponding to what mounted_on_fileid provides (and if the server 2227 does not support mounted_on_fileid, the client has no choice), there 2228 is a risk that the client will generate a fileid that conflicts with 2229 one that is already assigned to another object in the file system. 2230 Instead, if the server can provide the mounted_on_fileid, the 2231 potential for client operational problems in this area is eliminated. 2233 If the server detects that there is no mounted point at the target 2234 file object, then the value for mounted_on_fileid that it returns is 2235 the same as that of the fileid attribute. 2237 The mounted_on_fileid attribute is RECOMMENDED, so the server SHOULD 2238 provide it if possible, and for a UNIX-based server, this is 2239 straightforward. Usually, mounted_on_fileid will be requested during 2240 a READDIR operation, in which case it is trivial (at least for UNIX- 2241 based servers) to return mounted_on_fileid since it is equal to the 2242 fileid of a directory entry returned by readdir(). If 2243 mounted_on_fileid is requested in a GETATTR operation, the server 2244 should obey an invariant that has it returning a value that is equal 2245 to the file object's entry in the object's parent directory, i.e., 2246 what readdir() would have returned. Some operating environments 2247 allow a series of two or more file systems to be mounted onto a 2248 single mount point. In this case, for the server to obey the 2249 aforementioned invariant, it will need to find the base mount point, 2250 and not the intermediate mount points. 2252 5.8.2.20. Attribute 34: no_trunc 2254 If this attribute is TRUE, then if the client uses a file name longer 2255 than name_max, an error will be returned instead of the name being 2256 truncated. 2258 5.8.2.21. Attribute 35: numlinks 2260 Number of hard links to this object. 2262 5.8.2.22. Attribute 36: owner 2264 The string name of the owner of this object. 2266 5.8.2.23. Attribute 37: owner_group 2268 The string name of the group ownership of this object. 2270 5.8.2.24. Attribute 38: quota_avail_hard 2272 The value in bytes that represents the amount of additional disk 2273 space beyond the current allocation that can be allocated to this 2274 file or directory before further allocations will be refused. It is 2275 understood that this space may be consumed by allocations to other 2276 files or directories. 2278 5.8.2.25. Attribute 39: quota_avail_soft 2280 The value in bytes that represents the amount of additional disk 2281 space that can be allocated to this file or directory before the user 2282 may reasonably be warned. It is understood that this space may be 2283 consumed by allocations to other files or directories though there is 2284 a rule as to which other files or directories. 2286 5.8.2.26. Attribute 40: quota_used 2288 The value in bytes that represents the amount of disc space used by 2289 this file or directory and possibly a number of other similar files 2290 or directories, where the set of "similar" meets at least the 2291 criterion that allocating space to any file or directory in the set 2292 will reduce the "quota_avail_hard" of every other file or directory 2293 in the set. 2295 Note that there may be a number of distinct but overlapping sets of 2296 files or directories for which a quota_used value is maintained, e.g. 2297 "all files with a given owner", "all files with a given group owner". 2298 etc. The server is at liberty to choose any of those sets when 2299 providing the content of the quota_used attribute, but should do so 2300 in a repeatable way. The rule may be configured per file system or 2301 may be "choose the set with the smallest quota". 2303 5.8.2.27. Attribute 41: rawdev 2305 Raw device number of file of type NF4BLK or NF4CHR. The device 2306 number is split into major and minor numbers. If the file's type 2307 attribute is not NF4BLK or NF4CHR, the value returned SHOULD NOT be 2308 considered useful. 2310 5.8.2.28. Attribute 42: space_avail 2312 Disk space in bytes available to this user on the file system 2313 containing this object -- this should be the smallest relevant limit. 2315 5.8.2.29. Attribute 43: space_free 2317 Free disk space in bytes on the file system containing this object -- 2318 this should be the smallest relevant limit. 2320 5.8.2.30. Attribute 44: space_total 2322 Total disk space in bytes on the file system containing this object. 2324 5.8.2.31. Attribute 45: space_used 2326 Number of file system bytes allocated to this object. 2328 5.8.2.32. Attribute 46: system 2330 This attribute is TRUE if this file is a "system" file with respect 2331 to the Windows operating environment. 2333 5.8.2.33. Attribute 47: time_access 2335 The time_access attribute represents the time of last access to the 2336 object by a READ operation sent to the server. The notion of what is 2337 an "access" depends on the server's operating environment and/or the 2338 server's file system semantics. For example, for servers obeying 2339 Portable Operating System Interface (POSIX) semantics, time_access 2340 would be updated only by the READ and READDIR operations and not any 2341 of the operations that modify the content of the object [16], [17], 2342 [26], [27], [28]. Of course, setting the corresponding 2343 time_access_set attribute is another way to modify the time_access 2344 attribute. 2346 Whenever the file object resides on a writable file system, the 2347 server should make its best efforts to record time_access into stable 2348 storage. However, to mitigate the performance effects of doing so, 2349 and most especially whenever the server is satisfying the read of the 2350 object's content from its cache, the server MAY cache access time 2351 updates and lazily write them to stable storage. It is also 2352 acceptable to give administrators of the server the option to disable 2353 time_access updates. 2355 5.8.2.34. Attribute 48: time_access_set 2357 Sets the time of last access to the object. SETATTR use only. 2359 5.8.2.35. Attribute 49: time_backup 2361 The time of last backup of the object. 2363 5.8.2.36. Attribute 50: time_create 2365 The time of creation of the object. This attribute does not have any 2366 relation to the traditional UNIX file attribute "ctime" or "change 2367 time". 2369 5.8.2.37. Attribute 51: time_delta 2371 Smallest useful server time granularity. 2373 5.8.2.38. Attribute 52: time_metadata 2375 The time of last metadata modification of the object. 2377 5.8.2.39. Attribute 53: time_modify 2379 The time of last modification to the object. 2381 5.8.2.40. Attribute 54: time_modify_set 2383 Sets the time of last modification to the object. SETATTR use only. 2385 5.9. Interpreting owner and owner_group 2387 The RECOMMENDED attributes "owner" and "owner_group" (and also users 2388 and groups within the "acl" attribute) are represented in terms of a 2389 UTF-8 string. To avoid a representation that is tied to a particular 2390 underlying implementation at the client or server, the use of the 2391 UTF-8 string has been chosen. Note that section 6.1 of RFC 2624 [29] 2392 provides additional rationale. It is expected that the client and 2393 server will have their own local representation of owner and 2394 owner_group that is used for local storage or presentation to the end 2395 user. Therefore, it is expected that when these attributes are 2396 transferred between the client and server, the local representation 2397 is translated to a syntax of the form "user@dns_domain". This will 2398 allow for a client and server that do not use the same local 2399 representation the ability to translate to a common syntax that can 2400 be interpreted by both. 2402 Similarly, security principals may be represented in different ways 2403 by different security mechanisms. Servers normally translate these 2404 representations into a common format, generally that used by local 2405 storage, to serve as a means of identifying the users corresponding 2406 to these security principals. When these local identifiers are 2407 translated to the form of the owner attribute, associated with files 2408 created by such principals, they identify, in a common format, the 2409 users associated with each corresponding set of security principals. 2411 The translation used to interpret owner and group strings is not 2412 specified as part of the protocol. This allows various solutions to 2413 be employed. For example, a local translation table may be consulted 2414 that maps a numeric identifier to the user@dns_domain syntax. A name 2415 service may also be used to accomplish the translation. A server may 2416 provide a more general service, not limited by any particular 2417 translation (which would only translate a limited set of possible 2418 strings) by storing the owner and owner_group attributes in local 2419 storage without any translation or it may augment a translation 2420 method by storing the entire string for attributes for which no 2421 translation is available while using the local representation for 2422 those cases in which a translation is available. 2424 Servers that do not provide support for all possible values of the 2425 owner and owner_group attributes SHOULD return an error 2426 (NFS4ERR_BADOWNER) when a string is presented that has no 2427 translation, as the value to be set for a SETATTR of the owner, 2428 owner_group, or acl attributes. When a server does accept an owner 2429 or owner_group value as valid on a SETATTR (and similarly for the 2430 owner and group strings in an acl), it is promising to return that 2431 same string for which see below) when a corresponding GETATTR is 2432 done. For some internationalization-related exceptions where this is 2433 not possible, see below. Configuration changes (including changes 2434 from the mapping of the string to the local representation) and ill- 2435 constructed name translations (those that contain aliasing) may make 2436 that promise impossible to honor. Servers should make appropriate 2437 efforts to avoid a situation in which these attributes have their 2438 values changed when no real change to ownership has occurred. 2440 The "dns_domain" portion of the owner string is meant to be a DNS 2441 domain name. For example, user@example.org. Servers should accept 2442 as valid a set of users for at least one domain. A server may treat 2443 other domains as having no valid translations. A more general 2444 service is provided when a server is capable of accepting users for 2445 multiple domains, or for all domains, subject to security 2446 constraints. 2448 As an implementation guide, both clients and servers may provide a 2449 means to configure the "dns_domain" portion of the owner string. For 2450 example, the DNS domain name might be "lab.example.org", but the user 2451 names are defined in "example.org". In the absence of such a 2452 configuration, or as a default, the current DNS domain name should be 2453 the value used for the "dns_domain". 2455 As mentioned above, it is desirable that a server when accepting a 2456 string of the form user@domain or group@domain in an attribute, 2457 return this same string when that corresponding attribute is fetched. 2458 Internationalization issues (for a general discussion of which see 2459 Section 12) make this impossible and the client needs to take note of 2460 the following situations: 2462 o The string representing the domain may be converted to equivalent 2463 U-label, if presented using a form other a a U-label. See 2464 Section 12.6 for details. 2466 o The user or group may be returned in a different form, due to 2467 normalization issues, although it will always be a canonically 2468 equivalent string. See See Section 12.7.3 for details. 2470 In the case where there is no translation available to the client or 2471 server, the attribute value will be constructed without the "@". 2472 Therefore, the absence of the "@" from the owner or owner_group 2473 attribute signifies that no translation was available at the sender 2474 and that the receiver of the attribute should not use that string as 2475 a basis for translation into its own internal format. Even though 2476 the attribute value cannot be translated, it may still be useful. In 2477 the case of a client, the attribute string may be used for local 2478 display of ownership. 2480 To provide a greater degree of compatibility with NFSv3, which 2481 identified users and groups by 32-bit unsigned user identifiers and 2482 group identifiers, owner and group strings that consist of decimal 2483 numeric values with no leading zeros can be given a special 2484 interpretation by clients and servers that choose to provide such 2485 support. The receiver may treat such a user or group string as 2486 representing the same user as would be represented by an NFSv3 uid or 2487 gid having the corresponding numeric value. 2489 A server SHOULD reject such a numeric value if the security mechanism 2490 is kerberized. I.e., in such a scenario, the client will already 2491 need to form "user@domain" strings. For any other security 2492 mechanism, the server SHOULD accept such numeric values. As an 2493 implementation note, the server could make such an acceptance be 2494 configurable. If the server does not support numeric values or if it 2495 is configured off, then it MUST return an NFS4ERR_BADOWNER error. If 2496 the security mechanism is kerberized and the client attempts to use 2497 the special form, then the server SHOULD return an NFS4ERR_BADOWNER 2498 error when there is a valid translation for the user or owner 2499 designated in this way. In that case, the client must use the 2500 appropriate user@domain string and not the special form for 2501 compatibility. 2503 The client MUST always accept numeric values if the security 2504 mechanism is not kerberized. A client can determine if a server 2505 supports such a mechanism by first attempting to provide a numeric 2506 value and only if it is rejected with an NFS4ERR_BADOWNER error, then 2507 providing a name value. After the first detection of such an error, 2508 the client should only use the special form. 2510 The owner string "nobody" may be used to designate an anonymous user, 2511 which will be associated with a file created by a security principal 2512 that cannot be mapped through normal means to the owner attribute. 2514 5.10. Character Case Attributes 2516 With respect to the case_insensitive and case_preserving attributes, 2517 each UCS-4 character (which UTF-8 encodes) has a "long descriptive 2518 name" RFC1345 [30] which may or may not include the word "CAPITAL" or 2519 "SMALL". The presence of SMALL or CAPITAL allows an NFS server to 2520 implement unambiguous and efficient table driven mappings for case 2521 insensitive comparisons, and non-case-preserving storage, although 2522 there are variations that occur additional characters with a name 2523 including "SMALL" or "CAPITAL" are added in a subsequent version of 2524 Unicode. 2526 For general character handling and internationalization issues, see 2527 Section 12. For details regarding case mapping, see the section 2528 Case-based Mapping Used for Component4 Strings. 2530 6. Access Control Attributes 2532 Access Control Lists (ACLs) are file attributes that specify fine 2533 grained access control. This chapter covers the "acl", "aclsupport", 2534 "mode", file attributes, and their interactions. Note that file 2535 attributes may apply to any file system object. 2537 6.1. Goals 2539 ACLs and modes represent two well established models for specifying 2540 permissions. This chapter specifies requirements that attempt to 2541 meet the following goals: 2543 o If a server supports the mode attribute, it should provide 2544 reasonable semantics to clients that only set and retrieve the 2545 mode attribute. 2547 o If a server supports ACL attributes, it should provide reasonable 2548 semantics to clients that only set and retrieve those attributes. 2550 o On servers that support the mode attribute, if ACL attributes have 2551 never been set on an object, via inheritance or explicitly, the 2552 behavior should be traditional UNIX-like behavior. 2554 o On servers that support the mode attribute, if the ACL attributes 2555 have been previously set on an object, either explicitly or via 2556 inheritance: 2558 * Setting only the mode attribute should effectively control the 2559 traditional UNIX-like permissions of read, write, and execute 2560 on owner, owner_group, and other. 2562 * Setting only the mode attribute should provide reasonable 2563 security. For example, setting a mode of 000 should be enough 2564 to ensure that future opens for read or write by any principal 2565 fail, regardless of a previously existing or inherited ACL. 2567 o When a mode attribute is set on an object, the ACL attributes may 2568 need to be modified so as to not conflict with the new mode. In 2569 such cases, it is desirable that the ACL keep as much information 2570 as possible. This includes information about inheritance, AUDIT 2571 and ALARM ACEs, and permissions granted and denied that do not 2572 conflict with the new mode. 2574 6.2. File Attributes Discussion 2576 6.2.1. Attribute 12: acl 2578 The NFSv4.0 ACL attribute contains an array of access control entries 2579 (ACEs) that are associated with the file system object. Although the 2580 client can read and write the acl attribute, the server is 2581 responsible for using the ACL to perform access control. The client 2582 can use the OPEN or ACCESS operations to check access without 2583 modifying or reading data or metadata. 2585 The NFS ACE structure is defined as follows: 2587 typedef uint32_t acetype4; 2589 typedef uint32_t aceflag4; 2591 typedef uint32_t acemask4; 2593 struct nfsace4 { 2594 acetype4 type; 2595 aceflag4 flag; 2596 acemask4 access_mask; 2597 utf8val_must who; 2598 }; 2599 To determine if a request succeeds, the server processes each nfsace4 2600 entry in order. Only ACEs which have a "who" that matches the 2601 requester are considered. Each ACE is processed until all of the 2602 bits of the requester's access have been ALLOWED. Once a bit (see 2603 below) has been ALLOWED by an ACCESS_ALLOWED_ACE, it is no longer 2604 considered in the processing of later ACEs. If an ACCESS_DENIED_ACE 2605 is encountered where the requester's access still has unALLOWED bits 2606 in common with the "access_mask" of the ACE, the request is denied. 2607 When the ACL is fully processed, if there are bits in the requester's 2608 mask that have not been ALLOWED or DENIED, access is denied. 2610 Unlike the ALLOW and DENY ACE types, the ALARM and AUDIT ACE types do 2611 not affect a requester's access, and instead are for triggering 2612 events as a result of a requester's access attempt. Therefore, AUDIT 2613 and ALARM ACEs are processed only after processing ALLOW and DENY 2614 ACEs. 2616 The NFSv4.0 ACL model is quite rich. Some server platforms may 2617 provide access control functionality that goes beyond the UNIX-style 2618 mode attribute, but which is not as rich as the NFS ACL model. So 2619 that users can take advantage of this more limited functionality, the 2620 server may support the acl attributes by mapping between its ACL 2621 model and the NFSv4.0 ACL model. Servers must ensure that the ACL 2622 they actually store or enforce is at least as strict as the NFSv4 ACL 2623 that was set. It is tempting to accomplish this by rejecting any ACL 2624 that falls outside the small set that can be represented accurately. 2625 However, such an approach can render ACLs unusable without special 2626 client-side knowledge of the server's mapping, which defeats the 2627 purpose of having a common NFSv4 ACL protocol. Therefore servers 2628 should accept every ACL that they can without compromising security. 2629 To help accomplish this, servers may make a special exception, in the 2630 case of unsupported permission bits, to the rule that bits not 2631 ALLOWED or DENIED by an ACL must be denied. For example, a UNIX- 2632 style server might choose to silently allow read attribute 2633 permissions even though an ACL does not explicitly allow those 2634 permissions. (An ACL that explicitly denies permission to read 2635 attributes should still be rejected.) 2637 The situation is complicated by the fact that a server may have 2638 multiple modules that enforce ACLs. For example, the enforcement for 2639 NFSv4.0 access may be different from, but not weaker than, the 2640 enforcement for local access, and both may be different from the 2641 enforcement for access through other protocols such as SMB. So it 2642 may be useful for a server to accept an ACL even if not all of its 2643 modules are able to support it. 2645 The guiding principle with regard to NFSv4 access is that the server 2646 must not accept ACLs that appear to make access to the file more 2647 restrictive than it really is. 2649 6.2.1.1. ACE Type 2651 The constants used for the type field (acetype4) are as follows: 2653 const ACE4_ACCESS_ALLOWED_ACE_TYPE = 0x00000000; 2654 const ACE4_ACCESS_DENIED_ACE_TYPE = 0x00000001; 2655 const ACE4_SYSTEM_AUDIT_ACE_TYPE = 0x00000002; 2656 const ACE4_SYSTEM_ALARM_ACE_TYPE = 0x00000003; 2658 All four but types are permitted in the acl attribute. 2660 +------------------------------+--------------+---------------------+ 2661 | Value | Abbreviation | Description | 2662 +------------------------------+--------------+---------------------+ 2663 | ACE4_ACCESS_ALLOWED_ACE_TYPE | ALLOW | Explicitly grants | 2664 | | | the access defined | 2665 | | | in acemask4 to the | 2666 | | | file or directory. | 2667 | ACE4_ACCESS_DENIED_ACE_TYPE | DENY | Explicitly denies | 2668 | | | the access defined | 2669 | | | in acemask4 to the | 2670 | | | file or directory. | 2671 | ACE4_SYSTEM_AUDIT_ACE_TYPE | AUDIT | LOG (in a system | 2672 | | | dependent way) any | 2673 | | | access attempt to a | 2674 | | | file or directory | 2675 | | | which uses any of | 2676 | | | the access methods | 2677 | | | specified in | 2678 | | | acemask4. | 2679 | ACE4_SYSTEM_ALARM_ACE_TYPE | ALARM | Generate a system | 2680 | | | ALARM (system | 2681 | | | dependent) when any | 2682 | | | access attempt is | 2683 | | | made to a file or | 2684 | | | directory for the | 2685 | | | access methods | 2686 | | | specified in | 2687 | | | acemask4. | 2688 +------------------------------+--------------+---------------------+ 2690 The "Abbreviation" column denotes how the types will be referred to 2691 throughout the rest of this chapter. 2693 6.2.1.2. Attribute 13: aclsupport 2695 A server need not support all of the above ACE types. This attribute 2696 indicates which ACE types are supported for the current file system. 2697 The bitmask constants used to represent the above definitions within 2698 the aclsupport attribute are as follows: 2700 const ACL4_SUPPORT_ALLOW_ACL = 0x00000001; 2701 const ACL4_SUPPORT_DENY_ACL = 0x00000002; 2702 const ACL4_SUPPORT_AUDIT_ACL = 0x00000004; 2703 const ACL4_SUPPORT_ALARM_ACL = 0x00000008; 2705 Servers which support either the ALLOW or DENY ACE type SHOULD 2706 support both ALLOW and DENY ACE types. 2708 Clients should not attempt to set an ACE unless the server claims 2709 support for that ACE type. If the server receives a request to set 2710 an ACE that it cannot store, it MUST reject the request with 2711 NFS4ERR_ATTRNOTSUPP. If the server receives a request to set an ACE 2712 that it can store but cannot enforce, the server SHOULD reject the 2713 request with NFS4ERR_ATTRNOTSUPP. 2715 Support for any of the ACL attributes is optional (albeit, 2716 RECOMMENDED). 2718 6.2.1.3. ACE Access Mask 2720 The bitmask constants used for the access mask field are as follows: 2722 const ACE4_READ_DATA = 0x00000001; 2723 const ACE4_LIST_DIRECTORY = 0x00000001; 2724 const ACE4_WRITE_DATA = 0x00000002; 2725 const ACE4_ADD_FILE = 0x00000002; 2726 const ACE4_APPEND_DATA = 0x00000004; 2727 const ACE4_ADD_SUBDIRECTORY = 0x00000004; 2728 const ACE4_READ_NAMED_ATTRS = 0x00000008; 2729 const ACE4_WRITE_NAMED_ATTRS = 0x00000010; 2730 const ACE4_EXECUTE = 0x00000020; 2731 const ACE4_DELETE_CHILD = 0x00000040; 2732 const ACE4_READ_ATTRIBUTES = 0x00000080; 2733 const ACE4_WRITE_ATTRIBUTES = 0x00000100; 2735 const ACE4_DELETE = 0x00010000; 2736 const ACE4_READ_ACL = 0x00020000; 2737 const ACE4_WRITE_ACL = 0x00040000; 2738 const ACE4_WRITE_OWNER = 0x00080000; 2739 const ACE4_SYNCHRONIZE = 0x00100000; 2740 Note that some masks have coincident values, for example, 2741 ACE4_READ_DATA and ACE4_LIST_DIRECTORY. The mask entries 2742 ACE4_LIST_DIRECTORY, ACE4_ADD_FILE, and ACE4_ADD_SUBDIRECTORY are 2743 intended to be used with directory objects, while ACE4_READ_DATA, 2744 ACE4_WRITE_DATA, and ACE4_APPEND_DATA are intended to be used with 2745 non-directory objects. 2747 6.2.1.3.1. Discussion of Mask Attributes 2749 ACE4_READ_DATA 2751 Operation(s) affected: 2753 READ 2755 OPEN 2757 Discussion: 2759 Permission to read the data of the file. 2761 Servers SHOULD allow a user the ability to read the data of the 2762 file when only the ACE4_EXECUTE access mask bit is allowed. 2764 ACE4_LIST_DIRECTORY 2766 Operation(s) affected: 2768 READDIR 2770 Discussion: 2772 Permission to list the contents of a directory. 2774 ACE4_WRITE_DATA 2776 Operation(s) affected: 2778 WRITE 2780 OPEN 2782 SETATTR of size 2784 Discussion: 2786 Permission to modify a file's data. 2788 ACE4_ADD_FILE 2790 Operation(s) affected: 2792 CREATE 2794 LINK 2796 OPEN 2798 RENAME 2800 Discussion: 2802 Permission to add a new file in a directory. The CREATE 2803 operation is affected when nfs_ftype4 is NF4LNK, NF4BLK, 2804 NF4CHR, NF4SOCK, or NF4FIFO. (NF4DIR is not listed because it 2805 is covered by ACE4_ADD_SUBDIRECTORY.) OPEN is affected when 2806 used to create a regular file. LINK and RENAME are always 2807 affected. 2809 ACE4_APPEND_DATA 2811 Operation(s) affected: 2813 WRITE 2815 OPEN 2817 SETATTR of size 2819 Discussion: 2821 The ability to modify a file's data, but only starting at EOF. 2822 This allows for the notion of append-only files, by allowing 2823 ACE4_APPEND_DATA and denying ACE4_WRITE_DATA to the same user 2824 or group. If a file has an ACL such as the one described above 2825 and a WRITE request is made for somewhere other than EOF, the 2826 server SHOULD return NFS4ERR_ACCESS. 2828 ACE4_ADD_SUBDIRECTORY 2830 Operation(s) affected: 2832 CREATE 2834 RENAME 2836 Discussion: 2838 Permission to create a subdirectory in a directory. The CREATE 2839 operation is affected when nfs_ftype4 is NF4DIR. The RENAME 2840 operation is always affected. 2842 ACE4_READ_NAMED_ATTRS 2844 Operation(s) affected: 2846 OPENATTR 2848 Discussion: 2850 Permission to read the named attributes of a file or to lookup 2851 the named attributes directory. OPENATTR is affected when it 2852 is not used to create a named attribute directory. This is 2853 when 1.) createdir is TRUE, but a named attribute directory 2854 already exists, or 2.) createdir is FALSE. 2856 ACE4_WRITE_NAMED_ATTRS 2858 Operation(s) affected: 2860 OPENATTR 2862 Discussion: 2864 Permission to write the named attributes of a file or to create 2865 a named attribute directory. OPENATTR is affected when it is 2866 used to create a named attribute directory. This is when 2867 createdir is TRUE and no named attribute directory exists. The 2868 ability to check whether or not a named attribute directory 2869 exists depends on the ability to look it up, therefore, users 2870 also need the ACE4_READ_NAMED_ATTRS permission in order to 2871 create a named attribute directory. 2873 ACE4_EXECUTE 2875 Operation(s) affected: 2877 READ 2879 OPEN 2881 REMOVE 2883 RENAME 2885 LINK 2887 CREATE 2889 Discussion: 2891 Permission to execute a file. 2893 Servers SHOULD allow a user the ability to read the data of the 2894 file when only the ACE4_EXECUTE access mask bit is allowed. 2895 This is because there is no way to execute a file without 2896 reading the contents. Though a server may treat ACE4_EXECUTE 2897 and ACE4_READ_DATA bits identically when deciding to permit a 2898 READ operation, it SHOULD still allow the two bits to be set 2899 independently in ACLs, and MUST distinguish between them when 2900 replying to ACCESS operations. In particular, servers SHOULD 2901 NOT silently turn on one of the two bits when the other is set, 2902 as that would make it impossible for the client to correctly 2903 enforce the distinction between read and execute permissions. 2905 As an example, following a SETATTR of the following ACL: 2907 nfsuser:ACE4_EXECUTE:ALLOW 2909 A subsequent GETATTR of ACL for that file SHOULD return: 2911 nfsuser:ACE4_EXECUTE:ALLOW 2913 Rather than: 2915 nfsuser:ACE4_EXECUTE/ACE4_READ_DATA:ALLOW 2917 ACE4_EXECUTE 2919 Operation(s) affected: 2921 LOOKUP 2923 Discussion: 2925 Permission to traverse/search a directory. 2927 ACE4_DELETE_CHILD 2929 Operation(s) affected: 2931 REMOVE 2933 RENAME 2935 Discussion: 2937 Permission to delete a file or directory within a directory. 2938 See Section 6.2.1.3.2 for information on ACE4_DELETE and 2939 ACE4_DELETE_CHILD interact. 2941 ACE4_READ_ATTRIBUTES 2943 Operation(s) affected: 2945 GETATTR of file system object attributes 2947 VERIFY 2949 NVERIFY 2951 READDIR 2953 Discussion: 2955 The ability to read basic attributes (non-ACLs) of a file. On 2956 a UNIX system, basic attributes can be thought of as the stat 2957 level attributes. Allowing this access mask bit would mean the 2958 entity can execute "ls -l" and stat. If a READDIR operation 2959 requests attributes, this mask must be allowed for the READDIR 2960 to succeed. 2962 ACE4_WRITE_ATTRIBUTES 2964 Operation(s) affected: 2966 SETATTR of time_access_set, time_backup, 2968 time_create, time_modify_set, mimetype, hidden, system 2970 Discussion: 2972 Permission to change the times associated with a file or 2973 directory to an arbitrary value. Also permission to change the 2974 mimetype, hidden and system attributes. A user having 2975 ACE4_WRITE_DATA or ACE4_WRITE_ATTRIBUTES will be allowed to set 2976 the times associated with a file to the current server time. 2978 ACE4_DELETE 2980 Operation(s) affected: 2982 REMOVE 2984 Discussion: 2986 Permission to delete the file or directory. See 2987 Section 6.2.1.3.2 for information on ACE4_DELETE and 2988 ACE4_DELETE_CHILD interact. 2990 ACE4_READ_ACL 2992 Operation(s) affected: 2994 GETATTR of acl 2996 NVERIFY 2998 VERIFY 3000 Discussion: 3002 Permission to read the ACL. 3004 ACE4_WRITE_ACL 3006 Operation(s) affected: 3008 SETATTR of acl and mode 3010 Discussion: 3012 Permission to write the acl and mode attributes. 3014 ACE4_WRITE_OWNER 3016 Operation(s) affected: 3018 SETATTR of owner and owner_group 3020 Discussion: 3022 Permission to write the owner and owner_group attributes. On 3023 UNIX systems, this is the ability to execute chown() and 3024 chgrp(). 3026 ACE4_SYNCHRONIZE 3028 Operation(s) affected: 3030 NONE 3032 Discussion: 3034 Permission to access file locally at the server with 3035 synchronized reads and writes. 3037 Server implementations need not provide the granularity of control 3038 that is implied by this list of masks. For example, POSIX-based 3039 systems might not distinguish ACE4_APPEND_DATA (the ability to append 3040 to a file) from ACE4_WRITE_DATA (the ability to modify existing 3041 contents); both masks would be tied to a single "write" permission. 3042 When such a server returns attributes to the client, it would show 3043 both ACE4_APPEND_DATA and ACE4_WRITE_DATA if and only if the write 3044 permission is enabled. 3046 If a server receives a SETATTR request that it cannot accurately 3047 implement, it should err in the direction of more restricted access, 3048 except in the previously discussed cases of execute and read. For 3049 example, suppose a server cannot distinguish overwriting data from 3050 appending new data, as described in the previous paragraph. If a 3051 client submits an ALLOW ACE where ACE4_APPEND_DATA is set but 3052 ACE4_WRITE_DATA is not (or vice versa), the server should either turn 3053 off ACE4_APPEND_DATA or reject the request with NFS4ERR_ATTRNOTSUPP. 3055 6.2.1.3.2. ACE4_DELETE vs. ACE4_DELETE_CHILD 3057 Two access mask bits govern the ability to delete a directory entry: 3058 ACE4_DELETE on the object itself (the "target"), and 3059 ACE4_DELETE_CHILD on the containing directory (the "parent"). 3061 Many systems also take the "sticky bit" (MODE4_SVTX) on a directory 3062 to allow unlink only to a user that owns either the target or the 3063 parent; on some such systems the decision also depends on whether the 3064 target is writable. 3066 Servers SHOULD allow unlink if either ACE4_DELETE is permitted on the 3067 target, or ACE4_DELETE_CHILD is permitted on the parent. (Note that 3068 this is true even if the parent or target explicitly denies one of 3069 these permissions.) 3071 If the ACLs in question neither explicitly ALLOW nor DENY either of 3072 the above, and if MODE4_SVTX is not set on the parent, then the 3073 server SHOULD allow the removal if and only if ACE4_ADD_FILE is 3074 permitted. In the case where MODE4_SVTX is set, the server may also 3075 require the remover to own either the parent or the target, or may 3076 require the target to be writable. 3078 This allows servers to support something close to traditional UNIX- 3079 like semantics, with ACE4_ADD_FILE taking the place of the write bit. 3081 6.2.1.4. ACE flag 3083 The bitmask constants used for the flag field are as follows: 3085 const ACE4_FILE_INHERIT_ACE = 0x00000001; 3086 const ACE4_DIRECTORY_INHERIT_ACE = 0x00000002; 3087 const ACE4_NO_PROPAGATE_INHERIT_ACE = 0x00000004; 3088 const ACE4_INHERIT_ONLY_ACE = 0x00000008; 3089 const ACE4_SUCCESSFUL_ACCESS_ACE_FLAG = 0x00000010; 3090 const ACE4_FAILED_ACCESS_ACE_FLAG = 0x00000020; 3091 const ACE4_IDENTIFIER_GROUP = 0x00000040; 3093 A server need not support any of these flags. If the server supports 3094 flags that are similar to, but not exactly the same as, these flags, 3095 the implementation may define a mapping between the protocol-defined 3096 flags and the implementation-defined flags. 3098 For example, suppose a client tries to set an ACE with 3099 ACE4_FILE_INHERIT_ACE set but not ACE4_DIRECTORY_INHERIT_ACE. If the 3100 server does not support any form of ACL inheritance, the server 3101 should reject the request with NFS4ERR_ATTRNOTSUPP. If the server 3102 supports a single "inherit ACE" flag that applies to both files and 3103 directories, the server may reject the request (i.e., requiring the 3104 client to set both the file and directory inheritance flags). The 3105 server may also accept the request and silently turn on the 3106 ACE4_DIRECTORY_INHERIT_ACE flag. 3108 6.2.1.4.1. Discussion of Flag Bits 3110 ACE4_FILE_INHERIT_ACE 3111 Any non-directory file in any sub-directory will get this ACE 3112 inherited. 3114 ACE4_DIRECTORY_INHERIT_ACE 3115 Can be placed on a directory and indicates that this ACE should be 3116 added to each new directory created. 3117 If this flag is set in an ACE in an ACL attribute to be set on a 3118 non-directory file system object, the operation attempting to set 3119 the ACL SHOULD fail with NFS4ERR_ATTRNOTSUPP. 3121 ACE4_INHERIT_ONLY_ACE 3122 Can be placed on a directory but does not apply to the directory; 3123 ALLOW and DENY ACEs with this bit set do not affect access to the 3124 directory, and AUDIT and ALARM ACEs with this bit set do not 3125 trigger log or alarm events. Such ACEs only take effect once they 3126 are applied (with this bit cleared) to newly created files and 3127 directories as specified by the above two flags. 3128 If this flag is present on an ACE, but neither 3129 ACE4_DIRECTORY_INHERIT_ACE nor ACE4_FILE_INHERIT_ACE is present, 3130 then an operation attempting to set such an attribute SHOULD fail 3131 with NFS4ERR_ATTRNOTSUPP. 3133 ACE4_NO_PROPAGATE_INHERIT_ACE 3134 Can be placed on a directory. This flag tells the server that 3135 inheritance of this ACE should stop at newly created child 3136 directories. 3138 ACE4_SUCCESSFUL_ACCESS_ACE_FLAG 3140 ACE4_FAILED_ACCESS_ACE_FLAG 3141 The ACE4_SUCCESSFUL_ACCESS_ACE_FLAG (SUCCESS) and 3142 ACE4_FAILED_ACCESS_ACE_FLAG (FAILED) flag bits may be set only on 3143 ACE4_SYSTEM_AUDIT_ACE_TYPE (AUDIT) and ACE4_SYSTEM_ALARM_ACE_TYPE 3144 (ALARM) ACE types. If during the processing of the file's ACL, 3145 the server encounters an AUDIT or ALARM ACE that matches the 3146 principal attempting the OPEN, the server notes that fact, and the 3147 presence, if any, of the SUCCESS and FAILED flags encountered in 3148 the AUDIT or ALARM ACE. Once the server completes the ACL 3149 processing, it then notes if the operation succeeded or failed. 3150 If the operation succeeded, and if the SUCCESS flag was set for a 3151 matching AUDIT or ALARM ACE, then the appropriate AUDIT or ALARM 3152 event occurs. If the operation failed, and if the FAILED flag was 3153 set for the matching AUDIT or ALARM ACE, then the appropriate 3154 AUDIT or ALARM event occurs. Either or both of the SUCCESS or 3155 FAILED can be set, but if neither is set, the AUDIT or ALARM ACE 3156 is not useful. 3158 The previously described processing applies to ACCESS operations 3159 even when they return NFS4_OK. For the purposes of AUDIT and 3160 ALARM, we consider an ACCESS operation to be a "failure" if it 3161 fails to return a bit that was requested and supported. 3163 ACE4_IDENTIFIER_GROUP 3164 Indicates that the "who" refers to a GROUP as defined under UNIX 3165 or a GROUP ACCOUNT as defined under Windows. Clients and servers 3166 MUST ignore the ACE4_IDENTIFIER_GROUP flag on ACEs with a who 3167 value equal to one of the special identifiers outlined in 3168 Section 6.2.1.5. 3170 6.2.1.5. ACE Who 3172 The "who" field of an ACE is an identifier that specifies the 3173 principal or principals to whom the ACE applies. It may refer to a 3174 user or a group, with the flag bit ACE4_IDENTIFIER_GROUP specifying 3175 which. 3177 There are several special identifiers which need to be understood 3178 universally, rather than in the context of a particular DNS domain. 3179 Some of these identifiers cannot be understood when an NFS client 3180 accesses the server, but have meaning when a local process accesses 3181 the file. The ability to display and modify these permissions is 3182 permitted over NFS, even if none of the access methods on the server 3183 understands the identifiers. 3185 +---------------+--------------------------------------------------+ 3186 | Who | Description | 3187 +---------------+--------------------------------------------------+ 3188 | OWNER | The owner of the file | 3189 | GROUP | The group associated with the file. | 3190 | EVERYONE | The world, including the owner and owning group. | 3191 | INTERACTIVE | Accessed from an interactive terminal. | 3192 | NETWORK | Accessed via the network. | 3193 | DIALUP | Accessed as a dialup user to the server. | 3194 | BATCH | Accessed from a batch job. | 3195 | ANONYMOUS | Accessed without any authentication. | 3196 | AUTHENTICATED | Any authenticated user (opposite of ANONYMOUS) | 3197 | SERVICE | Access from a system service. | 3198 +---------------+--------------------------------------------------+ 3200 Table 4 3202 To avoid conflict, these special identifiers are distinguished by an 3203 appended "@" and should appear in the form "xxxx@" (with no domain 3204 name after the "@"). For example: ANONYMOUS@. 3206 The ACE4_IDENTIFIER_GROUP flag MUST be ignored on entries with these 3207 special identifiers. When encoding entries with these special 3208 identifiers, the ACE4_IDENTIFIER_GROUP flag SHOULD be set to zero. 3210 6.2.1.5.1. Discussion of EVERYONE@ 3212 It is important to note that "EVERYONE@" is not equivalent to the 3213 UNIX "other" entity. This is because, by definition, UNIX "other" 3214 does not include the owner or owning group of a file. "EVERYONE@" 3215 means literally everyone, including the owner or owning group. 3217 6.2.2. Attribute 33: mode 3219 The NFSv4.0 mode attribute is based on the UNIX mode bits. The 3220 following bits are defined: 3222 const MODE4_SUID = 0x800; /* set user id on execution */ 3223 const MODE4_SGID = 0x400; /* set group id on execution */ 3224 const MODE4_SVTX = 0x200; /* save text even after use */ 3225 const MODE4_RUSR = 0x100; /* read permission: owner */ 3226 const MODE4_WUSR = 0x080; /* write permission: owner */ 3227 const MODE4_XUSR = 0x040; /* execute permission: owner */ 3228 const MODE4_RGRP = 0x020; /* read permission: group */ 3229 const MODE4_WGRP = 0x010; /* write permission: group */ 3230 const MODE4_XGRP = 0x008; /* execute permission: group */ 3231 const MODE4_ROTH = 0x004; /* read permission: other */ 3232 const MODE4_WOTH = 0x002; /* write permission: other */ 3233 const MODE4_XOTH = 0x001; /* execute permission: other */ 3235 Bits MODE4_RUSR, MODE4_WUSR, and MODE4_XUSR apply to the principal 3236 identified in the owner attribute. Bits MODE4_RGRP, MODE4_WGRP, and 3237 MODE4_XGRP apply to principals identified in the owner_group 3238 attribute but who are not identified in the owner attribute. Bits 3239 MODE4_ROTH, MODE4_WOTH, MODE4_XOTH apply to any principal that does 3240 not match that in the owner attribute, and does not have a group 3241 matching that of the owner_group attribute. 3243 Bits within the mode other than those specified above are not defined 3244 by this protocol. A server MUST NOT return bits other than those 3245 defined above in a GETATTR or READDIR operation, and it MUST return 3246 NFS4ERR_INVAL if bits other than those defined above are set in a 3247 SETATTR, CREATE, OPEN, VERIFY or NVERIFY operation. 3249 6.3. Common Methods 3251 The requirements in this section will be referred to in future 3252 sections, especially Section 6.4. 3254 6.3.1. Interpreting an ACL 3256 6.3.1.1. Server Considerations 3258 The server uses the algorithm described in Section 6.2.1 to determine 3259 whether an ACL allows access to an object. However, the ACL may not 3260 be the sole determiner of access. For example: 3262 o In the case of a file system exported as read-only, the server may 3263 deny write permissions even though an object's ACL grants it. 3265 o Server implementations MAY grant ACE4_WRITE_ACL and ACE4_READ_ACL 3266 permissions to prevent a situation from arising in which there is 3267 no valid way to ever modify the ACL. 3269 o All servers will allow a user the ability to read the data of the 3270 file when only the execute permission is granted (i.e., If the ACL 3271 denies the user the ACE4_READ_DATA access and allows the user 3272 ACE4_EXECUTE, the server will allow the user to read the data of 3273 the file). 3275 o Many servers have the notion of owner-override in which the owner 3276 of the object is allowed to override accesses that are denied by 3277 the ACL. This may be helpful, for example, to allow users 3278 continued access to open files on which the permissions have 3279 changed. 3281 o Many servers have the notion of a "superuser" that has privileges 3282 beyond an ordinary user. The superuser may be able to read or 3283 write data or metadata in ways that would not be permitted by the 3284 ACL. 3286 6.3.1.2. Client Considerations 3288 Clients SHOULD NOT do their own access checks based on their 3289 interpretation the ACL, but rather use the OPEN and ACCESS operations 3290 to do access checks. This allows the client to act on the results of 3291 having the server determine whether or not access should be granted 3292 based on its interpretation of the ACL. 3294 Clients must be aware of situations in which an object's ACL will 3295 define a certain access even though the server will not enforce it. 3296 In general, but especially in these situations, the client needs to 3297 do its part in the enforcement of access as defined by the ACL. To 3298 do this, the client MAY send the appropriate ACCESS operation prior 3299 to servicing the request of the user or application in order to 3300 determine whether the user or application should be granted the 3301 access requested. For examples in which the ACL may define accesses 3302 that the server doesn't enforce see Section 6.3.1.1. 3304 6.3.2. Computing a Mode Attribute from an ACL 3306 The following method can be used to calculate the MODE4_R*, MODE4_W* 3307 and MODE4_X* bits of a mode attribute, based upon an ACL. 3309 First, for each of the special identifiers OWNER@, GROUP@, and 3310 EVERYONE@, evaluate the ACL in order, considering only ALLOW and DENY 3311 ACEs for the identifier EVERYONE@ and for the identifier under 3312 consideration. The result of the evaluation will be an NFSv4 ACL 3313 mask showing exactly which bits are permitted to that identifier. 3315 Then translate the calculated mask for OWNER@, GROUP@, and EVERYONE@ 3316 into mode bits for, respectively, the user, group, and other, as 3317 follows: 3319 1. Set the read bit (MODE4_RUSR, MODE4_RGRP, or MODE4_ROTH) if and 3320 only if ACE4_READ_DATA is set in the corresponding mask. 3322 2. Set the write bit (MODE4_WUSR, MODE4_WGRP, or MODE4_WOTH) if and 3323 only if ACE4_WRITE_DATA and ACE4_APPEND_DATA are both set in the 3324 corresponding mask. 3326 3. Set the execute bit (MODE4_XUSR, MODE4_XGRP, or MODE4_XOTH), if 3327 and only if ACE4_EXECUTE is set in the corresponding mask. 3329 6.3.2.1. Discussion 3331 Some server implementations also add bits permitted to named users 3332 and groups to the group bits (MODE4_RGRP, MODE4_WGRP, and 3333 MODE4_XGRP). 3335 Implementations are discouraged from doing this, because it has been 3336 found to cause confusion for users who see members of a file's group 3337 denied access that the mode bits appear to allow. (The presence of 3338 DENY ACEs may also lead to such behavior, but DENY ACEs are expected 3339 to be more rarely used.) 3341 The same user confusion seen when fetching the mode also results if 3342 setting the mode does not effectively control permissions for the 3343 owner, group, and other users; this motivates some of the 3344 requirements that follow. 3346 6.4. Requirements 3348 The server that supports both mode and ACL must take care to 3349 synchronize the MODE4_*USR, MODE4_*GRP, and MODE4_*OTH bits with the 3350 ACEs which have respective who fields of "OWNER@", "GROUP@", and 3351 "EVERYONE@" so that the client can see semantically equivalent access 3352 permissions exist whether the client asks for owner, owner_group and 3353 mode attributes, or for just the ACL. 3355 In this section, much is made of the methods in Section 6.3.2. Many 3356 requirements refer to this section. But note that the methods have 3357 behaviors specified with "SHOULD". This is intentional, to avoid 3358 invalidating existing implementations that compute the mode according 3359 to the withdrawn POSIX ACL draft (1003.1e draft 17), rather than by 3360 actual permissions on owner, group, and other. 3362 6.4.1. Setting the mode and/or ACL Attributes 3364 6.4.1.1. Setting mode and not ACL 3366 When any of the nine low-order mode bits are subject to change, 3367 either because the mode attribute was set or because the 3368 mode_set_masked attribute was set and the mask included one or more 3369 bits from the nine low-order mode bits, and no ACL attribute is 3370 explicitly set, the acl attribute must be modified in accordance with 3371 the updated value of those bits. This must happen even if the value 3372 of the low-order bits is the same after the mode is set as before. 3374 Note that any AUDIT or ALARM ACEs are unaffected by changes to the 3375 mode. 3377 In cases in which the permissions bits are subject to change, the acl 3378 attribute MUST be modified such that the mode computed via the method 3379 in Section 6.3.2 yields the low-order nine bits (MODE4_R*, MODE4_W*, 3380 MODE4_X*) of the mode attribute as modified by the attribute change. 3381 The ACL attributes SHOULD also be modified such that: 3383 1. If MODE4_RGRP is not set, entities explicitly listed in the ACL 3384 other than OWNER@ and EVERYONE@ SHOULD NOT be granted 3385 ACE4_READ_DATA. 3387 2. If MODE4_WGRP is not set, entities explicitly listed in the ACL 3388 other than OWNER@ and EVERYONE@ SHOULD NOT be granted 3389 ACE4_WRITE_DATA or ACE4_APPEND_DATA. 3391 3. If MODE4_XGRP is not set, entities explicitly listed in the ACL 3392 other than OWNER@ and EVERYONE@ SHOULD NOT be granted 3393 ACE4_EXECUTE. 3395 Access mask bits other those listed above, appearing in ALLOW ACEs, 3396 MAY also be disabled. 3398 Note that ACEs with the flag ACE4_INHERIT_ONLY_ACE set do not affect 3399 the permissions of the ACL itself, nor do ACEs of the type AUDIT and 3400 ALARM. As such, it is desirable to leave these ACEs unmodified when 3401 modifying the ACL attributes. 3403 Also note that the requirement may be met by discarding the acl in 3404 favor of an ACL that represents the mode and only the mode. This is 3405 permitted, but it is preferable for a server to preserve as much of 3406 the ACL as possible without violating the above requirements. 3407 Discarding the ACL makes it effectively impossible for a file created 3408 with a mode attribute to inherit an ACL (see Section 6.4.3). 3410 6.4.1.2. Setting ACL and not mode 3412 When setting the acl and not setting the mode or mode_set_masked 3413 attributes, the permission bits of the mode need to be derived from 3414 the ACL. In this case, the ACL attribute SHOULD be set as given. 3415 The nine low-order bits of the mode attribute (MODE4_R*, MODE4_W*, 3416 MODE4_X*) MUST be modified to match the result of the method 3417 Section 6.3.2. The three high-order bits of the mode (MODE4_SUID, 3418 MODE4_SGID, MODE4_SVTX) SHOULD remain unchanged. 3420 6.4.1.3. Setting both ACL and mode 3422 When setting both the mode (includes use of either the mode attribute 3423 or the mode_set_masked attribute) and the acl attribute in the same 3424 operation, the attributes MUST be applied in this order: mode (or 3425 mode_set_masked), then ACL. The mode-related attribute is set as 3426 given, then the ACL attribute is set as given, possibly changing the 3427 final mode, as described above in Section 6.4.1.2. 3429 6.4.2. Retrieving the mode and/or ACL Attributes 3431 This section applies only to servers that support both the mode and 3432 ACL attributes. 3434 Some server implementations may have a concept of "objects without 3435 ACLs", meaning that all permissions are granted and denied according 3436 to the mode attribute, and that no ACL attribute is stored for that 3437 object. If an ACL attribute is requested of such a server, the 3438 server SHOULD return an ACL that does not conflict with the mode; 3439 that is to say, the ACL returned SHOULD represent the nine low-order 3440 bits of the mode attribute (MODE4_R*, MODE4_W*, MODE4_X*) as 3441 described in Section 6.3.2. 3443 For other server implementations, the ACL attribute is always present 3444 for every object. Such servers SHOULD store at least the three high- 3445 order bits of the mode attribute (MODE4_SUID, MODE4_SGID, 3446 MODE4_SVTX). The server SHOULD return a mode attribute if one is 3447 requested, and the low-order nine bits of the mode (MODE4_R*, 3448 MODE4_W*, MODE4_X*) MUST match the result of applying the method in 3449 Section 6.3.2 to the ACL attribute. 3451 6.4.3. Creating New Objects 3453 If a server supports any ACL attributes, it may use the ACL 3454 attributes on the parent directory to compute an initial ACL 3455 attribute for a newly created object. This will be referred to as 3456 the inherited ACL within this section. The act of adding one or more 3457 ACEs to the inherited ACL that are based upon ACEs in the parent 3458 directory's ACL will be referred to as inheriting an ACE within this 3459 section. 3461 Implementors should standardize on what the behavior of CREATE and 3462 OPEN must be depending on the presence or absence of the mode and ACL 3463 attributes. 3465 1. If just the mode is given in the call: 3467 In this case, inheritance SHOULD take place, but the mode MUST be 3468 applied to the inherited ACL as described in Section 6.4.1.1, 3469 thereby modifying the ACL. 3471 2. If just the ACL is given in the call: 3473 In this case, inheritance SHOULD NOT take place, and the ACL as 3474 defined in the CREATE or OPEN will be set without modification, 3475 and the mode modified as in Section 6.4.1.2 3477 3. If both mode and ACL are given in the call: 3479 In this case, inheritance SHOULD NOT take place, and both 3480 attributes will be set as described in Section 6.4.1.3. 3482 4. If neither mode nor ACL are given in the call: 3484 In the case where an object is being created without any initial 3485 attributes at all, e.g., an OPEN operation with an opentype4 of 3486 OPEN4_CREATE and a createmode4 of EXCLUSIVE4, inheritance SHOULD 3487 NOT take place. Instead, the server SHOULD set permissions to 3488 deny all access to the newly created object. It is expected that 3489 the appropriate client will set the desired attributes in a 3490 subsequent SETATTR operation, and the server SHOULD allow that 3491 operation to succeed, regardless of what permissions the object 3492 is created with. For example, an empty ACL denies all 3493 permissions, but the server should allow the owner's SETATTR to 3494 succeed even though WRITE_ACL is implicitly denied. 3496 In other cases, inheritance SHOULD take place, and no 3497 modifications to the ACL will happen. The mode attribute, if 3498 supported, MUST be as computed in Section 6.3.2, with the 3499 MODE4_SUID, MODE4_SGID and MODE4_SVTX bits clear. If no 3500 inheritable ACEs exist on the parent directory, the rules for 3501 creating acl attributes are implementation defined. 3503 6.4.3.1. The Inherited ACL 3505 If the object being created is not a directory, the inherited ACL 3506 SHOULD NOT inherit ACEs from the parent directory ACL unless the 3507 ACE4_FILE_INHERIT_FLAG is set. 3509 If the object being created is a directory, the inherited ACL should 3510 inherit all inheritable ACEs from the parent directory, those that 3511 have ACE4_FILE_INHERIT_ACE or ACE4_DIRECTORY_INHERIT_ACE flag set. 3512 If the inheritable ACE has ACE4_FILE_INHERIT_ACE set, but 3513 ACE4_DIRECTORY_INHERIT_ACE is clear, the inherited ACE on the newly 3514 created directory MUST have the ACE4_INHERIT_ONLY_ACE flag set to 3515 prevent the directory from being affected by ACEs meant for non- 3516 directories. 3518 When a new directory is created, the server MAY split any inherited 3519 ACE which is both inheritable and effective (in other words, which 3520 has neither ACE4_INHERIT_ONLY_ACE nor ACE4_NO_PROPAGATE_INHERIT_ACE 3521 set), into two ACEs, one with no inheritance flags, and one with 3522 ACE4_INHERIT_ONLY_ACE set. This makes it simpler to modify the 3523 effective permissions on the directory without modifying the ACE 3524 which is to be inherited to the new directory's children. 3526 7. Multi-Server Namespace 3528 NFSv4 supports attributes that allow a namespace to extend beyond the 3529 boundaries of a single server. It is RECOMMENDED that clients and 3530 servers support construction of such multi-server namespaces. Use of 3531 such multi-server namespaces is OPTIONAL, however, and for many 3532 purposes, single-server namespaces are perfectly acceptable. Use of 3533 multi-server namespaces can provide many advantages, however, by 3534 separating a file system's logical position in a namespace from the 3535 (possibly changing) logistical and administrative considerations that 3536 result in particular file systems being located on particular 3537 servers. 3539 7.1. Location Attributes 3541 NFSv4 contains RECOMMENDED attributes that allow file systems on one 3542 server to be associated with one or more instances of that file 3543 system on other servers. These attributes specify such file system 3544 instances by specifying a server address target (either as a DNS name 3545 representing one or more IP addresses or as a literal IP address) 3546 together with the path of that file system within the associated 3547 single-server namespace. 3549 The fs_locations RECOMMENDED attribute allows specification of the 3550 file system locations where the data corresponding to a given file 3551 system may be found. 3553 7.2. File System Presence or Absence 3555 A given location in an NFSv4 namespace (typically but not necessarily 3556 a multi-server namespace) can have a number of file system instance 3557 locations associated with it via the fs_locations attribute. There 3558 may also be an actual current file system at that location, 3559 accessible via normal namespace operations (e.g., LOOKUP). In this 3560 case, the file system is said to be "present" at that position in the 3561 namespace, and clients will typically use it, reserving use of 3562 additional locations specified via the location-related attributes to 3563 situations in which the principal location is no longer available. 3565 When there is no actual file system at the namespace location in 3566 question, the file system is said to be "absent". An absent file 3567 system contains no files or directories other than the root. Any 3568 reference to it, except to access a small set of attributes useful in 3569 determining alternate locations, will result in an error, 3570 NFS4ERR_MOVED. Note that if the server ever returns the error 3571 NFS4ERR_MOVED, it MUST support the fs_locations attribute. 3573 While the error name suggests that we have a case of a file system 3574 that once was present, and has only become absent later, this is only 3575 one possibility. A position in the namespace may be permanently 3576 absent with the set of file system(s) designated by the location 3577 attributes being the only realization. The name NFS4ERR_MOVED 3578 reflects an earlier, more limited conception of its function, but 3579 this error will be returned whenever the referenced file system is 3580 absent, whether it has moved or not. 3582 Except in the case of GETATTR-type operations (to be discussed 3583 later), when the current filehandle at the start of an operation is 3584 within an absent file system, that operation is not performed and the 3585 error NFS4ERR_MOVED is returned, to indicate that the file system is 3586 absent on the current server. 3588 Because a GETFH cannot succeed if the current filehandle is within an 3589 absent file system, filehandles within an absent file system cannot 3590 be transferred to the client. When a client does have filehandles 3591 within an absent file system, it is the result of obtaining them when 3592 the file system was present, and having the file system become absent 3593 subsequently. 3595 It should be noted that because the check for the current filehandle 3596 being within an absent file system happens at the start of every 3597 operation, operations that change the current filehandle so that it 3598 is within an absent file system will not result in an error. This 3599 allows such combinations as PUTFH-GETATTR and LOOKUP-GETATTR to be 3600 used to get attribute information, particularly location attribute 3601 information, as discussed below. 3603 7.3. Getting Attributes for an Absent File System 3605 When a file system is absent, most attributes are not available, but 3606 it is necessary to allow the client access to the small set of 3607 attributes that are available, and most particularly that which gives 3608 information about the correct current locations for this file system, 3609 fs_locations. 3611 7.3.1. GETATTR Within an Absent File System 3613 As mentioned above, an exception is made for GETATTR in that 3614 attributes may be obtained for a filehandle within an absent file 3615 system. This exception only applies if the attribute mask contains 3616 at least the fs_locations attribute bit, which indicates the client 3617 is interested in a result regarding an absent file system. If it is 3618 not requested, GETATTR will result in an NFS4ERR_MOVED error. 3620 When a GETATTR is done on an absent file system, the set of supported 3621 attributes is very limited. Many attributes, including those that 3622 are normally REQUIRED, will not be available on an absent file 3623 system. In addition to the fs_locations attribute, the following 3624 attributes SHOULD be available on absent file systems. In the case 3625 of RECOMMENDED attributes, they should be available at least to the 3626 same degree that they are available on present file systems. 3628 fsid: This attribute should be provided so that the client can 3629 determine file system boundaries, including, in particular, the 3630 boundary between present and absent file systems. This value must 3631 be different from any other fsid on the current server and need 3632 have no particular relationship to fsids on any particular 3633 destination to which the client might be directed. 3635 mounted_on_fileid: For objects at the top of an absent file system, 3636 this attribute needs to be available. Since the fileid is within 3637 the present parent file system, there should be no need to 3638 reference the absent file system to provide this information. 3640 Other attributes SHOULD NOT be made available for absent file 3641 systems, even when it is possible to provide them. The server should 3642 not assume that more information is always better and should avoid 3643 gratuitously providing additional information. 3645 When a GETATTR operation includes a bit mask for the attribute 3646 fs_locations, but where the bit mask includes attributes that are not 3647 supported, GETATTR will not return an error, but will return the mask 3648 of the actual attributes supported with the results. 3650 Handling of VERIFY/NVERIFY is similar to GETATTR in that if the 3651 attribute mask does not include fs_locations the error NFS4ERR_MOVED 3652 will result. It differs in that any appearance in the attribute mask 3653 of an attribute not supported for an absent file system (and note 3654 that this will include some normally REQUIRED attributes) will also 3655 cause an NFS4ERR_MOVED result. 3657 7.3.2. READDIR and Absent File Systems 3659 A READDIR performed when the current filehandle is within an absent 3660 file system will result in an NFS4ERR_MOVED error, since, unlike the 3661 case of GETATTR, no such exception is made for READDIR. 3663 Attributes for an absent file system may be fetched via a READDIR for 3664 a directory in a present file system, when that directory contains 3665 the root directories of one or more absent file systems. In this 3666 case, the handling is as follows: 3668 o If the attribute set requested includes fs_locations, then 3669 fetching of attributes proceeds normally and no NFS4ERR_MOVED 3670 indication is returned, even when the rdattr_error attribute is 3671 requested. 3673 o If the attribute set requested does not include fs_locations, then 3674 if the rdattr_error attribute is requested, each directory entry 3675 for the root of an absent file system will report NFS4ERR_MOVED as 3676 the value of the rdattr_error attribute. 3678 o If the attribute set requested does not include either of the 3679 attributes fs_locations or rdattr_error then the occurrence of the 3680 root of an absent file system within the directory will result in 3681 the READDIR failing with an NFS4ERR_MOVED error. 3683 o The unavailability of an attribute because of a file system's 3684 absence, even one that is ordinarily REQUIRED, does not result in 3685 any error indication. The set of attributes returned for the root 3686 directory of the absent file system in that case is simply 3687 restricted to those actually available. 3689 7.4. Uses of Location Information 3691 The location-bearing attribute of fs_locations provides, together 3692 with the possibility of absent file systems, a number of important 3693 facilities in providing reliable, manageable, and scalable data 3694 access. 3696 When a file system is present, these attributes can provide 3697 alternative locations, to be used to access the same data, in the 3698 event of server failures, communications problems, or other 3699 difficulties that make continued access to the current file system 3700 impossible or otherwise impractical. Under some circumstances, 3701 multiple alternative locations may be used simultaneously to provide 3702 higher-performance access to the file system in question. Provision 3703 of such alternate locations is referred to as "replication" although 3704 there are cases in which replicated sets of data are not in fact 3705 present, and the replicas are instead different paths to the same 3706 data. 3708 When a file system is present and becomes absent, clients can be 3709 given the opportunity to have continued access to their data, at an 3710 alternate location. In this case, a continued attempt to use the 3711 data in the now-absent file system will result in an NFS4ERR_MOVED 3712 error and, at that point, the successor locations (typically only one 3713 although multiple choices are possible) can be fetched and used to 3714 continue access. Transfer of the file system contents to the new 3715 location is referred to as "migration", but it should be kept in mind 3716 that there are cases in which this term can be used, like 3717 "replication", when there is no actual data migration per se. 3719 Where a file system was not previously present, specification of file 3720 system location provides a means by which file systems located on one 3721 server can be associated with a namespace defined by another server, 3722 thus allowing a general multi-server namespace facility. A 3723 designation of such a location, in place of an absent file system, is 3724 called a "referral". 3726 Because client support for location-related attributes is OPTIONAL, a 3727 server may (but is not required to) take action to hide migration and 3728 referral events from such clients, by acting as a proxy, for example. 3730 7.4.1. File System Replication 3732 The fs_locations attribute provides alternative locations, to be used 3733 to access data in place of or in addition to the current file system 3734 instance. On first access to a file system, the client should obtain 3735 the value of the set of alternate locations by interrogating the 3736 fs_locations attribute. 3738 In the event that server failures, communications problems, or other 3739 difficulties make continued access to the current file system 3740 impossible or otherwise impractical, the client can use the alternate 3741 locations as a way to get continued access to its data. Multiple 3742 locations may be used simultaneously, to provide higher performance 3743 through the exploitation of multiple paths between client and target 3744 file system. 3746 The alternate locations may be physical replicas of the (typically 3747 read-only) file system data, or they may reflect alternate paths to 3748 the same server or provide for the use of various forms of server 3749 clustering in which multiple servers provide alternate ways of 3750 accessing the same physical file system. How these different modes 3751 of file system transition are represented within the fs_locations 3752 attribute and how the client deals with file system transition issues 3753 will be discussed in detail below. 3755 Multiple server addresses, whether they are derived from a single 3756 entry with a DNS name representing a set of IP addresses or from 3757 multiple entries each with its own server address, may correspond to 3758 the same actual server. 3760 7.4.2. File System Migration 3762 When a file system is present and becomes absent, clients can be 3763 given the opportunity to have continued access to their data, at an 3764 alternate location, as specified by the fs_locations attribute. 3765 Typically, a client will be accessing the file system in question, 3766 get an NFS4ERR_MOVED error, and then use the fs_locations attribute 3767 to determine the new location of the data. 3769 Such migration can be helpful in providing load balancing or general 3770 resource reallocation. The protocol does not specify how the file 3771 system will be moved between servers. It is anticipated that a 3772 number of different server-to-server transfer mechanisms might be 3773 used with the choice left to the server implementor. The NFSv4 3774 protocol specifies the method used to communicate the migration event 3775 between client and server. 3777 The new location may be an alternate communication path to the same 3778 server or, in the case of various forms of server clustering, another 3779 server providing access to the same physical file system. The 3780 client's responsibilities in dealing with this transition depend on 3781 the specific nature of the new access path as well as how and whether 3782 data was in fact migrated. These issues will be discussed in detail 3783 below. 3785 When an alternate location is designated as the target for migration, 3786 it must designate the same data. Where file systems are writable, a 3787 change made on the original file system must be visible on all 3788 migration targets. Where a file system is not writable but 3789 represents a read-only copy (possibly periodically updated) of a 3790 writable file system, similar requirements apply to the propagation 3791 of updates. Any change visible in the original file system must 3792 already be effected on all migration targets, to avoid any 3793 possibility that a client, in effecting a transition to the migration 3794 target, will see any reversion in file system state. 3796 7.4.3. Referrals 3798 Referrals provide a way of placing a file system in a location within 3799 the namespace essentially without respect to its physical location on 3800 a given server. This allows a single server or a set of servers to 3801 present a multi-server namespace that encompasses file systems 3802 located on multiple servers. Some likely uses of this include 3803 establishment of site-wide or organization-wide namespaces, or even 3804 knitting such together into a truly global namespace. 3806 Referrals occur when a client determines, upon first referencing a 3807 position in the current namespace, that it is part of a new file 3808 system and that the file system is absent. When this occurs, 3809 typically by receiving the error NFS4ERR_MOVED, the actual location 3810 or locations of the file system can be determined by fetching the 3811 fs_locations attribute. 3813 The locations-related attribute may designate a single file system 3814 location or multiple file system locations, to be selected based on 3815 the needs of the client. 3817 Use of multi-server namespaces is enabled by NFSv4 but is not 3818 required. The use of multi-server namespaces and their scope will 3819 depend on the applications used and system administration 3820 preferences. 3822 Multi-server namespaces can be established by a single server 3823 providing a large set of referrals to all of the included file 3824 systems. Alternatively, a single multi-server namespace may be 3825 administratively segmented with separate referral file systems (on 3826 separate servers) for each separately administered portion of the 3827 namespace. The top-level referral file system or any segment may use 3828 replicated referral file systems for higher availability. 3830 Generally, multi-server namespaces are for the most part uniform, in 3831 that the same data made available to one client at a given location 3832 in the namespace is made available to all clients at that location. 3834 7.5. Location Entries and Server Identity 3836 As mentioned above, a single location entry may have a server address 3837 target in the form of a DNS name that may represent multiple IP 3838 addresses, while multiple location entries may have their own server 3839 address targets that reference the same server. 3841 When multiple addresses for the same server exist, the client may 3842 assume that for each file system in the namespace of a given server 3843 network address, there exist file systems at corresponding namespace 3844 locations for each of the other server network addresses. It may do 3845 this even in the absence of explicit listing in fs_locations. Such 3846 corresponding file system locations can be used as alternate 3847 locations, just as those explicitly specified via the fs_locations 3848 attribute. 3850 If a single location entry designates multiple server IP addresses, 3851 the client cannot assume that these addresses are multiple paths to 3852 the same server. In most cases, they will be, but the client MUST 3853 verify that before acting on that assumption. When two server 3854 addresses are designated by a single location entry and they 3855 correspond to different servers, this normally indicates some sort of 3856 misconfiguration, and so the client should avoid using such location 3857 entries when alternatives are available. When they are not, clients 3858 should pick one of IP addresses and use it, without using others that 3859 are not directed to the same server. 3861 7.6. Additional Client-Side Considerations 3863 When clients make use of servers that implement referrals, 3864 replication, and migration, care should be taken that a user who 3865 mounts a given file system that includes a referral or a relocated 3866 file system continues to see a coherent picture of that user-side 3867 file system despite the fact that it contains a number of server-side 3868 file systems that may be on different servers. 3870 One important issue is upward navigation from the root of a server- 3871 side file system to its parent (specified as ".." in UNIX), in the 3872 case in which it transitions to that file system as a result of 3873 referral, migration, or a transition as a result of replication. 3874 When the client is at such a point, and it needs to ascend to the 3875 parent, it must go back to the parent as seen within the multi-server 3876 namespace rather than sending a LOOKUPP operation to the server, 3877 which would result in the parent within that server's single-server 3878 namespace. In order to do this, the client needs to remember the 3879 filehandles that represent such file system roots and use these 3880 instead of issuing a LOOKUPP operation to the current server. This 3881 will allow the client to present to applications a consistent 3882 namespace, where upward navigation and downward navigation are 3883 consistent. 3885 Another issue concerns refresh of referral locations. When referrals 3886 are used extensively, they may change as server configurations 3887 change. It is expected that clients will cache information related 3888 to traversing referrals so that future client-side requests are 3889 resolved locally without server communication. This is usually 3890 rooted in client-side name look up caching. Clients should 3891 periodically purge this data for referral points in order to detect 3892 changes in location information. 3894 A problem exists if a client allows an open owner to have state on 3895 multiple filesystems on a server. If one of those filesystems is 3896 migrated, what happens to the sequence numbers? A client can avoid 3897 such a situation with the stipulation that any client which supports 3898 migration MUST ensure that any open owner is confined to a single 3899 filesystem. If the server finds itself migrating open owners that 3900 span multiple filesystems, then it MUST not migrate the state for the 3901 conflicting open owners on the non-migrated filesystems; instead it 3902 MUST return NFS4ERR_STALE_STATEID if the client tries to use those 3903 stateids. 3905 7.7. Effecting File System Transitions 3907 Transitions between file system instances, whether due to switching 3908 between replicas upon server unavailability or to server-initiated 3909 migration events, are best dealt with together. This is so even 3910 though, for the server, pragmatic considerations will normally force 3911 different implementation strategies for planned and unplanned 3912 transitions. Even though the prototypical use cases of replication 3913 and migration contain distinctive sets of features, when all 3914 possibilities for these operations are considered, there is an 3915 underlying unity of these operations, from the client's point of 3916 view, that makes treating them together desirable. 3918 A number of methods are possible for servers to replicate data and to 3919 track client state in order to allow clients to transition between 3920 file system instances with a minimum of disruption. Such methods 3921 vary between those that use inter-server clustering techniques to 3922 limit the changes seen by the client, to those that are less 3923 aggressive, use more standard methods of replicating data, and impose 3924 a greater burden on the client to adapt to the transition. 3926 The NFSv4 protocol does not impose choices on clients and servers 3927 with regard to that spectrum of transition methods. In fact, there 3928 are many valid choices, depending on client and application 3929 requirements and their interaction with server implementation 3930 choices. The NFSv4.0 protocol does not provide the servers a means 3931 of communicating the transition methods. In the NFSv4.1 protocol 3932 [31], an additional attribute "fs_locations_info" is presented, which 3933 will define the specific choices that can be made, how these choices 3934 are communicated to the client, and how the client is to deal with 3935 any discontinuities. 3937 In the sections below, references will be made to various possible 3938 server implementation choices as a way of illustrating the transition 3939 scenarios that clients may deal with. The intent here is not to 3940 define or limit server implementations but rather to illustrate the 3941 range of issues that clients may face. Again, as the NFSv4.0 3942 protocol does not have an explicit means of communicating these 3943 issues to the client, the intent is to document the problems that can 3944 be faced in a multi-server name space and allow the client to use the 3945 inferred transitions available via fs_locations and other attributes 3946 (see Section 7.9.1). 3948 In the discussion below, references will be made to a file system 3949 having a particular property or to two file systems (typically the 3950 source and destination) belonging to a common class of any of several 3951 types. Two file systems that belong to such a class share some 3952 important aspects of file system behavior that clients may depend 3953 upon when present, to easily effect a seamless transition between 3954 file system instances. Conversely, where the file systems do not 3955 belong to such a common class, the client has to deal with various 3956 sorts of implementation discontinuities that may cause performance or 3957 other issues in effecting a transition. 3959 While fs_locations is available, default assumptions with regard to 3960 such classifications have to be inferred (see Section 7.9.1 for 3961 details). 3963 In cases in which one server is expected to accept opaque values from 3964 the client that originated from another server, the servers SHOULD 3965 encode the "opaque" values in big-endian byte order. If this is 3966 done, servers acting as replicas or immigrating file systems will be 3967 able to parse values like stateids, directory cookies, filehandles, 3968 etc., even if their native byte order is different from that of other 3969 servers cooperating in the replication and migration of the file 3970 system. 3972 7.7.1. File System Transitions and Simultaneous Access 3974 When a single file system may be accessed at multiple locations, 3975 either because of an indication of file system identity as reported 3976 by the fs_locations attribute, the client will, depending on specific 3977 circumstances as discussed below, either: 3979 o Access multiple instances simultaneously, each of which represents 3980 an alternate path to the same data and metadata. 3982 o Accesses one instance (or set of instances) and then transition to 3983 an alternative instance (or set of instances) as a result of 3984 network issues, server unresponsiveness, or server-directed 3985 migration. 3987 7.7.2. Filehandles and File System Transitions 3989 There are a number of ways in which filehandles can be handled across 3990 a file system transition. These can be divided into two broad 3991 classes depending upon whether the two file systems across which the 3992 transition happens share sufficient state to effect some sort of 3993 continuity of file system handling. 3995 When there is no such cooperation in filehandle assignment, the two 3996 file systems are reported as being in different handle classes. In 3997 this case, all filehandles are assumed to expire as part of the file 3998 system transition. Note that this behavior does not depend on 3999 fh_expire_type attribute and depends on the specification of the 4000 FH4_VOL_MIGRATION bit. 4002 When there is co-operation in filehandle assignment, the two file 4003 systems are reported as being in the same handle classes. In this 4004 case, persistent filehandles remain valid after the file system 4005 transition, while volatile filehandles (excluding those that are only 4006 volatile due to the FH4_VOL_MIGRATION bit) are subject to expiration 4007 on the target server. 4009 7.7.3. Fileids and File System Transitions 4011 The issue of continuity of fileids in the event of a file system 4012 transition needs to be addressed. The general expectation is that in 4013 situations in which the two file system instances are created by a 4014 single vendor using some sort of file system image copy, fileids will 4015 be consistent across the transition, while in the analogous multi- 4016 vendor transitions they will not. This poses difficulties, 4017 especially for the client without special knowledge of the transition 4018 mechanisms adopted by the server. Note that although fileid is not a 4019 REQUIRED attribute, many servers support fileids and many clients 4020 provide APIs that depend on fileids. 4022 It is important to note that while clients themselves may have no 4023 trouble with a fileid changing as a result of a file system 4024 transition event, applications do typically have access to the fileid 4025 (e.g., via stat). The result is that an application may work 4026 perfectly well if there is no file system instance transition or if 4027 any such transition is among instances created by a single vendor, 4028 yet be unable to deal with the situation in which a multi-vendor 4029 transition occurs at the wrong time. 4031 Providing the same fileids in a multi-vendor (multiple server 4032 vendors) environment has generally been held to be quite difficult. 4033 While there is work to be done, it needs to be pointed out that this 4034 difficulty is partly self-imposed. Servers have typically identified 4035 fileid with inode number, i.e., with a quantity used to find the file 4036 in question. This identification poses special difficulties for 4037 migration of a file system between vendors where assigning the same 4038 index to a given file may not be possible. Note here that a fileid 4039 is not required to be useful to find the file in question, only that 4040 it is unique within the given file system. Servers prepared to 4041 accept a fileid as a single piece of metadata and store it apart from 4042 the value used to index the file information can relatively easily 4043 maintain a fileid value across a migration event, allowing a truly 4044 transparent migration event. 4046 In any case, where servers can provide continuity of fileids, they 4047 should, and the client should be able to find out that such 4048 continuity is available and take appropriate action. Information 4049 about the continuity (or lack thereof) of fileids across a file 4050 system transition is represented by specifying whether the file 4051 systems in question are of the same fileid class. 4053 Note that when consistent fileids do not exist across a transition 4054 (either because there is no continuity of fileids or because fileid 4055 is not a supported attribute on one of instances involved), and there 4056 are no reliable filehandles across a transition event (either because 4057 there is no filehandle continuity or because the filehandles are 4058 volatile), the client is in a position where it cannot verify that 4059 files it was accessing before the transition are the same objects. 4060 It is forced to assume that no object has been renamed, and, unless 4061 there are guarantees that provide this (e.g., the file system is 4062 read-only), problems for applications may occur. Therefore, use of 4063 such configurations should be limited to situations where the 4064 problems that this may cause can be tolerated. 4066 7.7.4. Fsids and File System Transitions 4068 Since fsids are generally only unique within a per-server basis, it 4069 is likely that they will change during a file system transition. 4070 Clients should not make the fsids received from the server visible to 4071 applications since they may not be globally unique, and because they 4072 may change during a file system transition event. Applications are 4073 best served if they are isolated from such transitions to the extent 4074 possible. 4076 7.7.5. The Change Attribute and File System Transitions 4078 Since the change attribute is defined as a server-specific one, 4079 change attributes fetched from one server are normally presumed to be 4080 invalid on another server. Such a presumption is troublesome since 4081 it would invalidate all cached change attributes, requiring 4082 refetching. Even more disruptive, the absence of any assured 4083 continuity for the change attribute means that even if the same value 4084 is retrieved on refetch, no conclusions can be drawn as to whether 4085 the object in question has changed. The identical change attribute 4086 could be merely an artifact of a modified file with a different 4087 change attribute construction algorithm, with that new algorithm just 4088 happening to result in an identical change value. 4090 When the two file systems have consistent change attribute formats, 4091 and we say that they are in the same change class, the client may 4092 assume a continuity of change attribute construction and handle this 4093 situation just as it would be handled without any file system 4094 transition. 4096 7.7.6. Lock State and File System Transitions 4098 In a file system transition, the client needs to handle cases in 4099 which the two servers have cooperated in state management and in 4100 which they have not. Cooperation by two servers in state management 4101 requires coordination of client IDs. Before the client attempts to 4102 use a client ID associated with one server in a request to the server 4103 of the other file system, it must eliminate the possibility that two 4104 non-cooperating servers have assigned the same client ID by accident. 4106 In the case of migration, the servers involved in the migration of a 4107 file system SHOULD transfer all server state from the original to the 4108 new server. When this is done, it must be done in a way that is 4109 transparent to the client. With replication, such a degree of common 4110 state is typically not the case. 4112 This state transfer will reduce disruption to the client when a file 4113 system transition occurs. If the servers are successful in 4114 transferring all state, the client can attempt to establish sessions 4115 associated with the client ID used for the source file system 4116 instance. If the server accepts that as a valid client ID, then the 4117 client may use the existing stateids associated with that client ID 4118 for the old file system instance in connection with that same client 4119 ID in connection with the transitioned file system instance. 4121 File systems cooperating in state management may actually share state 4122 or simply divide the identifier space so as to recognize (and reject 4123 as stale) each other's stateids and client IDs. Servers that do 4124 share state may not do so under all conditions or at all times. If 4125 the server cannot be sure when accepting a client ID that it reflects 4126 the locks the client was given, the server must treat all associated 4127 state as stale and report it as such to the client. 4129 The client must establish a new client ID on the destination, if it 4130 does not have one already, and reclaim locks if allowed by the 4131 server. In this case, old stateids and client IDs should not be 4132 presented to the new server since there is no assurance that they 4133 will not conflict with IDs valid on that server. 4135 When actual locks are not known to be maintained, the destination 4136 server may establish a grace period specific to the given file 4137 system, with non-reclaim locks being rejected for that file system, 4138 even though normal locks are being granted for other file systems. 4140 Clients should not infer the absence of a grace period for file 4141 systems being transitioned to a server from responses to requests for 4142 other file systems. 4144 In the case of lock reclamation for a given file system after a file 4145 system transition, edge conditions can arise similar to those for 4146 reclaim after server restart (although in the case of the planned 4147 state transfer associated with migration, these can be avoided by 4148 securely recording lock state as part of state migration). Unless 4149 the destination server can guarantee that locks will not be 4150 incorrectly granted, the destination server should not allow lock 4151 reclaims and should avoid establishing a grace period. (See 4152 Section 9.14 for further details.) 4154 Information about client identity may be propagated between servers 4155 in the form of client_owner4 and associated verifiers, under the 4156 assumption that the client presents the same values to all the 4157 servers with which it deals. 4159 Servers are encouraged to provide facilities to allow locks to be 4160 reclaimed on the new server after a file system transition. Often 4161 such facilities may not be available and client should be prepared to 4162 re-obtain locks, even though it is possible that the client may have 4163 its LOCK or OPEN request denied due to a conflicting lock. 4165 The consequences of having no facilities available to reclaim locks 4166 on the new server will depend on the type of environment. In some 4167 environments, such as the transition between read-only file systems, 4168 such denial of locks should not pose large difficulties in practice. 4169 When an attempt to re-establish a lock on a new server is denied, the 4170 client should treat the situation as if its original lock had been 4171 revoked. Note that when the lock is granted, the client cannot 4172 assume that no conflicting lock could have been granted in the 4173 interim. Where change attribute continuity is present, the client 4174 may check the change attribute to check for unwanted file 4175 modifications. Where even this is not available, and the file system 4176 is not read-only, a client may reasonably treat all pending locks as 4177 having been revoked. 4179 7.7.6.1. Transitions and the Lease_time Attribute 4181 In order that the client may appropriately manage its lease in the 4182 case of a file system transition, the destination server must 4183 establish proper values for the lease_time attribute. 4185 When state is transferred transparently, that state should include 4186 the correct value of the lease_time attribute. The lease_time 4187 attribute on the destination server must never be less than that on 4188 the source, since this would result in premature expiration of a 4189 lease granted by the source server. Upon transitions in which state 4190 is transferred transparently, the client is under no obligation to 4191 refetch the lease_time attribute and may continue to use the value 4192 previously fetched (on the source server). 4194 If state has not been transferred transparently because the client ID 4195 is rejected when presented to the new server, the client should fetch 4196 the value of lease_time on the new (i.e., destination) server, and 4197 use it for subsequent locking requests. However, the server must 4198 respect a grace period of at least as long as the lease_time on the 4199 source server, in order to ensure that clients have ample time to 4200 reclaim their lock before potentially conflicting non-reclaimed locks 4201 are granted. 4203 7.7.7. Write Verifiers and File System Transitions 4205 In a file system transition, the two file systems may be clustered in 4206 the handling of unstably written data. When this is the case, and 4207 the two file systems belong to the same write-verifier class, write 4208 verifiers returned from one system may be compared to those returned 4209 by the other and superfluous writes avoided. 4211 When two file systems belong to different write-verifier classes, any 4212 verifier generated by one must not be compared to one provided by the 4213 other. Instead, it should be treated as not equal even when the 4214 values are identical. 4216 7.7.8. Readdir Cookies and Verifiers and File System Transitions 4218 In a file system transition, the two file systems may be consistent 4219 in their handling of READDIR cookies and verifiers. When this is the 4220 case, and the two file systems belong to the same readdir class, 4221 READDIR cookies and verifiers from one system may be recognized by 4222 the other and READDIR operations started on one server may be validly 4223 continued on the other, simply by presenting the cookie and verifier 4224 returned by a READDIR operation done on the first file system to the 4225 second. 4227 When two file systems belong to different readdir classes, any 4228 READDIR cookie and verifier generated by one is not valid on the 4229 second, and must not be presented to that server by the client. The 4230 client should act as if the verifier was rejected. 4232 7.7.9. File System Data and File System Transitions 4234 When multiple replicas exist and are used simultaneously or in 4235 succession by a client, applications using them will normally expect 4236 that they contain either the same data or data that is consistent 4237 with the normal sorts of changes that are made by other clients 4238 updating the data of the file system (with metadata being the same to 4239 the degree inferred by the fs_locations attribute). However, when 4240 multiple file systems are presented as replicas of one another, the 4241 precise relationship between the data of one and the data of another 4242 is not, as a general matter, specified by the NFSv4 protocol. It is 4243 quite possible to present as replicas file systems where the data of 4244 those file systems is sufficiently different that some applications 4245 have problems dealing with the transition between replicas. The 4246 namespace will typically be constructed so that applications can 4247 choose an appropriate level of support, so that in one position in 4248 the namespace a varied set of replicas will be listed, while in 4249 another only those that are up-to-date may be considered replicas. 4250 The protocol does define four special cases of the relationship among 4251 replicas to be specified by the server and relied upon by clients: 4253 o When multiple server addresses correspond to the same actual 4254 server, the client may depend on the fact that changes to data, 4255 metadata, or locks made on one file system are immediately 4256 reflected on others. 4258 o When multiple replicas exist and are used simultaneously by a 4259 client, they must designate the same data. Where file systems are 4260 writable, a change made on one instance must be visible on all 4261 instances, immediately upon the earlier of the return of the 4262 modifying requester or the visibility of that change on any of the 4263 associated replicas. This allows a client to use these replicas 4264 simultaneously without any special adaptation to the fact that 4265 there are multiple replicas. In this case, locks (whether share 4266 reservations or byte-range locks), and delegations obtained on one 4267 replica are immediately reflected on all replicas, even though 4268 these locks will be managed under a set of client IDs. 4270 o When one replica is designated as the successor instance to 4271 another existing instance after return NFS4ERR_MOVED (i.e., the 4272 case of migration), the client may depend on the fact that all 4273 changes written to stable storage on the original instance are 4274 written to stable storage of the successor (uncommitted writes are 4275 dealt with in Section 7.7.7). 4277 o Where a file system is not writable but represents a read-only 4278 copy (possibly periodically updated) of a writable file system, 4279 clients have similar requirements with regard to the propagation 4280 of updates. They may need a guarantee that any change visible on 4281 the original file system instance must be immediately visible on 4282 any replica before the client transitions access to that replica, 4283 in order to avoid any possibility that a client, in effecting a 4284 transition to a replica, will see any reversion in file system 4285 state. Since these file systems are presumed to be unsuitable for 4286 simultaneous use, there is no specification of how locking is 4287 handled; in general, locks obtained on one file system will be 4288 separate from those on others. Since these are going to be read- 4289 only file systems, this is not expected to pose an issue for 4290 clients or applications. 4292 7.8. Effecting File System Referrals 4294 Referrals are effected when an absent file system is encountered, and 4295 one or more alternate locations are made available by the 4296 fs_locations attribute. The client will typically get an 4297 NFS4ERR_MOVED error, fetch the appropriate location information, and 4298 proceed to access the file system on a different server, even though 4299 it retains its logical position within the original namespace. 4300 Referrals differ from migration events in that they happen only when 4301 the client has not previously referenced the file system in question 4302 (so there is nothing to transition). Referrals can only come into 4303 effect when an absent file system is encountered at its root. 4305 The examples given in the sections below are somewhat artificial in 4306 that an actual client will not typically do a multi-component look 4307 up, but will have cached information regarding the upper levels of 4308 the name hierarchy. However, these example are chosen to make the 4309 required behavior clear and easy to put within the scope of a small 4310 number of requests, without getting unduly into details of how 4311 specific clients might choose to cache things. 4313 7.8.1. Referral Example (LOOKUP) 4315 Let us suppose that the following COMPOUND is sent in an environment 4316 in which /this/is/the/path is absent from the target server. This 4317 may be for a number of reasons. It may be the case that the file 4318 system has moved, or it may be the case that the target server is 4319 functioning mainly, or solely, to refer clients to the servers on 4320 which various file systems are located. 4322 o PUTROOTFH 4324 o LOOKUP "this" 4326 o LOOKUP "is" 4328 o LOOKUP "the" 4330 o LOOKUP "path" 4331 o GETFH 4333 o GETATTR(fsid,fileid,size,time_modify) 4335 Under the given circumstances, the following will be the result. 4337 o PUTROOTFH --> NFS_OK. The current fh is now the root of the 4338 pseudo-fs. 4340 o LOOKUP "this" --> NFS_OK. The current fh is for /this and is 4341 within the pseudo-fs. 4343 o LOOKUP "is" --> NFS_OK. The current fh is for /this/is and is 4344 within the pseudo-fs. 4346 o LOOKUP "the" --> NFS_OK. The current fh is for /this/is/the and 4347 is within the pseudo-fs. 4349 o LOOKUP "path" --> NFS_OK. The current fh is for /this/is/the/path 4350 and is within a new, absent file system, but ... the client will 4351 never see the value of that fh. 4353 o GETFH --> NFS4ERR_MOVED. Fails because current fh is in an absent 4354 file system at the start of the operation, and the specification 4355 makes no exception for GETFH. 4357 o GETATTR(fsid,fileid,size,time_modify) Not executed because the 4358 failure of the GETFH stops processing of the COMPOUND. 4360 Given the failure of the GETFH, the client has the job of determining 4361 the root of the absent file system and where to find that file 4362 system, i.e., the server and path relative to that server's root fh. 4363 Note here that in this example, the client did not obtain filehandles 4364 and attribute information (e.g., fsid) for the intermediate 4365 directories, so that it would not be sure where the absent file 4366 system starts. It could be the case, for example, that /this/is/the 4367 is the root of the moved file system and that the reason that the 4368 look up of "path" succeeded is that the file system was not absent on 4369 that operation but was moved between the last LOOKUP and the GETFH 4370 (since COMPOUND is not atomic). Even if we had the fsids for all of 4371 the intermediate directories, we could have no way of knowing that 4372 /this/is/the/path was the root of a new file system, since we don't 4373 yet have its fsid. 4375 In order to get the necessary information, let us re-send the chain 4376 of LOOKUPs with GETFHs and GETATTRs to at least get the fsids so we 4377 can be sure where the appropriate file system boundaries are. The 4378 client could choose to get fs_locations at the same time but in most 4379 cases the client will have a good guess as to where file system 4380 boundaries are (because of where NFS4ERR_MOVED was, and was not, 4381 received) making fetching of fs_locations unnecessary. 4383 OP01: PUTROOTFH --> NFS_OK 4385 - Current fh is root of pseudo-fs. 4387 OP02: GETATTR(fsid) --> NFS_OK 4389 - Just for completeness. Normally, clients will know the fsid of 4390 the pseudo-fs as soon as they establish communication with a 4391 server. 4393 OP03: LOOKUP "this" --> NFS_OK 4395 OP04: GETATTR(fsid) --> NFS_OK 4397 - Get current fsid to see where file system boundaries are. The 4398 fsid will be that for the pseudo-fs in this example, so no 4399 boundary. 4401 OP05: GETFH --> NFS_OK 4403 - Current fh is for /this and is within pseudo-fs. 4405 OP06: LOOKUP "is" --> NFS_OK 4407 - Current fh is for /this/is and is within pseudo-fs. 4409 OP07: GETATTR(fsid) --> NFS_OK 4411 - Get current fsid to see where file system boundaries are. The 4412 fsid will be that for the pseudo-fs in this example, so no 4413 boundary. 4415 OP08: GETFH --> NFS_OK 4417 - Current fh is for /this/is and is within pseudo-fs. 4419 OP09: LOOKUP "the" --> NFS_OK 4421 - Current fh is for /this/is/the and is within pseudo-fs. 4423 OP10: GETATTR(fsid) --> NFS_OK 4424 - Get current fsid to see where file system boundaries are. The 4425 fsid will be that for the pseudo-fs in this example, so no 4426 boundary. 4428 OP11: GETFH --> NFS_OK 4430 - Current fh is for /this/is/the and is within pseudo-fs. 4432 OP12: LOOKUP "path" --> NFS_OK 4434 - Current fh is for /this/is/the/path and is within a new, absent 4435 file system, but ... 4437 - The client will never see the value of that fh. 4439 OP13: GETATTR(fsid, fs_locations) --> NFS_OK 4441 - We are getting the fsid to know where the file system boundaries 4442 are. In this operation, the fsid will be different than that of 4443 the parent directory (which in turn was retrieved in OP10). Note 4444 that the fsid we are given will not necessarily be preserved at 4445 the new location. That fsid might be different, and in fact the 4446 fsid we have for this file system might be a valid fsid of a 4447 different file system on that new server. 4449 - In this particular case, we are pretty sure anyway that what has 4450 moved is /this/is/the/path rather than /this/is/the since we have 4451 the fsid of the latter and it is that of the pseudo-fs, which 4452 presumably cannot move. However, in other examples, we might not 4453 have this kind of information to rely on (e.g., /this/is/the might 4454 be a non-pseudo file system separate from /this/is/the/path), so 4455 we need to have other reliable source information on the boundary 4456 of the file system that is moved. If, for example, the file 4457 system /this/is had moved, we would have a case of migration 4458 rather than referral, and once the boundaries of the migrated file 4459 system was clear we could fetch fs_locations. 4461 - We are fetching fs_locations because the fact that we got an 4462 NFS4ERR_MOVED at this point means that it is most likely that this 4463 is a referral and we need the destination. Even if it is the case 4464 that /this/is/the is a file system that has migrated, we will 4465 still need the location information for that file system. 4467 OP14: GETFH --> NFS4ERR_MOVED 4468 - Fails because current fh is in an absent file system at the start 4469 of the operation, and the specification makes no exception for 4470 GETFH. Note that this means the server will never send the client 4471 a filehandle from within an absent file system. 4473 Given the above, the client knows where the root of the absent file 4474 system is (/this/is/the/path) by noting where the change of fsid 4475 occurred (between "the" and "path"). The fs_locations attribute also 4476 gives the client the actual location of the absent file system, so 4477 that the referral can proceed. The server gives the client the bare 4478 minimum of information about the absent file system so that there 4479 will be very little scope for problems of conflict between 4480 information sent by the referring server and information of the file 4481 system's home. No filehandles and very few attributes are present on 4482 the referring server, and the client can treat those it receives as 4483 transient information with the function of enabling the referral. 4485 7.8.2. Referral Example (READDIR) 4487 Another context in which a client may encounter referrals is when it 4488 does a READDIR on a directory in which some of the sub-directories 4489 are the roots of absent file systems. 4491 Suppose such a directory is read as follows: 4493 o PUTROOTFH 4495 o LOOKUP "this" 4497 o LOOKUP "is" 4499 o LOOKUP "the" 4501 o READDIR (fsid, size, time_modify, mounted_on_fileid) 4503 In this case, because rdattr_error is not requested, fs_locations is 4504 not requested, and some of the attributes cannot be provided, the 4505 result will be an NFS4ERR_MOVED error on the READDIR, with the 4506 detailed results as follows: 4508 o PUTROOTFH --> NFS_OK. The current fh is at the root of the 4509 pseudo-fs. 4511 o LOOKUP "this" --> NFS_OK. The current fh is for /this and is 4512 within the pseudo-fs. 4514 o LOOKUP "is" --> NFS_OK. The current fh is for /this/is and is 4515 within the pseudo-fs. 4517 o LOOKUP "the" --> NFS_OK. The current fh is for /this/is/the and 4518 is within the pseudo-fs. 4520 o READDIR (fsid, size, time_modify, mounted_on_fileid) --> 4521 NFS4ERR_MOVED. Note that the same error would have been returned 4522 if /this/is/the had migrated, but it is returned because the 4523 directory contains the root of an absent file system. 4525 So now suppose that we re-send with rdattr_error: 4527 o PUTROOTFH 4529 o LOOKUP "this" 4531 o LOOKUP "is" 4533 o LOOKUP "the" 4535 o READDIR (rdattr_error, fsid, size, time_modify, mounted_on_fileid) 4537 The results will be: 4539 o PUTROOTFH --> NFS_OK. The current fh is at the root of the 4540 pseudo-fs. 4542 o LOOKUP "this" --> NFS_OK. The current fh is for /this and is 4543 within the pseudo-fs. 4545 o LOOKUP "is" --> NFS_OK. The current fh is for /this/is and is 4546 within the pseudo-fs. 4548 o LOOKUP "the" --> NFS_OK. The current fh is for /this/is/the and 4549 is within the pseudo-fs. 4551 o READDIR (rdattr_error, fsid, size, time_modify, mounted_on_fileid) 4552 --> NFS_OK. The attributes for directory entry with the component 4553 named "path" will only contain rdattr_error with the value 4554 NFS4ERR_MOVED, together with an fsid value and a value for 4555 mounted_on_fileid. 4557 So suppose we do another READDIR to get fs_locations (although we 4558 could have used a GETATTR directly, as in Section 7.8.1). 4560 o PUTROOTFH 4562 o LOOKUP "this" 4563 o LOOKUP "is" 4565 o LOOKUP "the" 4567 o READDIR (rdattr_error, fs_locations, mounted_on_fileid, fsid, 4568 size, time_modify) 4570 The results would be: 4572 o PUTROOTFH --> NFS_OK. The current fh is at the root of the 4573 pseudo-fs. 4575 o LOOKUP "this" --> NFS_OK. The current fh is for /this and is 4576 within the pseudo-fs. 4578 o LOOKUP "is" --> NFS_OK. The current fh is for /this/is and is 4579 within the pseudo-fs. 4581 o LOOKUP "the" --> NFS_OK. The current fh is for /this/is/the and 4582 is within the pseudo-fs. 4584 o READDIR (rdattr_error, fs_locations, mounted_on_fileid, fsid, 4585 size, time_modify) --> NFS_OK. The attributes will be as shown 4586 below. 4588 The attributes for the directory entry with the component named 4589 "path" will only contain: 4591 o rdattr_error (value: NFS_OK) 4593 o fs_locations 4595 o mounted_on_fileid (value: unique fileid within referring file 4596 system) 4598 o fsid (value: unique value within referring server) 4600 The attributes for entry "path" will not contain size or time_modify 4601 because these attributes are not available within an absent file 4602 system. 4604 7.9. The Attribute fs_locations 4606 The fs_locations attribute is structured in the following way: 4608 struct fs_location4 { 4609 utf8val_must server<>; 4610 pathname4 rootpath; 4611 }; 4613 struct fs_locations4 { 4614 pathname4 fs_root; 4615 fs_location4 locations<>; 4616 }; 4618 The fs_location4 data type is used to represent the location of a 4619 file system by providing a server name and the path to the root of 4620 the file system within that server's namespace. When a set of 4621 servers have corresponding file systems at the same path within their 4622 namespaces, an array of server names may be provided. An entry in 4623 the server array is a UTF-8 string and represents one of a 4624 traditional DNS host name, IPv4 address, IPv6 address, or an zero- 4625 length string. A zero-length string SHOULD be used to indicate the 4626 current address being used for the RPC call. It is not a requirement 4627 that all servers that share the same rootpath be listed in one 4628 fs_location4 instance. The array of server names is provided for 4629 convenience. Servers that share the same rootpath may also be listed 4630 in separate fs_location4 entries in the fs_locations attribute. 4632 The fs_locations4 data type and fs_locations attribute contain an 4633 array of such locations. Since the namespace of each server may be 4634 constructed differently, the "fs_root" field is provided. The path 4635 represented by fs_root represents the location of the file system in 4636 the current server's namespace, i.e., that of the server from which 4637 the fs_locations attribute was obtained. The fs_root path is meant 4638 to aid the client by clearly referencing the root of the file system 4639 whose locations are being reported, no matter what object within the 4640 current file system the current filehandle designates. The fs_root 4641 is simply the pathname the client used to reach the object on the 4642 current server (i.e., the object to which the fs_locations attribute 4643 applies). 4645 When the fs_locations attribute is interrogated and there are no 4646 alternate file system locations, the server SHOULD return a zero- 4647 length array of fs_location4 structures, together with a valid 4648 fs_root. 4650 As an example, suppose there is a replicated file system located at 4651 two servers (servA and servB). At servA, the file system is located 4652 at path /a/b/c. At, servB the file system is located at path /x/y/z. 4653 If the client were to obtain the fs_locations value for the directory 4654 at /a/b/c/d, it might not necessarily know that the file system's 4655 root is located in servA's namespace at /a/b/c. When the client 4656 switches to servB, it will need to determine that the directory it 4657 first referenced at servA is now represented by the path /x/y/z/d on 4658 servB. To facilitate this, the fs_locations attribute provided by 4659 servA would have an fs_root value of /a/b/c and two entries in 4660 fs_locations. One entry in fs_locations will be for itself (servA) 4661 and the other will be for servB with a path of /x/y/z. With this 4662 information, the client is able to substitute /x/y/z for the /a/b/c 4663 at the beginning of its access path and construct /x/y/z/d to use for 4664 the new server. 4666 Note that: there is no requirement that the number of components in 4667 each rootpath be the same; there is no relation between the number of 4668 components in rootpath or fs_root, and none of the components in each 4669 rootpath and fs_root have to be the same. In the above example, we 4670 could have had a third element in the locations array, with server 4671 equal to "servC", and rootpath equal to "/I/II", and a fourth element 4672 in locations with server equal to "servD" and rootpath equal to 4673 "/aleph/beth/gimel/daleth/he". 4675 The relationship between fs_root to a rootpath is that the client 4676 replaces the pathname indicated in fs_root for the current server for 4677 the substitute indicated in rootpath for the new server. 4679 For an example of a referred or migrated file system, suppose there 4680 is a file system located at serv1. At serv1, the file system is 4681 located at /az/buky/vedi/glagoli. The client finds that object at 4682 glagoli has migrated (or is a referral). The client gets the 4683 fs_locations attribute, which contains an fs_root of /az/buky/vedi/ 4684 glagoli, and one element in the locations array, with server equal to 4685 serv2, and rootpath equal to /izhitsa/fita. The client replaces /az/ 4686 buky/vedi/glagoli with /izhitsa/fita, and uses the latter pathname on 4687 serv2. 4689 Thus, the server MUST return an fs_root that is equal to the path the 4690 client used to reach the object to which the fs_locations attribute 4691 applies. Otherwise, the client cannot determine the new path to use 4692 on the new server. 4694 7.9.1. Inferring Transition Modes 4696 When fs_locations is used, information about the specific locations 4697 should be assumed based on the following rules. 4699 The following rules are general and apply irrespective of the 4700 context. 4702 o All listed file system instances should be considered as of the 4703 same handle class if and only if the current fh_expire_type 4704 attribute does not include the FH4_VOL_MIGRATION bit. Note that 4705 in the case of referral, filehandle issues do not apply since 4706 there can be no filehandles known within the current file system 4707 nor is there any access to the fh_expire_type attribute on the 4708 referring (absent) file system. 4710 o All listed file system instances should be considered as of the 4711 same fileid class if and only if the fh_expire_type attribute 4712 indicates persistent filehandles and does not include the 4713 FH4_VOL_MIGRATION bit. Note that in the case of referral, fileid 4714 issues do not apply since there can be no fileids known within the 4715 referring (absent) file system nor is there any access to the 4716 fh_expire_type attribute. 4718 o All file system instances servers should be considered as of 4719 different change classes. 4721 o All file system instances servers should be considered as of 4722 different readdir classes. 4724 For other class assignments, handling of file system transitions 4725 depends on the reasons for the transition: 4727 o When the transition is due to migration, that is, the client was 4728 directed to a new file system after receiving an NFS4ERR_MOVED 4729 error, the target should be treated as being of the same write- 4730 verifier class as the source. 4732 o When the transition is due to failover to another replica, that 4733 is, the client selected another replica without receiving and 4734 NFS4ERR_MOVED error, the target should be treated as being of a 4735 different write-verifier class from the source. 4737 The specific choices reflect typical implementation patterns for 4738 failover and controlled migration, respectively. 4740 See Section 17 for a discussion on the recommendations for the 4741 security flavor to be used by any GETATTR operation that requests the 4742 "fs_locations" attribute. 4744 8. NFS Server Name Space 4745 8.1. Server Exports 4747 On a UNIX server the name space describes all the files reachable by 4748 pathnames under the root directory or "/". On a Windows NT server 4749 the name space constitutes all the files on disks named by mapped 4750 disk letters. NFS server administrators rarely make the entire 4751 server's filesystem name space available to NFS clients. More often 4752 portions of the name space are made available via an "export" 4753 feature. In previous versions of the NFS protocol, the root 4754 filehandle for each export is obtained through the MOUNT protocol; 4755 the client sends a string that identifies the export of name space 4756 and the server returns the root filehandle for it. The MOUNT 4757 protocol supports an EXPORTS procedure that will enumerate the 4758 server's exports. 4760 8.2. Browsing Exports 4762 The NFSv4 protocol provides a root filehandle that clients can use to 4763 obtain filehandles for these exports via a multi-component LOOKUP. A 4764 common user experience is to use a graphical user interface (perhaps 4765 a file "Open" dialog window) to find a file via progressive browsing 4766 through a directory tree. The client must be able to move from one 4767 export to another export via single-component, progressive LOOKUP 4768 operations. 4770 This style of browsing is not well supported by the NFSv2 and NFSv3 4771 protocols. The client expects all LOOKUP operations to remain within 4772 a single server filesystem. For example, the device attribute will 4773 not change. This prevents a client from taking name space paths that 4774 span exports. 4776 An automounter on the client can obtain a snapshot of the server's 4777 name space using the EXPORTS procedure of the MOUNT protocol. If it 4778 understands the server's pathname syntax, it can create an image of 4779 the server's name space on the client. The parts of the name space 4780 that are not exported by the server are filled in with a "pseudo 4781 filesystem" that allows the user to browse from one mounted 4782 filesystem to another. There is a drawback to this representation of 4783 the server's name space on the client: it is static. If the server 4784 administrator adds a new export the client will be unaware of it. 4786 8.3. Server Pseudo Filesystem 4788 NFSv4 servers avoid this name space inconsistency by presenting all 4789 the exports within the framework of a single server name space. An 4790 NFSv4 client uses LOOKUP and READDIR operations to browse seamlessly 4791 from one export to another. Portions of the server name space that 4792 are not exported are bridged via a "pseudo filesystem" that provides 4793 a view of exported directories only. A pseudo filesystem has a 4794 unique fsid and behaves like a normal, read only filesystem. 4796 Based on the construction of the server's name space, it is possible 4797 that multiple pseudo filesystems may exist. For example, 4799 /a pseudo filesystem 4800 /a/b real filesystem 4801 /a/b/c pseudo filesystem 4802 /a/b/c/d real filesystem 4804 Each of the pseudo filesystems are considered separate entities and 4805 therefore will have a unique fsid. 4807 8.4. Multiple Roots 4809 The DOS and Windows operating environments are sometimes described as 4810 having "multiple roots". Filesystems are commonly represented as 4811 disk letters. MacOS represents filesystems as top level names. 4812 NFSv4 servers for these platforms can construct a pseudo file system 4813 above these root names so that disk letters or volume names are 4814 simply directory names in the pseudo root. 4816 8.5. Filehandle Volatility 4818 The nature of the server's pseudo filesystem is that it is a logical 4819 representation of filesystem(s) available from the server. 4820 Therefore, the pseudo filesystem is most likely constructed 4821 dynamically when the server is first instantiated. It is expected 4822 that the pseudo filesystem may not have an on disk counterpart from 4823 which persistent filehandles could be constructed. Even though it is 4824 preferable that the server provide persistent filehandles for the 4825 pseudo filesystem, the NFS client should expect that pseudo file 4826 system filehandles are volatile. This can be confirmed by checking 4827 the associated "fh_expire_type" attribute for those filehandles in 4828 question. If the filehandles are volatile, the NFS client must be 4829 prepared to recover a filehandle value (e.g., with a multi-component 4830 LOOKUP) when receiving an error of NFS4ERR_FHEXPIRED. 4832 8.6. Exported Root 4834 If the server's root filesystem is exported, one might conclude that 4835 a pseudo-filesystem is not needed. This would be wrong. Assume the 4836 following filesystems on a server: 4838 / disk1 (exported) 4839 /a disk2 (not exported) 4840 /a/b disk3 (exported) 4841 Because disk2 is not exported, disk3 cannot be reached with simple 4842 LOOKUPs. The server must bridge the gap with a pseudo-filesystem. 4844 8.7. Mount Point Crossing 4846 The server filesystem environment may be constructed in such a way 4847 that one filesystem contains a directory which is 'covered' or 4848 mounted upon by a second filesystem. For example: 4850 /a/b (filesystem 1) 4851 /a/b/c/d (filesystem 2) 4853 The pseudo filesystem for this server may be constructed to look 4854 like: 4856 / (place holder/not exported) 4857 /a/b (filesystem 1) 4858 /a/b/c/d (filesystem 2) 4860 It is the server's responsibility to present the pseudo filesystem 4861 that is complete to the client. If the client sends a lookup request 4862 for the path "/a/b/c/d", the server's response is the filehandle of 4863 the filesystem "/a/b/c/d". In previous versions of the NFS protocol, 4864 the server would respond with the filehandle of directory "/a/b/c/d" 4865 within the filesystem "/a/b". 4867 The NFS client will be able to determine if it crosses a server mount 4868 point by a change in the value of the "fsid" attribute. 4870 8.8. Security Policy and Name Space Presentation 4872 The application of the server's security policy needs to be carefully 4873 considered by the implementor. One may choose to limit the 4874 viewability of portions of the pseudo filesystem based on the 4875 server's perception of the client's ability to authenticate itself 4876 properly. However, with the support of multiple security mechanisms 4877 and the ability to negotiate the appropriate use of these mechanisms, 4878 the server is unable to properly determine if a client will be able 4879 to authenticate itself. If, based on its policies, the server 4880 chooses to limit the contents of the pseudo filesystem, the server 4881 may effectively hide filesystems from a client that may otherwise 4882 have legitimate access. 4884 As suggested practice, the server should apply the security policy of 4885 a shared resource in the server's namespace to the components of the 4886 resource's ancestors. For example: 4888 / 4889 /a/b 4890 /a/b/c 4892 The /a/b/c directory is a real filesystem and is the shared resource. 4893 The security policy for /a/b/c is Kerberos with integrity. The 4894 server should apply the same security policy to /, /a, and /a/b. 4895 This allows for the extension of the protection of the server's 4896 namespace to the ancestors of the real shared resource. 4898 For the case of the use of multiple, disjoint security mechanisms in 4899 the server's resources, the security for a particular object in the 4900 server's namespace should be the union of all security mechanisms of 4901 all direct descendants. 4903 9. File Locking and Share Reservations 4905 Integrating locking into the NFS protocol necessarily causes it to be 4906 stateful. With the inclusion of share reservations the protocol 4907 becomes substantially more dependent on state than the traditional 4908 combination of NFS and NLM (Network Lock Manager) [32]. There are 4909 three components to making this state manageable: 4911 o clear division between client and server 4913 o ability to reliably detect inconsistency in state between client 4914 and server 4916 o simple and robust recovery mechanisms 4918 In this model, the server owns the state information. The client 4919 requests changes in locks and the server responds with the changes 4920 made. Non-client-initiated changes in locking state are infrequent. 4921 The client receives prompt notification of such changes and can 4922 adjust its view of the locking state to reflect the server's changes. 4924 Individual pieces of state created by the server and passed to the 4925 client at its request are represented by 128-bit stateids. These 4926 stateids may represent a particular open file, a set of byte-range 4927 locks held by a particular owner, or a recallable delegation of 4928 privileges to access a file in particular ways or at a particular 4929 location. 4931 In all cases, there is a transition from the most general information 4932 that represents a client as a whole to the eventual lightweight 4933 stateid used for most client and server locking interactions. The 4934 details of this transition will vary with the type of object but it 4935 always starts with a client ID. 4937 To support Win32 share reservations it is necessary to atomically 4938 OPEN or CREATE files. Having a separate share/unshare operation 4939 would not allow correct implementation of the Win32 OpenFile API. In 4940 order to correctly implement share semantics, the previous NFS 4941 protocol mechanisms used when a file is opened or created (LOOKUP, 4942 CREATE, ACCESS) need to be replaced. The NFSv4 protocol has an OPEN 4943 operation that subsumes the NFSv3 methodology of LOOKUP, CREATE, and 4944 ACCESS. However, because many operations require a filehandle, the 4945 traditional LOOKUP is preserved to map a file name to filehandle 4946 without establishing state on the server. The policy of granting 4947 access or modifying files is managed by the server based on the 4948 client's state. These mechanisms can implement policy ranging from 4949 advisory only locking to full mandatory locking. 4951 9.1. Opens and Byte-Range Locks 4953 It is assumed that manipulating a byte-range lock is rare when 4954 compared to READ and WRITE operations. It is also assumed that 4955 server restarts and network partitions are relatively rare. 4956 Therefore it is important that the READ and WRITE operations have a 4957 lightweight mechanism to indicate if they possess a held lock. A 4958 byte-range lock request contains the heavyweight information required 4959 to establish a lock and uniquely define the owner of the lock. 4961 The following sections describe the transition from the heavy weight 4962 information to the eventual stateid used for most client and server 4963 locking and lease interactions. 4965 9.1.1. Client ID 4967 For each LOCK request, the client must identify itself to the server. 4968 This is done in such a way as to allow for correct lock 4969 identification and crash recovery. A sequence of a SETCLIENTID 4970 operation followed by a SETCLIENTID_CONFIRM operation is required to 4971 establish the identification onto the server. Establishment of 4972 identification by a new incarnation of the client also has the effect 4973 of immediately breaking any leased state that a previous incarnation 4974 of the client might have had on the server, as opposed to forcing the 4975 new client incarnation to wait for the leases to expire. Breaking 4976 the lease state amounts to the server removing all lock, share 4977 reservation, and, where the server is not supporting the 4978 CLAIM_DELEGATE_PREV claim type, all delegation state associated with 4979 same client with the same identity. For discussion of delegation 4980 state recovery, see Section 10.2.1. 4982 Owners of opens and owners of byte-range locks are separate entities 4983 and remain separate even if the same opaque arrays are used to 4984 designate owners of each. The protocol distinguishes between open- 4985 owners (represented by open_owner4 structures) and lock-owners 4986 (represented by lock_owner4 structures). 4988 Each open is associated with a specific open-owner while each byte- 4989 range lock is associated with a lock-owner and an open-owner, the 4990 latter being the open-owner associated with the open file under which 4991 the LOCK operation was done. 4993 Client identification is encapsulated in the following structure: 4995 struct nfs_client_id4 { 4996 verifier4 verifier; 4997 opaque id; 4998 }; 5000 The first field, verifier is a client incarnation verifier that is 5001 used to detect client reboots. Only if the verifier is different 5002 from that which the server has previously recorded the client (as 5003 identified by the second field of the structure, id) does the server 5004 start the process of canceling the client's leased state. 5006 The second field, id is a variable length string that uniquely 5007 defines the client. 5009 There are several considerations for how the client generates the id 5010 string: 5012 o The string should be unique so that multiple clients do not 5013 present the same string. The consequences of two clients 5014 presenting the same string range from one client getting an error 5015 to one client having its leased state abruptly and unexpectedly 5016 canceled. 5018 o The string should be selected so the subsequent incarnations 5019 (e.g., reboots) of the same client cause the client to present the 5020 same string. The implementor is cautioned against an approach 5021 that requires the string to be recorded in a local file because 5022 this precludes the use of the implementation in an environment 5023 where there is no local disk and all file access is from an NFSv4 5024 server. 5026 o The string should be different for each server network address 5027 that the client accesses, rather than common to all server network 5028 addresses. The reason is that it may not be possible for the 5029 client to tell if the same server is listening on multiple network 5030 addresses. If the client issues SETCLIENTID with the same id 5031 string to each network address of such a server, the server will 5032 think it is the same client, and each successive SETCLIENTID will 5033 cause the server to begin the process of removing the client's 5034 previous leased state. 5036 o The algorithm for generating the string should not assume that the 5037 client's network address won't change. This includes changes 5038 between client incarnations and even changes while the client is 5039 stilling running in its current incarnation. This means that if 5040 the client includes just the client's and server's network address 5041 in the id string, there is a real risk, after the client gives up 5042 the network address, that another client, using a similar 5043 algorithm for generating the id string, will generate a 5044 conflicting id string. 5046 Given the above considerations, an example of a well generated id 5047 string is one that includes: 5049 o The server's network address. 5051 o The client's network address. 5053 o For a user level NFSv4 client, it should contain additional 5054 information to distinguish the client from other user level 5055 clients running on the same host, such as an universally unique 5056 identifier (UUID). 5058 o Additional information that tends to be unique, such as one or 5059 more of: 5061 * The client machine's serial number (for privacy reasons, it is 5062 best to perform some one way function on the serial number). 5064 * A MAC address. 5066 * The timestamp of when the NFSv4 software was first installed on 5067 the client (though this is subject to the previously mentioned 5068 caution about using information that is stored in a file, 5069 because the file might only be accessible over NFSv4). 5071 * A true random number. However since this number ought to be 5072 the same between client incarnations, this shares the same 5073 problem as that of the using the timestamp of the software 5074 installation. 5076 As a security measure, the server MUST NOT cancel a client's leased 5077 state if the principal that established the state for a given id 5078 string is not the same as the principal issuing the SETCLIENTID. 5080 Note that SETCLIENTID and SETCLIENTID_CONFIRM has a secondary purpose 5081 of establishing the information the server needs to make callbacks to 5082 the client for purpose of supporting delegations. It is permitted to 5083 change this information via SETCLIENTID and SETCLIENTID_CONFIRM 5084 within the same incarnation of the client without removing the 5085 client's leased state. 5087 Once a SETCLIENTID and SETCLIENTID_CONFIRM sequence has successfully 5088 completed, the client uses the shorthand client identifier, of type 5089 clientid4, instead of the longer and less compact nfs_client_id4 5090 structure. This shorthand client identifier (a client ID) is 5091 assigned by the server and should be chosen so that it will not 5092 conflict with a client ID previously assigned by the server. This 5093 applies across server restarts or reboots. When a client ID is 5094 presented to a server and that client ID is not recognized, as would 5095 happen after a server reboot, the server will reject the request with 5096 the error NFS4ERR_STALE_CLIENTID. When this happens, the client must 5097 obtain a new client ID by use of the SETCLIENTID operation and then 5098 proceed to any other necessary recovery for the server reboot case 5099 (See Section 9.6.2). 5101 The client must also employ the SETCLIENTID operation when it 5102 receives a NFS4ERR_STALE_STATEID error using a stateid derived from 5103 its current client ID, since this also indicates a server reboot 5104 which has invalidated the existing client ID (see Section 9.1.4 for 5105 details). 5107 See the detailed descriptions of SETCLIENTID and SETCLIENTID_CONFIRM 5108 for a complete specification of the operations. 5110 9.1.2. Server Release of Client ID 5112 If the server determines that the client holds no associated state 5113 for its client ID, the server may choose to release the client ID. 5114 The server may make this choice for an inactive client so that 5115 resources are not consumed by those intermittently active clients. 5116 If the client contacts the server after this release, the server must 5117 ensure the client receives the appropriate error so that it will use 5118 the SETCLIENTID/SETCLIENTID_CONFIRM sequence to establish a new 5119 identity. It should be clear that the server must be very hesitant 5120 to release a client ID since the resulting work on the client to 5121 recover from such an event will be the same burden as if the server 5122 had failed and restarted. Typically a server would not release a 5123 client ID unless there had been no activity from that client for many 5124 minutes. 5126 Note that if the id string in a SETCLIENTID request is properly 5127 constructed, and if the client takes care to use the same principal 5128 for each successive use of SETCLIENTID, then, barring an active 5129 denial of service attack, NFS4ERR_CLID_INUSE should never be 5130 returned. 5132 However, client bugs, server bugs, or perhaps a deliberate change of 5133 the principal owner of the id string (such as the case of a client 5134 that changes security flavors, and under the new flavor, there is no 5135 mapping to the previous owner) will in rare cases result in 5136 NFS4ERR_CLID_INUSE. 5138 In that event, when the server gets a SETCLIENTID for a client ID 5139 that currently has no state, or it has state, but the lease has 5140 expired, rather than returning NFS4ERR_CLID_INUSE, the server MUST 5141 allow the SETCLIENTID, and confirm the new client ID if followed by 5142 the appropriate SETCLIENTID_CONFIRM. 5144 9.1.3. Stateid Definition 5146 When the server grants a lock of any type (including opens, byte- 5147 range locks, and delegations), it responds with a unique stateid that 5148 represents a set of locks (often a single lock) for the same file, of 5149 the same type, and sharing the same ownership characteristics. Thus, 5150 opens of the same file by different open-owners each have an 5151 identifying stateid. Similarly, each set of byte-range locks on a 5152 file owned by a specific lock-owner has its own identifying stateid. 5153 Delegations also have associated stateids by which they may be 5154 referenced. The stateid is used as a shorthand reference to a lock 5155 or set of locks, and given a stateid, the server can determine the 5156 associated state-owner or state-owners (in the case of an open-owner/ 5157 lock-owner pair) and the associated filehandle. When stateids are 5158 used, the current filehandle must be the one associated with that 5159 stateid. 5161 All stateids associated with a given client ID are associated with a 5162 common lease that represents the claim of those stateids and the 5163 objects they represent to be maintained by the server. See 5164 Section 9.5 for a discussion of the lease. 5166 The server may assign stateids independently for different clients. 5167 A stateid with the same bit pattern for one client may designate an 5168 entirely different set of locks for a different client. The stateid 5169 is always interpreted with respect to the client ID associated with 5170 the current session. 5172 9.1.3.1. Stateid Types 5174 With the exception of special stateids (see Section 9.1.3.3), each 5175 stateid represents locking objects of one of a set of types defined 5176 by the NFSv4 protocol. Note that in all these cases, where we speak 5177 of guarantee, it is understood there are situations such as a client 5178 restart, or lock revocation, that allow the guarantee to be voided. 5180 o Stateids may represent opens of files. 5182 Each stateid in this case represents the OPEN state for a given 5183 client ID/open-owner/filehandle triple. Such stateids are subject 5184 to change (with consequent incrementing of the stateid's seqid) in 5185 response to OPENs that result in upgrade and OPEN_DOWNGRADE 5186 operations. 5188 o Stateids may represent sets of byte-range locks. 5190 All locks held on a particular file by a particular owner and all 5191 gotten under the aegis of a particular open file are associated 5192 with a single stateid with the seqid being incremented whenever 5193 LOCK and LOCKU operations affect that set of locks. 5195 o Stateids may represent file delegations, which are recallable 5196 guarantees by the server to the client, that other clients will 5197 not reference, or will not modify a particular file, until the 5198 delegation is returned. 5200 A stateid represents a single delegation held by a client for a 5201 particular filehandle. 5203 9.1.3.2. Stateid Structure 5205 Stateids are divided into two fields, a 96-bit "other" field 5206 identifying the specific set of locks and a 32-bit "seqid" sequence 5207 value. Except in the case of special stateids (see Section 9.1.3.3), 5208 a particular value of the "other" field denotes a set of locks of the 5209 same type (for example, byte-range locks, opens, delegations, or 5210 layouts), for a specific file or directory, and sharing the same 5211 ownership characteristics. The seqid designates a specific instance 5212 of such a set of locks, and is incremented to indicate changes in 5213 such a set of locks, either by the addition or deletion of locks from 5214 the set, a change in the byte-range they apply to, or an upgrade or 5215 downgrade in the type of one or more locks. 5217 When such a set of locks is first created, the server returns a 5218 stateid with seqid value of one. On subsequent operations that 5219 modify the set of locks, the server is required to increment the 5220 "seqid" field by one whenever it returns a stateid for the same 5221 state-owner/file/type combination and there is some change in the set 5222 of locks actually designated. In this case, the server will return a 5223 stateid with an "other" field the same as previously used for that 5224 state-owner/file/type combination, with an incremented "seqid" field. 5225 This pattern continues until the seqid is incremented past 5226 NFS4_UINT32_MAX, and one (not zero) is the next seqid value. The 5227 purpose of the incrementing of the seqid is to allow the server to 5228 communicate to the client the order in which operations that modified 5229 locking state associated with a stateid have been processed and to 5230 make it possible for the client to send requests that are conditional 5231 on the set of locks not having changed since the stateid in question 5232 was returned. 5234 When a client sends a stateid to the server, it has two choices with 5235 regard to the seqid sent. It may set the seqid to zero to indicate 5236 to the server that it wishes the most up-to-date seqid for that 5237 stateid's "other" field to be used. This would be the common choice 5238 in the case of a stateid sent with a READ or WRITE operation. It 5239 also may set a non-zero value, in which case the server checks if 5240 that seqid is the correct one. In that case, the server is required 5241 to return NFS4ERR_OLD_STATEID if the seqid is lower than the most 5242 current value and NFS4ERR_BAD_STATEID if the seqid is greater than 5243 the most current value. This would be the common choice in the case 5244 of stateids sent with a CLOSE or OPEN_DOWNGRADE. Because OPENs may 5245 be sent in parallel for the same owner, a client might close a file 5246 without knowing that an OPEN upgrade had been done by the server, 5247 changing the lock in question. If CLOSE were sent with a zero seqid, 5248 the OPEN upgrade would be canceled before the client even received an 5249 indication that an upgrade had happened. 5251 When a stateid is sent by the server to the client as part of a 5252 callback operation, it is not subject to checking for a current seqid 5253 and returning NFS4ERR_OLD_STATEID. This is because the client is not 5254 in a position to know the most up-to-date seqid and thus cannot 5255 verify it. Unless specially noted, the seqid value for a stateid 5256 sent by the server to the client as part of a callback is required to 5257 be zero with NFS4ERR_BAD_STATEID returned if it is not. 5259 In making comparisons between seqids, both by the client in 5260 determining the order of operations and by the server in determining 5261 whether the NFS4ERR_OLD_STATEID is to be returned, the possibility of 5262 the seqid being swapped around past the NFS4_UINT32_MAX value needs 5263 to be taken into account. 5265 9.1.3.3. Special Stateids 5267 Stateid values whose "other" field is either all zeros or all ones 5268 are reserved. They may not be assigned by the server but have 5269 special meanings defined by the protocol. The particular meaning 5270 depends on whether the "other" field is all zeros or all ones and the 5271 specific value of the "seqid" field. 5273 The following combinations of "other" and "seqid" are defined in 5274 NFSv4: 5276 o When "other" and "seqid" are both zero, the stateid is treated as 5277 a special anonymous stateid, which can be used in READ, WRITE, and 5278 SETATTR requests to indicate the absence of any open state 5279 associated with the request. When an anonymous stateid value is 5280 used, and an existing open denies the form of access requested, 5281 then access will be denied to the request. 5283 o When "other" and "seqid" are both all ones, the stateid is a 5284 special READ bypass stateid. When this value is used in WRITE or 5285 SETATTR, it is treated like the anonymous value. When used in 5286 READ, the server MAY grant access, even if access would normally 5287 be denied to READ requests. 5289 o When "other" is zero and "seqid" is one, the stateid represents 5290 the current stateid, which is whatever value is the last stateid 5291 returned by an operation within the COMPOUND. In the case of an 5292 OPEN, the stateid returned for the open file, and not the 5293 delegation is used. The stateid passed to the operation in place 5294 of the special value has its "seqid" value set to zero, except 5295 when the current stateid is used by the operation CLOSE or 5296 OPEN_DOWNGRADE. If there is no operation in the COMPOUND which 5297 has returned a stateid value, the server MUST return the error 5298 NFS4ERR_BAD_STATEID. As illustrated in Figure 5, if the value of 5299 a current stateid is a special stateid, and the stateid of an 5300 operation's arguments has "other" set to zero, and "seqid" set to 5301 one, then the server MUST return the error NFS4ERR_BAD_STATEID. 5303 o When "other" is zero and "seqid" is NFS4_UINT32_MAX, the stateid 5304 represents a reserved stateid value defined to be invalid. When 5305 this stateid is used, the server MUST return the error 5306 NFS4ERR_BAD_STATEID. 5308 If a stateid value is used which has all zero or all ones in the 5309 "other" field, but does not match one of the cases above, the server 5310 MUST return the error NFS4ERR_BAD_STATEID. 5312 Special stateids, unlike other stateids, are not associated with 5313 individual client IDs or filehandles and can be used with all valid 5314 client IDs and filehandles. In the case of a special stateid 5315 designating the current stateid, the current stateid value 5316 substituted for the special stateid is associated with a particular 5317 client ID and filehandle, and so, if it is used where current 5318 filehandle does not match that associated with the current stateid, 5319 the operation to which the stateid is passed will return 5320 NFS4ERR_BAD_STATEID. 5322 9.1.3.4. Stateid Lifetime and Validation 5324 Stateids must remain valid until either a client restart or a server 5325 restart or until the client returns all of the locks associated with 5326 the stateid by means of an operation such as CLOSE or DELEGRETURN. 5327 If the locks are lost due to revocation as long as the client ID is 5328 valid, the stateid remains a valid designation of that revoked state. 5329 Stateids associated with byte-range locks are an exception. They 5330 remain valid even if a LOCKU frees all remaining locks, so long as 5331 the open file with which they are associated remains open. 5333 It should be noted that there are situations in which the client's 5334 locks become invalid, without the client requesting they be returned. 5335 These include lease expiration and a number of forms of lock 5336 revocation within the lease period. It is important to note that in 5337 these situations, the stateid remains valid and the client can use it 5338 to determine the disposition of the associated lost locks. 5340 An "other" value must never be reused for a different purpose (i.e. 5341 different filehandle, owner, or type of locks) within the context of 5342 a single client ID. A server may retain the "other" value for the 5343 same purpose beyond the point where it may otherwise be freed but if 5344 it does so, it must maintain "seqid" continuity with previous values. 5346 One mechanism that may be used to satisfy the requirement that the 5347 server recognize invalid and out-of-date stateids is for the server 5348 to divide the "other" field of the stateid into two fields. 5350 o An index into a table of locking-state structures. 5352 o A generation number which is incremented on each allocation of a 5353 table entry for a particular use. 5355 And then store in each table entry, 5357 o The client ID with which the stateid is associated. 5359 o The current generation number for the (at most one) valid stateid 5360 sharing this index value. 5362 o The filehandle of the file on which the locks are taken. 5364 o An indication of the type of stateid (open, byte-range lock, file 5365 delegation). 5367 o The last "seqid" value returned corresponding to the current 5368 "other" value. 5370 o An indication of the current status of the locks associated with 5371 this stateid. In particular, whether these have been revoked and 5372 if so, for what reason. 5374 With this information, an incoming stateid can be validated and the 5375 appropriate error returned when necessary. Special and non-special 5376 stateids are handled separately. (See Section 9.1.3.3 for a 5377 discussion of special stateids.) 5379 When a stateid is being tested, and the "other" field is all zeros or 5380 all ones, a check that the "other" and "seqid" fields match a defined 5381 combination for a special stateid is done and the results determined 5382 as follows: 5384 o If the "other" and "seqid" fields do not match a defined 5385 combination associated with a special stateid, the error 5386 NFS4ERR_BAD_STATEID is returned. 5388 o If the special stateid is one designating the current stateid, and 5389 there is a current stateid, then the current stateid is 5390 substituted for the special stateid and the checks appropriate to 5391 non-special stateids in performed. 5393 o If the combination is valid in general but is not appropriate to 5394 the context in which the stateid is used (e.g. an all-zero stateid 5395 is used when an open stateid is required in a LOCK operation), the 5396 error NFS4ERR_BAD_STATEID is also returned. 5398 o Otherwise, the check is completed and the special stateid is 5399 accepted as valid. 5401 When a stateid is being tested, and the "other" field is neither all 5402 zeros or all ones, the following procedure could be used to validate 5403 an incoming stateid and return an appropriate error, when necessary, 5404 assuming that the "other" field would be divided into a table index 5405 and an entry generation. 5407 o If the table index field is outside the range of the associated 5408 table, return NFS4ERR_BAD_STATEID. 5410 o If the selected table entry is of a different generation than that 5411 specified in the incoming stateid, return NFS4ERR_BAD_STATEID. 5413 o If the selected table entry does not match the current filehandle, 5414 return NFS4ERR_BAD_STATEID. 5416 o If the client ID in the table entry does not match the client ID 5417 associated with the current session, return NFS4ERR_BAD_STATEID. 5419 o If the stateid represents revoked state, then return 5420 NFS4ERR_EXPIRED, NFS4ERR_ADMIN_REVOKED, or NFS4ERR_DELEG_REVOKED, 5421 as appropriate. 5423 o If the stateid type is not valid for the context in which the 5424 stateid appears, return NFS4ERR_BAD_STATEID. Note that a stateid 5425 may be valid in general, but be invalid for a particular 5426 operation, as, for example, when a stateid which doesn't represent 5427 byte-range locks is passed to the non-from_open case of LOCK or to 5428 LOCKU, or when a stateid which does not represent an open is 5429 passed to CLOSE or OPEN_DOWNGRADE. In such cases, the server MUST 5430 return NFS4ERR_BAD_STATEID. 5432 o If the "seqid" field is not zero, and it is greater than the 5433 current sequence value corresponding the current "other" field, 5434 return NFS4ERR_BAD_STATEID. 5436 o If the "seqid" field is not zero, and it is less than the current 5437 sequence value corresponding the current "other" field, return 5438 NFS4ERR_OLD_STATEID. 5440 o Otherwise, the stateid is valid and the table entry should contain 5441 any additional information about the type of stateid and 5442 information associated with that particular type of stateid, such 5443 as the associated set of locks, such as open-owner and lock-owner 5444 information, as well as information on the specific locks, such as 5445 open modes and byte ranges. 5447 9.1.3.5. Stateid Use for I/O Operations 5449 Clients performing I/O operations need to select an appropriate 5450 stateid based on the locks (including opens and delegations) held by 5451 the client and the various types of state-owners sending the I/O 5452 requests. SETATTR operations that change the file size are treated 5453 like I/O operations in this regard. 5455 The following rules, applied in order of decreasing priority, govern 5456 the selection of the appropriate stateid. In following these rules, 5457 the client will only consider locks of which it has actually received 5458 notification by an appropriate operation response or callback. 5460 o If the client holds a delegation for the file in question, the 5461 delegation stateid SHOULD be used. 5463 o Otherwise, if the entity corresponding to the lock-owner (e.g., a 5464 process) sending the I/O has a byte-range lock stateid for the 5465 associated open file, then the byte-range lock stateid for that 5466 lock-owner and open file SHOULD be used. 5468 o If there is no byte-range lock stateid, then the OPEN stateid for 5469 the current open-owner, and that OPEN stateid for the open file in 5470 question SHOULD be used. 5472 o Finally, if none of the above apply, then a special stateid SHOULD 5473 be used. 5475 Ignoring these rules may result in situations in which the server 5476 does not have information necessary to properly process the request. 5477 For example, when mandatory byte-range locks are in effect, if the 5478 stateid does not indicate the proper lock-owner, via a lock stateid, 5479 a request might be avoidably rejected. 5481 The server however should not try to enforce these ordering rules and 5482 should use whatever information is available to properly process I/O 5483 requests. In particular, when a client has a delegation for a given 5484 file, it SHOULD take note of this fact in processing a request, even 5485 if it is sent with a special stateid. 5487 9.1.3.6. Stateid Use for SETATTR Operations 5489 In the case of SETATTR operations, a stateid is present. In cases 5490 other than those that set the file size, the client may send either a 5491 special stateid or, when a delegation is held for the file in 5492 question, a delegation stateid. While the server SHOULD validate the 5493 stateid and may use the stateid to optimize the determination as to 5494 whether a delegation is held, it SHOULD note the presence of a 5495 delegation even when a special stateid is sent, and MUST accept a 5496 valid delegation stateid when sent. 5498 9.1.4. lock-owner 5500 When requesting a lock, the client must present to the server the 5501 client ID and an identifier for the owner of the requested lock. 5502 These two fields are referred to as the lock-owner and the definition 5503 of those fields are: 5505 o A client ID returned by the server as part of the client's use of 5506 the SETCLIENTID operation. 5508 o A variable length opaque array used to uniquely define the owner 5509 of a lock managed by the client. 5511 This may be a thread id, process id, or other unique value. 5513 When the server grants the lock, it responds with a unique stateid. 5514 The stateid is used as a shorthand reference to the lock-owner, since 5515 the server will be maintaining the correspondence between them. 5517 9.1.5. Use of the Stateid and Locking 5519 All READ, WRITE and SETATTR operations contain a stateid. For the 5520 purposes of this section, SETATTR operations which change the size 5521 attribute of a file are treated as if they are writing the area 5522 between the old and new size (i.e., the range truncated or added to 5523 the file by means of the SETATTR), even where SETATTR is not 5524 explicitly mentioned in the text. The stateid passed to one of these 5525 operations must be one that represents an OPEN (e.g., via the open- 5526 owner), a set of byte-range locks, or a delegation, or it may be a 5527 special stateid representing anonymous access or the special bypass 5528 stateid. 5530 If the state-owner performs a READ or WRITE in a situation in which 5531 it has established a lock or share reservation on the server (any 5532 OPEN constitutes a share reservation) the stateid (previously 5533 returned by the server) must be used to indicate what locks, 5534 including both byte-range locks and share reservations, are held by 5535 the state-owner. If no state is established by the client, either 5536 byte-range lock or share reservation, a stateid of all bits 0 is 5537 used. Regardless whether a stateid of all bits 0, or a stateid 5538 returned by the server is used, if there is a conflicting share 5539 reservation or mandatory byte-range lock held on the file, the server 5540 MUST refuse to service the READ or WRITE operation. 5542 Share reservations are established by OPEN operations and by their 5543 nature are mandatory in that when the OPEN denies READ or WRITE 5544 operations, that denial results in such operations being rejected 5545 with error NFS4ERR_LOCKED. Byte-range locks may be implemented by 5546 the server as either mandatory or advisory, or the choice of 5547 mandatory or advisory behavior may be determined by the server on the 5548 basis of the file being accessed (for example, some UNIX-based 5549 servers support a "mandatory lock bit" on the mode attribute such 5550 that if set, byte-range locks are required on the file before I/O is 5551 possible). When byte-range locks are advisory, they only prevent the 5552 granting of conflicting lock requests and have no effect on READs or 5553 WRITEs. Mandatory byte-range locks, however, prevent conflicting I/O 5554 operations. When they are attempted, they are rejected with 5555 NFS4ERR_LOCKED. When the client gets NFS4ERR_LOCKED on a file it 5556 knows it has the proper share reservation for, it will need to issue 5557 a LOCK request on the region of the file that includes the region the 5558 I/O was to be performed on, with an appropriate locktype (i.e., 5559 READ*_LT for a READ operation, WRITE*_LT for a WRITE operation). 5561 With NFSv3, there was no notion of a stateid so there was no way to 5562 tell if the application process of the client sending the READ or 5563 WRITE operation had also acquired the appropriate byte-range lock on 5564 the file. Thus there was no way to implement mandatory locking. 5566 With the stateid construct, this barrier has been removed. 5568 Note that for UNIX environments that support mandatory file locking, 5569 the distinction between advisory and mandatory locking is subtle. In 5570 fact, advisory and mandatory byte-range locks are exactly the same in 5571 so far as the APIs and requirements on implementation. If the 5572 mandatory lock attribute is set on the file, the server checks to see 5573 if the lockowner has an appropriate shared (read) or exclusive 5574 (write) byte-range lock on the region it wishes to read or write to. 5575 If there is no appropriate lock, the server checks if there is a 5576 conflicting lock (which can be done by attempting to acquire the 5577 conflicting lock on the behalf of the lockowner, and if successful, 5578 release the lock after the READ or WRITE is done), and if there is, 5579 the server returns NFS4ERR_LOCKED. 5581 For Windows environments, there are no advisory byte-range locks, so 5582 the server always checks for byte-range locks during I/O requests. 5584 Thus, the NFSv4 LOCK operation does not need to distinguish between 5585 advisory and mandatory byte-range locks. It is the NFS version 4 5586 server's processing of the READ and WRITE operations that introduces 5587 the distinction. 5589 Every stateid other than the special stateid values noted in this 5590 section, whether returned by an OPEN-type operation (i.e., OPEN, 5591 OPEN_DOWNGRADE), or by a LOCK-type operation (i.e., LOCK or LOCKU), 5592 defines an access mode for the file (i.e., READ, WRITE, or READ- 5593 WRITE) as established by the original OPEN which began the stateid 5594 sequence, and as modified by subsequent OPENs and OPEN_DOWNGRADEs 5595 within that stateid sequence. When a READ, WRITE, or SETATTR which 5596 specifies the size attribute, is done, the operation is subject to 5597 checking against the access mode to verify that the operation is 5598 appropriate given the OPEN with which the operation is associated. 5600 In the case of WRITE-type operations (i.e., WRITEs and SETATTRs which 5601 set size), the server must verify that the access mode allows writing 5602 and return an NFS4ERR_OPENMODE error if it does not. In the case, of 5603 READ, the server may perform the corresponding check on the access 5604 mode, or it may choose to allow READ on opens for WRITE only, to 5605 accommodate clients whose write implementation may unavoidably do 5606 reads (e.g., due to buffer cache constraints). However, even if 5607 READs are allowed in these circumstances, the server MUST still check 5608 for locks that conflict with the READ (e.g., another open specify 5609 denial of READs). Note that a server which does enforce the access 5610 mode check on READs need not explicitly check for conflicting share 5611 reservations since the existence of OPEN for read access guarantees 5612 that no conflicting share reservation can exist. 5614 A stateid of all bits 1 (one) MAY allow READ operations to bypass 5615 locking checks at the server. However, WRITE operations with a 5616 stateid with bits all 1 (one) MUST NOT bypass locking checks and are 5617 treated exactly the same as if a stateid of all bits 0 were used. 5619 A lock may not be granted while a READ or WRITE operation using one 5620 of the special stateids is being performed and the range of the lock 5621 request conflicts with the range of the READ or WRITE operation. For 5622 the purposes of this paragraph, a conflict occurs when a shared lock 5623 is requested and a WRITE operation is being performed, or an 5624 exclusive lock is requested and either a READ or a WRITE operation is 5625 being performed. A SETATTR that sets size is treated similarly to a 5626 WRITE as discussed above. 5628 9.1.6. Sequencing of Lock Requests 5630 Locking is different than most NFS operations as it requires "at- 5631 most-one" semantics that are not provided by ONCRPC. ONCRPC over a 5632 reliable transport is not sufficient because a sequence of locking 5633 requests may span multiple TCP connections. In the face of 5634 retransmission or reordering, lock or unlock requests must have a 5635 well defined and consistent behavior. To accomplish this, each lock 5636 request contains a sequence number that is a consecutively increasing 5637 integer. Different state-owners have different sequences. The 5638 server maintains the last sequence number (L) received and the 5639 response that was returned. The server is free to assign any value 5640 for the first request issued for any given state-owner. 5642 Note that for requests that contain a sequence number, for each 5643 state-owner, there should be no more than one outstanding request. 5645 If a request (r) with a previous sequence number (r < L) is received, 5646 it is rejected with the return of error NFS4ERR_BAD_SEQID. Given a 5647 properly-functioning client, the response to (r) must have been 5648 received before the last request (L) was sent. If a duplicate of 5649 last request (r == L) is received, the stored response is returned. 5650 If a request beyond the next sequence (r == L + 2) is received, it is 5651 rejected with the return of error NFS4ERR_BAD_SEQID. Sequence 5652 history is reinitialized whenever the SETCLIENTID/SETCLIENTID_CONFIRM 5653 sequence changes the client verifier. 5655 Since the sequence number is represented with an unsigned 32-bit 5656 integer, the arithmetic involved with the sequence number is mod 5657 2^32. For an example of modulo arithmetic involving sequence numbers 5658 see [33]. 5660 It is critical the server maintain the last response sent to the 5661 client to provide a more reliable cache of duplicate non-idempotent 5662 requests than that of the traditional cache described in [34]. The 5663 traditional duplicate request cache uses a least recently used 5664 algorithm for removing unneeded requests. However, the last lock 5665 request and response on a given state-owner must be cached as long as 5666 the lock state exists on the server. 5668 The client MUST monotonically increment the sequence number for the 5669 CLOSE, LOCK, LOCKU, OPEN, OPEN_CONFIRM, and OPEN_DOWNGRADE 5670 operations. This is true even in the event that the previous 5671 operation that used the sequence number received an error. The only 5672 exception to this rule is if the previous operation received one of 5673 the following errors: NFS4ERR_STALE_CLIENTID, NFS4ERR_STALE_STATEID, 5674 NFS4ERR_BAD_STATEID, NFS4ERR_BAD_SEQID, NFS4ERR_BADXDR, 5675 NFS4ERR_RESOURCE, NFS4ERR_NOFILEHANDLE, or NFS4ERR_MOVED. 5677 9.1.7. Recovery from Replayed Requests 5679 As described above, the sequence number is per state-owner. As long 5680 as the server maintains the last sequence number received and follows 5681 the methods described above, there are no risks of a Byzantine router 5682 re-sending old requests. The server need only maintain the (state- 5683 owner, sequence number) state as long as there are open files or 5684 closed files with locks outstanding. 5686 LOCK, LOCKU, OPEN, OPEN_DOWNGRADE, and CLOSE each contain a sequence 5687 number and therefore the risk of the replay of these operations 5688 resulting in undesired effects is non-existent while the server 5689 maintains the state-owner state. 5691 9.1.8. Releasing state-owner State 5693 When a particular state-owner no longer holds open or file locking 5694 state at the server, the server may choose to release the sequence 5695 number state associated with the state-owner. The server may make 5696 this choice based on lease expiration, for the reclamation of server 5697 memory, or other implementation specific details. In any event, the 5698 server is able to do this safely only when the state-owner no longer 5699 is being utilized by the client. The server may choose to hold the 5700 state-owner state in the event that retransmitted requests are 5701 received. However, the period to hold this state is implementation 5702 specific. 5704 In the case that a LOCK, LOCKU, OPEN_DOWNGRADE, or CLOSE is 5705 retransmitted after the server has previously released the state- 5706 owner state, the server will find that the state-owner has no files 5707 open and an error will be returned to the client. If the state-owner 5708 does have a file open, the stateid will not match and again an error 5709 is returned to the client. 5711 9.1.9. Use of Open Confirmation 5713 In the case that an OPEN is retransmitted and the open-owner is being 5714 used for the first time or the open-owner state has been previously 5715 released by the server, the use of the OPEN_CONFIRM operation will 5716 prevent incorrect behavior. When the server observes the use of the 5717 open-owner for the first time, it will direct the client to perform 5718 the OPEN_CONFIRM for the corresponding OPEN. This sequence 5719 establishes the use of a open-owner and associated sequence number. 5720 Since the OPEN_CONFIRM sequence connects a new open-owner on the 5721 server with an existing open-owner on a client, the sequence number 5722 may have any value. The OPEN_CONFIRM step assures the server that 5723 the value received is the correct one. (see Section 15.20 for further 5724 details.) 5726 There are a number of situations in which the requirement to confirm 5727 an OPEN would pose difficulties for the client and server, in that 5728 they would be prevented from acting in a timely fashion on 5729 information received, because that information would be provisional, 5730 subject to deletion upon non-confirmation. Fortunately, these are 5731 situations in which the server can avoid the need for confirmation 5732 when responding to open requests. The two constraints are: 5734 o The server must not bestow a delegation for any open which would 5735 require confirmation. 5737 o The server MUST NOT require confirmation on a reclaim-type open 5738 (i.e., one specifying claim type CLAIM_PREVIOUS or 5739 CLAIM_DELEGATE_PREV). 5741 These constraints are related in that reclaim-type opens are the only 5742 ones in which the server may be required to send a delegation. For 5743 CLAIM_NULL, sending the delegation is optional while for 5744 CLAIM_DELEGATE_CUR, no delegation is sent. 5746 Delegations being sent with an open requiring confirmation are 5747 troublesome because recovering from non-confirmation adds undue 5748 complexity to the protocol while requiring confirmation on reclaim- 5749 type opens poses difficulties in that the inability to resolve the 5750 status of the reclaim until lease expiration may make it difficult to 5751 have timely determination of the set of locks being reclaimed (since 5752 the grace period may expire). 5754 Requiring open confirmation on reclaim-type opens is avoidable 5755 because of the nature of the environments in which such opens are 5756 done. For CLAIM_PREVIOUS opens, this is immediately after server 5757 reboot, so there should be no time for lockowners to be created, 5758 found to be unused, and recycled. For CLAIM_DELEGATE_PREV opens, we 5759 are dealing with a client reboot situation. A server which supports 5760 delegation can be sure that no lockowners for that client have been 5761 recycled since client initialization and thus can ensure that 5762 confirmation will not be required. 5764 9.2. Lock Ranges 5766 The protocol allows a lock owner to request a lock with a byte range 5767 and then either upgrade or unlock a sub-range of the initial lock. 5768 It is expected that this will be an uncommon type of request. In any 5769 case, servers or server filesystems may not be able to support sub- 5770 range lock semantics. In the event that a server receives a locking 5771 request that represents a sub-range of current locking state for the 5772 lock owner, the server is allowed to return the error 5773 NFS4ERR_LOCK_RANGE to signify that it does not support sub-range lock 5774 operations. Therefore, the client should be prepared to receive this 5775 error and, if appropriate, report the error to the requesting 5776 application. 5778 The client is discouraged from combining multiple independent locking 5779 ranges that happen to be adjacent into a single request since the 5780 server may not support sub-range requests and for reasons related to 5781 the recovery of file locking state in the event of server failure. 5782 As discussed in the Section 9.6.2 below, the server may employ 5783 certain optimizations during recovery that work effectively only when 5784 the client's behavior during lock recovery is similar to the client's 5785 locking behavior prior to server failure. 5787 9.3. Upgrading and Downgrading Locks 5789 If a client has a write lock on a record, it can request an atomic 5790 downgrade of the lock to a read lock via the LOCK request, by setting 5791 the type to READ_LT. If the server supports atomic downgrade, the 5792 request will succeed. If not, it will return NFS4ERR_LOCK_NOTSUPP. 5793 The client should be prepared to receive this error, and if 5794 appropriate, report the error to the requesting application. 5796 If a client has a read lock on a record, it can request an atomic 5797 upgrade of the lock to a write lock via the LOCK request by setting 5798 the type to WRITE_LT or WRITEW_LT. If the server does not support 5799 atomic upgrade, it will return NFS4ERR_LOCK_NOTSUPP. If the upgrade 5800 can be achieved without an existing conflict, the request will 5801 succeed. Otherwise, the server will return either NFS4ERR_DENIED or 5802 NFS4ERR_DEADLOCK. The error NFS4ERR_DEADLOCK is returned if the 5803 client issued the LOCK request with the type set to WRITEW_LT and the 5804 server has detected a deadlock. The client should be prepared to 5805 receive such errors and if appropriate, report the error to the 5806 requesting application. 5808 9.4. Blocking Locks 5810 Some clients require the support of blocking locks. The NFS version 5811 4 protocol must not rely on a callback mechanism and therefore is 5812 unable to notify a client when a previously denied lock has been 5813 granted. Clients have no choice but to continually poll for the 5814 lock. This presents a fairness problem. Two new lock types are 5815 added, READW and WRITEW, and are used to indicate to the server that 5816 the client is requesting a blocking lock. The server should maintain 5817 an ordered list of pending blocking locks. When the conflicting lock 5818 is released, the server may wait the lease period for the first 5819 waiting client to re-request the lock. After the lease period 5820 expires the next waiting client request is allowed the lock. Clients 5821 are required to poll at an interval sufficiently small that it is 5822 likely to acquire the lock in a timely manner. The server is not 5823 required to maintain a list of pending blocked locks as it is used to 5824 increase fairness and not correct operation. Because of the 5825 unordered nature of crash recovery, storing of lock state to stable 5826 storage would be required to guarantee ordered granting of blocking 5827 locks. 5829 Servers may also note the lock types and delay returning denial of 5830 the request to allow extra time for a conflicting lock to be 5831 released, allowing a successful return. In this way, clients can 5832 avoid the burden of needlessly frequent polling for blocking locks. 5833 The server should take care in the length of delay in the event the 5834 client retransmits the request. 5836 If a server receives a blocking lock request, denies it, and then 5837 later receives a nonblocking request for the same lock, which is also 5838 denied, then it should remove the lock in question from its list of 5839 pending blocking locks. Clients should use such a nonblocking 5840 request to indicate to the server that this is the last time they 5841 intend to poll for the lock, as may happen when the process 5842 requesting the lock is interrupted. This is a courtesy to the 5843 server, to prevent it from unnecessarily waiting a lease period 5844 before granting other lock requests. However, clients are not 5845 required to perform this courtesy, and servers must not depend on 5846 them doing so. Also, clients must be prepared for the possibility 5847 that this final locking request will be accepted. 5849 9.5. Lease Renewal 5851 The purpose of a lease is to allow a server to remove stale locks 5852 that are held by a client that has crashed or is otherwise 5853 unreachable. It is not a mechanism for cache consistency and lease 5854 renewals may not be denied if the lease interval has not expired. 5856 The following events cause implicit renewal of all of the leases for 5857 a given client (i.e., all those sharing a given client ID). Each of 5858 these is a positive indication that the client is still active and 5859 that the associated state held at the server, for the client, is 5860 still valid. 5862 o An OPEN with a valid client ID. 5864 o Any operation made with a valid stateid (CLOSE, DELEGPURGE, 5865 DELEGRETURN, LOCK, LOCKU, OPEN, OPEN_CONFIRM, OPEN_DOWNGRADE, 5866 READ, RENEW, SETATTR, or WRITE). This does not include the 5867 special stateids of all bits 0 or all bits 1. 5869 Note that if the client had restarted or rebooted, the client 5870 would not be making these requests without issuing the 5871 SETCLIENTID/SETCLIENTID_CONFIRM sequence. The use of the 5872 SETCLIENTID/SETCLIENTID_CONFIRM sequence (one that changes the 5873 client verifier) notifies the server to drop the locking state 5874 associated with the client. SETCLIENTID/SETCLIENTID_CONFIRM never 5875 renews a lease. 5877 If the server has rebooted, the stateids (NFS4ERR_STALE_STATEID 5878 error) or the client ID (NFS4ERR_STALE_CLIENTID error) will not be 5879 valid hence preventing spurious renewals. 5881 This approach allows for low overhead lease renewal which scales 5882 well. In the typical case no extra RPC calls are required for lease 5883 renewal and in the worst case one RPC is required every lease period 5884 (i.e., a RENEW operation). The number of locks held by the client is 5885 not a factor since all state for the client is involved with the 5886 lease renewal action. 5888 Since all operations that create a new lease also renew existing 5889 leases, the server must maintain a common lease expiration time for 5890 all valid leases for a given client. This lease time can then be 5891 easily updated upon implicit lease renewal actions. 5893 9.6. Crash Recovery 5895 The important requirement in crash recovery is that both the client 5896 and the server know when the other has failed. Additionally, it is 5897 required that a client sees a consistent view of data across server 5898 restarts or reboots. All READ and WRITE operations that may have 5899 been queued within the client or network buffers must wait until the 5900 client has successfully recovered the locks protecting the READ and 5901 WRITE operations. 5903 9.6.1. Client Failure and Recovery 5905 In the event that a client fails, the server may recover the client's 5906 locks when the associated leases have expired. Conflicting locks 5907 from another client may only be granted after this lease expiration. 5908 If the client is able to restart or reinitialize within the lease 5909 period the client may be forced to wait the remainder of the lease 5910 period before obtaining new locks. 5912 To minimize client delay upon restart, lock requests are associated 5913 with an instance of the client by a client supplied verifier. This 5914 verifier is part of the initial SETCLIENTID call made by the client. 5915 The server returns a client ID as a result of the SETCLIENTID 5916 operation. The client then confirms the use of the client ID with 5917 SETCLIENTID_CONFIRM. The client ID in combination with an opaque 5918 owner field is then used by the client to identify the lock owner for 5919 OPEN. This chain of associations is then used to identify all locks 5920 for a particular client. 5922 Since the verifier will be changed by the client upon each 5923 initialization, the server can compare a new verifier to the verifier 5924 associated with currently held locks and determine that they do not 5925 match. This signifies the client's new instantiation and subsequent 5926 loss of locking state. As a result, the server is free to release 5927 all locks held which are associated with the old client ID which was 5928 derived from the old verifier. 5930 Note that the verifier must have the same uniqueness properties of 5931 the verifier for the COMMIT operation. 5933 9.6.2. Server Failure and Recovery 5935 If the server loses locking state (usually as a result of a restart 5936 or reboot), it must allow clients time to discover this fact and re- 5937 establish the lost locking state. The client must be able to re- 5938 establish the locking state without having the server deny valid 5939 requests because the server has granted conflicting access to another 5940 client. Likewise, if there is the possibility that clients have not 5941 yet re-established their locking state for a file, the server must 5942 disallow READ and WRITE operations for that file. The duration of 5943 this recovery period is equal to the duration of the lease period. 5945 A client can determine that server failure (and thus loss of locking 5946 state) has occurred, when it receives one of two errors. The 5947 NFS4ERR_STALE_STATEID error indicates a stateid invalidated by a 5948 reboot or restart. The NFS4ERR_STALE_CLIENTID error indicates a 5949 client ID invalidated by reboot or restart. When either of these are 5950 received, the client must establish a new client ID (see 5951 Section 9.1.1) and re-establish the locking state as discussed below. 5953 The period of special handling of locking and READs and WRITEs, equal 5954 in duration to the lease period, is referred to as the "grace 5955 period". During the grace period, clients recover locks and the 5956 associated state by reclaim-type locking requests (i.e., LOCK 5957 requests with reclaim set to true and OPEN operations with a claim 5958 type of CLAIM_PREVIOUS). During the grace period, the server must 5959 reject READ and WRITE operations and non-reclaim locking requests 5960 (i.e., other LOCK and OPEN operations) with an error of 5961 NFS4ERR_GRACE. 5963 If the server can reliably determine that granting a non-reclaim 5964 request will not conflict with reclamation of locks by other clients, 5965 the NFS4ERR_GRACE error does not have to be returned and the non- 5966 reclaim client request can be serviced. For the server to be able to 5967 service READ and WRITE operations during the grace period, it must 5968 again be able to guarantee that no possible conflict could arise 5969 between an impending reclaim locking request and the READ or WRITE 5970 operation. If the server is unable to offer that guarantee, the 5971 NFS4ERR_GRACE error must be returned to the client. 5973 For a server to provide simple, valid handling during the grace 5974 period, the easiest method is to simply reject all non-reclaim 5975 locking requests and READ and WRITE operations by returning the 5976 NFS4ERR_GRACE error. However, a server may keep information about 5977 granted locks in stable storage. With this information, the server 5978 could determine if a regular lock or READ or WRITE operation can be 5979 safely processed. 5981 For example, if a count of locks on a given file is available in 5982 stable storage, the server can track reclaimed locks for the file and 5983 when all reclaims have been processed, non-reclaim locking requests 5984 may be processed. This way the server can ensure that non-reclaim 5985 locking requests will not conflict with potential reclaim requests. 5986 With respect to I/O requests, if the server is able to determine that 5987 there are no outstanding reclaim requests for a file by information 5988 from stable storage or another similar mechanism, the processing of 5989 I/O requests could proceed normally for the file. 5991 To reiterate, for a server that allows non-reclaim lock and I/O 5992 requests to be processed during the grace period, it MUST determine 5993 that no lock subsequently reclaimed will be rejected and that no lock 5994 subsequently reclaimed would have prevented any I/O operation 5995 processed during the grace period. 5997 Clients should be prepared for the return of NFS4ERR_GRACE errors for 5998 non-reclaim lock and I/O requests. In this case the client should 5999 employ a retry mechanism for the request. A delay (on the order of 6000 several seconds) between retries should be used to avoid overwhelming 6001 the server. Further discussion of the general issue is included in 6002 [20]. The client must account for the server that is able to perform 6003 I/O and non-reclaim locking requests within the grace period as well 6004 as those that cannot do so. 6006 A reclaim-type locking request outside the server's grace period can 6007 only succeed if the server can guarantee that no conflicting lock or 6008 I/O request has been granted since reboot or restart. 6010 A server may, upon restart, establish a new value for the lease 6011 period. Therefore, clients should, once a new client ID is 6012 established, refetch the lease_time attribute and use it as the basis 6013 for lease renewal for the lease associated with that server. 6014 However, the server must establish, for this restart event, a grace 6015 period at least as long as the lease period for the previous server 6016 instantiation. This allows the client state obtained during the 6017 previous server instance to be reliably re-established. 6019 9.6.3. Network Partitions and Recovery 6021 If the duration of a network partition is greater than the lease 6022 period provided by the server, the server will have not received a 6023 lease renewal from the client. If this occurs, the server may free 6024 all locks held for the client. As a result, all stateids held by the 6025 client will become invalid or stale. Once the client is able to 6026 reach the server after such a network partition, all I/O submitted by 6027 the client with the now invalid stateids will fail with the server 6028 returning the error NFS4ERR_EXPIRED. Once this error is received, 6029 the client will suitably notify the application that held the lock. 6031 9.6.3.1. Courtesy Locks 6033 As a courtesy to the client or as an optimization, the server may 6034 continue to hold locks on behalf of a client for which recent 6035 communication has extended beyond the lease period. If the server 6036 receives a lock or I/O request that conflicts with one of these 6037 courtesy locks, the server MUST free the courtesy lock and grant the 6038 new request. If the server runs out of resources, it MAY free all 6039 courtesy locks. I.e., the client MUST not make an assumption that 6040 the server has issued courtesy locks. 6042 If the server does not reboot before the network partition is healed, 6043 when the original client tries to access a courtesy lock which was 6044 freed, the server SHOULD send back a NFS4ERR_BAD_STATEID to the 6045 client. If the client tries to access a courtesy lock which was not 6046 freed, then the server SHOULD mark all of the courtesy locks as 6047 implicitly being renewed. 6049 When a network partition is combined with a server reboot, then both 6050 the server and client have responsibilities to ensure that the client 6051 does not reclaim a lock which it should no longer be able to access. 6052 Briefly those are: 6054 o Client's responsibility: A client MUST NOT attempt to reclaim any 6055 locks which it did not hold at the end of its most recent 6056 successfully established client lease. 6058 o Server's responsibility: A server MUST NOT allow a client to 6059 reclaim a lock unless it knows that it could not have since 6060 granted a conflicting lock. However, in deciding whether a 6061 conflicting lock could have been granted, it is permitted to 6062 assume its clients are responsible, as above. 6064 A server may consider a client's lease "successfully established" 6065 once it has received an open operation from that client. 6067 The next sections give examples showing what can go wrong if these 6068 responsibilites are neglected, and provides examples of server 6069 implementation strategies that could meet a server's 6070 responsibilities. 6072 9.6.3.1.1. First Server Edge Condition 6074 The first edge condition has the following scenario: 6076 1. Client A acquires a lock. 6078 2. Client A and server experience mutual network partition, such 6079 that client A is unable to renew its lease. 6081 3. Client A's lease expires, so server releases lock. 6083 4. Client B acquires a lock that would have conflicted with that of 6084 Client A. 6086 5. Client B releases the lock 6088 6. Server reboots 6090 7. Network partition between client A and server heals. 6092 8. Client A issues a RENEW operation, and gets back a 6093 NFS4ERR_STALE_CLIENTID. 6095 9. Client A reclaims its lock within the server's grace period. 6097 Thus, at the final step, the server has erroneously granted client 6098 A's lock reclaim. If client B modified the object the lock was 6099 protecting, client A will experience object corruption. 6101 9.6.3.1.2. Second Server Edge Condition 6103 The second known edge condition follows: 6105 1. Client A acquires a lock. 6107 2. Server reboots. 6109 3. Client A and server experience mutual network partition, such 6110 that client A is unable to reclaim its lock within the grace 6111 period. 6113 4. Server's reclaim grace period ends. Client A has no locks 6114 recorded on server. 6116 5. Client B acquires a lock that would have conflicted with that of 6117 Client A. 6119 6. Client B releases the lock. 6121 7. Server reboots a second time. 6123 8. Network partition between client A and server heals. 6125 9. Client A issues a RENEW operation, and gets back a 6126 NFS4ERR_STALE_CLIENTID. 6128 10. Client A reclaims its lock within the server's grace period. 6130 As with the first edge condition, the final step of the scenario of 6131 the second edge condition has the server erroneously granting client 6132 A's lock reclaim. 6134 9.6.3.1.3. Handling Server Edge Conditions 6136 In both of the above examples, the client attempts reclaim of a lock 6137 that it held at the end of its most recent successfully established 6138 lease; thus, it has fulfilled its responsibility. 6140 The server, however, has failed, by granting a reclaim, despite 6141 having granted a conflicting lock since the reclaimed lock was last 6142 held. 6144 Solving these edge conditions requires that the server either assume 6145 after it reboots that edge condition occurs, and thus return 6146 NFS4ERR_NO_GRACE for all reclaim attempts, or that the server record 6147 some information in stable storage. The amount of information the 6148 server records in stable storage is in inverse proportion to how 6149 harsh the server wants to be whenever the edge conditions occur. The 6150 server that is completely tolerant of all edge conditions will record 6151 in stable storage every lock that is acquired, removing the lock 6152 record from stable storage only when the lock is unlocked by the 6153 client and the lock's lockowner advances the sequence number such 6154 that the lock release is not the last stateful event for the 6155 lockowner's sequence. For the two aforementioned edge conditions, 6156 the harshest a server can be, and still support a grace period for 6157 reclaims, requires that the server record in stable storage 6158 information some minimal information. For example, a server 6159 implementation could, for each client, save in stable storage a 6160 record containing: 6162 o the client's id string 6164 o a boolean that indicates if the client's lease expired or if there 6165 was administrative intervention (see Section 9.8) to revoke a 6166 byte-range lock, share reservation, or delegation 6168 o a timestamp that is updated the first time after a server boot or 6169 reboot the client acquires byte-range locking, share reservation, 6170 or delegation state on the server. The timestamp need not be 6171 updated on subsequent lock requests until the server reboots. 6173 The server implementation would also record in the stable storage the 6174 timestamps from the two most recent server reboots. 6176 Assuming the above record keeping, for the first edge condition, 6177 after the server reboots, the record that client A's lease expired 6178 means that another client could have acquired a conflicting record 6179 lock, share reservation, or delegation. Hence the server must reject 6180 a reclaim from client A with the error NFS4ERR_NO_GRACE. 6182 For the second edge condition, after the server reboots for a second 6183 time, the record that the client had an unexpired record lock, share 6184 reservation, or delegation established before the server's previous 6185 incarnation means that the server must reject a reclaim from client A 6186 with the error NFS4ERR_NO_GRACE. 6188 Regardless of the level and approach to record keeping, the server 6189 MUST implement one of the following strategies (which apply to 6190 reclaims of share reservations, byte-range locks, and delegations): 6192 1. Reject all reclaims with NFS4ERR_NO_GRACE. This is super harsh, 6193 but necessary if the server does not want to record lock state in 6194 stable storage. 6196 2. Record sufficient state in stable storage to meet its 6197 responsibilities. In doubt, the server should err on the side of 6198 being harsh. 6200 In the event that, after a server reboot, the server determines 6201 that there is unrecoverable damage or corruption to the the 6202 stable storage, then for all clients and/or locks affected, the 6203 server MUST return NFS4ERR_NO_GRACE. 6205 9.6.3.1.4. Client Edge Condition 6207 A third edge condition effects the client and not the server. If the 6208 server reboots in the middle of the client reclaiming some locks and 6209 then a network partition is established, the client might be in the 6210 situation of having reclaimed some, but not all locks. In that case, 6211 a conservative client would assume that the non-reclaimed locks were 6212 revoked. 6214 The third known edge condition follows: 6216 1. Client A acquires a lock 1. 6218 2. Client A acquires a lock 2. 6220 3. Server reboots. 6222 4. Client A issues a RENEW operation, and gets back a 6223 NFS4ERR_STALE_CLIENTID. 6225 5. Client A reclaims its lock 1 within the server's grace period. 6227 6. Client A and server experience mutual network partition, such 6228 that client A is unable to reclaim its remaining locks within 6229 the grace period. 6231 7. Server's reclaim grace period ends. 6233 8. Client B acquires a lock that would have conflicted with Client 6234 A's lock 2. 6236 9. Client B releases the lock. 6238 10. Server reboots a second time. 6240 11. Network partition between client A and server heals. 6242 12. Client A issues a RENEW operation, and gets back a 6243 NFS4ERR_STALE_CLIENTID. 6245 13. Client A reclaims both lock 1 and lock 2 within the server's 6246 grace period. 6248 At the last step, the client reclaims lock 2 as if it had held that 6249 lock continuously, when in fact a conflicting lock was granted to 6250 client B. 6252 This occurs because the client failed its responsibility, by 6253 attempting to reclaim lock 2 even though it had not held that lock at 6254 the end of the lease that was established by the SETCLIENTID after 6255 the first server reboot. (The client did hold lock 2 on a previous 6256 lease. But it is only the most recent lease that matters.) 6258 A server could avoid this situation by rejecting the reclaim of lock 6259 2. However, to do so accurately it would have to ensure that 6260 additional information about individual locks held survives reboot. 6261 Server implementations are not required to do that, so the client 6262 must not assume that the server will. 6264 Instead, a client MUST reclaim only those locks which it successfully 6265 acquired from the previous server instance, omitting any that it 6266 failed to reclaim before a new reboot. Thus, in the last step above, 6267 client A should reclaim only lock 1. 6269 9.6.3.1.5. Client's Handling of NFS4ERR_NO_GRACE 6271 A mandate for the client's handling of the NFS4ERR_NO_GRACE error is 6272 outside the scope of this specification, since the strategies for 6273 such handling are very dependent on the client's operating 6274 environment. However, one potential approach is described below. 6276 When the client receives NFS4ERR_NO_GRACE, it could examine the 6277 change attribute of the objects the client is trying to reclaim state 6278 for, and use that to determine whether to re-establish the state via 6279 normal OPEN or LOCK requests. This is acceptable provided the 6280 client's operating environment allows it. In other words, the client 6281 implementor is advised to document for his users the behavior. The 6282 client could also inform the application that its byte-range lock or 6283 share reservations (whether they were delegated or not) have been 6284 lost, such as via a UNIX signal, a GUI pop-up window, etc. See 6285 Section 10.5, for a discussion of what the client should do for 6286 dealing with unreclaimed delegations on client state. 6288 For further discussion of revocation of locks see Section 9.8. 6290 9.6.3.2. Client's Reaction to a Freed Lock 6292 There is no way for a client to predetermine how a given server is 6293 going to behave during a network partition. When the partition 6294 heals, either the client still has all of its locks, it has some of 6295 its locks, or it has none of them. The client will be able to 6296 examine the various error return values to determine its response. 6298 NFS4ERR_EXPIRED: 6300 All locks has been revoked during the partition. The client 6301 should use a SETCLIENTID to recover. 6303 NFS4ERR_ADMIN_REVOKED: 6305 The current lock has been revoked during the partition and there 6306 is no clue as to whether the server rebooted. 6308 NFS4ERR_BAD_STATEID: 6310 The current lock has been revoked during the partition and the 6311 server did not reboot. Other locks MAY still be renewed. The 6312 client MAY NOT want to do a SETCLIENTID and instead SHOULD probe 6313 via a RENEW call. 6315 NFS4ERR_NO_GRACE: 6317 The current lock has been revoked during the partition and the 6318 server rebooted. The server might have no information on the 6319 other locks. They may still be renewable. 6321 NFS4ERR_OLD_STATEID: 6323 The server has not rebooted. The client SHOULD handle this error 6324 as it normally would. 6326 9.7. Recovery from a Lock Request Timeout or Abort 6328 In the event a lock request times out, a client may decide to not 6329 retry the request. The client may also abort the request when the 6330 process for which it was issued is terminated (e.g., in UNIX due to a 6331 signal). It is possible though that the server received the request 6332 and acted upon it. This would change the state on the server without 6333 the client being aware of the change. It is paramount that the 6334 client re-synchronize state with server before it attempts any other 6335 operation that takes a seqid and/or a stateid with the same state- 6336 owner. This is straightforward to do without a special re- 6337 synchronize operation. 6339 Since the server maintains the last lock request and response 6340 received on the state-owner, for each state-owner, the client should 6341 cache the last lock request it sent such that the lock request did 6342 not receive a response. From this, the next time the client does a 6343 lock operation for the state-owner, it can send the cached request, 6344 if there is one, and if the request was one that established state 6345 (e.g., a LOCK or OPEN operation), the server will return the cached 6346 result or if never saw the request, perform it. The client can 6347 follow up with a request to remove the state (e.g., a LOCKU or CLOSE 6348 operation). With this approach, the sequencing and stateid 6349 information on the client and server for the given state-owner will 6350 re-synchronize and in turn the lock state will re-synchronize. 6352 9.8. Server Revocation of Locks 6354 At any point, the server can revoke locks held by a client and the 6355 client must be prepared for this event. When the client detects that 6356 its locks have been or may have been revoked, the client is 6357 responsible for validating the state information between itself and 6358 the server. Validating locking state for the client means that it 6359 must verify or reclaim state for each lock currently held. 6361 The first instance of lock revocation is upon server reboot or re- 6362 initialization. In this instance the client will receive an error 6363 (NFS4ERR_STALE_STATEID or NFS4ERR_STALE_CLIENTID) and the client will 6364 proceed with normal crash recovery as described in the previous 6365 section. 6367 The second lock revocation event is the inability to renew the lease 6368 before expiration. While this is considered a rare or unusual event, 6369 the client must be prepared to recover. Both the server and client 6370 will be able to detect the failure to renew the lease and are capable 6371 of recovering without data corruption. For the server, it tracks the 6372 last renewal event serviced for the client and knows when the lease 6373 will expire. Similarly, the client must track operations which will 6374 renew the lease period. Using the time that each such request was 6375 sent and the time that the corresponding reply was received, the 6376 client should bound the time that the corresponding renewal could 6377 have occurred on the server and thus determine if it is possible that 6378 a lease period expiration could have occurred. 6380 The third lock revocation event can occur as a result of 6381 administrative intervention within the lease period. While this is 6382 considered a rare event, it is possible that the server's 6383 administrator has decided to release or revoke a particular lock held 6384 by the client. As a result of revocation, the client will receive an 6385 error of NFS4ERR_ADMIN_REVOKED. In this instance the client may 6386 assume that only the state-owner's locks have been lost. The client 6387 notifies the lock holder appropriately. The client may not assume 6388 the lease period has been renewed as a result of a failed operation. 6390 When the client determines the lease period may have expired, the 6391 client must mark all locks held for the associated lease as 6392 "unvalidated". This means the client has been unable to re-establish 6393 or confirm the appropriate lock state with the server. As described 6394 in Section 9.6, there are scenarios in which the server may grant 6395 conflicting locks after the lease period has expired for a client. 6396 When it is possible that the lease period has expired, the client 6397 must validate each lock currently held to ensure that a conflicting 6398 lock has not been granted. The client may accomplish this task by 6399 issuing an I/O request, either a pending I/O or a zero-length read, 6400 specifying the stateid associated with the lock in question. If the 6401 response to the request is success, the client has validated all of 6402 the locks governed by that stateid and re-established the appropriate 6403 state between itself and the server. 6405 If the I/O request is not successful, then one or more of the locks 6406 associated with the stateid was revoked by the server and the client 6407 must notify the owner. 6409 9.9. Share Reservations 6411 A share reservation is a mechanism to control access to a file. It 6412 is a separate and independent mechanism from byte-range locking. 6413 When a client opens a file, it issues an OPEN operation to the server 6414 specifying the type of access required (READ, WRITE, or BOTH) and the 6415 type of access to deny others (OPEN4_SHARE_DENY_NONE, 6416 OPEN4_SHARE_DENY_READ, OPEN4_SHARE_DENY_WRITE, or 6417 OPEN4_SHARE_DENY_BOTH). If the OPEN fails the client will fail the 6418 application's open request. 6420 Pseudo-code definition of the semantics: 6422 if (request.access == 0) 6423 return (NFS4ERR_INVAL) 6424 else if ((request.access & file_state.deny)) || 6425 (request.deny & file_state.access)) 6426 return (NFS4ERR_DENIED) 6428 This checking of share reservations on OPEN is done with no exception 6429 for an existing OPEN for the same open-owner. 6431 The constants used for the OPEN and OPEN_DOWNGRADE operations for the 6432 access and deny fields are as follows: 6434 const OPEN4_SHARE_ACCESS_READ = 0x00000001; 6435 const OPEN4_SHARE_ACCESS_WRITE = 0x00000002; 6436 const OPEN4_SHARE_ACCESS_BOTH = 0x00000003; 6438 const OPEN4_SHARE_DENY_NONE = 0x00000000; 6439 const OPEN4_SHARE_DENY_READ = 0x00000001; 6440 const OPEN4_SHARE_DENY_WRITE = 0x00000002; 6441 const OPEN4_SHARE_DENY_BOTH = 0x00000003; 6443 9.10. OPEN/CLOSE Operations 6445 To provide correct share semantics, a client MUST use the OPEN 6446 operation to obtain the initial filehandle and indicate the desired 6447 access and what access, if any, to deny. Even if the client intends 6448 to use a stateid of all 0's or all 1's, it must still obtain the 6449 filehandle for the regular file with the OPEN operation so the 6450 appropriate share semantics can be applied. Clients that do not have 6451 a deny mode built into their programming interfaces for opening a 6452 file should request a deny mode of OPEN4_SHARE_DENY_NONE. 6454 The OPEN operation with the CREATE flag, also subsumes the CREATE 6455 operation for regular files as used in previous versions of the NFS 6456 protocol. This allows a create with a share to be done atomically. 6458 The CLOSE operation removes all share reservations held by the open- 6459 owner on that file. If byte-range locks are held, the client SHOULD 6460 release all locks before issuing a CLOSE. The server MAY free all 6461 outstanding locks on CLOSE but some servers may not support the CLOSE 6462 of a file that still has byte-range locks held. The server MUST 6463 return failure, NFS4ERR_LOCKS_HELD, if any locks would exist after 6464 the CLOSE. 6466 The LOOKUP operation will return a filehandle without establishing 6467 any lock state on the server. Without a valid stateid, the server 6468 will assume the client has the least access. For example, if one 6469 client opened a file with OPEN4_SHARE_DENY_BOTH and another client 6470 accesses the file via a filehandle obtained through LOOKUP, the 6471 second client could only read the file using the special read bypass 6472 stateid. The second client could not WRITE the file at all because 6473 it would not have a valid stateid from OPEN and the special anonymous 6474 stateid would not be allowed access. 6476 9.10.1. Close and Retention of State Information 6478 Since a CLOSE operation requests deallocation of a stateid, dealing 6479 with retransmission of the CLOSE, may pose special difficulties, 6480 since the state information, which normally would be used to 6481 determine the state of the open file being designated, might be 6482 deallocated, resulting in an NFS4ERR_BAD_STATEID error. 6484 Servers may deal with this problem in a number of ways. To provide 6485 the greatest degree assurance that the protocol is being used 6486 properly, a server should, rather than deallocate the stateid, mark 6487 it as close-pending, and retain the stateid with this status, until 6488 later deallocation. In this way, a retransmitted CLOSE can be 6489 recognized since the stateid points to state information with this 6490 distinctive status, so that it can be handled without error. 6492 When adopting this strategy, a server should retain the state 6493 information until the earliest of: 6495 o Another validly sequenced request for the same lockowner, that is 6496 not a retransmission. 6498 o The time that a lockowner is freed by the server due to period 6499 with no activity. 6501 o All locks for the client are freed as a result of a SETCLIENTID. 6503 Servers may avoid this complexity, at the cost of less complete 6504 protocol error checking, by simply responding NFS4_OK in the event of 6505 a CLOSE for a deallocated stateid, on the assumption that this case 6506 must be caused by a retransmitted close. When adopting this 6507 approach, it is desirable to at least log an error when returning a 6508 no-error indication in this situation. If the server maintains a 6509 reply-cache mechanism, it can verify the CLOSE is indeed a 6510 retransmission and avoid error logging in most cases. 6512 9.11. Open Upgrade and Downgrade 6514 When an OPEN is done for a file and the lockowner for which the open 6515 is being done already has the file open, the result is to upgrade the 6516 open file status maintained on the server to include the access and 6517 deny bits specified by the new OPEN as well as those for the existing 6518 OPEN. The result is that there is one open file, as far as the 6519 protocol is concerned, and it includes the union of the access and 6520 deny bits for all of the OPEN requests completed. Only a single 6521 CLOSE will be done to reset the effects of both OPENs. Note that the 6522 client, when issuing the OPEN, may not know that the same file is in 6523 fact being opened. The above only applies if both OPENs result in 6524 the OPENed object being designated by the same filehandle. 6526 When the server chooses to export multiple filehandles corresponding 6527 to the same file object and returns different filehandles on two 6528 different OPENs of the same file object, the server MUST NOT "OR" 6529 together the access and deny bits and coalesce the two open files. 6530 Instead the server must maintain separate OPENs with separate 6531 stateids and will require separate CLOSEs to free them. 6533 When multiple open files on the client are merged into a single open 6534 file object on the server, the close of one of the open files (on the 6535 client) may necessitate change of the access and deny status of the 6536 open file on the server. This is because the union of the access and 6537 deny bits for the remaining opens may be smaller (i.e., a proper 6538 subset) than previously. The OPEN_DOWNGRADE operation is used to 6539 make the necessary change and the client should use it to update the 6540 server so that share reservation requests by other clients are 6541 handled properly. The stateid returned has the same "other" field as 6542 that passed to the server. The "seqid" value in the returned stateid 6543 MUST be incremented, even in situations in which there is no change 6544 to the access and deny bits for the file. 6546 9.12. Short and Long Leases 6548 When determining the time period for the server lease, the usual 6549 lease tradeoffs apply. Short leases are good for fast server 6550 recovery at a cost of increased RENEW or READ (with zero length) 6551 requests. Longer leases are certainly kinder and gentler to servers 6552 trying to handle very large numbers of clients. The number of RENEW 6553 requests drop in proportion to the lease time. The disadvantages of 6554 long leases are slower recovery after server failure (the server must 6555 wait for the leases to expire and the grace period to elapse before 6556 granting new lock requests) and increased file contention (if client 6557 fails to transmit an unlock request then server must wait for lease 6558 expiration before granting new locks). 6560 Long leases are usable if the server is able to store lease state in 6561 non-volatile memory. Upon recovery, the server can reconstruct the 6562 lease state from its non-volatile memory and continue operation with 6563 its clients and therefore long leases would not be an issue. 6565 9.13. Clocks, Propagation Delay, and Calculating Lease Expiration 6567 To avoid the need for synchronized clocks, lease times are granted by 6568 the server as a time delta. However, there is a requirement that the 6569 client and server clocks do not drift excessively over the duration 6570 of the lock. There is also the issue of propagation delay across the 6571 network which could easily be several hundred milliseconds as well as 6572 the possibility that requests will be lost and need to be 6573 retransmitted. 6575 To take propagation delay into account, the client should subtract it 6576 from lease times (e.g., if the client estimates the one-way 6577 propagation delay as 200 msec, then it can assume that the lease is 6578 already 200 msec old when it gets it). In addition, it will take 6579 another 200 msec to get a response back to the server. So the client 6580 must send a lock renewal or write data back to the server 400 msec 6581 before the lease would expire. 6583 The server's lease period configuration should take into account the 6584 network distance of the clients that will be accessing the server's 6585 resources. It is expected that the lease period will take into 6586 account the network propagation delays and other network delay 6587 factors for the client population. Since the protocol does not allow 6588 for an automatic method to determine an appropriate lease period, the 6589 server's administrator may have to tune the lease period. 6591 9.14. Migration, Replication and State 6593 When responsibility for handling a given file system is transferred 6594 to a new server (migration) or the client chooses to use an alternate 6595 server (e.g., in response to server unresponsiveness) in the context 6596 of file system replication, the appropriate handling of state shared 6597 between the client and server (i.e., locks, leases, stateids, and 6598 client IDs) is as described below. The handling differs between 6599 migration and replication. For related discussion of file server 6600 state and recover of such see the sections under Section 9.6. 6602 If a server replica or a server immigrating a filesystem agrees to, 6603 or is expected to, accept opaque values from the client that 6604 originated from another server, then it is a wise implementation 6605 practice for the servers to encode the "opaque" values in network 6606 byte order. This way, servers acting as replicas or immigrating 6607 filesystems will be able to parse values like stateids, directory 6608 cookies, filehandles, etc. even if their native byte order is 6609 different from other servers cooperating in the replication and 6610 migration of the filesystem. 6612 9.14.1. Migration and State 6614 In the case of migration, the servers involved in the migration of a 6615 filesystem SHOULD transfer all server state from the original to the 6616 new server. This must be done in a way that is transparent to the 6617 client. This state transfer will ease the client's transition when a 6618 filesystem migration occurs. If the servers are successful in 6619 transferring all state, the client will continue to use stateids 6620 assigned by the original server. Therefore the new server must 6621 recognize these stateids as valid. This holds true for the client ID 6622 as well. Since responsibility for an entire filesystem is 6623 transferred with a migration event, there is no possibility that 6624 conflicts will arise on the new server as a result of the transfer of 6625 locks. 6627 As part of the transfer of information between servers, leases would 6628 be transferred as well. The leases being transferred to the new 6629 server will typically have a different expiration time from those for 6630 the same client, previously on the old server. To maintain the 6631 property that all leases on a given server for a given client expire 6632 at the same time, the server should advance the expiration time to 6633 the later of the leases being transferred or the leases already 6634 present. This allows the client to maintain lease renewal of both 6635 classes without special effort. 6637 The servers may choose not to transfer the state information upon 6638 migration. However, this choice is discouraged. In this case, when 6639 the client presents state information from the original server (e.g., 6640 in a RENEW op or a READ op of zero length), the client must be 6641 prepared to receive either NFS4ERR_STALE_CLIENTID or 6642 NFS4ERR_STALE_STATEID from the new server. The client should then 6643 recover its state information as it normally would in response to a 6644 server failure. The new server must take care to allow for the 6645 recovery of state information as it would in the event of server 6646 restart. 6648 A client SHOULD re-establish new callback information with the new 6649 server as soon as possible, according to sequences described in 6650 Section 15.35 and Section 15.36. This ensures that server operations 6651 are not blocked by the inability to recall delegations. 6653 9.14.2. Replication and State 6655 Since client switch-over in the case of replication is not under 6656 server control, the handling of state is different. In this case, 6657 leases, stateids and client IDs do not have validity across a 6658 transition from one server to another. The client must re-establish 6659 its locks on the new server. This can be compared to the re- 6660 establishment of locks by means of reclaim-type requests after a 6661 server reboot. The difference is that the server has no provision to 6662 distinguish requests reclaiming locks from those obtaining new locks 6663 or to defer the latter. Thus, a client re-establishing a lock on the 6664 new server (by means of a LOCK or OPEN request), may have the 6665 requests denied due to a conflicting lock. Since replication is 6666 intended for read-only use of filesystems, such denial of locks 6667 should not pose large difficulties in practice. When an attempt to 6668 re-establish a lock on a new server is denied, the client should 6669 treat the situation as if his original lock had been revoked. 6671 9.14.3. Notification of Migrated Lease 6673 In the case of lease renewal, the client may not be submitting 6674 requests for a filesystem that has been migrated to another server. 6675 This can occur because of the implicit lease renewal mechanism. The 6676 client renews leases for all filesystems when submitting a request to 6677 any one filesystem at the server. 6679 In order for the client to schedule renewal of leases that may have 6680 been relocated to the new server, the client must find out about 6681 lease relocation before those leases expire. To accomplish this, all 6682 operations which implicitly renew leases for a client (such as OPEN, 6683 CLOSE, READ, WRITE, RENEW, LOCK, and others), will return the error 6684 NFS4ERR_LEASE_MOVED if responsibility for any of the leases to be 6685 renewed has been transferred to a new server. This condition will 6686 continue until the client receives an NFS4ERR_MOVED error and the 6687 server receives the subsequent GETATTR(fs_locations) for an access to 6688 each filesystem for which a lease has been moved to a new server. By 6689 convention, the compound including the GETATTR(fs_locations) SHOULD 6690 append a RENEW operation to permit the server to identify the client 6691 doing the access. 6693 Upon receiving the NFS4ERR_LEASE_MOVED error, a client that supports 6694 filesystem migration MUST probe all filesystems from that server on 6695 which it holds open state. Once the client has successfully probed 6696 all those filesystems which are migrated, the server MUST resume 6697 normal handling of stateful requests from that client. 6699 In order to support legacy clients that do not handle the 6700 NFS4ERR_LEASE_MOVED error correctly, the server SHOULD time out after 6701 a wait of at least two lease periods, at which time it will resume 6702 normal handling of stateful requests from all clients. If a client 6703 attempts to access the migrated files, the server MUST reply 6704 NFS4ERR_MOVED. 6706 When the client receives an NFS4ERR_MOVED error, the client can 6707 follow the normal process to obtain the new server information 6708 (through the fs_locations attribute) and perform renewal of those 6709 leases on the new server. If the server has not had state 6710 transferred to it transparently, the client will receive either 6711 NFS4ERR_STALE_CLIENTID or NFS4ERR_STALE_STATEID from the new server, 6712 as described above. The client can then recover state information as 6713 it does in the event of server failure. 6715 9.14.4. Migration and the Lease_time Attribute 6717 In order that the client may appropriately manage its leases in the 6718 case of migration, the destination server must establish proper 6719 values for the lease_time attribute. 6721 When state is transferred transparently, that state should include 6722 the correct value of the lease_time attribute. The lease_time 6723 attribute on the destination server must never be less than that on 6724 the source since this would result in premature expiration of leases 6725 granted by the source server. Upon migration in which state is 6726 transferred transparently, the client is under no obligation to re- 6727 fetch the lease_time attribute and may continue to use the value 6728 previously fetched (on the source server). 6730 If state has not been transferred transparently (i.e., the client 6731 sees a real or simulated server reboot), the client should fetch the 6732 value of lease_time on the new (i.e., destination) server, and use it 6733 for subsequent locking requests. However the server must respect a 6734 grace period at least as long as the lease_time on the source server, 6735 in order to ensure that clients have ample time to reclaim their 6736 locks before potentially conflicting non-reclaimed locks are granted. 6737 The means by which the new server obtains the value of lease_time on 6738 the old server is left to the server implementations. It is not 6739 specified by the NFS version 4 protocol. 6741 10. Client-Side Caching 6743 Client-side caching of data, of file attributes, and of file names is 6744 essential to providing good performance with the NFS protocol. 6745 Providing distributed cache coherence is a difficult problem and 6746 previous versions of the NFS protocol have not attempted it. 6747 Instead, several NFS client implementation techniques have been used 6748 to reduce the problems that a lack of coherence poses for users. 6749 These techniques have not been clearly defined by earlier protocol 6750 specifications and it is often unclear what is valid or invalid 6751 client behavior. 6753 The NFSv4 protocol uses many techniques similar to those that have 6754 been used in previous protocol versions. The NFSv4 protocol does not 6755 provide distributed cache coherence. However, it defines a more 6756 limited set of caching guarantees to allow locks and share 6757 reservations to be used without destructive interference from client 6758 side caching. 6760 In addition, the NFSv4 protocol introduces a delegation mechanism 6761 which allows many decisions normally made by the server to be made 6762 locally by clients. This mechanism provides efficient support of the 6763 common cases where sharing is infrequent or where sharing is read- 6764 only. 6766 10.1. Performance Challenges for Client-Side Caching 6768 Caching techniques used in previous versions of the NFS protocol have 6769 been successful in providing good performance. However, several 6770 scalability challenges can arise when those techniques are used with 6771 very large numbers of clients. This is particularly true when 6772 clients are geographically distributed which classically increases 6773 the latency for cache re-validation requests. 6775 The previous versions of the NFS protocol repeat their file data 6776 cache validation requests at the time the file is opened. This 6777 behavior can have serious performance drawbacks. A common case is 6778 one in which a file is only accessed by a single client. Therefore, 6779 sharing is infrequent. 6781 In this case, repeated reference to the server to find that no 6782 conflicts exist is expensive. A better option with regards to 6783 performance is to allow a client that repeatedly opens a file to do 6784 so without reference to the server. This is done until potentially 6785 conflicting operations from another client actually occur. 6787 A similar situation arises in connection with file locking. Sending 6788 file lock and unlock requests to the server as well as the read and 6789 write requests necessary to make data caching consistent with the 6790 locking semantics (see Section 10.3.2) can severely limit 6791 performance. When locking is used to provide protection against 6792 infrequent conflicts, a large penalty is incurred. This penalty may 6793 discourage the use of file locking by applications. 6795 The NFSv4 protocol provides more aggressive caching strategies with 6796 the following design goals: 6798 o Compatibility with a large range of server semantics. 6800 o Provide the same caching benefits as previous versions of the NFS 6801 protocol when unable to provide the more aggressive model. 6803 o Requirements for aggressive caching are organized so that a large 6804 portion of the benefit can be obtained even when not all of the 6805 requirements can be met. 6807 The appropriate requirements for the server are discussed in later 6808 sections in which specific forms of caching are covered (see 6809 Section 10.4). 6811 10.2. Delegation and Callbacks 6813 Recallable delegation of server responsibilities for a file to a 6814 client improves performance by avoiding repeated requests to the 6815 server in the absence of inter-client conflict. With the use of a 6816 "callback" RPC from server to client, a server recalls delegated 6817 responsibilities when another client engages in sharing of a 6818 delegated file. 6820 A delegation is passed from the server to the client, specifying the 6821 object of the delegation and the type of delegation. There are 6822 different types of delegations but each type contains a stateid to be 6823 used to represent the delegation when performing operations that 6824 depend on the delegation. This stateid is similar to those 6825 associated with locks and share reservations but differs in that the 6826 stateid for a delegation is associated with a client ID and may be 6827 used on behalf of all the open-owners for the given client. A 6828 delegation is made to the client as a whole and not to any specific 6829 process or thread of control within it. 6831 Because callback RPCs may not work in all environments (due to 6832 firewalls, for example), correct protocol operation does not depend 6833 on them. Preliminary testing of callback functionality by means of a 6834 CB_NULL procedure determines whether callbacks can be supported. The 6835 CB_NULL procedure checks the continuity of the callback path. A 6836 server makes a preliminary assessment of callback availability to a 6837 given client and avoids delegating responsibilities until it has 6838 determined that callbacks are supported. Because the granting of a 6839 delegation is always conditional upon the absence of conflicting 6840 access, clients must not assume that a delegation will be granted and 6841 they must always be prepared for OPENs to be processed without any 6842 delegations being granted. 6844 Once granted, a delegation behaves in most ways like a lock. There 6845 is an associated lease that is subject to renewal together with all 6846 of the other leases held by that client. 6848 Unlike locks, an operation by a second client to a delegated file 6849 will cause the server to recall a delegation through a callback. 6851 On recall, the client holding the delegation must flush modified 6852 state (such as modified data) to the server and return the 6853 delegation. The conflicting request will not be acted on until the 6854 recall is complete. The recall is considered complete when the 6855 client returns the delegation or the server times its wait for the 6856 delegation to be returned and revokes the delegation as a result of 6857 the timeout. In the interim, the server will either delay responding 6858 to conflicting requests or respond to them with NFS4ERR_DELAY. 6860 Following the resolution of the recall, the server has the 6861 information necessary to grant or deny the second client's request. 6863 At the time the client receives a delegation recall, it may have 6864 substantial state that needs to be flushed to the server. Therefore, 6865 the server should allow sufficient time for the delegation to be 6866 returned since it may involve numerous RPCs to the server. If the 6867 server is able to determine that the client is diligently flushing 6868 state to the server as a result of the recall, the server may extend 6869 the usual time allowed for a recall. However, the time allowed for 6870 recall completion should not be unbounded. 6872 An example of this is when responsibility to mediate opens on a given 6873 file is delegated to a client (see Section 10.4). The server will 6874 not know what opens are in effect on the client. Without this 6875 knowledge the server will be unable to determine if the access and 6876 deny state for the file allows any particular open until the 6877 delegation for the file has been returned. 6879 A client failure or a network partition can result in failure to 6880 respond to a recall callback. In this case, the server will revoke 6881 the delegation which in turn will render useless any modified state 6882 still on the client. 6884 Clients need to be aware that server implementors may enforce 6885 practical limitations on the number of delegations issued. Further, 6886 as there is no way to determine which delegations to revoke, the 6887 server is allowed to revoke any. If the server is implemented to 6888 revoke another delegation held by that client, then the client may be 6889 able to determine that a limit has been reached because each new 6890 delegation request results in a revoke. The client could then 6891 determine which delegations it may not need and preemptively release 6892 them. 6894 10.2.1. Delegation Recovery 6896 There are three situations that delegation recovery must deal with: 6898 o Client reboot or restart 6900 o Server reboot or restart 6902 o Network partition (full or callback-only) 6904 In the event the client reboots or restarts, the failure to renew 6905 leases will result in the revocation of byte-range locks and share 6906 reservations. Delegations, however, may be treated a bit 6907 differently. 6909 There will be situations in which delegations will need to be 6910 reestablished after a client reboots or restarts. The reason for 6911 this is the client may have file data stored locally and this data 6912 was associated with the previously held delegations. The client will 6913 need to reestablish the appropriate file state on the server. 6915 To allow for this type of client recovery, the server MAY extend the 6916 period for delegation recovery beyond the typical lease expiration 6917 period. This implies that requests from other clients that conflict 6918 with these delegations will need to wait. Because the normal recall 6919 process may require significant time for the client to flush changed 6920 state to the server, other clients need be prepared for delays that 6921 occur because of a conflicting delegation. This longer interval 6922 would increase the window for clients to reboot and consult stable 6923 storage so that the delegations can be reclaimed. For open 6924 delegations, such delegations are reclaimed using OPEN with a claim 6925 type of CLAIM_DELEGATE_PREV. (See Section 10.5 and Section 15.18 for 6926 discussion of open delegation and the details of OPEN respectively). 6928 A server MAY support a claim type of CLAIM_DELEGATE_PREV, but if it 6929 does, it MUST NOT remove delegations upon SETCLIENTID_CONFIRM, and 6930 instead MUST, for a period of time no less than that of the value of 6931 the lease_time attribute, maintain the client's delegations to allow 6932 time for the client to issue CLAIM_DELEGATE_PREV requests. The 6933 server that supports CLAIM_DELEGATE_PREV MUST support the DELEGPURGE 6934 operation. 6936 When the server reboots or restarts, delegations are reclaimed (using 6937 the OPEN operation with CLAIM_PREVIOUS) in a similar fashion to byte- 6938 range locks and share reservations. However, there is a slight 6939 semantic difference. In the normal case if the server decides that a 6940 delegation should not be granted, it performs the requested action 6941 (e.g., OPEN) without granting any delegation. For reclaim, the 6942 server grants the delegation but a special designation is applied so 6943 that the client treats the delegation as having been granted but 6944 recalled by the server. Because of this, the client has the duty to 6945 write all modified state to the server and then return the 6946 delegation. This process of handling delegation reclaim reconciles 6947 three principles of the NFSv4 protocol: 6949 o Upon reclaim, a client reporting resources assigned to it by an 6950 earlier server instance must be granted those resources. 6952 o The server has unquestionable authority to determine whether 6953 delegations are to be granted and, once granted, whether they are 6954 to be continued. 6956 o The use of callbacks is not to be depended upon until the client 6957 has proven its ability to receive them. 6959 When a client has more than a single open associated with a 6960 delegation, state for those additional opens can be established using 6961 OPEN operations of type CLAIM_DELEGATE_CUR. When these are used to 6962 establish opens associated with reclaimed delegations, the server 6963 MUST allow them when made within the grace period. 6965 When a network partition occurs, delegations are subject to freeing 6966 by the server when the lease renewal period expires. This is similar 6967 to the behavior for locks and share reservations. For delegations, 6968 however, the server may extend the period in which conflicting 6969 requests are held off. Eventually the occurrence of a conflicting 6970 request from another client will cause revocation of the delegation. 6971 A loss of the callback path (e.g., by later network configuration 6972 change) will have the same effect. A recall request will fail and 6973 revocation of the delegation will result. 6975 A client normally finds out about revocation of a delegation when it 6976 uses a stateid associated with a delegation and receives the error 6977 NFS4ERR_EXPIRED. It also may find out about delegation revocation 6978 after a client reboot when it attempts to reclaim a delegation and 6979 receives that same error. Note that in the case of a revoked 6980 OPEN_DELEGATE_WRITE delegation, there are issues because data may 6981 have been modified by the client whose delegation is revoked and 6982 separately by other clients. See Section 10.5.1 for a discussion of 6983 such issues. Note also that when delegations are revoked, 6984 information about the revoked delegation will be written by the 6985 server to stable storage (as described in Section 9.6). This is done 6986 to deal with the case in which a server reboots after revoking a 6987 delegation but before the client holding the revoked delegation is 6988 notified about the revocation. 6990 10.3. Data Caching 6992 When applications share access to a set of files, they need to be 6993 implemented so as to take account of the possibility of conflicting 6994 access by another application. This is true whether the applications 6995 in question execute on different clients or reside on the same 6996 client. 6998 Share reservations and byte-range locks are the facilities the NFS 6999 version 4 protocol provides to allow applications to coordinate 7000 access by providing mutual exclusion facilities. The NFSv4 7001 protocol's data caching must be implemented such that it does not 7002 invalidate the assumptions that those using these facilities depend 7003 upon. 7005 10.3.1. Data Caching and OPENs 7007 In order to avoid invalidating the sharing assumptions that 7008 applications rely on, NFSv4 clients should not provide cached data to 7009 applications or modify it on behalf of an application when it would 7010 not be valid to obtain or modify that same data via a READ or WRITE 7011 operation. 7013 Furthermore, in the absence of open delegation (see Section 10.4) two 7014 additional rules apply. Note that these rules are obeyed in practice 7015 by many NFSv2 and NFSv3 clients. 7017 o First, cached data present on a client must be revalidated after 7018 doing an OPEN. Revalidating means that the client fetches the 7019 change attribute from the server, compares it with the cached 7020 change attribute, and if different, declares the cached data (as 7021 well as the cached attributes) as invalid. This is to ensure that 7022 the data for the OPENed file is still correctly reflected in the 7023 client's cache. This validation must be done at least when the 7024 client's OPEN operation includes DENY=WRITE or BOTH thus 7025 terminating a period in which other clients may have had the 7026 opportunity to open the file with WRITE access. Clients may 7027 choose to do the revalidation more often (i.e., at OPENs 7028 specifying DENY=NONE) to parallel the NFSv3 protocol's practice 7029 for the benefit of users assuming this degree of cache 7030 revalidation. Since the change attribute is updated for data and 7031 metadata modifications, some client implementors may be tempted to 7032 use the time_modify attribute and not change to validate cached 7033 data, so that metadata changes do not spuriously invalidate clean 7034 data. The implementor is cautioned in this approach. The change 7035 attribute is guaranteed to change for each update to the file, 7036 whereas time_modify is guaranteed to change only at the 7037 granularity of the time_delta attribute. Use by the client's data 7038 cache validation logic of time_modify and not change runs the risk 7039 of the client incorrectly marking stale data as valid. 7041 o Second, modified data must be flushed to the server before closing 7042 a file OPENed for write. This is complementary to the first rule. 7043 If the data is not flushed at CLOSE, the revalidation done after 7044 client OPENs as file is unable to achieve its purpose. The other 7045 aspect to flushing the data before close is that the data must be 7046 committed to stable storage, at the server, before the CLOSE 7047 operation is requested by the client. In the case of a server 7048 reboot or restart and a CLOSEd file, it may not be possible to 7049 retransmit the data to be written to the file. Hence, this 7050 requirement. 7052 10.3.2. Data Caching and File Locking 7054 For those applications that choose to use file locking instead of 7055 share reservations to exclude inconsistent file access, there is an 7056 analogous set of constraints that apply to client side data caching. 7057 These rules are effective only if the file locking is used in a way 7058 that matches in an equivalent way the actual READ and WRITE 7059 operations executed. This is as opposed to file locking that is 7060 based on pure convention. For example, it is possible to manipulate 7061 a two-megabyte file by dividing the file into two one-megabyte 7062 regions and protecting access to the two regions by file locks on 7063 bytes zero and one. A lock for write on byte zero of the file would 7064 represent the right to do READ and WRITE operations on the first 7065 region. A lock for write on byte one of the file would represent the 7066 right to do READ and WRITE operations on the second region. As long 7067 as all applications manipulating the file obey this convention, they 7068 will work on a local filesystem. However, they may not work with the 7069 NFSv4 protocol unless clients refrain from data caching. 7071 The rules for data caching in the file locking environment are: 7073 o First, when a client obtains a file lock for a particular region, 7074 the data cache corresponding to that region (if any cached data 7075 exists) must be revalidated. If the change attribute indicates 7076 that the file may have been updated since the cached data was 7077 obtained, the client must flush or invalidate the cached data for 7078 the newly locked region. A client might choose to invalidate all 7079 of non-modified cached data that it has for the file but the only 7080 requirement for correct operation is to invalidate all of the data 7081 in the newly locked region. 7083 o Second, before releasing a write lock for a region, all modified 7084 data for that region must be flushed to the server. The modified 7085 data must also be written to stable storage. 7087 Note that flushing data to the server and the invalidation of cached 7088 data must reflect the actual byte ranges locked or unlocked. 7089 Rounding these up or down to reflect client cache block boundaries 7090 will cause problems if not carefully done. For example, writing a 7091 modified block when only half of that block is within an area being 7092 unlocked may cause invalid modification to the region outside the 7093 unlocked area. This, in turn, may be part of a region locked by 7094 another client. Clients can avoid this situation by synchronously 7095 performing portions of write operations that overlap that portion 7096 (initial or final) that is not a full block. Similarly, invalidating 7097 a locked area which is not an integral number of full buffer blocks 7098 would require the client to read one or two partial blocks from the 7099 server if the revalidation procedure shows that the data which the 7100 client possesses may not be valid. 7102 The data that is written to the server as a prerequisite to the 7103 unlocking of a region must be written, at the server, to stable 7104 storage. The client may accomplish this either with synchronous 7105 writes or by following asynchronous writes with a COMMIT operation. 7106 This is required because retransmission of the modified data after a 7107 server reboot might conflict with a lock held by another client. 7109 A client implementation may choose to accommodate applications which 7110 use byte-range locking in non-standard ways (e.g., using a byte-range 7111 lock as a global semaphore) by flushing to the server more data upon 7112 a LOCKU than is covered by the locked range. This may include 7113 modified data within files other than the one for which the unlocks 7114 are being done. In such cases, the client must not interfere with 7115 applications whose READs and WRITEs are being done only within the 7116 bounds of record locks which the application holds. For example, an 7117 application locks a single byte of a file and proceeds to write that 7118 single byte. A client that chose to handle a LOCKU by flushing all 7119 modified data to the server could validly write that single byte in 7120 response to an unrelated unlock. However, it would not be valid to 7121 write the entire block in which that single written byte was located 7122 since it includes an area that is not locked and might be locked by 7123 another client. Client implementations can avoid this problem by 7124 dividing files with modified data into those for which all 7125 modifications are done to areas covered by an appropriate byte-range 7126 lock and those for which there are modifications not covered by a 7127 byte-range lock. Any writes done for the former class of files must 7128 not include areas not locked and thus not modified on the client. 7130 10.3.3. Data Caching and Mandatory File Locking 7132 Client side data caching needs to respect mandatory file locking when 7133 it is in effect. The presence of mandatory file locking for a given 7134 file is indicated when the client gets back NFS4ERR_LOCKED from a 7135 READ or WRITE on a file it has an appropriate share reservation for. 7136 When mandatory locking is in effect for a file, the client must check 7137 for an appropriate file lock for data being read or written. If a 7138 lock exists for the range being read or written, the client may 7139 satisfy the request using the client's validated cache. If an 7140 appropriate file lock is not held for the range of the read or write, 7141 the read or write request must not be satisfied by the client's cache 7142 and the request must be sent to the server for processing. When a 7143 read or write request partially overlaps a locked region, the request 7144 should be subdivided into multiple pieces with each region (locked or 7145 not) treated appropriately. 7147 10.3.4. Data Caching and File Identity 7149 When clients cache data, the file data needs to be organized 7150 according to the filesystem object to which the data belongs. For 7151 NFSv3 clients, the typical practice has been to assume for the 7152 purpose of caching that distinct filehandles represent distinct 7153 filesystem objects. The client then has the choice to organize and 7154 maintain the data cache on this basis. 7156 In the NFSv4 protocol, there is now the possibility to have 7157 significant deviations from a "one filehandle per object" model 7158 because a filehandle may be constructed on the basis of the object's 7159 pathname. Therefore, clients need a reliable method to determine if 7160 two filehandles designate the same filesystem object. If clients 7161 were simply to assume that all distinct filehandles denote distinct 7162 objects and proceed to do data caching on this basis, caching 7163 inconsistencies would arise between the distinct client side objects 7164 which mapped to the same server side object. 7166 By providing a method to differentiate filehandles, the NFSv4 7167 protocol alleviates a potential functional regression in comparison 7168 with the NFSv3 protocol. Without this method, caching 7169 inconsistencies within the same client could occur and this has not 7170 been present in previous versions of the NFS protocol. Note that it 7171 is possible to have such inconsistencies with applications executing 7172 on multiple clients but that is not the issue being addressed here. 7174 For the purposes of data caching, the following steps allow an NFSv4 7175 client to determine whether two distinct filehandles denote the same 7176 server side object: 7178 o If GETATTR directed to two filehandles returns different values of 7179 the fsid attribute, then the filehandles represent distinct 7180 objects. 7182 o If GETATTR for any file with an fsid that matches the fsid of the 7183 two filehandles in question returns a unique_handles attribute 7184 with a value of TRUE, then the two objects are distinct. 7186 o If GETATTR directed to the two filehandles does not return the 7187 fileid attribute for both of the handles, then it cannot be 7188 determined whether the two objects are the same. Therefore, 7189 operations which depend on that knowledge (e.g., client side data 7190 caching) cannot be done reliably. Note that if GETATTR does not 7191 return the fileid attribute for both filehandles, it will return 7192 it for neither of the filehandles, since the fsid for both 7193 filehandles is the same. 7195 o If GETATTR directed to the two filehandles returns different 7196 values for the fileid attribute, then they are distinct objects. 7198 o Otherwise they are the same object. 7200 10.4. Open Delegation 7202 When a file is being OPENed, the server may delegate further handling 7203 of opens and closes for that file to the opening client. Any such 7204 delegation is recallable, since the circumstances that allowed for 7205 the delegation are subject to change. In particular, the server may 7206 receive a conflicting OPEN from another client, the server must 7207 recall the delegation before deciding whether the OPEN from the other 7208 client may be granted. Making a delegation is up to the server and 7209 clients should not assume that any particular OPEN either will or 7210 will not result in an open delegation. The following is a typical 7211 set of conditions that servers might use in deciding whether OPEN 7212 should be delegated: 7214 o The client must be able to respond to the server's callback 7215 requests. The server will use the CB_NULL procedure for a test of 7216 callback ability. 7218 o The client must have responded properly to previous recalls. 7220 o There must be no current open conflicting with the requested 7221 delegation. 7223 o There should be no current delegation that conflicts with the 7224 delegation being requested. 7226 o The probability of future conflicting open requests should be low 7227 based on the recent history of the file. 7229 o The existence of any server-specific semantics of OPEN/CLOSE that 7230 would make the required handling incompatible with the prescribed 7231 handling that the delegated client would apply (see below). 7233 There are two types of open delegations, OPEN_DELEGATE_READ and 7234 OPEN_DELEGATE_WRITE. A OPEN_DELEGATE_READ delegation allows a client 7235 to handle, on its own, requests to open a file for reading that do 7236 not deny read access to others. Multiple OPEN_DELEGATE_READ 7237 delegations may be outstanding simultaneously and do not conflict. A 7238 OPEN_DELEGATE_WRITE delegation allows the client to handle, on its 7239 own, all opens. Only one OPEN_DELEGATE_WRITE delegation may exist 7240 for a given file at a given time and it is inconsistent with any 7241 OPEN_DELEGATE_READ delegations. 7243 When a client has a OPEN_DELEGATE_READ delegation, it may not make 7244 any changes to the contents or attributes of the file but it is 7245 assured that no other client may do so. When a client has a 7246 OPEN_DELEGATE_WRITE delegation, it may modify the file data since no 7247 other client will be accessing the file's data. The client holding a 7248 OPEN_DELEGATE_WRITE delegation may only affect file attributes which 7249 are intimately connected with the file data: size, time_modify, 7250 change. 7252 When a client has an open delegation, it does not send OPENs or 7253 CLOSEs to the server but updates the appropriate status internally. 7254 For a OPEN_DELEGATE_READ delegation, opens that cannot be handled 7255 locally (opens for write or that deny read access) must be sent to 7256 the server. 7258 When an open delegation is made, the response to the OPEN contains an 7259 open delegation structure which specifies the following: 7261 o the type of delegation (read or write) 7263 o space limitation information to control flushing of data on close 7264 (OPEN_DELEGATE_WRITE delegation only, see Section 10.4.1) 7266 o an nfsace4 specifying read and write permissions 7268 o a stateid to represent the delegation for READ and WRITE 7270 The delegation stateid is separate and distinct from the stateid for 7271 the OPEN proper. The standard stateid, unlike the delegation 7272 stateid, is associated with a particular lock-owner and will continue 7273 to be valid after the delegation is recalled and the file remains 7274 open. 7276 When a request internal to the client is made to open a file and open 7277 delegation is in effect, it will be accepted or rejected solely on 7278 the basis of the following conditions. Any requirement for other 7279 checks to be made by the delegate should result in open delegation 7280 being denied so that the checks can be made by the server itself. 7282 o The access and deny bits for the request and the file as described 7283 in Section 9.9. 7285 o The read and write permissions as determined below. 7287 The nfsace4 passed with delegation can be used to avoid frequent 7288 ACCESS calls. The permission check should be as follows: 7290 o If the nfsace4 indicates that the open may be done, then it should 7291 be granted without reference to the server. 7293 o If the nfsace4 indicates that the open may not be done, then an 7294 ACCESS request must be sent to the server to obtain the definitive 7295 answer. 7297 The server may return an nfsace4 that is more restrictive than the 7298 actual ACL of the file. This includes an nfsace4 that specifies 7299 denial of all access. Note that some common practices such as 7300 mapping the traditional user "root" to the user "nobody" may make it 7301 incorrect to return the actual ACL of the file in the delegation 7302 response. 7304 The use of delegation together with various other forms of caching 7305 creates the possibility that no server authentication will ever be 7306 performed for a given user since all of the user's requests might be 7307 satisfied locally. Where the client is depending on the server for 7308 authentication, the client should be sure authentication occurs for 7309 each user by use of the ACCESS operation. This should be the case 7310 even if an ACCESS operation would not be required otherwise. As 7311 mentioned before, the server may enforce frequent authentication by 7312 returning an nfsace4 denying all access with every open delegation. 7314 10.4.1. Open Delegation and Data Caching 7316 OPEN delegation allows much of the message overhead associated with 7317 the opening and closing files to be eliminated. An open when an open 7318 delegation is in effect does not require that a validation message be 7319 sent to the server. The continued endurance of the 7320 "OPEN_DELEGATE_READ delegation" provides a guarantee that no OPEN for 7321 write and thus no write has occurred. Similarly, when closing a file 7322 opened for write and if OPEN_DELEGATE_WRITE delegation is in effect, 7323 the data written does not have to be flushed to the server until the 7324 open delegation is recalled. The continued endurance of the open 7325 delegation provides a guarantee that no open and thus no read or 7326 write has been done by another client. 7328 For the purposes of open delegation, READs and WRITEs done without an 7329 OPEN are treated as the functional equivalents of a corresponding 7330 type of OPEN. This refers to the READs and WRITEs that use the 7331 special stateids consisting of all zero bits or all one bits. 7332 Therefore, READs or WRITEs with a special stateid done by another 7333 client will force the server to recall a OPEN_DELEGATE_WRITE 7334 delegation. A WRITE with a special stateid done by another client 7335 will force a recall of OPEN_DELEGATE_READ delegations. 7337 With delegations, a client is able to avoid writing data to the 7338 server when the CLOSE of a file is serviced. The file close system 7339 call is the usual point at which the client is notified of a lack of 7340 stable storage for the modified file data generated by the 7341 application. At the close, file data is written to the server and 7342 through normal accounting the server is able to determine if the 7343 available filesystem space for the data has been exceeded (i.e., 7344 server returns NFS4ERR_NOSPC or NFS4ERR_DQUOT). This accounting 7345 includes quotas. The introduction of delegations requires that a 7346 alternative method be in place for the same type of communication to 7347 occur between client and server. 7349 In the delegation response, the server provides either the limit of 7350 the size of the file or the number of modified blocks and associated 7351 block size. The server must ensure that the client will be able to 7352 flush data to the server of a size equal to that provided in the 7353 original delegation. The server must make this assurance for all 7354 outstanding delegations. Therefore, the server must be careful in 7355 its management of available space for new or modified data taking 7356 into account available filesystem space and any applicable quotas. 7357 The server can recall delegations as a result of managing the 7358 available filesystem space. The client should abide by the server's 7359 state space limits for delegations. If the client exceeds the stated 7360 limits for the delegation, the server's behavior is undefined. 7362 Based on server conditions, quotas or available filesystem space, the 7363 server may grant OPEN_DELEGATE_WRITE delegations with very 7364 restrictive space limitations. The limitations may be defined in a 7365 way that will always force modified data to be flushed to the server 7366 on close. 7368 With respect to authentication, flushing modified data to the server 7369 after a CLOSE has occurred may be problematic. For example, the user 7370 of the application may have logged off the client and unexpired 7371 authentication credentials may not be present. In this case, the 7372 client may need to take special care to ensure that local unexpired 7373 credentials will in fact be available. This may be accomplished by 7374 tracking the expiration time of credentials and flushing data well in 7375 advance of their expiration or by making private copies of 7376 credentials to assure their availability when needed. 7378 10.4.2. Open Delegation and File Locks 7380 When a client holds a OPEN_DELEGATE_WRITE delegation, lock operations 7381 may be performed locally. This includes those required for mandatory 7382 file locking. This can be done since the delegation implies that 7383 there can be no conflicting locks. Similarly, all of the 7384 revalidations that would normally be associated with obtaining locks 7385 and the flushing of data associated with the releasing of locks need 7386 not be done. 7388 When a client holds a OPEN_DELEGATE_READ delegation, lock operations 7389 are not performed locally. All lock operations, including those 7390 requesting non-exclusive locks, are sent to the server for 7391 resolution. 7393 10.4.3. Handling of CB_GETATTR 7395 The server needs to employ special handling for a GETATTR where the 7396 target is a file that has a OPEN_DELEGATE_WRITE delegation in effect. 7397 The reason for this is that the client holding the 7398 OPEN_DELEGATE_WRITE delegation may have modified the data and the 7399 server needs to reflect this change to the second client that 7400 submitted the GETATTR. Therefore, the client holding the 7401 OPEN_DELEGATE_WRITE delegation needs to be interrogated. The server 7402 will use the CB_GETATTR operation. The only attributes that the 7403 server can reliably query via CB_GETATTR are size and change. 7405 Since CB_GETATTR is being used to satisfy another client's GETATTR 7406 request, the server only needs to know if the client holding the 7407 delegation has a modified version of the file. If the client's copy 7408 of the delegated file is not modified (data or size), the server can 7409 satisfy the second client's GETATTR request from the attributes 7410 stored locally at the server. If the file is modified, the server 7411 only needs to know about this modified state. If the server 7412 determines that the file is currently modified, it will respond to 7413 the second client's GETATTR as if the file had been modified locally 7414 at the server. 7416 Since the form of the change attribute is determined by the server 7417 and is opaque to the client, the client and server need to agree on a 7418 method of communicating the modified state of the file. For the size 7419 attribute, the client will report its current view of the file size. 7420 For the change attribute, the handling is more involved. 7422 For the client, the following steps will be taken when receiving a 7423 OPEN_DELEGATE_WRITE delegation: 7425 o The value of the change attribute will be obtained from the server 7426 and cached. Let this value be represented by c. 7428 o The client will create a value greater than c that will be used 7429 for communicating modified data is held at the client. Let this 7430 value be represented by d. 7432 o When the client is queried via CB_GETATTR for the change 7433 attribute, it checks to see if it holds modified data. If the 7434 file is modified, the value d is returned for the change attribute 7435 value. If this file is not currently modified, the client returns 7436 the value c for the change attribute. 7438 For simplicity of implementation, the client MAY for each CB_GETATTR 7439 return the same value d. This is true even if, between successive 7440 CB_GETATTR operations, the client again modifies in the file's data 7441 or metadata in its cache. The client can return the same value 7442 because the only requirement is that the client be able to indicate 7443 to the server that the client holds modified data. Therefore, the 7444 value of d may always be c + 1. 7446 While the change attribute is opaque to the client in the sense that 7447 it has no idea what units of time, if any, the server is counting 7448 change with, it is not opaque in that the client has to treat it as 7449 an unsigned integer, and the server has to be able to see the results 7450 of the client's changes to that integer. Therefore, the server MUST 7451 encode the change attribute in network order when sending it to the 7452 client. The client MUST decode it from network order to its native 7453 order when receiving it and the client MUST encode it network order 7454 when sending it to the server. For this reason, change is defined as 7455 an unsigned integer rather than an opaque array of bytes. 7457 For the server, the following steps will be taken when providing a 7458 OPEN_DELEGATE_WRITE delegation: 7460 o Upon providing a OPEN_DELEGATE_WRITE delegation, the server will 7461 cache a copy of the change attribute in the data structure it uses 7462 to record the delegation. Let this value be represented by sc. 7464 o When a second client sends a GETATTR operation on the same file to 7465 the server, the server obtains the change attribute from the first 7466 client. Let this value be cc. 7468 o If the value cc is equal to sc, the file is not modified and the 7469 server returns the current values for change, time_metadata, and 7470 time_modify (for example) to the second client. 7472 o If the value cc is NOT equal to sc, the file is currently modified 7473 at the first client and most likely will be modified at the server 7474 at a future time. The server then uses its current time to 7475 construct attribute values for time_metadata and time_modify. A 7476 new value of sc, which we will call nsc, is computed by the 7477 server, such that nsc >= sc + 1. The server then returns the 7478 constructed time_metadata, time_modify, and nsc values to the 7479 requester. The server replaces sc in the delegation record with 7480 nsc. To prevent the possibility of time_modify, time_metadata, 7481 and change from appearing to go backward (which would happen if 7482 the client holding the delegation fails to write its modified data 7483 to the server before the delegation is revoked or returned), the 7484 server SHOULD update the file's metadata record with the 7485 constructed attribute values. For reasons of reasonable 7486 performance, committing the constructed attribute values to stable 7487 storage is OPTIONAL. 7489 As discussed earlier in this section, the client MAY return the same 7490 cc value on subsequent CB_GETATTR calls, even if the file was 7491 modified in the client's cache yet again between successive 7492 CB_GETATTR calls. Therefore, the server must assume that the file 7493 has been modified yet again, and MUST take care to ensure that the 7494 new nsc it constructs and returns is greater than the previous nsc it 7495 returned. An example implementation's delegation record would 7496 satisfy this mandate by including a boolean field (let us call it 7497 "modified") that is set to FALSE when the delegation is granted, and 7498 an sc value set at the time of grant to the change attribute value. 7499 The modified field would be set to TRUE the first time cc != sc, and 7500 would stay TRUE until the delegation is returned or revoked. The 7501 processing for constructing nsc, time_modify, and time_metadata would 7502 use this pseudo code: 7504 if (!modified) { 7505 do CB_GETATTR for change and size; 7507 if (cc != sc) 7508 modified = TRUE; 7509 } else { 7510 do CB_GETATTR for size; 7511 } 7513 if (modified) { 7514 sc = sc + 1; 7515 time_modify = time_metadata = current_time; 7516 update sc, time_modify, time_metadata into file's metadata; 7517 } 7519 This would return to the client (that sent GETATTR) the attributes it 7520 requested, but make sure size comes from what CB_GETATTR returned. 7521 The server would not update the file's metadata with the client's 7522 modified size. 7524 In the case that the file attribute size is different than the 7525 server's current value, the server treats this as a modification 7526 regardless of the value of the change attribute retrieved via 7527 CB_GETATTR and responds to the second client as in the last step. 7529 This methodology resolves issues of clock differences between client 7530 and server and other scenarios where the use of CB_GETATTR break 7531 down. 7533 It should be noted that the server is under no obligation to use 7534 CB_GETATTR and therefore the server MAY simply recall the delegation 7535 to avoid its use. 7537 10.4.4. Recall of Open Delegation 7539 The following events necessitate recall of an open delegation: 7541 o Potentially conflicting OPEN request (or READ/WRITE done with 7542 "special" stateid) 7544 o SETATTR issued by another client 7546 o REMOVE request for the file 7548 o RENAME request for the file as either source or target of the 7549 RENAME 7551 Whether a RENAME of a directory in the path leading to the file 7552 results in recall of an open delegation depends on the semantics of 7553 the server filesystem. If that filesystem denies such RENAMEs when a 7554 file is open, the recall must be performed to determine whether the 7555 file in question is, in fact, open. 7557 In addition to the situations above, the server may choose to recall 7558 open delegations at any time if resource constraints make it 7559 advisable to do so. Clients should always be prepared for the 7560 possibility of recall. 7562 When a client receives a recall for an open delegation, it needs to 7563 update state on the server before returning the delegation. These 7564 same updates must be done whenever a client chooses to return a 7565 delegation voluntarily. The following items of state need to be 7566 dealt with: 7568 o If the file associated with the delegation is no longer open and 7569 no previous CLOSE operation has been sent to the server, a CLOSE 7570 operation must be sent to the server. 7572 o If a file has other open references at the client, then OPEN 7573 operations must be sent to the server. The appropriate stateids 7574 will be provided by the server for subsequent use by the client 7575 since the delegation stateid will not longer be valid. These OPEN 7576 requests are done with the claim type of CLAIM_DELEGATE_CUR. This 7577 will allow the presentation of the delegation stateid so that the 7578 client can establish the appropriate rights to perform the OPEN. 7579 (see Section 15.18 for details.) 7581 o If there are granted file locks, the corresponding LOCK operations 7582 need to be performed. This applies to the OPEN_DELEGATE_WRITE 7583 delegation case only. 7585 o For a OPEN_DELEGATE_WRITE delegation, if at the time of recall the 7586 file is not open for write, all modified data for the file must be 7587 flushed to the server. If the delegation had not existed, the 7588 client would have done this data flush before the CLOSE operation. 7590 o For a OPEN_DELEGATE_WRITE delegation when a file is still open at 7591 the time of recall, any modified data for the file needs to be 7592 flushed to the server. 7594 o With the OPEN_DELEGATE_WRITE delegation in place, it is possible 7595 that the file was truncated during the duration of the delegation. 7596 For example, the truncation could have occurred as a result of an 7597 OPEN UNCHECKED4 with a size attribute value of zero. Therefore, 7598 if a truncation of the file has occurred and this operation has 7599 not been propagated to the server, the truncation must occur 7600 before any modified data is written to the server. 7602 In the case of OPEN_DELEGATE_WRITE delegation, file locking imposes 7603 some additional requirements. To precisely maintain the associated 7604 invariant, it is required to flush any modified data in any region 7605 for which a write lock was released while the OPEN_DELEGATE_WRITE 7606 delegation was in effect. However, because the OPEN_DELEGATE_WRITE 7607 delegation implies no other locking by other clients, a simpler 7608 implementation is to flush all modified data for the file (as 7609 described just above) if any write lock has been released while the 7610 OPEN_DELEGATE_WRITE delegation was in effect. 7612 An implementation need not wait until delegation recall (or deciding 7613 to voluntarily return a delegation) to perform any of the above 7614 actions, if implementation considerations (e.g., resource 7615 availability constraints) make that desirable. Generally, however, 7616 the fact that the actual open state of the file may continue to 7617 change makes it not worthwhile to send information about opens and 7618 closes to the server, except as part of delegation return. Only in 7619 the case of closing the open that resulted in obtaining the 7620 delegation would clients be likely to do this early, since, in that 7621 case, the close once done will not be undone. Regardless of the 7622 client's choices on scheduling these actions, all must be performed 7623 before the delegation is returned, including (when applicable) the 7624 close that corresponds to the open that resulted in the delegation. 7626 These actions can be performed either in previous requests or in 7627 previous operations in the same COMPOUND request. 7629 10.4.5. OPEN Delegation Race with CB_RECALL 7631 The server informs the client of recall via a CB_RECALL. A race case 7632 which may develop is when the delegation is immediately recalled 7633 before the COMPOUND which established the delegation is returned to 7634 the client. As the CB_RECALL provides both a stateid and a 7635 filehandle for which the client has no mapping, it cannot honor the 7636 recall attempt. At this point, the client has two choices, either do 7637 not respond or respond with NFS4ERR_BADHANDLE. If it does not 7638 respond, then it runs the risk of the server deciding to not grant it 7639 further delegations. 7641 If instead it does reply with NFS4ERR_BADHANDLE, then both the client 7642 and the server might be able to detect that a race condition is 7643 occurring. The client can keep a list of pending delegations. When 7644 it receives a CB_RECALL for an unknown delegation, it can cache the 7645 stateid and filehandle on a list of pending recalls. When it is 7646 provided with a delegation, it would only use it if it was not on the 7647 pending recall list. Upon the next CB_RECALL, it could immediately 7648 return the delegation. 7650 In turn, the server can keep track of when it issues a delegation and 7651 assume that if a client responds to the CB_RECALL with a 7652 NFS4ERR_BADHANDLE, then the client has yet to receive the delegation. 7653 The server SHOULD give the client a reasonable time both to get this 7654 delegation and to return it before revoking the delegation. Unlike a 7655 failed callback path, the server should periodically probe the client 7656 with CB_RECALL to see if it has received the delegation and is ready 7657 to return it. 7659 When the server finally determines that enough time has lapsed, it 7660 SHOULD revoke the delegation and it SHOULD NOT revoke the lease. 7661 During this extended recall process, the server SHOULD be renewing 7662 the client lease. The intent here is that the client not pay too 7663 onerous a burden for a condition caused by the server. 7665 10.4.6. Clients that Fail to Honor Delegation Recalls 7667 A client may fail to respond to a recall for various reasons, such as 7668 a failure of the callback path from server to the client. The client 7669 may be unaware of a failure in the callback path. This lack of 7670 awareness could result in the client finding out long after the 7671 failure that its delegation has been revoked, and another client has 7672 modified the data for which the client had a delegation. This is 7673 especially a problem for the client that held a OPEN_DELEGATE_WRITE 7674 delegation. 7676 The server also has a dilemma in that the client that fails to 7677 respond to the recall might also be sending other NFS requests, 7678 including those that renew the lease before the lease expires. 7679 Without returning an error for those lease renewing operations, the 7680 server leads the client to believe that the delegation it has is in 7681 force. 7683 This difficulty is solved by the following rules: 7685 o When the callback path is down, the server MUST NOT revoke the 7686 delegation if one of the following occurs: 7688 * The client has issued a RENEW operation and the server has 7689 returned an NFS4ERR_CB_PATH_DOWN error. The server MUST renew 7690 the lease for any byte-range locks and share reservations the 7691 client has that the server has known about (as opposed to those 7692 locks and share reservations the client has established but not 7693 yet sent to the server, due to the delegation). The server 7694 SHOULD give the client a reasonable time to return its 7695 delegations to the server before revoking the client's 7696 delegations. 7698 * The client has not issued a RENEW operation for some period of 7699 time after the server attempted to recall the delegation. This 7700 period of time MUST NOT be less than the value of the 7701 lease_time attribute. 7703 o When the client holds a delegation, it cannot rely on operations, 7704 except for RENEW, that take a stateid, to renew delegation leases 7705 across callback path failures. The client that wants to keep 7706 delegations in force across callback path failures must use RENEW 7707 to do so. 7709 10.4.7. Delegation Revocation 7711 At the point a delegation is revoked, if there are associated opens 7712 on the client, the applications holding these opens need to be 7713 notified. This notification usually occurs by returning errors for 7714 READ/WRITE operations or when a close is attempted for the open file. 7716 If no opens exist for the file at the point the delegation is 7717 revoked, then notification of the revocation is unnecessary. 7718 However, if there is modified data present at the client for the 7719 file, the user of the application should be notified. Unfortunately, 7720 it may not be possible to notify the user since active applications 7721 may not be present at the client. See Section 10.5.1 for additional 7722 details. 7724 10.5. Data Caching and Revocation 7726 When locks and delegations are revoked, the assumptions upon which 7727 successful caching depend are no longer guaranteed. For any locks or 7728 share reservations that have been revoked, the corresponding owner 7729 needs to be notified. This notification includes applications with a 7730 file open that has a corresponding delegation which has been revoked. 7731 Cached data associated with the revocation must be removed from the 7732 client. In the case of modified data existing in the client's cache, 7733 that data must be removed from the client without it being written to 7734 the server. As mentioned, the assumptions made by the client are no 7735 longer valid at the point when a lock or delegation has been revoked. 7736 For example, another client may have been granted a conflicting lock 7737 after the revocation of the lock at the first client. Therefore, the 7738 data within the lock range may have been modified by the other 7739 client. Obviously, the first client is unable to guarantee to the 7740 application what has occurred to the file in the case of revocation. 7742 Notification to a lock owner will in many cases consist of simply 7743 returning an error on the next and all subsequent READs/WRITEs to the 7744 open file or on the close. Where the methods available to a client 7745 make such notification impossible because errors for certain 7746 operations may not be returned, more drastic action such as signals 7747 or process termination may be appropriate. The justification for 7748 this is that an invariant for which an application depends on may be 7749 violated. Depending on how errors are typically treated for the 7750 client operating environment, further levels of notification 7751 including logging, console messages, and GUI pop-ups may be 7752 appropriate. 7754 10.5.1. Revocation Recovery for Write Open Delegation 7756 Revocation recovery for a OPEN_DELEGATE_WRITE delegation poses the 7757 special issue of modified data in the client cache while the file is 7758 not open. In this situation, any client which does not flush 7759 modified data to the server on each close must ensure that the user 7760 receives appropriate notification of the failure as a result of the 7761 revocation. Since such situations may require human action to 7762 correct problems, notification schemes in which the appropriate user 7763 or administrator is notified may be necessary. Logging and console 7764 messages are typical examples. 7766 If there is modified data on the client, it must not be flushed 7767 normally to the server. A client may attempt to provide a copy of 7768 the file data as modified during the delegation under a different 7769 name in the filesystem name space to ease recovery. Note that when 7770 the client can determine that the file has not been modified by any 7771 other client, or when the client has a complete cached copy of file 7772 in question, such a saved copy of the client's view of the file may 7773 be of particular value for recovery. In other case, recovery using a 7774 copy of the file based partially on the client's cached data and 7775 partially on the server copy as modified by other clients, will be 7776 anything but straightforward, so clients may avoid saving file 7777 contents in these situations or mark the results specially to warn 7778 users of possible problems. 7780 Saving of such modified data in delegation revocation situations may 7781 be limited to files of a certain size or might be used only when 7782 sufficient disk space is available within the target filesystem. 7783 Such saving may also be restricted to situations when the client has 7784 sufficient buffering resources to keep the cached copy available 7785 until it is properly stored to the target filesystem. 7787 10.6. Attribute Caching 7789 The attributes discussed in this section do not include named 7790 attributes. Individual named attributes are analogous to files and 7791 caching of the data for these needs to be handled just as data 7792 caching is for ordinary files. Similarly, LOOKUP results from an 7793 OPENATTR directory are to be cached on the same basis as any other 7794 pathnames and similarly for directory contents. 7796 Clients may cache file attributes obtained from the server and use 7797 them to avoid subsequent GETATTR requests. Such caching is write 7798 through in that modification to file attributes is always done by 7799 means of requests to the server and should not be done locally and 7800 cached. The exception to this are modifications to attributes that 7801 are intimately connected with data caching. Therefore, extending a 7802 file by writing data to the local data cache is reflected immediately 7803 in the size as seen on the client without this change being 7804 immediately reflected on the server. Normally such changes are not 7805 propagated directly to the server but when the modified data is 7806 flushed to the server, analogous attribute changes are made on the 7807 server. When open delegation is in effect, the modified attributes 7808 may be returned to the server in the response to a CB_RECALL call. 7810 The result of local caching of attributes is that the attribute 7811 caches maintained on individual clients will not be coherent. 7812 Changes made in one order on the server may be seen in a different 7813 order on one client and in a third order on a different client. 7815 The typical filesystem application programming interfaces do not 7816 provide means to atomically modify or interrogate attributes for 7817 multiple files at the same time. The following rules provide an 7818 environment where the potential incoherency mentioned above can be 7819 reasonably managed. These rules are derived from the practice of 7820 previous NFS protocols. 7822 o All attributes for a given file (per-fsid attributes excepted) are 7823 cached as a unit at the client so that no non-serializability can 7824 arise within the context of a single file. 7826 o An upper time boundary is maintained on how long a client cache 7827 entry can be kept without being refreshed from the server. 7829 o When operations are performed that change attributes at the 7830 server, the updated attribute set is requested as part of the 7831 containing RPC. This includes directory operations that update 7832 attributes indirectly. This is accomplished by following the 7833 modifying operation with a GETATTR operation and then using the 7834 results of the GETATTR to update the client's cached attributes. 7836 Note that if the full set of attributes to be cached is requested by 7837 READDIR, the results can be cached by the client on the same basis as 7838 attributes obtained via GETATTR. 7840 A client may validate its cached version of attributes for a file by 7841 fetching just both the change and time_access attributes and assuming 7842 that if the change attribute has the same value as it did when the 7843 attributes were cached, then no attributes other than time_access 7844 have changed. The reason why time_access is also fetched is because 7845 many servers operate in environments where the operation that updates 7846 change does not update time_access. For example, POSIX file 7847 semantics do not update access time when a file is modified by the 7848 write system call. Therefore, the client that wants a current 7849 time_access value should fetch it with change during the attribute 7850 cache validation processing and update its cached time_access. 7852 The client may maintain a cache of modified attributes for those 7853 attributes intimately connected with data of modified regular files 7854 (size, time_modify, and change). Other than those three attributes, 7855 the client MUST NOT maintain a cache of modified attributes. 7856 Instead, attribute changes are immediately sent to the server. 7858 In some operating environments, the equivalent to time_access is 7859 expected to be implicitly updated by each read of the content of the 7860 file object. If an NFS client is caching the content of a file 7861 object, whether it is a regular file, directory, or symbolic link, 7862 the client SHOULD NOT update the time_access attribute (via SETATTR 7863 or a small READ or READDIR request) on the server with each read that 7864 is satisfied from cache. The reason is that this can defeat the 7865 performance benefits of caching content, especially since an explicit 7866 SETATTR of time_access may alter the change attribute on the server. 7867 If the change attribute changes, clients that are caching the content 7868 will think the content has changed, and will re-read unmodified data 7869 from the server. Nor is the client encouraged to maintain a modified 7870 version of time_access in its cache, since this would mean that the 7871 client will either eventually have to write the access time to the 7872 server with bad performance effects, or it would never update the 7873 server's time_access, thereby resulting in a situation where an 7874 application that caches access time between a close and open of the 7875 same file observes the access time oscillating between the past and 7876 present. The time_access attribute always means the time of last 7877 access to a file by a read that was satisfied by the server. This 7878 way clients will tend to see only time_access changes that go forward 7879 in time. 7881 10.7. Data and Metadata Caching and Memory Mapped Files 7883 Some operating environments include the capability for an application 7884 to map a file's content into the application's address space. Each 7885 time the application accesses a memory location that corresponds to a 7886 block that has not been loaded into the address space, a page fault 7887 occurs and the file is read (or if the block does not exist in the 7888 file, the block is allocated and then instantiated in the 7889 application's address space). 7891 As long as each memory mapped access to the file requires a page 7892 fault, the relevant attributes of the file that are used to detect 7893 access and modification (time_access, time_metadata, time_modify, and 7894 change) will be updated. However, in many operating environments, 7895 when page faults are not required these attributes will not be 7896 updated on reads or updates to the file via memory access (regardless 7897 whether the file is local file or is being access remotely). A 7898 client or server MAY fail to update attributes of a file that is 7899 being accessed via memory mapped I/O. This has several implications: 7901 o If there is an application on the server that has memory mapped a 7902 file that a client is also accessing, the client may not be able 7903 to get a consistent value of the change attribute to determine 7904 whether its cache is stale or not. A server that knows that the 7905 file is memory mapped could always pessimistically return updated 7906 values for change so as to force the application to always get the 7907 most up to date data and metadata for the file. However, due to 7908 the negative performance implications of this, such behavior is 7909 OPTIONAL. 7911 o If the memory mapped file is not being modified on the server, and 7912 instead is just being read by an application via the memory mapped 7913 interface, the client will not see an updated time_access 7914 attribute. However, in many operating environments, neither will 7915 any process running on the server. Thus NFS clients are at no 7916 disadvantage with respect to local processes. 7918 o If there is another client that is memory mapping the file, and if 7919 that client is holding a OPEN_DELEGATE_WRITE delegation, the same 7920 set of issues as discussed in the previous two bullet items apply. 7921 So, when a server does a CB_GETATTR to a file that the client has 7922 modified in its cache, the response from CB_GETATTR will not 7923 necessarily be accurate. As discussed earlier, the client's 7924 obligation is to report that the file has been modified since the 7925 delegation was granted, not whether it has been modified again 7926 between successive CB_GETATTR calls, and the server MUST assume 7927 that any file the client has modified in cache has been modified 7928 again between successive CB_GETATTR calls. Depending on the 7929 nature of the client's memory management system, this weak 7930 obligation may not be possible. A client MAY return stale 7931 information in CB_GETATTR whenever the file is memory mapped. 7933 o The mixture of memory mapping and file locking on the same file is 7934 problematic. Consider the following scenario, where the page size 7935 on each client is 8192 bytes. 7937 * Client A memory maps first page (8192 bytes) of file X 7939 * Client B memory maps first page (8192 bytes) of file X 7941 * Client A write locks first 4096 bytes 7943 * Client B write locks second 4096 bytes 7945 * Client A, via a STORE instruction modifies part of its locked 7946 region. 7948 * Simultaneous to client A, client B issues a STORE on part of 7949 its locked region. 7951 Here the challenge is for each client to resynchronize to get a 7952 correct view of the first page. In many operating environments, the 7953 virtual memory management systems on each client only know a page is 7954 modified, not that a subset of the page corresponding to the 7955 respective lock regions has been modified. So it is not possible for 7956 each client to do the right thing, which is to only write to the 7957 server that portion of the page that is locked. For example, if 7958 client A simply writes out the page, and then client B writes out the 7959 page, client A's data is lost. 7961 Moreover, if mandatory locking is enabled on the file, then we have a 7962 different problem. When clients A and B issue the STORE 7963 instructions, the resulting page faults require a byte-range lock on 7964 the entire page. Each client then tries to extend their locked range 7965 to the entire page, which results in a deadlock. 7967 Communicating the NFS4ERR_DEADLOCK error to a STORE instruction is 7968 difficult at best. 7970 If a client is locking the entire memory mapped file, there is no 7971 problem with advisory or mandatory byte-range locking, at least until 7972 the client unlocks a region in the middle of the file. 7974 Given the above issues the following are permitted: 7976 o Clients and servers MAY deny memory mapping a file they know there 7977 are byte-range locks for. 7979 o Clients and servers MAY deny a byte-range lock on a file they know 7980 is memory mapped. 7982 o A client MAY deny memory mapping a file that it knows requires 7983 mandatory locking for I/O. If mandatory locking is enabled after 7984 the file is opened and mapped, the client MAY deny the application 7985 further access to its mapped file. 7987 10.8. Name Caching 7989 The results of LOOKUP and READDIR operations may be cached to avoid 7990 the cost of subsequent LOOKUP operations. Just as in the case of 7991 attribute caching, inconsistencies may arise among the various client 7992 caches. To mitigate the effects of these inconsistencies and given 7993 the context of typical filesystem APIs, an upper time boundary is 7994 maintained on how long a client name cache entry can be kept without 7995 verifying that the entry has not been made invalid by a directory 7996 change operation performed by another client. 7998 When a client is not making changes to a directory for which there 7999 exist name cache entries, the client needs to periodically fetch 8000 attributes for that directory to ensure that it is not being 8001 modified. After determining that no modification has occurred, the 8002 expiration time for the associated name cache entries may be updated 8003 to be the current time plus the name cache staleness bound. 8005 When a client is making changes to a given directory, it needs to 8006 determine whether there have been changes made to the directory by 8007 other clients. It does this by using the change attribute as 8008 reported before and after the directory operation in the associated 8009 change_info4 value returned for the operation. The server is able to 8010 communicate to the client whether the change_info4 data is provided 8011 atomically with respect to the directory operation. If the change 8012 values are provided atomically, the client is then able to compare 8013 the pre-operation change value with the change value in the client's 8014 name cache. If the comparison indicates that the directory was 8015 updated by another client, the name cache associated with the 8016 modified directory is purged from the client. If the comparison 8017 indicates no modification, the name cache can be updated on the 8018 client to reflect the directory operation and the associated timeout 8019 extended. The post-operation change value needs to be saved as the 8020 basis for future change_info4 comparisons. 8022 As demonstrated by the scenario above, name caching requires that the 8023 client revalidate name cache data by inspecting the change attribute 8024 of a directory at the point when the name cache item was cached. 8025 This requires that the server update the change attribute for 8026 directories when the contents of the corresponding directory is 8027 modified. For a client to use the change_info4 information 8028 appropriately and correctly, the server must report the pre and post 8029 operation change attribute values atomically. When the server is 8030 unable to report the before and after values atomically with respect 8031 to the directory operation, the server must indicate that fact in the 8032 change_info4 return value. When the information is not atomically 8033 reported, the client should not assume that other clients have not 8034 changed the directory. 8036 10.9. Directory Caching 8038 The results of READDIR operations may be used to avoid subsequent 8039 READDIR operations. Just as in the cases of attribute and name 8040 caching, inconsistencies may arise among the various client caches. 8041 To mitigate the effects of these inconsistencies, and given the 8042 context of typical filesystem APIs, the following rules should be 8043 followed: 8045 o Cached READDIR information for a directory which is not obtained 8046 in a single READDIR operation must always be a consistent snapshot 8047 of directory contents. This is determined by using a GETATTR 8048 before the first READDIR and after the last of READDIR that 8049 contributes to the cache. 8051 o An upper time boundary is maintained to indicate the length of 8052 time a directory cache entry is considered valid before the client 8053 must revalidate the cached information. 8055 The revalidation technique parallels that discussed in the case of 8056 name caching. When the client is not changing the directory in 8057 question, checking the change attribute of the directory with GETATTR 8058 is adequate. The lifetime of the cache entry can be extended at 8059 these checkpoints. When a client is modifying the directory, the 8060 client needs to use the change_info4 data to determine whether there 8061 are other clients modifying the directory. If it is determined that 8062 no other client modifications are occurring, the client may update 8063 its directory cache to reflect its own changes. 8065 As demonstrated previously, directory caching requires that the 8066 client revalidate directory cache data by inspecting the change 8067 attribute of a directory at the point when the directory was cached. 8068 This requires that the server update the change attribute for 8069 directories when the contents of the corresponding directory is 8070 modified. For a client to use the change_info4 information 8071 appropriately and correctly, the server must report the pre and post 8072 operation change attribute values atomically. When the server is 8073 unable to report the before and after values atomically with respect 8074 to the directory operation, the server must indicate that fact in the 8075 change_info4 return value. When the information is not atomically 8076 reported, the client should not assume that other clients have not 8077 changed the directory. 8079 11. Minor Versioning 8081 To address the requirement of an NFS protocol that can evolve as the 8082 need arises, the NFSv4 protocol contains the rules and framework to 8083 allow for future minor changes or versioning. 8085 The base assumption with respect to minor versioning is that any 8086 future accepted minor version must follow the IETF process and be 8087 documented in a standards track RFC. Therefore, each minor version 8088 number will correspond to an RFC. Minor version 0 of the NFS version 8089 4 protocol is represented by this RFC. The COMPOUND and CB_COMPOUND 8090 procedures support the encoding of the minor version being requested 8091 by the client. 8093 The following items represent the basic rules for the development of 8094 minor versions. Note that a future minor version may decide to 8095 modify or add to the following rules as part of the minor version 8096 definition. 8098 1. Procedures are not added or deleted 8100 To maintain the general RPC model, NFSv4 minor versions will not 8101 add to or delete procedures from the NFS program. 8103 2. Minor versions may add operations to the COMPOUND and 8104 CB_COMPOUND procedures. 8106 The addition of operations to the COMPOUND and CB_COMPOUND 8107 procedures does not affect the RPC model. 8109 1. Minor versions may append attributes to the bitmap4 that 8110 represents sets of attributes and to the fattr4 that 8111 represents sets of attribute values. 8113 This allows for the expansion of the attribute model to 8114 allow for future growth or adaptation. 8116 2. Minor version X must append any new attributes after the 8117 last documented attribute. 8119 Since attribute results are specified as an opaque array of 8120 per-attribute XDR encoded results, the complexity of adding 8121 new attributes in the midst of the current definitions would 8122 be too burdensome. 8124 3. Minor versions must not modify the structure of an existing 8125 operation's arguments or results. 8127 Again, the complexity of handling multiple structure definitions 8128 for a single operation is too burdensome. New operations should 8129 be added instead of modifying existing structures for a minor 8130 version. 8132 This rule does not preclude the following adaptations in a minor 8133 version. 8135 * adding bits to flag fields, such as new attributes to 8136 GETATTR's bitmap4 data type, and providing corresponding 8137 variants of opaque arrays, such as a notify4 used together 8138 with such bitmaps 8140 * adding bits to existing attributes like ACLs that have flag 8141 words 8143 * extending enumerated types (including NFS4ERR_*) with new 8144 values 8146 4. Minor versions must not modify the structure of existing 8147 attributes. 8149 5. Minor versions must not delete operations. 8151 This prevents the potential reuse of a particular operation 8152 "slot" in a future minor version. 8154 6. Minor versions must not delete attributes. 8156 7. Minor versions must not delete flag bits or enumeration values. 8158 8. Minor versions may declare an operation MUST NOT be implement. 8160 Specifying that an operation MUST NOT be implemented is 8161 equivalent to obsoleting an operation. For the client, it means 8162 that the operation MUST NOT be sent to the server. For the 8163 server, an NFS error can be returned as opposed to "dropping" 8164 the request as an XDR decode error. This approach allows for 8165 the obsolescence of an operation while maintaining its structure 8166 so that a future minor version can reintroduce the operation. 8168 1. Minor versions may declare that an attribute MUST NOT be 8169 implemented. 8171 2. Minor versions may declare that a flag bit or enumeration 8172 value MUST NOT be implemented. 8174 9. Minor versions may downgrade features from REQUIRED to 8175 RECOMMENDED, or RECOMMENDED to OPTIONAL. 8177 10. Minor versions may upgrade features from OPTIONAL to RECOMMENDED 8178 or RECOMMENDED to REQUIRED. 8180 11. A client and server that support minor version X SHOULD support 8181 minor versions 0 through X-1 as well. 8183 12. Except for infrastructural changes, no new features may be 8184 introduced as REQUIRED in a minor version. 8186 This rule allows for the introduction of new functionality and 8187 forces the use of implementation experience before designating a 8188 feature as REQUIRED. On the other hand, some classes of 8189 features are infrastructural and have broad effects. Allowing 8190 infrastructural features to be RECOMMENDED or OPTIONAL 8191 complicates implementation of the minor version. 8193 13. A client MUST NOT attempt to use a stateid, filehandle, or 8194 similar returned object from the COMPOUND procedure with minor 8195 version X for another COMPOUND procedure with minor version Y, 8196 where X != Y. 8198 12. Internationalization 8200 This chapter describes the string-handling aspects of the NFSv4 8201 protocol, and how they address issues related to 8202 internationalization, including issues related to UTF-8, 8203 normalization, string preparation, case folding, and handling of 8204 internationalization issues related to domains. 8206 The NFSv4 protocol needs to deal with internationalization, or I18N, 8207 with respect to file names and other strings as used within the 8208 protocol. The choice of string representation must allow for 8209 reasonable name/string access to clients, applications, and users 8210 which use various languages. The UTF-8 encoding of the UCS as 8211 defined by [7] allows for this type of access and follows the policy 8212 described in "IETF Policy on Character Sets and Languages", [8]. 8214 In implementing such policies, it is important to understand and 8215 respect the nature of NFSv4 as a means by which client 8216 implementations may invoke operations on remote file systems. Server 8217 implementations act as a conduit to a range of file system 8218 implementations that the NFSv4 server typically invokes through a 8219 virtual-file-system interface. 8221 Keeping this context in mind, one needs to understand that the file 8222 systems with which clients will be interacting will generally not be 8223 devoted solely to access using NFS version 4. Local access and its 8224 requirements will generally be important and often access over other 8225 remote file access protocols will be as well. It is generally a 8226 functional requirement in practice for the users of the NFSv4 8227 protocol (although it may be formally out of scope for this document) 8228 for the implementation to allow files created by other protocols and 8229 by local operations on the file system to be accessed using NFS 8230 version 4 as well. 8232 It also needs to be understood that a considerable portion of file 8233 name processing will occur within the implementation of the file 8234 system rather than within the limits of the NFSv4 server 8235 implementation per se. As a result, cetain aspects of name 8236 processing may change as the locus of processing moves from file 8237 system to file system. As a result of these factors, the protocol 8238 cannot enforce uniformity of name-related processing upon NFSv4 8239 server requests on the server as a whole. Because the server 8240 interacts with existing file system implementations, the same server 8241 handling will produce different behavior when interacting with 8242 different file system implementations. To attempt to require uniform 8243 behavior, and treat the the protocol server and the file system as a 8244 unified application, would considerably limit the usefulness of the 8245 protocol. 8247 12.1. Use of UTF-8 8249 As mentioned above, UTF-8 is used as a convenient way to encode 8250 Unicode which allows clients that have no internationalization 8251 requirements to avoid these issues since the mapping of ASCII names 8252 to UTF-8 is the identity. 8254 12.1.1. Relation to Stringprep 8256 RFC 3454 [9], otherwise known as "stringprep", documents a framework 8257 for using Unicode/UTF-8 in networking protocols, intended "to 8258 increase the likelihood that string input and string comparison work 8259 in ways that make sense for typical users throughout the world." A 8260 protocol conforming to this framework must define a profile of 8261 stringprep "in order to fully specify the processing options." 8262 NFSv4, while it does make normative references to stringprep and uses 8263 elements of that framework, it does not, for reasons that are 8264 explained below, conform to that framework, for all of the strings 8265 that are used within it. 8267 In addition to some specific issues which have caused stringprep to 8268 add confusion in handling certain characters for certain languages, 8269 there are a number of general reasons why stringprep profiles are not 8270 suitable for describing NFSv4. 8272 o Restricting the character repertoire to Unicode 3.2, as required 8273 by stringprep is unduly constricting. 8275 o Many of the character tables in stringprep are inappropriate 8276 because of this limited character repertoire, so that normative 8277 reference to stringprep is not desirable in many case and instead, 8278 we allow more flexibility in the definition of case mapping 8279 tables. 8281 o Because of the presence of different file systems, the specifics 8282 of processing are not fully defined and some aspects that are are 8283 RECOMMENDED, rather than REQUIRED. 8285 Despite these issues, in many cases the general structure of 8286 stringprep profiles, consisting of sections which deal with the 8287 applicability of the description, the character repertoire, character 8288 mapping, normalization, prohibited characters, and issues of the 8289 handling (i.e., possible prohibition) of bidirectional strings, is a 8290 convenient way to describe the string handling which is needed and 8291 will be used where appropriate. 8293 12.1.2. Normalization, Equivalence, and Confusability 8295 Unicode has defined several equivalence relationships among the set 8296 of possible strings. Understanding the nature and purpose of these 8297 equivalence relations is important to understand the handling of 8298 Unicode strings within NFSv4. 8300 Some string pairs are thought as only differing in the way accents 8301 and other diacritics are encoded, as illustrated in the examples 8302 below. Such string pairs are called "canonically equivalent". 8304 Such equivalence can occur when there are precomposed characters, 8305 as an alternative to encoding a base character in addition to a 8306 combining accent. For example, the character LATIN SMALL LETTER E 8307 WITH ACUTE (U+00E9) is defined as canonically equivalent to the 8308 string consisting of LATIN SMALL LETTER E followed by COMBINING 8309 ACUTE ACCENT (U+0065, U+0301). 8311 When multiple combining diacritics are present, differences in the 8312 ordering are not reflected in resulting display and the strings 8313 are defined as canonically equivalent. For example, the string 8314 consisting of LATIN SMALL LETTER Q, COMBINING ACUTE ACCENT, 8315 COMBINING GRAVE ACCENT (U+0071, U+0301, U+0300) is canonically 8316 equivalent to the string consisting of LATIN SMALL LETTER Q, 8317 COMBINING GRAVE ACCENT, COMBINING ACUTE ACCENT (U+0071, U+0300, 8318 U+0301) 8320 When both situations are present, the number of canonically 8321 equivalent strings can be greater. Thus, the following strings 8322 are all canonically equivalent: 8324 LATIN SMALL LETTER E, COMBINING MACRON, ACCENT, COMBINING ACUTE 8325 ACCENT (U+0xxx, U+0304, U+0301) 8327 LATIN SMALL LETTER E, COMBINING ACUTE ACCENT, COMBINING MACRON 8328 (U+0xxx, U+0301, U+0304) 8330 LATIN SMALL LETTER E WITH MACRON, COMBINING ACUTE ACCENT 8331 (U+011E, U+0301) 8333 LATIN SMALL LETTER E WITH ACUTE, COMBINING MACRON (U+00E9, 8334 U+0304) 8336 LATIN SMALL LETTER E WITH MACRON AND ACUTE (U+1E16) 8338 Additionally there is an equivalence relation of "compatibility 8339 equivalence". Two canonically equivalent strings are necessarily 8340 compatibility equivalent, although not the converse. An example of 8341 compatibility equivalent strings which are not canonically equivalent 8342 are GREEK CAPITAL LETTER OMEGA (U+03A9) and OHM SIGN (U+2129). These 8343 are identical in appearance while other compatibility equivalent 8344 strings are not. Another example would be "x2" and the two character 8345 string denoting x-squared which are clearly different in appearance 8346 although compatibility equivalent and not canonically equivalent. 8347 These have Unicode encodings LATIN SMALL LETTER X, DIGIT TWO (U+0078, 8348 U+0032) and LATIN SMALL LETTER X, SUPERSCRIPT TWO (U+0078, U+00B2), 8350 One way to deal with these equivalence relations is via 8351 normalization. A normalization form maps all strings to a 8352 corresponding normalized string in such a fashion that all strings 8353 that are equivalent (canonically or compatibly, depending on the 8354 form) are mapped to the same value. Thus the image of the mapping is 8355 a subset of Unicode strings conceived as the representatives of the 8356 equivalence classes defined by the chosen equivalence relation. 8358 In the NFSv4 protocol, handling of issues related to 8359 internationalization with regard to normalization follows one of two 8360 basic patterns: 8362 o For strings whose function is related to other internet standards, 8363 such as server and domain naming, the normalization form defined 8364 by the appropriate internet standards is used. For server and 8365 domain naming, this involves normalization form NFKC as specified 8366 in [10] 8368 o For other strings, particular those passed by the server to file 8369 system implementations, normalization requirements are the 8370 province of the file system and the job of this specification is 8371 not to specify a particular form but to make sure that 8372 interoperability is maximized, even when clients and server-based 8373 file systems have different preferences. 8375 A related but distinct issue concerns string confusability. This can 8376 occur when two strings (including single-character strings) having a 8377 similar appearance. There have been attempts to define uniform 8378 processing in an attempt to avoid such confusion (see stringprep [9]) 8379 but the results have often added confusion. 8381 Some examples of possible confusions and proposed processing intended 8382 to reduce/avoid confusions: 8384 o Deletion of characters believed to be invisible and appropriately 8385 ignored, justifying their deletion, including, WORD JOINER 8386 (U+2060), and the ZERO WIDTH SPACE (U+200B). 8388 o Deletion of characters supposed to not bear semantics and only 8389 affect glyph choice, including the ZERO WIDTH NON-JOINER (U+200C) 8390 and the ZERO WIDTH JOINER (U+200D), where the deletion turns out 8391 to be a problem for Farsi speakers. 8393 o Prohibition of space characters such as the EM SPACE (U+2003), the 8394 EN SPACE (U+2002), and the THIN SPACE (U+2009). 8396 In addition, character pairs which appear very similar and could and 8397 often do result in confusion. In addition to what Unicode defines as 8398 "compatibility equivalence", there are a considerable number of 8399 additional character pairs that could cause confusion. This includes 8400 characters such as LATIN CAPITAL LETTER O (U+004F) and DIGIT ZERO 8401 (U+0030), and CYRILLIC SMALL LETTER ER (U+0440) LATIN SMALL LETTER P 8402 (U+0070) (also with MATHEMATICAL BOLD SMALL P (U+1D429) and GREEK 8403 SMALL LETTER RHO (U+1D56, for good measure). 8405 NFSv4, as it does with normalization, takes a two-part approach to 8406 this issue: 8408 o For strings whose function is related to other internet standards, 8409 such as server and domain naming, any string processing to address 8410 the confusability issue is defined by the appropriate internet 8411 standards is used. For server and domain naming, this is the 8412 responsibility of IDNA as described in [10]. 8414 o For other strings, particularly those passed by the server to file 8415 system implementations, any such preparation requirements 8416 including the choice of how, or whether to address the 8417 confusability issue, are the responsibility of the file system to 8418 define, and for this specification to try to add its own set would 8419 add unacceptably to complexity, and make many files accessible 8420 locally and by other remote file access protocols, inaccessible by 8421 NFSv4. This specification defines how the protocol maximizes 8422 interoperability in the face of different file system 8423 implementations. NFSv4 does allow file systems to map and to 8424 reject characters, including those likely to result in confusion, 8425 since file systems may choose to do such things. It defines what 8426 the client will see in such cases, in order to limit problems that 8427 can arise when a file name is created and it appears to have a 8428 different name from the one it is assigned when the name is 8429 created. 8431 12.2. String Type Overview 8432 12.2.1. Overall String Class Divisions 8434 NFSv4 has to deal with a large set of different types of strings and 8435 because of the different role of each, internationalization issues 8436 will be different for each: 8438 o For some types of strings, the fundamental internationalization- 8439 related decisions are the province of the file system or the 8440 security-handling functions of the server and the protocol's job 8441 is to establish the rules under which file systems and servers are 8442 allowed to exercise this freedom, to avoid adding to confusion. 8444 o In other cases, the fundamental internationalization issues are 8445 the responsibility of other IETF groups and our job is simply to 8446 reference those and perhaps make a few choices as to how they are 8447 to be used (e.g., U-labels vs. A-labels). 8449 o There are also cases in which a string has a small amount of NFSv4 8450 processing which results in one or more strings being referred to 8451 one of the other categories. 8453 We will divide strings to be dealt with into the following classes: 8455 MIX: indicating that there is small amount of preparatory processing 8456 that either picks an internationalization handling mode or divides 8457 the string into a set of (two) strings with a different mode 8458 internationalization handling for each. The details are discussed 8459 in the section "Types with Pre-processing to Resolve Mixture 8460 Issues". 8462 NIP: indicating that, for various reasons, there is no need for 8463 internationalization-specific processing to be performed. The 8464 specifics of the various string types handled in this way are 8465 described in the section "String Types without 8466 Internationalization Processing". 8468 INET: indicating that the string needs to be processed in a fashion 8469 governed by non-NFS-specific internet specifications. The details 8470 are discussed in the section "Types with Processing Defined by 8471 Other Internet Areas". 8473 NFS: indicating that the string needs to be processed in a fashion 8474 governed by NFSv4-specific considerations. The primary focus is 8475 on enabling flexibility for the various file systems to be 8476 accessed and is described in the section "String Types with NFS- 8477 specific Processing". 8479 12.2.2. Divisions by Typedef Parent types 8481 There are a number of different string types within NFSv4 and 8482 internationalization handling will be different for different types 8483 of strings. Each the types will be in one of four groups based on 8484 the parent type that specifies the nature of its relationship to utf8 8485 and ascii. 8487 utf8_should/USHOULD: indicating that strings of this type SHOULD be 8488 UTF-8 but clients and servers will not check for valid UTF-8 8489 encoding. 8491 utf8val_should/UVSHOULD: indicating that strings of this type SHOULD 8492 be and generally will be in the form of the UTF-8 encoding of 8493 Unicode. Strings in most cases will be checked by the server for 8494 valid UTF-8 but for certain file systems, such checking may be 8495 inhibited. 8497 utf8val_must/UVMUST: indicating that strings of this type MUST be in 8498 the form of the UTF-8 encoding of Unicode. Strings will be 8499 checked by the server for valid UTF-8 and the server SHOULD ensure 8500 that when sent to the client, they are valid UTF-8. 8502 ascii_must/ASCII: indicating that strings of this type MUST be pure 8503 ASCII, and thus automatically UTF-8. The processing of these 8504 string must ensure that they are only have ASCII characters but 8505 this need not be a separate step if any normally required check 8506 for validity inherently assures that only ASCII characters are 8507 present. 8509 In those cases where UTF-8 is not required, USHOULD and UVSHOULD, and 8510 strings that are not valid UTF-8 are received and accepted, the 8511 receiver MUST NOT modify the strings. For example, setting 8512 particular bits such as the high-order bit to zero MUST NOT be done. 8514 12.2.3. Individual Types and Their Handling 8516 The first table outlines the handling for the primary string types, 8517 i.e., those not derived as a prefix or a suffix from a mixture type. 8519 +-----------------+----------+-------+------------------------------+ 8520 | Type | Parent | Class | Explanation | 8521 +-----------------+----------+-------+------------------------------+ 8522 | comptag4 | USHOULD | NIP | Should be utf8 but no | 8523 | | | | validation by server or | 8524 | | | | client is to be done. | 8525 | component4 | UVSHOULD | NFS | Should be utf8 but clients | 8526 | | | | may need to access file | 8527 | | | | systems with a different | 8528 | | | | name structure, such as file | 8529 | | | | systems that have non-utf8 | 8530 | | | | names. | 8531 | linktext4 | UVSHOULD | NFS | Should be utf8 since text | 8532 | | | | may include name components. | 8533 | | | | Because of the need to | 8534 | | | | access existing file | 8535 | | | | systems, this check may be | 8536 | | | | inhibited. | 8537 | fattr4_mimetype | ASCII | NIP | All mime types are ascii so | 8538 | | | | no specific utf8 processing | 8539 | | | | is required, given that you | 8540 | | | | are comparing to that list. | 8541 +-----------------+----------+-------+------------------------------+ 8543 Table 5 8545 There are a number of string types that are subject to preliminary 8546 processing. This processing may take the form either of selecting 8547 one of two possible forms based on the string contents or it in may 8548 consist of dividing the string into multiple conjoined strings each 8549 with different utf8-related processing. 8551 +---------+--------+-------+----------------------------------------+ 8552 | Type | Parent | Class | Explanation | 8553 +---------+--------+-------+----------------------------------------+ 8554 | prin4 | UVMUST | MIX | Consists of two parts separated by an | 8555 | | | | at-sign, a prinpfx4 and a prinsfx4. | 8556 | | | | These are described in the next table. | 8557 | server4 | UVMUST | MIX | Is either an IP address (serveraddr4) | 8558 | | | | which has to be pure ascii or a server | 8559 | | | | name svrname4, which is described | 8560 | | | | immediately below. | 8561 +---------+--------+-------+----------------------------------------+ 8563 Table 6 8565 The last table describes the components of the compound types 8566 described above. 8568 +----------+--------+------+----------------------------------------+ 8569 | Type | Class | Def | Explanation | 8570 +----------+--------+------+----------------------------------------+ 8571 | svraddr4 | ASCII | NIP | Server as IP address, whether IPv4 or | 8572 | | | | IPv6. | 8573 | svrname4 | UVMUST | INET | Server name as returned by server. | 8574 | | | | Not sent by client, except in | 8575 | | | | VERIFY/NVERIFY. | 8576 | prinsfx4 | UVMUST | INET | Suffix part of principal, in the form | 8577 | | | | of a domain name. | 8578 | prinpfx4 | UVMUST | NFS | Must match one of a list of valid | 8579 | | | | users or groups for that particular | 8580 | | | | domain. | 8581 +----------+--------+------+----------------------------------------+ 8583 Table 7 8585 12.3. Errors Related to Strings 8587 When the client sends an invalid UTF-8 string in a context in which 8588 UTF-8 is REQUIRED, the server MUST return an NFS4ERR_INVAL error. 8589 Within the framework of the previous section, this applies to strings 8590 whose type is defined as utf8val_must or ascii_must. When the client 8591 sends an invalid UTF-8 string in a context in which UTF-8 is 8592 RECOMMENDED and the server should test for UTF-8, the server SHOULD 8593 return an NFS4ERR_INVAL error. Within the framework of the previous 8594 section, this applies to strings whose type is defined as 8595 utf8val_should. These situations apply to cases in which 8596 inappropriate prefixes are detected and where the count includes 8597 trailing bytes that do not constitute a full UCS character. 8599 Where the client-supplied string is valid UTF-8 but contains 8600 characters that are not supported by the server file system as a 8601 value for that string (e.g., names containing characters that have 8602 more than two octets on a file system that supports UCS-2 characters 8603 only, file name components containing slashes on file systems that do 8604 not allow them in file name components), the server MUST return an 8605 NFS4ERR_BADCHAR error. 8607 Where a UTF-8 string is used as a file name component, and the file 8608 system, while supporting all of the characters within the name, does 8609 not allow that particular name to be used, the server should return 8610 the error NFS4ERR_BADNAME. This includes file system prohibitions of 8611 "." and ".." as file names for certain operations, and other such 8612 similar constraints. It does not include use of strings with non- 8613 preferred normalization modes. 8615 Where a UTF-8 string is used as a file name component, the file 8616 system implementation MUST NOT return NFS4ERR_BADNAME, simply due to 8617 a normalization mismatch. In such cases the implementation SHOULD 8618 convert the string to its own preferred normalization mode before 8619 performing the operation. As a result, a client cannot assume that a 8620 file created with a name it specifies will have that name when the 8621 directory is read. It may have instead, the name converted to the 8622 file system's preferred normalization form. 8624 Where a UTF-8 string is used as other than as file name component (or 8625 as symbolic link text) and the string does not meet the normalization 8626 requirements specified for it, the error NFS4ERR_INVAL is returned. 8628 12.4. Types with Pre-processing to Resolve Mixture Issues 8630 12.4.1. Processing of Principal Strings 8632 Strings denoting principals (users or groups) MUST be UTF-8 but since 8633 they consist of a principal prefix, an at-sign, and a domain, all 8634 three of which either are checked for being UTF-8, or inherently are 8635 UTF-8, checking the string as a whole for being UTF-8 is not 8636 required. Although a server implementation may choose to make this 8637 check on the string as whole, for example in converting it to 8638 Unicode, the description within this document, will reflect a 8639 processing model in which such checking happens after the division 8640 into a principal prefix and suffix, the latter being in the form of a 8641 domain name. 8643 The string should be scanned for at-signs. If there is more that one 8644 at-sign, the string is considered invalid. For cases in which there 8645 are no at-signs or the at-sign appears at the start or end of the 8646 string see Interpreting owner and owner_group. Otherwise, the 8647 portion before the at-sign is dealt with as a prinpfx4 and the 8648 portion after is dealt with as a prinsfx4. 8650 12.4.2. Processing of Server Id Strings 8652 Server id strings typically appear in responses (as attribute values) 8653 and only appear in requests as an attribute value presented to VERIFY 8654 and NVERIFY. With that exception, they are not subject to server 8655 validation and possible rejection. It is not expected that clients 8656 will typically do such validation on receipt of responses but they 8657 may as a way to check for proper server behavior. The responsibility 8658 for sending correct UTF-8 strings is with the server. 8660 Servers are identified by either server names or IP addresses. Once 8661 an id has been identified as an IP address, then there is no 8662 processing specific to internationalization to be done, since such an 8663 address must be ASCII to be valid. 8665 12.5. String Types without Internationalization Processing 8667 There are a number of types of strings which, for a number of 8668 different reasons, do not require any internationalization-specific 8669 handling, such as validation of UTF-8, normalization, or character 8670 mapping or checking. This does not necessarily mean that the strings 8671 need not be UTF-8. In some case, other checking on the string 8672 ensures that they are valid UTF-8, without doing any checking 8673 specific to internationalization. 8675 The following are the specific types: 8677 comptag4: strings are an aid to debugging and the sender should 8678 avoid confusion by not using anything but valid UTF-8. But any 8679 work validating the string or modifying it would only add 8680 complication to a mechanism whose basic function is best supported 8681 by making it not subject to any checking and having data maximally 8682 available to be looked at in a network trace. 8684 fattr4_mimetype: strings need to be validated by matching against a 8685 list of valid mime types. Since these are all ASCII, no 8686 processing specific to internationalization is required since 8687 anything that does not match is invalid and anything which does 8688 not obey the rules of UTF-8 will not be ASCII and consequently 8689 will not match, and will be invalid. 8691 svraddr4: strings, in order to be valid, need to be ASCII, but if 8692 you check them for validity, you have inherently checked that that 8693 they are ASCII and thus UTF-8. 8695 12.6. Types with Processing Defined by Other Internet Areas 8697 There are two types of strings which NFSv4 deals with whose 8698 processing is defined by other Internet standards, and where issues 8699 related to different handling choices by server operating systems or 8700 server file systems do not apply. 8702 These are as follows: 8704 o Server names as they appear in the fs_locations attribute. Note 8705 that for most purposes, such server names will only be sent by the 8706 server to the client. The exception is use of the fs_locations 8707 attribute in a VERIFY or NVERIFY operation. 8709 o Principal suffixes which are used to denote sets of users and 8710 groups, and are in the form of domain names. 8712 The general rules for handling all of these domain-related strings 8713 are similar and independent of role the of the sender or receiver as 8714 client or server although the consequences of failure to obey these 8715 rules may be different for client or server. The server can report 8716 errors when it is sent invalid strings, whereas the client will 8717 simply ignore invalid string or use a default value in their place. 8719 The string sent SHOULD be in the form of a U-label although it MAY be 8720 in the form of an A-label or a UTF-8 string that would not map to 8721 itself when canonicalized by applying ToUnicode(ToASCII(...)). The 8722 receiver needs to be able to accept domain and server names in any of 8723 the formats allowed. The server MUST reject, using the the error 8724 NFS4ERR_INVAL, a string which is not valid UTF-8 or which begins with 8725 "xn--" and violates the rules for a valid A-label. 8727 When a domain string is part of id@domain or group@domain, the server 8728 SHOULD map domain strings which are A-labels or are UTF-8 domain 8729 names which are not U-labels, to the corresponding U-label, using 8730 ToUnicode(domain) or ToUnicode(ToASCII(domain)). As a result, the 8731 domain name returned within a userid on a GETATTR may not match that 8732 sent when the userid is set using SETATTR, although when this 8733 happens, the domain will be in the form of a U-label. When the 8734 server does not map domain strings which are not U-labels into a 8735 U-label, which it MAY do, it MUST NOT modify the domain and the 8736 domain returned on a GETATTR of the userid MUST be the same as that 8737 used when setting the userid by the SETATTTR. 8739 The server MAY implement VERIFY and NVERIFY without translating 8740 internal state to a string form, so that, for example, a user 8741 principal which represents a specific numeric user id, will match a 8742 different principal string which represents the same numeric user id. 8744 12.7. String Types with NFS-specific Processing 8746 For a number of data types within NFSv4, the primary responsibility 8747 for internationalization-related handling is that of some entity 8748 other than the server itself (see below for details). In these 8749 situations, the primary responsibility of NFSv4 is to provide a 8750 framework in which that other entity (file system and server 8751 operating system principal naming framework) implements its own 8752 decisions while establishing rules to limit interoperability issues. 8754 This pattern applies to the following data types: 8756 o In the case of name components (strings of type component4), the 8757 server-side file system implementation (of which there may be more 8758 than one for a particular server) deals with internationalization 8759 issues, in a fashion that is appropriate to NFSv4, other remote 8760 file access protocols, and local file access methods. See 8761 "Handling of File Name Components" for the detailed treatment. 8763 o In the case of link text strings (strings of type lintext4), the 8764 issues are similar, but file systems are restricted in the set of 8765 acceptable internationalization-related processing that they may 8766 do, principally because symbolic links may contain name components 8767 that, when used, are presented to other file systems and/or other 8768 servers. See "Processing of Link Text" for the detailed 8769 treatment. 8771 o In the case of principal prefix strings, any decisions regarding 8772 internationalization are the responsibility of the server 8773 operating systems which may make its own rules regarding user and 8774 group name encoding. See "Processing of Principal Prefixes" for 8775 the detailed treatment. 8777 12.7.1. Handling of File Name Components 8779 There are a number of places within client and server where file name 8780 components are processed: 8782 o On the client, file names may be processed as part of forming 8783 NFSv4 requests. Any such processing will reflect specific needs 8784 of the client's environment and will be treated as out-of-scope 8785 from the viewpoint of this specification. 8787 o On the server, file names are processed as part of processing 8788 NFSv4 requests. In practice, parts of the processing will be 8789 implemented within the NFS version 4 server while other parts will 8790 be implemented within the file system. This processing is 8791 described in the sections below. These sections are organized in 8792 a fashion parallel to a stringprep profile. The same sorts of 8793 topics are dealt with but they differ in that there is a wider 8794 range of possible processing choices. 8796 o On the server, file name components might potentially be subject 8797 to processing as part of generating NFS version 4 responses. This 8798 specification assumes that this processing will be empty and that 8799 file name components will be copied verbatim at this point. The 8800 file name components may be modified as they appear in responses, 8801 relative to the values used in the request but this is only 8802 treated as reflecting changes made as part of request processing. 8803 For example, a change to a file name component made in processing 8804 a CREATE operation will be reflected in the READDIR since the 8805 files created will have names that reflect CREATE-time processing. 8807 o On the client, responses will need to be properly dealt with and 8808 the relevant issues will be discussed in the sections below. 8810 Primarily, this will involve dealing with the fact that file name 8811 components received in responses may need to be processed to meet 8812 the requirements of the client's internal environment. This will 8813 mainly involve dealing with changes in name components possibly 8814 made by server processing. It also addresses other sorts of 8815 expected behavior that do not involve a returned component4, such 8816 as whether a LOOKUP finds a given component4 or whether a CREATE 8817 or OPEN finds that a specified name already exists. 8819 12.7.1.1. Nature of Server Processing of Name Components in Request 8821 The component4 type defines a potentially case sensitive string, 8822 typically of UTF-8 characters. Its use in NFS version 4 is for 8823 representing file name components. Since file systems can implement 8824 case insensitive file name handling, it can be used for both case 8825 sensitive and case insensitive file name handling, based on the 8826 attributes of the file system. 8828 It may be the case that two valid distinct UTF-8 strings will be the 8829 same after the processing described below. In such a case, a server 8830 may either, 8832 o disallow the creation of a second name if its post-processed form 8833 collides with that of an existing name, or 8835 o allow the creation of the second name, but arrange so that after 8836 post processing, the second name is different than the post- 8837 processed form of the first name. 8839 12.7.1.2. Character Repertoire for the Component4 Type 8841 The RECOMMENDED character repertoire for file name components is a 8842 recent/current version of Unicode, as encoded via UTF-8. There are a 8843 number of alternate character repertoires which may be chosen by the 8844 server based on implementation constraints including the requirements 8845 of the file system being accessed. 8847 Two important alternative repertoires are: 8849 o One alternate character repertoire is to represent file name 8850 components as strings of bytes with no protocol-defined encoding 8851 of multi-byte characters. Most typically, implementations that 8852 support this single-byte alternative will make it available as an 8853 option set by an administrator for all file systems within a 8854 server or for some particular file systems. If a server accepts 8855 non-UTF-8 strings anywhere within a specific file system, then it 8856 MUST do so throughout the entire file system. 8858 o Another alternate character repertoire is the set of codepoints, 8859 representable by the file system, most typically UCS-4. 8861 Individual file system implementations may have more restricted 8862 character repertoires, as for example file system that only are 8863 capable of storing names consisting of UCS-2 characters. When this 8864 is the case, and the character repertoire is not restricted to 8865 single-byte characters, characters not within that repertoire are 8866 treated as prohibited and the error NFS4ERR_BADCHAR is returned by 8867 the server when that character is encountered. 8869 Strings are intended to be in UTF-8 format and servers SHOULD return 8870 NFS4ERR_INVAL, as discussed above, when the characters sent are not 8871 valid UTF-8. When the character repertoire consists of single-byte 8872 characters, UTF-8 is not enforced. Such situations should be 8873 restricted to those where use is within a restricted environment 8874 where a single character mapping locale can be administratively 8875 enforced, allowing a file name to be treated as a string of bytes, 8876 rather than as a string of characters. Such an arrangement might be 8877 necessary when NFSv4 access to a file system containing names which 8878 are not valid UTF-8 needs to be provided. 8880 However, in any of the following situations, file names have to be 8881 treated as strings of Unicode characters and servers MUST return 8882 NFS4ERR_INVAL when file names that are not in UTF-8 format: 8884 o Case-insensitive comparisons are specified by the file system and 8885 any characters sent contain non-ASCII byte codes. 8887 o Any normalization constraints are enforced by the server or file 8888 system implementation. 8890 o The server accepts a given name when creating a file and reports a 8891 different one when the directory is being examined. 8893 Much of the discussion below regarding normalization and silent 8894 deletion of characters within component4 strings is not applicable 8895 when the server does not enforce UTF-8 component4 strings and treats 8896 them as strings of bytes. A client may determine that a given 8897 filesystem is operating in this mode by performing a LOOKUP using a 8898 non-UTF-8 string, if NFS4ERR_INVAL is not returned, then name 8899 components will be treated as opaque and those sorts of modifications 8900 will not be seen. 8902 12.7.1.3. Case-based Mapping Used for Component4 Strings 8904 Case-based mapping is not always a required part of server processing 8905 of name components. However, if the NFSv4 file server supports the 8906 case_insensitive file system attribute, and if the case_insensitive 8907 attribute is true for a given file system, the NFS version 4 server 8908 MUST use the Unicode case mapping tables for the version of Unicode 8909 corresponding to the character repertoire. In the case where the 8910 character repertoire is UCS-2 or UCS-4, the case mapping tables from 8911 the latest available version of Unicode SHOULD be used. 8913 If the case_preserving attribute is present and set to false, then 8914 the NFSv4 server MUST use the corresponding Unicode case mapping 8915 table to map case when processing component4 strings. Whether the 8916 server maps from lower to upper case or the upper to lower case is a 8917 matter for implementation choice. 8919 Stringprep Table B.2 should not be used for these purpose since it is 8920 limited to Unicode version 3.2 and also because it erroneously maps 8921 the German ligature eszett to the string "ss", whereas later versions 8922 of Unicode contain both lower-case and upper-case versions of Eszett 8923 (SMALL LETTER SHARP S and CAPITAL LETTER SHARP S). 8925 Clients should be aware that servers may have mapped SMALL LETTER 8926 SHARP S to the string "ss" when case-insensitive mapping is in 8927 effect, with result that file whose name contains SMALL LETTER SHARP 8928 S may have that character replaced by "ss" or "SS". 8930 12.7.1.4. Other Mapping Used for Component4 Strings 8932 Other than for issues of case mapping, an NFSv4 server SHOULD limit 8933 visible (i.e., those that change the name of file to reflect those 8934 mappings to those from from a subset of the stringprep table B.1. 8935 Note particularly, the mappings from U+200C and U+200D to the empty 8936 string should be avoided, due to their undesirable effect on some 8937 strings in Farsi. 8939 Table B.1 may be used but it should be used only if required by the 8940 local file system implementation. For example, if the file system in 8941 question accepts file names containing the MONGOLIAN TODO SOFT HYPHEN 8942 character (U+1806) and they are distinct from the corresponding file 8943 names with this character removed, then using Table B.1 will cause 8944 functional problems when clients attempt to interact with that file 8945 system. The NFSv4 server implementation including the filesystem 8946 MUST NOT silently remove characters not within Table B.1. 8948 If an implementation wishes to eliminate other characters because it 8949 is believed that allowing component name versions that both include 8950 the character and do not have while otherwise the same, will 8951 contribute to confusion, it has two options: 8953 o Treat the characters as prohibited and return NFS4ERR_BADCHAR. 8955 o Eliminate the character as part of the name matching processing, 8956 while retaining it when a file is created. This would be 8957 analogous to file systems that are both case-insensitive and case- 8958 preserving,as discussed above, or those which are both 8959 normalization-insensitive and normalization-preserving, as 8960 discussed below. The handling will be insensitive to the presence 8961 of the chosen characters while preserving the presence or absence 8962 of such characters within names. 8964 Note that the second of these choices is a desirable way to handle 8965 characters within table B.1, again with the exception of U+200C and 8966 U+200D, which can cause issues for Farsi. 8968 In addition to modification due to normalization, discussed below, 8969 clients have to be able to deal with name modifications and other 8970 consequences of character mapping on the server, as discussed above. 8972 12.7.1.5. Normalization Issues for Component Strings 8974 The issues are best discussed separately for the server and the 8975 client. It is important to note that the server and client may have 8976 different approaches to this area, and that the server choice may not 8977 match the client operating environment. The issue of mismatches and 8978 how they may be best dealt with by the client is discussed in a later 8979 section. 8981 12.7.1.5.1. Server Normalization Issues for Component Strings 8983 The NFSv4 does not specify required use of a particular normalization 8984 form for component4 strings. Therefore, the server may receive 8985 unnormalized strings or strings that reflect either normalization 8986 form within protocol requests and responses. If the file system 8987 requires normalization, then the server implementation must normalize 8988 component4 strings within the protocol server before presenting the 8989 information to the local file system. 8991 With regard to normalization, servers have the following choices, 8992 with the possibility that different choices may be selected for 8993 different file systems. 8995 o Implement a particular normalization form, either NFC, or NFD, in 8996 which case file names received from a client are converted to that 8997 normalization form and as a consequence, the client will always 8998 receive names in that normalization form. If this option is 8999 chosen, then it is impossible to create two files in the same 9000 directory that have different names which map to the same name 9001 when normalized. 9003 o Implement handling which is both normalization-insensitive and 9004 normalization-preserving. This makes it impossible to create two 9005 files in the same directory that have two different canonically 9006 equivalent names, i.e., names which map to the same name when 9007 normalized. However, unlike the previous option, clients will not 9008 have the names that they present modified to meet the server's 9009 normalization constraints. 9011 o Implement normalization-sensitive handling without enforcing a 9012 normalization form constraint on file names. This exposes the 9013 client to the possibility that two files can be created in the 9014 same directory which have different names which map to the same 9015 name when normalized. This may be a significant issue when 9016 clients which use different normalization forms are used on the 9017 same file system, but this issue needs to be set against the 9018 difficulty of providing other sorts of normalization handling for 9019 some existing file systems. 9021 12.7.1.5.2. Client Normalization Issues for Component Strings 9023 The client, in processing name components, needs to deal with the 9024 fact that the server may impose normalization on file name components 9025 presented to it. As a result, a file can be created within a 9026 directory and that name be different from that sent by the client due 9027 to normalization at the server. 9029 Client operating environments differ in their handling of canonically 9030 equivalent names. Some environments treat canonically equivalent 9031 strings as essentially equal and we will call these environments 9032 normalization-aware. Others, because of the pattern of their 9033 development with regard to these issues treat different strings as 9034 different, even if they are canonically equivalent. We call these 9035 normalization-unaware. 9037 We discuss below issues that may arise when each of these types of 9038 environments interact with the various types of file systems, with 9039 regard to normalization handling. Note that complexity for the 9040 client is increased given that there are no file system attributes to 9041 determine the normalization handling present for that file system. 9042 Where the client has the ability to create files (file system not 9043 read-only and security allows it), attempting to create multiple 9044 files with canonically equivalent names and looking at success 9045 patterns and the names assigned by the server to these files can 9046 serve as a way to determine the relevant information. 9048 Normalization-aware environments interoperate most normally with 9049 servers that either impose a given normalization form or those that 9050 implement name handling which is both normalization-insensitive and 9051 normalization-preserving name handling. However, clients need to be 9052 prepared to interoperate with servers that have normalization- 9053 sensitive file naming. In this situation, the client needs to be 9054 prepared for the fact that a directory may contain multiple names 9055 that it considers equivalent. 9057 The following suggestions may be helpful in handling interoperability 9058 issues for normalization-aware client environments, when they 9059 interact with normalization-sensitive file systems. 9061 When READDIR is done, the names returned may include names that do 9062 not match the client's normalization form, but instead are other 9063 names canonically equivalent to the normalized name. 9065 When it can be determined that a normalization-insensitive server 9066 file system is not involved, the client can simply normalize 9067 filename components strings to its preferred normalization form. 9069 When it cannot be determined that a normalization-insensitive 9070 server file system is not involved, the client is generally best 9071 advised to process incoming name components so as to allow all 9072 name components in a canonical equivalence class to be together. 9073 When only a single member of class exists, it should generally 9074 mapped directly to the preferred normalization form, whether the 9075 name was of that form or not. 9077 When the client sees multiple names that are canonically 9078 equivalent, it is clear you have a file system which is 9079 normalization sensitive. Clients should generally replace each 9080 canonically equivalent name with one that appends some 9081 distinguishing suffix, usually including a number. The numbers 9082 should be assigned so that each distinct possible name with the 9083 set of canonically equivalent names has an assigned numeric value. 9084 Note that for some cases in which there are multiple instances of 9085 strings that might be composed or decomposed and/or situations 9086 with multiple diacritics to be applied to the same character, the 9087 class might be large. 9089 When interacting with a normalization-sensitive filesystem, it may 9090 be that the environment contains clients or implementations local 9091 to the OS in which the file system is embedded, which use a 9092 different normalization form. In such situations, a LOOKUP may 9093 well fail, even though the directory contains a name canonically 9094 equivalent to the name sought. One solution to this problem is to 9095 re-do the LOOKUP in that situation with name converted to the 9096 alternate normalization form. 9098 In the case in which normalization-unaware clients are involved in 9099 the mix, LOOKUP can fail and then the second LOOKUP, described 9100 above can also fail, even though there may well be a canonically 9101 equivalent name in the directory. One possible approach in that 9102 case is to use a READDIR to find the equivalent name and lookup 9103 that, although this can greatly add to client implementation 9104 complexity. 9106 When interacting with a normalization-sensitive filesystem, the 9107 situation where the environment contains clients or 9108 implementations local to the OS in which the file system is 9109 embedded, which use a different normalization form can also cause 9110 issues when a file (or symlink or directory, etc.) is being 9111 created. In such cases, you may be able to create an object of 9112 the specified name even though, the directory contains a 9113 canonically equivalent name. Similar issues can occur with LINK 9114 and RENAME. The client can't really do much about such 9115 situations, except be aware that they may occur. That's one of 9116 the reasons normalization-sensitive server file system 9117 implementations can be problematic to use when 9118 internationalization issues are important. 9120 Normalization-unaware environments interoperate most normally with 9121 servers that implement normalization-sensitive file naming. However, 9122 clients need to be prepared to interoperate with servers that impose 9123 a given normalization form or that implement name handling which is 9124 both normalization-insensitive and normalization-preserving. In the 9125 former case, a file created with a given name may find it changed to 9126 a different (although related name). In both cases, the client will 9127 have to deal with the fact that it is unable to create two names 9128 within a directory that are canonically equivalent. 9130 Note that although the client implementation itself and the kernel 9131 implementation may be normalization-unaware, treating name components 9132 as strings not subject to normalization, the environment as a whole 9133 may be normalization-aware if commonly used libraries result in an 9134 application environment where a single normalization form is used 9135 throughout. Because of this, normalization-unaware environments may 9136 be relatively rare. 9138 The following suggestions may be helpful in handling interoperability 9139 issues for truly normalization-unaware client environments, when they 9140 interact with file systems other than those which are normalization- 9141 sensitive. The issues tend to be the inverse of those for 9142 normalization-aware environments. The implementer should be careful 9143 not to erroneously treat the environment as normalization-unaware, 9144 based solely on the details of the kernel implementation. 9146 Unless the file system is normalization-preserving, when files (or 9147 other objects) are created, the object name as reported by a 9148 READDIR of the associated directory may show a name different than 9149 the one used to create the object. This behavior is something 9150 that the client has to accept. Since it has no preferred 9151 normalization form, it has no way of converting the name to a 9152 preferred form. 9154 In situations where there is an attempt to create multiple objects 9155 in the same directory which have canonically-equivalent names. 9156 these file systems will either report that an object of name 9157 already exists or simply open a file of that other name. 9159 If it desired to have those two objects in the same directory, the 9160 names must be made not canonically equivalent. It is possible to 9161 append some distinguishing character to the name of the second 9162 object but in clients having a typical file API (such as POSIX), 9163 the fact that the name change occurred cannot be propagated back 9164 to the requester. 9166 In cases where a client is application-specific, it may be 9167 possible for it to deal with such a collision by modifying the 9168 name and taking note of the changed name. 9170 12.7.1.6. Prohibited Characters for Component Names 9172 The NFSv4 protocol does not specify particular characters that may 9173 not appear in component names. File systems may have their own set 9174 of prohibited characters for which the error NFS4ERR_BADCHAR should 9175 be returned by the server. Clients need to be prepared for this 9176 error to occur whenever file name components are presented to the 9177 server. 9179 Clients whose character repertoire for acceptable characters in file 9180 name components is smaller than the entire scope of UCS-4 may need to 9181 deal with names returned by the server that contain characters 9182 outside that repertoire. It is up to the client whether it simply 9183 ignores these files or modifies the name to meet its own rules for 9184 acceptable names. 9186 Clients may encounter names that do not consist of valid UTF-8, if 9187 they interact with servers configured to allow this option. They are 9188 not required to deal with this case and may treat the server as not 9189 functioning correctly, or they may handle this as normal. Clients 9190 will normally make this a configuration option. As discussed above, 9191 a client can determine whether a particular file system is being 9192 supported by the server in this mode by issuing a LOOKUP specifying a 9193 name which is not valid UTF-8 and seeing if NFS4ERR_INVAL is 9194 returned. 9196 12.7.1.7. Bidirectional String Checking for Component Names 9198 The NFSv4 protocol does not require processing of component names to 9199 check for and reject bidirectional strings. Such processing may be a 9200 part of the file system implementation but if so, its particular form 9201 will be defined by the file system implementation. When strings are 9202 rejected on this basis, the error NFS4ERR_BADNAME would be returned. 9204 Clients need to be prepared for the fact that the server may reject a 9205 file name component if it consists of a bidirectional string, 9206 returning NFS4ERR_BADNAME. 9208 Clients may encounter names with bidirectional strings returned in 9209 responses from the server. If clients treat such strings as not 9210 valid file name components, it is up to the client whether it simply 9211 ignores these files or modifies the name component to meet its own 9212 rules for acceptable name component strings. 9214 12.7.2. Processing of Link Text 9216 Symbolic link text is defined as utf8val_should and therefore the 9217 server SHOULD validate link text on a CREATE and return NFS4ERR_INVAL 9218 if it is is not valid UTF-8. Note that file systems which treat 9219 names as strings of byte are an exception for which such validation 9220 need not be done. One other situation in which an NFSv4 might choose 9221 (or be configured) not to make such a check is when links within file 9222 system reference names in another which is configured to treat names 9223 as strings of bytes. 9225 On the other hand, UTF-8 validation of symbolic link text need not be 9226 done on the data resulting from a READLINK. Such data might have 9227 been stored by an NFS Version 4 server configured to allow non-UTF-8 9228 link text or it might have resulted from symbolic link text stored 9229 via local file system access or access via another remote file access 9230 protocol. 9232 Note that because of the role of the symbolic link, as data stored 9233 and read by the user, other sorts of validations or modifications 9234 should not be done. Note that when component names with the symbolic 9235 link text are used, such checks and modifications will be done at 9236 that time. In particular, 9238 o Limitation of the character repertoire MUST NOT be done. This 9239 includes limitations to reflect a particular version of Unicode, 9240 or the inability of any particularly file system to store 9241 characters beyond UCS-2. 9243 o Name mapping, whether for case folding or otherwise MUST NOT be 9244 done. 9246 o Checks for a type of normalization or normalization to a 9247 particular form MUST NOT be done. 9249 o Checks for specific characters excluded by the server or file 9250 system MUST NOT be done. 9252 o Checks for bidirectional strings MUST NOT be done. 9254 12.7.3. Processing of Principal Prefixes 9256 As mentioned above, users and groups are designated as a particular 9257 string at a specified domain. Servers will recognize a set of valid 9258 principals for one or more domains. With regard to the handling of 9259 these strings, the following rules MUST be followed 9261 o The string MUST be checked by the server for valid UTF-8 and the 9262 error NFS4ERR_INVAL returned if it is not valid. 9264 o The character repertoire for the principal prefix string should be 9265 limited to a current version of Unicode when the server is 9266 implemented. However, the client cannot be assured that all 9267 characters it receives as part of a user or group attribute are 9268 those that are defined in the Unicode version it expects to work 9269 with. 9271 o No character mapping is to be done, as for example table B.1 in 9272 stringprep, and no case mapping is to be done. The user and group 9273 names are to be treated as case-sensitive. 9275 o Strings must not be rejected based on their normalization. 9276 Servers should do normalization insensitive matching in converting 9277 a user to group to an internal id. The client cannot assume that 9278 the server preserves normalization so a user set to one string 9279 value may be returned as a string which differs in normalization 9280 and the client must be prepared to deal with that, by, for 9281 example, normalizing the string to the client's preferred form. 9283 o There are no checks for specific invalid characters but servers 9284 may limit the characters, with the result that any principal 9285 presented by the client which has such a characters is treated as 9286 invalid. 9288 o Specific checks for bidirectional strings are not done but servers 9289 may limit the principal prefix strings to those which are 9290 unidirectional or are of a certain direction, with the result that 9291 any principal presented by the client which done not meet that 9292 criterion will be treated as invalid. 9294 13. Error Values 9296 NFS error numbers are assigned to failed operations within a Compound 9297 (COMPOUND or CB_COMPOUND) request. A Compound request contains a 9298 number of NFS operations that have their results encoded in sequence 9299 in a Compound reply. The results of successful operations will 9300 consist of an NFS4_OK status followed by the encoded results of the 9301 operation. If an NFS operation fails, an error status will be 9302 entered in the reply and the Compound request will be terminated. 9304 13.1. Error Definitions 9306 Protocol Error Definitions 9308 +-----------------------------+--------+-------------------+ 9309 | Error | Number | Description | 9310 +-----------------------------+--------+-------------------+ 9311 | NFS4_OK | 0 | Section 13.1.3.1 | 9312 | NFS4ERR_ACCESS | 13 | Section 13.1.6.1 | 9313 | NFS4ERR_ATTRNOTSUPP | 10032 | Section 13.1.11.1 | 9314 | NFS4ERR_ADMIN_REVOKED | 10047 | Section 13.1.5.1 | 9315 | NFS4ERR_BADCHAR | 10040 | Section 13.1.7.1 | 9316 | NFS4ERR_BADHANDLE | 10001 | Section 13.1.2.1 | 9317 | NFS4ERR_BADNAME | 10041 | Section 13.1.7.2 | 9318 | NFS4ERR_BADOWNER | 10039 | Section 13.1.11.2 | 9319 | NFS4ERR_BADTYPE | 10007 | Section 13.1.4.1 | 9320 | NFS4ERR_BADXDR | 10036 | Section 13.1.1.1 | 9321 | NFS4ERR_BAD_COOKIE | 10003 | Section 13.1.1.2 | 9322 | NFS4ERR_BAD_RANGE | 10042 | Section 13.1.8.1 | 9323 | NFS4ERR_BAD_SEQID | 10026 | Section 13.1.8.2 | 9324 | NFS4ERR_BAD_STATEID | 10025 | Section 13.1.5.2 | 9325 | NFS4ERR_CLID_INUSE | 10017 | Section 13.1.10.1 | 9326 | NFS4ERR_DEADLOCK | 10045 | Section 13.1.8.3 | 9327 | NFS4ERR_DELAY | 10008 | Section 13.1.1.3 | 9328 | NFS4ERR_DENIED | 10010 | Section 13.1.8.4 | 9329 | NFS4ERR_DQUOT | 69 | Section 13.1.4.2 | 9330 | NFS4ERR_EXIST | 17 | Section 13.1.4.3 | 9331 | NFS4ERR_EXPIRED | 10011 | Section 13.1.5.3 | 9332 | NFS4ERR_FBIG | 27 | Section 13.1.4.4 | 9333 | NFS4ERR_FHEXPIRED | 10014 | Section 13.1.2.2 | 9334 | NFS4ERR_FILE_OPEN | 10046 | Section 13.1.4.5 | 9335 | NFS4ERR_GRACE | 10013 | Section 13.1.9.1 | 9336 | NFS4ERR_INVAL | 22 | Section 13.1.1.4 | 9337 | NFS4ERR_IO | 5 | Section 13.1.4.6 | 9338 | NFS4ERR_ISDIR | 21 | Section 13.1.2.3 | 9339 | NFS4ERR_LEASE_MOVED | 10031 | Section 13.1.5.4 | 9340 | NFS4ERR_LOCKED | 10012 | Section 13.1.8.5 | 9341 | NFS4ERR_LOCKS_HELD | 10037 | Section 13.1.8.6 | 9342 | NFS4ERR_LOCK_NOTSUPP | 10043 | Section 13.1.8.7 | 9343 | NFS4ERR_LOCK_RANGE | 10028 | Section 13.1.8.8 | 9344 | NFS4ERR_MINOR_VERS_MISMATCH | 10021 | Section 13.1.3.2 | 9345 | NFS4ERR_MLINK | 31 | Section 13.1.4.7 | 9346 | NFS4ERR_MOVED | 10019 | Section 13.1.2.4 | 9347 | NFS4ERR_NAMETOOLONG | 63 | Section 13.1.7.3 | 9348 | NFS4ERR_NOENT | 2 | Section 13.1.4.8 | 9349 | NFS4ERR_NOFILEHANDLE | 10020 | Section 13.1.2.5 | 9350 | NFS4ERR_NOSPC | 28 | Section 13.1.4.9 | 9351 | NFS4ERR_NOTDIR | 20 | Section 13.1.2.6 | 9352 | NFS4ERR_NOTEMPTY | 66 | Section 13.1.4.10 | 9353 | NFS4ERR_NOTSUPP | 10004 | Section 13.1.1.5 | 9354 | NFS4ERR_NOT_SAME | 10027 | Section 13.1.11.3 | 9355 | NFS4ERR_NO_GRACE | 10033 | Section 13.1.9.2 | 9356 | NFS4ERR_NXIO | 6 | Section 13.1.4.11 | 9357 | NFS4ERR_OLD_STATEID | 10024 | Section 13.1.5.5 | 9358 | NFS4ERR_OPENMODE | 10038 | Section 13.1.8.9 | 9359 | NFS4ERR_OP_ILLEGAL | 10044 | Section 13.1.3.3 | 9360 | NFS4ERR_PERM | 1 | Section 13.1.6.2 | 9361 | NFS4ERR_RECLAIM_BAD | 10034 | Section 13.1.9.3 | 9362 | NFS4ERR_RECLAIM_CONFLICT | 10035 | Section 13.1.9.4 | 9363 | NFS4ERR_RESOURCE | 10018 | Section 13.1.3.4 | 9364 | NFS4ERR_RESTOREFH | 10030 | Section 13.1.4.12 | 9365 | NFS4ERR_ROFS | 30 | Section 13.1.4.13 | 9366 | NFS4ERR_SAME | 10009 | Section 13.1.11.4 | 9367 | NFS4ERR_SERVERFAULT | 10006 | Section 13.1.1.6 | 9368 | NFS4ERR_STALE | 70 | Section 13.1.2.7 | 9369 | NFS4ERR_STALE_CLIENTID | 10022 | Section 13.1.10.2 | 9370 | NFS4ERR_STALE_STATEID | 10023 | Section 13.1.5.6 | 9371 | NFS4ERR_SYMLINK | 10029 | Section 13.1.2.8 | 9372 | NFS4ERR_TOOSMALL | 10005 | Section 13.1.1.7 | 9373 | NFS4ERR_WRONGSEC | 10016 | Section 13.1.6.3 | 9374 | NFS4ERR_XDEV | 18 | Section 13.1.4.14 | 9375 +-----------------------------+--------+-------------------+ 9377 Table 8 9379 13.1.1. General Errors 9381 This section deals with errors that are applicable to a broad set of 9382 different purposes. 9384 13.1.1.1. NFS4ERR_BADXDR (Error Code 10036) 9386 The arguments for this operation do not match those specified in the 9387 XDR definition. This includes situations in which the request ends 9388 before all the arguments have been seen. Note that this error 9389 applies when fixed enumerations (these include booleans) have a value 9390 within the input stream which is not valid for the enum. A replier 9391 may pre-parse all operations for a Compound procedure before doing 9392 any operation execution and return RPC-level XDR errors in that case. 9394 13.1.1.2. NFS4ERR_BAD_COOKIE (Error Code 10003) 9396 Used for operations that provide a set of information indexed by some 9397 quantity provided by the client or cookie sent by the server for an 9398 earlier invocation. Where the value cannot be used for its intended 9399 purpose, this error results. 9401 13.1.1.3. NFS4ERR_DELAY (Error Code 10008) 9403 For any of a number of reasons, the replier could not process this 9404 operation in what was deemed a reasonable time. The client should 9405 wait and then try the request with a new RPC transaction ID. 9407 Some example of situations that might lead to this situation: 9409 o A server that supports hierarchical storage receives a request to 9410 process a file that had been migrated. 9412 o An operation requires a delegation recall to proceed and waiting 9413 for this delegation recall makes processing this request in a 9414 timely fashion impossible. 9416 13.1.1.4. NFS4ERR_INVAL (Error Code 22) 9418 The arguments for this operation are not valid for some reason, even 9419 though they do match those specified in the XDR definition for the 9420 request. 9422 13.1.1.5. NFS4ERR_NOTSUPP (Error Code 10004) 9424 Operation not supported, either because the operation is an OPTIONAL 9425 one and is not supported by this server or because the operation MUST 9426 NOT be implemented in the current minor version. 9428 13.1.1.6. NFS4ERR_SERVERFAULT (Error Code 10006) 9430 An error occurred on the server which does not map to any of the 9431 specific legal NFSv4 protocol error values. The client should 9432 translate this into an appropriate error. UNIX clients may choose to 9433 translate this to EIO. 9435 13.1.1.7. NFS4ERR_TOOSMALL (Error Code 10005) 9437 Used where an operation returns a variable amount of data, with a 9438 limit specified by the client. Where the data returned cannot be fit 9439 within the limit specified by the client, this error results. 9441 13.1.2. Filehandle Errors 9443 These errors deal with the situation in which the current or saved 9444 filehandle, or the filehandle passed to PUTFH intended to become the 9445 current filehandle, is invalid in some way. This includes situations 9446 in which the filehandle is a valid filehandle in general but is not 9447 of the appropriate object type for the current operation. 9449 Where the error description indicates a problem with the current or 9450 saved filehandle, it is to be understood that filehandles are only 9451 checked for the condition if they are implicit arguments of the 9452 operation in question. 9454 13.1.2.1. NFS4ERR_BADHANDLE (Error Code 10001) 9456 Illegal NFS filehandle for the current server. The current file 9457 handle failed internal consistency checks. Once accepted as valid 9458 (by PUTFH), no subsequent status change can cause the filehandle to 9459 generate this error. 9461 13.1.2.2. NFS4ERR_FHEXPIRED (Error Code 10014) 9463 A current or saved filehandle which is an argument to the current 9464 operation is volatile and has expired at the server. 9466 13.1.2.3. NFS4ERR_ISDIR (Error Code 21) 9468 The current or saved filehandle designates a directory when the 9469 current operation does not allow a directory to be accepted as the 9470 target of this operation. 9472 13.1.2.4. NFS4ERR_MOVED (Error Code 10019) 9474 The file system which contains the current filehandle object is not 9475 present at the server. It may have been relocated, migrated to 9476 another server or may have never been present. The client may obtain 9477 the new file system location by obtaining the "fs_locations" or 9478 attribute for the current filehandle. For further discussion, refer 9479 to Section 7 9481 13.1.2.5. NFS4ERR_NOFILEHANDLE (Error Code 10020) 9483 The logical current or saved filehandle value is required by the 9484 current operation and is not set. This may be a result of a 9485 malformed COMPOUND operation (i.e., no PUTFH or PUTROOTFH before an 9486 operation that requires the current filehandle be set). 9488 13.1.2.6. NFS4ERR_NOTDIR (Error Code 20) 9490 The current (or saved) filehandle designates an object which is not a 9491 directory for an operation in which a directory is required. 9493 13.1.2.7. NFS4ERR_STALE (Error Code 70) 9495 The current or saved filehandle value designating an argument to the 9496 current operation is invalid The file referred to by that filehandle 9497 no longer exists or access to it has been revoked. 9499 13.1.2.8. NFS4ERR_SYMLINK (Error Code 10029) 9501 The current filehandle designates a symbolic link when the current 9502 operation does not allow a symbolic link as the target. 9504 13.1.3. Compound Structure Errors 9506 This section deals with errors that relate to overall structure of a 9507 Compound request (by which we mean to include both COMPOUND and 9508 CB_COMPOUND), rather than to particular operations. 9510 There are a number of basic constraints on the operations that may 9511 appear in a Compound request. 9513 13.1.3.1. NFS_OK (Error code 0) 9515 Indicates the operation completed successfully, in that all of the 9516 constituent operations completed without error. 9518 13.1.3.2. NFS4ERR_MINOR_VERS_MISMATCH (Error code 10021) 9520 The minor version specified is not one that the current listener 9521 supports. This value is returned in the overall status for the 9522 Compound but is not associated with a specific operation since the 9523 results must specify a result count of zero. 9525 13.1.3.3. NFS4ERR_OP_ILLEGAL (Error Code 10044) 9527 The operation code is not a valid one for the current Compound 9528 procedure. The opcode in the result stream matched with this error 9529 is the ILLEGAL value, although the value that appears in the request 9530 stream may be different. Where an illegal value appears and the 9531 replier pre-parses all operations for a Compound procedure before 9532 doing any operation execution, an RPC-level XDR error may be returned 9533 in this case. 9535 13.1.3.4. NFS4ERR_RESOURCE (Error Code 10018) 9537 For the processing of the Compound procedure, the server may exhaust 9538 available resources and cannot continue processing operations within 9539 the Compound procedure. This error will be returned from the server 9540 in those instances of resource exhaustion related to the processing 9541 of the Compound procedure. 9543 13.1.4. File System Errors 9545 These errors describe situations which occurred in the underlying 9546 file system implementation rather than in the protocol or any NFSv4.x 9547 feature. 9549 13.1.4.1. NFS4ERR_BADTYPE (Error Code 10007) 9551 An attempt was made to create an object with an inappropriate type 9552 specified to CREATE. This may be because the type is undefined, 9553 because it is a type not supported by the server, or because it is a 9554 type for which create is not intended such as a regular file or named 9555 attribute, for which OPEN is used to do the file creation. 9557 13.1.4.2. NFS4ERR_DQUOT (Error Code 19) 9559 Resource (quota) hard limit exceeded. The user's resource limit on 9560 the server has been exceeded. 9562 13.1.4.3. NFS4ERR_EXIST (Error Code 17) 9564 A file of the specified target name (when creating, renaming or 9565 linking) already exists. 9567 13.1.4.4. NFS4ERR_FBIG (Error Code 27) 9569 File too large. The operation would have caused a file to grow 9570 beyond the server's limit. 9572 13.1.4.5. NFS4ERR_FILE_OPEN (Error Code 10046) 9574 The operation is not allowed because a file involved in the operation 9575 is currently open. Servers may, but are not required to disallow 9576 linking-to, removing, or renaming open files. 9578 13.1.4.6. NFS4ERR_IO (Error Code 5) 9580 Indicates that an I/O error occurred for which the file system was 9581 unable to provide recovery. 9583 13.1.4.7. NFS4ERR_MLINK (Error Code 31) 9585 The request would have caused the server's limit for the number of 9586 hard links a file may have to be exceeded. 9588 13.1.4.8. NFS4ERR_NOENT (Error Code 2) 9590 Indicates no such file or directory. The file or directory name 9591 specified does not exist. 9593 13.1.4.9. NFS4ERR_NOSPC (Error Code 28) 9595 Indicates no space left on device. The operation would have caused 9596 the server's file system to exceed its limit. 9598 13.1.4.10. NFS4ERR_NOTEMPTY (Error Code 66) 9600 An attempt was made to remove a directory that was not empty. 9602 13.1.4.11. NFS4ERR_NXIO (Error Code 5) 9604 I/O error. No such device or address. 9606 13.1.4.12. NFS4ERR_RESTOREFH (Error Code 10030) 9608 The RESTOREFH operation does not have a saved filehandle (identified 9609 by SAVEFH) to operate upon. 9611 13.1.4.13. NFS4ERR_ROFS (Error Code 30) 9613 Indicates a read-only file system. A modifying operation was 9614 attempted on a read-only file system. 9616 13.1.4.14. NFS4ERR_XDEV (Error Code 18) 9618 Indicates an attempt to do an operation, such as linking, that 9619 inappropriately crosses a boundary. This may be due to such 9620 boundaries as: 9622 o That between file systems (where the fsids are different). 9624 o That between different named attribute directories or between a 9625 named attribute directory and an ordinary directory. 9627 o That between regions of a file system that the file system 9628 implementation treats as separate (for example for space 9629 accounting purposes), and where cross-connection between the 9630 regions are not allowed. 9632 13.1.5. State Management Errors 9634 These errors indicate problems with the stateid (or one of the 9635 stateids) passed to a given operation. This includes situations in 9636 which the stateid is invalid as well as situations in which the 9637 stateid is valid but designates revoked locking state. Depending on 9638 the operation, the stateid when valid may designate opens, byte-range 9639 locks, file or directory delegations, layouts, or device maps. 9641 13.1.5.1. NFS4ERR_ADMIN_REVOKED (Error Code 10047) 9643 A stateid designates locking state of any type that has been revoked 9644 due to administrative interaction, possibly while the lease is valid. 9646 13.1.5.2. NFS4ERR_BAD_STATEID (Error Code 10026) 9648 A stateid generated by the current server instance, but which does 9649 not designate any locking state (either current or superseded) for a 9650 current lockowner-file pair, was used. 9652 13.1.5.3. NFS4ERR_EXPIRED (Error Code 10011) 9654 A stateid designates locking state of any type that has been revoked 9655 due to expiration of the client's lease, either immediately upon 9656 lease expiration, or following a later request for a conflicting 9657 lock. 9659 13.1.5.4. NFS4ERR_LEASE_MOVED (Error Code 10031) 9661 A lease being renewed is associated with a file system that has been 9662 migrated to a new server. 9664 13.1.5.5. NFS4ERR_OLD_STATEID (Error Code 10024) 9666 A stateid with a non-zero seqid value does match the current seqid 9667 for the state designated by the user. 9669 13.1.5.6. NFS4ERR_STALE_STATEID (Error Code 10023) 9671 A stateid generated by an earlier server instance was used. 9673 13.1.6. Security Errors 9675 These are the various permission-related errors in NFSv4. 9677 13.1.6.1. NFS4ERR_ACCESS (Error Code 13) 9679 Indicates permission denied. The caller does not have the correct 9680 permission to perform the requested operation. Contrast this with 9681 NFS4ERR_PERM (Section 13.1.6.2), which restricts itself to owner or 9682 privileged user permission failures. 9684 13.1.6.2. NFS4ERR_PERM (Error Code 1) 9686 Indicates requester is not the owner. The operation was not allowed 9687 because the caller is neither a privileged user (root) nor the owner 9688 of the target of the operation. 9690 13.1.6.3. NFS4ERR_WRONGSEC (Error Code 10016) 9692 Indicates that the security mechanism being used by the client for 9693 the operation does not match the server's security policy. The 9694 client should change the security mechanism being used and re-send 9695 the operation. SECINFO can be used to determine the appropriate 9696 mechanism. 9698 13.1.7. Name Errors 9700 Names in NFSv4 are UTF-8 strings. When the strings are not are of 9701 length zero, the error NFS4ERR_INVAL results. When they are not 9702 valid UTF-8 the error NFS4ERR_INVAL also results, but servers may 9703 accommodate file systems with different character formats and not 9704 return this error. Besides this, there are a number of other errors 9705 to indicate specific problems with names. 9707 13.1.7.1. NFS4ERR_BADCHAR (Error Code 10040) 9709 A UTF-8 string contains a character which is not supported by the 9710 server in the context in which it being used. 9712 13.1.7.2. NFS4ERR_BADNAME (Error Code 10041) 9714 A name string in a request consisted of valid UTF-8 characters 9715 supported by the server but the name is not supported by the server 9716 as a valid name for current operation. An example might be creating 9717 a file or directory named ".." on a server whose file system uses 9718 that name for links to parent directories. 9720 This error should not be returned due a normalization issue in a 9721 string. When a file system keeps names in a particular normalization 9722 form, it is the server's responsibility to do the appropriate 9723 normalization, rather than rejecting the name. 9725 13.1.7.3. NFS4ERR_NAMETOOLONG (Error Code 63) 9727 Returned when the filename in an operation exceeds the server's 9728 implementation limit. 9730 13.1.8. Locking Errors 9732 This section deal with errors related to locking, both as to share 9733 reservations and byte-range locking. It does not deal with errors 9734 specific to the process of reclaiming locks. Those are dealt with in 9735 the next section. 9737 13.1.8.1. NFS4ERR_BAD_RANGE (Error Code 10042) 9739 The range for a LOCK, LOCKT, or LOCKU operation is not appropriate to 9740 the allowable range of offsets for the server. E.g., this error 9741 results when a server which only supports 32-bit ranges receives a 9742 range that cannot be handled by that server. (See Section 15.12.4). 9744 13.1.8.2. NFS4ERR_BAD_SEQID (Error Code 10026) 9746 The sequence number (seqid) in a locking request is neither the next 9747 expected number or the last number processed. 9749 13.1.8.3. NFS4ERR_DEADLOCK (Error Code 10045) 9751 The server has been able to determine a file locking deadlock 9752 condition for a blocking lock request. 9754 13.1.8.4. NFS4ERR_DENIED (Error Code 10010) 9756 An attempt to lock a file is denied. Since this may be a temporary 9757 condition, the client is encouraged to re-send the lock request until 9758 the lock is accepted. See Section 9.4 for a discussion of the re- 9759 send. 9761 13.1.8.5. NFS4ERR_LOCKED (Error Code 10012) 9763 A read or write operation was attempted on a file where there was a 9764 conflict between the I/O and an existing lock: 9766 o There is a share reservation inconsistent with the I/O being done. 9768 o The range to be read or written intersects an existing mandatory 9769 byte range lock. 9771 13.1.8.6. NFS4ERR_LOCKS_HELD (Error Code 10037) 9773 An operation was prevented by the unexpected presence of locks. 9775 13.1.8.7. NFS4ERR_LOCK_NOTSUPP (Error Code 10043) 9777 A locking request was attempted which would require the upgrade or 9778 downgrade of a lock range already held by the owner when the server 9779 does not support atomic upgrade or downgrade of locks. 9781 13.1.8.8. NFS4ERR_LOCK_RANGE (Error Code 10028) 9783 A lock request is operating on a range that overlaps in part a 9784 currently held lock for the current lock owner and does not precisely 9785 match a single such lock where the server does not support this type 9786 of request, and thus does not implement POSIX locking semantics [35]. 9787 See Section 15.12.5, Section 15.13.5, and Section 15.14.5 for a 9788 discussion of how this applies to LOCK, LOCKT, and LOCKU 9789 respectively. 9791 13.1.8.9. NFS4ERR_OPENMODE (Error Code 10038) 9793 The client attempted a READ, WRITE, LOCK or other operation not 9794 sanctioned by the stateid passed (e.g., writing to a file opened only 9795 for read). 9797 13.1.9. Reclaim Errors 9799 These errors relate to the process of reclaiming locks after a server 9800 restart. 9802 13.1.9.1. NFS4ERR_GRACE (Error Code 10013) 9804 The server is in its recovery or grace period which should at least 9805 match the lease period of the server. A locking request other than a 9806 reclaim could not be granted during that period. 9808 13.1.9.2. NFS4ERR_NO_GRACE (Error Code 10033) 9810 A reclaim of client state was attempted in circumstances in which the 9811 server cannot guarantee that conflicting state has not been provided 9812 to another client. As a result, the server cannot guarantee that 9813 conflicting state has not been provided to another client. 9815 13.1.9.3. NFS4ERR_RECLAIM_BAD (Error Code 10034) 9817 A reclaim attempted by the client does not match the server's state 9818 consistency checks and has been rejected therefore as invalid. 9820 13.1.9.4. NFS4ERR_RECLAIM_CONFLICT (Error Code 10035) 9822 The reclaim attempted by the client has encountered a conflict and 9823 cannot be satisfied. Potentially indicates a misbehaving client, 9824 although not necessarily the one receiving the error. The 9825 misbehavior might be on the part of the client that established the 9826 lock with which this client conflicted. 9828 13.1.10. Client Management Errors 9830 This sections deals with errors associated with requests used to 9831 create and manage client IDs. 9833 13.1.10.1. NFS4ERR_CLID_INUSE (Error Code 10017) 9835 The SETCLIENTID operation has found that a client id is already in 9836 use by another client. 9838 13.1.10.2. NFS4ERR_STALE_CLIENTID (Error Code 10022) 9840 A client ID not recognized by the server was used in a locking or 9841 SETCLIENTID_CONFIRM request. 9843 13.1.11. Attribute Handling Errors 9845 This section deals with errors specific to attribute handling within 9846 NFSv4. 9848 13.1.11.1. NFS4ERR_ATTRNOTSUPP (Error Code 10032) 9850 An attribute specified is not supported by the server. This error 9851 MUST NOT be returned by the GETATTR operation. 9853 13.1.11.2. NFS4ERR_BADOWNER (Error Code 10039) 9855 Returned when an owner or owner_group attribute value or the who 9856 field of an ace within an ACL attribute value cannot be translated to 9857 a local representation. 9859 13.1.11.3. NFS4ERR_NOT_SAME (Error Code 10027) 9861 This error is returned by the VERIFY operation to signify that the 9862 attributes compared were not the same as those provided in the 9863 client's request. 9865 13.1.11.4. NFS4ERR_SAME (Error Code 10009) 9867 This error is returned by the NVERIFY operation to signify that the 9868 attributes compared were the same as those provided in the client's 9869 request. 9871 13.2. Operations and their valid errors 9873 This section contains a table which gives the valid error returns for 9874 each protocol operation. The error code NFS4_OK (indicating no 9875 error) is not listed but should be understood to be returnable by all 9876 operations except ILLEGAL. 9878 Valid error returns for each protocol operation 9880 +---------------------+---------------------------------------------+ 9881 | Operation | Errors | 9882 +---------------------+---------------------------------------------+ 9883 | ACCESS | NFS4ERR_ACCESS, NFS4ERR_BADHANDLE, | 9884 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 9885 | | NFS4ERR_FHEXPIRED, NFS4ERR_INVAL, | 9886 | | NFS4ERR_IO, NFS4ERR_MOVED, | 9887 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_RESOURCE, | 9888 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE | 9889 | CLOSE | NFS4ERR_ADMIN_REVOKED, NFS4ERR_BADHANDLE, | 9890 | | NFS4ERR_BAD_SEQID, NFS4ERR_BAD_STATEID, | 9891 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 9892 | | NFS4ERR_EXPIRED, NFS4ERR_FHEXPIRED, | 9893 | | NFS4ERR_INVAL, NFS4ERR_ISDIR, | 9894 | | NFS4ERR_LEASE_MOVED, NFS4ERR_LOCKS_HELD, | 9895 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 9896 | | NFS4ERR_OLD_STATEID, NFS4ERR_RESOURCE, | 9897 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 9898 | | NFS4ERR_STALE_STATEID | 9899 | COMMIT | NFS4ERR_ACCESS, NFS4ERR_BADHANDLE, | 9900 | | NFS4ERR_BADXDR, NFS4ERR_FHEXPIRED, | 9901 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_ISDIR, | 9902 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 9903 | | NFS4ERR_RESOURCE, NFS4ERR_ROFS, | 9904 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 9905 | | NFS4ERR_SYMLINK | 9906 | CREATE | NFS4ERR_ACCESS, NFS4ERR_ATTRNOTSUPP, | 9907 | | NFS4ERR_BADCHAR, NFS4ERR_BADHANDLE, | 9908 | | NFS4ERR_BADNAME, NFS4ERR_BADOWNER, | 9909 | | NFS4ERR_BADTYPE, NFS4ERR_BADXDR, | 9910 | | NFS4ERR_DELAY, NFS4ERR_DQUOT, | 9911 | | NFS4ERR_EXIST, NFS4ERR_FHEXPIRED, | 9912 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_MOVED, | 9913 | | NFS4ERR_NAMETOOLONG, NFS4ERR_NOFILEHANDLE, | 9914 | | NFS4ERR_NOSPC, NFS4ERR_NOTDIR, | 9915 | | NFS4ERR_PERM, NFS4ERR_RESOURCE, | 9916 | | NFS4ERR_ROFS, NFS4ERR_SERVERFAULT, | 9917 | | NFS4ERR_STALE | 9918 | DELEGPURGE | NFS4ERR_BADXDR, NFS4ERR_NOTSUPP, | 9919 | | NFS4ERR_LEASE_MOVED, NFS4ERR_RESOURCE, | 9920 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE_CLIENTID | 9921 | DELEGRETURN | NFS4ERR_ADMIN_REVOKED, NFS4ERR_BAD_STATEID, | 9922 | | NFS4ERR_BADXDR, NFS4ERR_EXPIRED, | 9923 | | NFS4ERR_INVAL, NFS4ERR_LEASE_MOVED, | 9924 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 9925 | | NFS4ERR_NOTSUPP, NFS4ERR_OLD_STATEID, | 9926 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT, | 9927 | | NFS4ERR_STALE, NFS4ERR_STALE_STATEID | 9928 | GETATTR | NFS4ERR_ACCESS, NFS4ERR_BADHANDLE, | 9929 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 9930 | | NFS4ERR_FHEXPIRED, NFS4ERR_GRACE, | 9931 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_MOVED, | 9932 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_RESOURCE, | 9933 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE | 9934 | GETFH | NFS4ERR_BADHANDLE, NFS4ERR_FHEXPIRED, | 9935 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 9936 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT, | 9937 | | NFS4ERR_STALE | 9938 | ILLEGAL | NFS4ERR_BADXDR, NFS4ERR_OP_ILLEGAL | 9939 | LINK | NFS4ERR_ACCESS, NFS4ERR_BADCHAR, | 9940 | | NFS4ERR_BADHANDLE, NFS4ERR_BADNAME, | 9941 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 9942 | | NFS4ERR_DQUOT, NFS4ERR_EXIST, | 9943 | | NFS4ERR_FHEXPIRED, NFS4ERR_FILE_OPEN, | 9944 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_ISDIR, | 9945 | | NFS4ERR_MLINK, NFS4ERR_MOVED, | 9946 | | NFS4ERR_NAMETOOLONG, NFS4ERR_NOENT, | 9947 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_NOSPC, | 9948 | | NFS4ERR_NOTDIR, NFS4ERR_NOTSUPP, | 9949 | | NFS4ERR_RESOURCE, NFS4ERR_ROFS, | 9950 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 9951 | | NFS4ERR_WRONGSEC, NFS4ERR_XDEV | 9952 | LOCK | NFS4ERR_ACCESS, NFS4ERR_ADMIN_REVOKED, | 9953 | | NFS4ERR_BADHANDLE, NFS4ERR_BAD_RANGE, | 9954 | | NFS4ERR_BAD_SEQID, NFS4ERR_BAD_STATEID, | 9955 | | NFS4ERR_BADXDR, NFS4ERR_DEADLOCK, | 9956 | | NFS4ERR_DELAY, NFS4ERR_DENIED, | 9957 | | NFS4ERR_EXPIRED, NFS4ERR_FHEXPIRED, | 9958 | | NFS4ERR_GRACE, NFS4ERR_INVAL, | 9959 | | NFS4ERR_ISDIR, NFS4ERR_LEASE_MOVED, | 9960 | | NFS4ERR_LOCK_NOTSUPP, NFS4ERR_LOCK_RANGE, | 9961 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 9962 | | NFS4ERR_NO_GRACE, NFS4ERR_OLD_STATEID, | 9963 | | NFS4ERR_OPENMODE, NFS4ERR_RECLAIM_BAD, | 9964 | | NFS4ERR_RECLAIM_CONFLICT, NFS4ERR_RESOURCE, | 9965 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 9966 | | NFS4ERR_STALE_CLIENTID, | 9967 | | NFS4ERR_STALE_STATEID | 9968 | LOCKT | NFS4ERR_ACCESS, NFS4ERR_BADHANDLE, | 9969 | | NFS4ERR_BAD_RANGE, NFS4ERR_BADXDR, | 9970 | | NFS4ERR_DELAY, NFS4ERR_DENIED, | 9971 | | NFS4ERR_FHEXPIRED, NFS4ERR_GRACE, | 9972 | | NFS4ERR_INVAL, NFS4ERR_ISDIR, | 9973 | | NFS4ERR_LEASE_MOVED, NFS4ERR_LOCK_RANGE, | 9974 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 9975 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT, | 9976 | | NFS4ERR_STALE, NFS4ERR_STALE_CLIENTID | 9977 | LOCKU | NFS4ERR_ACCESS, NFS4ERR_ADMIN_REVOKED, | 9978 | | NFS4ERR_BADHANDLE, NFS4ERR_BAD_RANGE, | 9979 | | NFS4ERR_BAD_SEQID, NFS4ERR_BAD_STATEID, | 9980 | | NFS4ERR_BADXDR, NFS4ERR_EXPIRED, | 9981 | | NFS4ERR_FHEXPIRED, NFS4ERR_GRACE, | 9982 | | NFS4ERR_INVAL, NFS4ERR_ISDIR, | 9983 | | NFS4ERR_LEASE_MOVED, NFS4ERR_LOCK_RANGE, | 9984 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 9985 | | NFS4ERR_OLD_STATEID, NFS4ERR_RESOURCE, | 9986 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 9987 | | NFS4ERR_STALE_STATEID | 9988 | LOOKUP | NFS4ERR_ACCESS, NFS4ERR_BADCHAR, | 9989 | | NFS4ERR_BADHANDLE, NFS4ERR_BADNAME, | 9990 | | NFS4ERR_BADXDR, NFS4ERR_FHEXPIRED, | 9991 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_MOVED, | 9992 | | NFS4ERR_NAMETOOLONG, NFS4ERR_NOENT, | 9993 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_NOTDIR, | 9994 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT, | 9995 | | NFS4ERR_STALE, NFS4ERR_SYMLINK, | 9996 | | NFS4ERR_WRONGSEC | 9997 | LOOKUPP | NFS4ERR_ACCESS, NFS4ERR_BADHANDLE, | 9998 | | NFS4ERR_DELAY, NFS4ERR_FHEXPIRED, | 9999 | | NFS4ERR_IO, NFS4ERR_MOVED, NFS4ERR_NOENT, | 10000 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_NOTDIR, | 10001 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT, | 10002 | | NFS4ERR_STALE, NFS4ERR_SYMLINK, | 10003 | | NFS4ERR_WRONGSEC | 10004 | NVERIFY | NFS4ERR_ACCESS, NFS4ERR_ATTRNOTSUPP, | 10005 | | NFS4ERR_BADCHAR, NFS4ERR_BADHANDLE, | 10006 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 10007 | | NFS4ERR_FHEXPIRED, NFS4ERR_GRACE, | 10008 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_MOVED, | 10009 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_SAME, | 10010 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE | 10011 | OPEN | NFS4ERR_ACCESS, NFS4ERR_ADMIN_REVOKED, | 10012 | | NFS4ERR_ATTRNOTSUPP, NFS4ERR_BADCHAR, | 10013 | | NFS4ERR_BADHANDLE, NFS4ERR_BADNAME, | 10014 | | NFS4ERR_BADOWNER, NFS4ERR_BADXDR, | 10015 | | NFS4ERR_BAD_SEQID, NFS4ERR_BAD_STATEID, | 10016 | | NFS4ERR_DELAY, NFS4ERR_DQUOT, | 10017 | | NFS4ERR_EXIST, NFS4ERR_EXPIRED, | 10018 | | NFS4ERR_FBIG, NFS4ERR_FHEXPIRED, | 10019 | | NFS4ERR_GRACE, NFS4ERR_INVAL, NFS4ERR_IO, | 10020 | | NFS4ERR_ISDIR, NFS4ERR_MOVED, | 10021 | | NFS4ERR_NAMETOOLONG, NFS4ERR_NOENT, | 10022 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_NOSPC, | 10023 | | NFS4ERR_NOTDIR, NFS4ERR_NOTSUP, | 10024 | | NFS4ERR_NO_GRACE, NFS4ERR_OLD_STATEID, | 10025 | | NFS4ERR_PERM, NFS4ERR_RECLAIM_BAD, | 10026 | | NFS4ERR_RECLAIM_CONFLICT, NFS4ERR_RESOURCE, | 10027 | | NFS4ERR_ROFS, NFS4ERR_SERVERFAULT, | 10028 | | NFS4ERR_SHARE_DENIED, NFS4ERR_STALE, | 10029 | | NFS4ERR_STALE_CLIENTID, NFS4ERR_SYMLINK, | 10030 | | NFS4ERR_WRONGSEC | 10031 | OPENATTR | NFS4ERR_ACCESS, NFS4ERR_BADHANDLE, | 10032 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 10033 | | NFS4ERR_DQUOT, NFS4ERR_FHEXPIRED, | 10034 | | NFS4ERR_IO, NFS4ERR_MOVED, NFS4ERR_NOENT, | 10035 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_NOSPC, | 10036 | | NFS4ERR_NOTSUPP, NFS4ERR_RESOURCE, | 10037 | | NFS4ERR_ROFS, NFS4ERR_SERVERFAULT, | 10038 | | NFS4ERR_STALE | 10039 | OPEN_CONFIRM | NFS4ERR_ADMIN_REVOKED, NFS4ERR_BADHANDLE, | 10040 | | NFS4ERR_BAD_SEQID, NFS4ERR_BAD_STATEID, | 10041 | | NFS4ERR_BADXDR, NFS4ERR_EXPIRED, | 10042 | | NFS4ERR_FHEXPIRED, NFS4ERR_INVAL, | 10043 | | NFS4ERR_ISDIR, NFS4ERR_LEASE_MOVED, | 10044 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 10045 | | NFS4ERR_OLD_STATEID, NFS4ERR_RESOURCE, | 10046 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 10047 | | NFS4ERR_STALE_STATEID | 10048 | OPEN_DOWNGRADE | NFS4ERR_ADMIN_REVOKED, NFS4ERR_BADHANDLE, | 10049 | | NFS4ERR_BADXDR, NFS4ERR_BAD_SEQID, | 10050 | | NFS4ERR_BAD_STATEID, NFS4ERR_DELAY, | 10051 | | NFS4ERR_EXPIRED, NFS4ERR_FHEXPIRED, | 10052 | | NFS4ERR_INVAL, NFS4ERR_LEASE_MOVED, | 10053 | | NFS4ERR_LOCKS_HELD, NFS4ERR_MOVED, | 10054 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_OLD_STATEID, | 10055 | | NFS4ERR_RESOURCE, NFS4ERR_ROFS, | 10056 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 10057 | | NFS4ERR_STALE_STATEID | 10058 | PUTFH | NFS4ERR_BADHANDLE, NFS4ERR_BADXDR, | 10059 | | NFS4ERR_DELAY, NFS4ERR_FHEXPIRED, | 10060 | | NFS4ERR_MOVED, NFS4ERR_SERVERFAULT, | 10061 | | NFS4ERR_STALE, NFS4ERR_WRONGSEC | 10062 | PUTPUBFH | NFS4ERR_DELAY, NFS4ERR_SERVERFAULT, | 10063 | | NFS4ERR_WRONGSEC | 10064 | PUTROOTFH | NFS4ERR_DELAY, NFS4ERR_SERVERFAULT, | 10065 | | NFS4ERR_WRONGSEC | 10066 | READ | NFS4ERR_ACCESS, NFS4ERR_ADMIN_REVOKED, | 10067 | | NFS4ERR_BADHANDLE, NFS4ERR_BADXDR, | 10068 | | NFS4ERR_BAD_STATEID, NFS4ERR_DELAY, | 10069 | | NFS4ERR_EXPIRED, NFS4ERR_FHEXPIRED, | 10070 | | NFS4ERR_GRACE, NFS4ERR_INVAL, NFS4ERR_IO, | 10071 | | NFS4ERR_ISDIR, NFS4ERR_LEASE_MOVED, | 10072 | | NFS4ERR_LOCKED, NFS4ERR_MOVED, | 10073 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_OLD_STATEID, | 10074 | | NFS4ERR_OPENMODE, NFS4ERR_RESOURCE, | 10075 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 10076 | | NFS4ERR_STALE_STATEID, NFS4ERR_SYMLINK | 10077 | READDIR | NFS4ERR_ACCESS, NFS4ERR_BADHANDLE, | 10078 | | NFS4ERR_BADXDR, NFS4ERR_BAD_COOKIE, | 10079 | | NFS4ERR_DELAY, NFS4ERR_FHEXPIRED, | 10080 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_MOVED, | 10081 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_NOTDIR, | 10082 | | NFS4ERR_NOT_SAME, NFS4ERR_RESOURCE, | 10083 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 10084 | | NFS4ERR_TOOSMALL | 10085 | READLINK | NFS4ERR_ACCESS, NFS4ERR_BADHANDLE, | 10086 | | NFS4ERR_DELAY, NFS4ERR_FHEXPIRED, | 10087 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_ISDIR, | 10088 | | NFS4ERR_MOVED, NFS4ERR_NOTSUP, | 10089 | | NFS4ERR_RESOURCE, NFS4ERR_NOFILEHANDLE, | 10090 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE | 10091 | RELEASE_LOCKOWNER | NFS4ERR_ADMIN_REVOKED, NFS4ERR_BADXDR, | 10092 | | NFS4ERR_EXPIRED, NFS4ERR_LEASE_MOVED, | 10093 | | NFS4ERR_LOCKS_HELD, NFS4ERR_RESOURCE, | 10094 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE_CLIENTID | 10095 | REMOVE | NFS4ERR_ACCESS, NFS4ERR_BADCHAR, | 10096 | | NFS4ERR_BADHANDLE, NFS4ERR_BADNAME, | 10097 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 10098 | | NFS4ERR_FHEXPIRED, NFS4ERR_FILE_OPEN, | 10099 | | NFS4ERR_GRACE, NFS4ERR_INVAL, NFS4ERR_IO, | 10100 | | NFS4ERR_MOVED, NFS4ERR_NAMETOOLONG, | 10101 | | NFS4ERR_NOENT, NFS4ERR_NOFILEHANDLE, | 10102 | | NFS4ERR_NOTDIR, NFS4ERR_NOTEMPTY, | 10103 | | NFS4ERR_RESOURCE, NFS4ERR_ROFS, | 10104 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE | 10105 | RENAME | NFS4ERR_ACCESS, NFS4ERR_BADCHAR, | 10106 | | NFS4ERR_BADHANDLE, NFS4ERR_BADNAME, | 10107 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 10108 | | NFS4ERR_DQUOT, NFS4ERR_EXIST, | 10109 | | NFS4ERR_FHEXPIRED, NFS4ERR_FILE_OPEN, | 10110 | | NFS4ERR_GRACE, NFS4ERR_INVAL, NFS4ERR_IO, | 10111 | | NFS4ERR_MOVED, NFS4ERR_NAMETOOLONG, | 10112 | | NFS4ERR_NOENT, NFS4ERR_NOFILEHANDLE, | 10113 | | NFS4ERR_NOSPC, NFS4ERR_NOTDIR, | 10114 | | NFS4ERR_NOTEMPTY, NFS4ERR_RESOURCE, | 10115 | | NFS4ERR_ROFS, NFS4ERR_SERVERFAULT, | 10116 | | NFS4ERR_STALE, NFS4ERR_WRONGSEC, | 10117 | | NFS4ERR_XDEV | 10118 | RENEW | NFS4ERR_ACCESS, NFS4ERR_ADMIN_REVOKED, | 10119 | | NFS4ERR_BADXDR, NFS4ERR_CB_PATH_DOWN, | 10120 | | NFS4ERR_EXPIRED, NFS4ERR_LEASE_MOVED, | 10121 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT, | 10122 | | NFS4ERR_STALE_CLIENTID | 10123 | RESTOREFH | NFS4ERR_BADHANDLE, NFS4ERR_FHEXPIRED, | 10124 | | NFS4ERR_MOVED, NFS4ERR_RESOURCE, | 10125 | | NFS4ERR_RESTOREFH, NFS4ERR_SERVERFAULT, | 10126 | | NFS4ERR_STALE, NFS4ERR_WRONGSEC | 10127 | SAVEFH | NFS4ERR_BADHANDLE, NFS4ERR_FHEXPIRED, | 10128 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 10129 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT, | 10130 | | NFS4ERR_STALE | 10131 | SECINFO | NFS4ERR_ACCESS, NFS4ERR_BADCHAR, | 10132 | | NFS4ERR_BADHANDLE, NFS4ERR_BADNAME, | 10133 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 10134 | | NFS4ERR_FHEXPIRED, NFS4ERR_INVAL, | 10135 | | NFS4ERR_MOVED, NFS4ERR_NAMETOOLONG, | 10136 | | NFS4ERR_NOENT, NFS4ERR_NOFILEHANDLE, | 10137 | | NFS4ERR_NOTDIR, NFS4ERR_RESOURCE, | 10138 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE | 10139 | SETATTR | NFS4ERR_ACCESS, NFS4ERR_ADMIN_REVOKED, | 10140 | | NFS4ERR_ATTRNOTSUPP, NFS4ERR_BADCHAR, | 10141 | | NFS4ERR_BADHANDLE, NFS4ERR_BADOWNER, | 10142 | | NFS4ERR_BADXDR, NFS4ERR_BAD_STATEID, | 10143 | | NFS4ERR_DELAY, NFS4ERR_DQUOT, | 10144 | | NFS4ERR_EXPIRED, NFS4ERR_FBIG, | 10145 | | NFS4ERR_FHEXPIRED, NFS4ERR_GRACE, | 10146 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_ISDIR, | 10147 | | NFS4ERR_LEASE_MOVED, NFS4ERR_LOCKED, | 10148 | | NFS4ERR_MOVED, NFS4ERR_NOFILEHANDLE, | 10149 | | NFS4ERR_NOSPC, NFS4ERR_OLD_STATEID, | 10150 | | NFS4ERR_OPENMODE, NFS4ERR_PERM, | 10151 | | NFS4ERR_RESOURCE, NFS4ERR_ROFS, | 10152 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE, | 10153 | | NFS4ERR_STALE_STATEID | 10154 | SETCLIENTID | NFS4ERR_BADXDR, NFS4ERR_CLID_INUSE, | 10155 | | NFS4ERR_DELAY, NFS4ERR_INVAL, | 10156 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT | 10157 | SETCLIENTID_CONFIRM | NFS4ERR_BADXDR, NFS4ERR_CLID_INUSE, | 10158 | | NFS4ERR_DELAY, NFS4ERR_RESOURCE, | 10159 | | NFS4ERR_SERVERFAULT, NFS4ERR_STALE_CLIENTID | 10160 | VERIFY | NFS4ERR_ACCESS, NFS4ERR_ATTRNOTSUPP, | 10161 | | NFS4ERR_BADCHAR, NFS4ERR_BADHANDLE, | 10162 | | NFS4ERR_BADXDR, NFS4ERR_DELAY, | 10163 | | NFS4ERR_FHEXPIRED, NFS4ERR_GRACE, | 10164 | | NFS4ERR_INVAL, NFS4ERR_IO, NFS4ERR_MOVED, | 10165 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_NOT_SAME, | 10166 | | NFS4ERR_RESOURCE, NFS4ERR_SERVERFAULT, | 10167 | | NFS4ERR_STALE | 10168 | WRITE | NFS4ERR_ACCESS, NFS4ERR_ADMIN_REVOKED, | 10169 | | NFS4ERR_BADXDR, NFS4ERR_BADHANDLE, | 10170 | | NFS4ERR_BAD_STATEID, NFS4ERR_DELAY, | 10171 | | NFS4ERR_DQUOT, NFS4ERR_EXPIRED, | 10172 | | NFS4ERR_FBIG, NFS4ERR_FHEXPIRED, | 10173 | | NFS4ERR_GRACE, NFS4ERR_INVAL, NFS4ERR_IO, | 10174 | | NFS4ERR_ISDIR, NFS4ERR_LEASE_MOVED, | 10175 | | NFS4ERR_LOCKED, NFS4ERR_MOVED, | 10176 | | NFS4ERR_NOFILEHANDLE, NFS4ERR_NOSPC, | 10177 | | NFS4ERR_NXIO, NFS4ERR_OLD_STATEID, | 10178 | | NFS4ERR_OPENMODE, NFS4ERR_RESOURCE, | 10179 | | NFS4ERR_ROFS, NFS4ERR_SERVERFAULT, | 10180 | | NFS4ERR_STALE, NFS4ERR_STALE_STATEID, | 10181 | | NFS4ERR_SYMLINK | 10182 +---------------------+---------------------------------------------+ 10184 Table 9 10186 13.3. Callback operations and their valid errors 10188 This section contains a table which gives the valid error returns for 10189 each callback operation. The error code NFS4_OK (indicating no 10190 error) is not listed but should be understood to be returnable by all 10191 callback operations with the exception of CB_ILLEGAL. 10193 Valid error returns for each protocol callback operation 10195 +-------------+-----------------------------------------------------+ 10196 | Callback | Errors | 10197 | Operation | | 10198 +-------------+-----------------------------------------------------+ 10199 | CB_GETATTR | NFS4ERR_BADHANDLE, NFS4ERR_BADXDR, NFS4ERR_DELAY, | 10200 | | NFS4ERR_INVAL, NFS4ERR_SERVERFAULT | 10201 | CB_ILLEGAL | NFS4ERR_BADXDR, NFS4ERR_OP_ILLEGAL | 10202 | CB_RECALL | NFS4ERR_BADHANDLE, NFS4ERR_BADXDR, | 10203 | | NFS4ERR_BAD_STATEID, NFS4ERR_DELAY, | 10204 | | NFS4ERR_SERVERFAULT | 10205 +-------------+-----------------------------------------------------+ 10207 Table 10 10209 13.4. Errors and the operations that use them 10210 +--------------------------+----------------------------------------+ 10211 | Error | Operations | 10212 +--------------------------+----------------------------------------+ 10213 | NFS4ERR_ACCESS | ACCESS, COMMIT, CREATE, GETATTR, LINK, | 10214 | | LOCK, LOCKT, LOCKU, LOOKUP, LOOKUPP, | 10215 | | NVERIFY, OPEN, OPENATTR, READ, | 10216 | | READDIR, READLINK, REMOVE, RENAME, | 10217 | | RENEW, SECINFO, SETATTR, VERIFY, WRITE | 10218 | NFS4ERR_ADMIN_REVOKED | CLOSE, DELEGRETURN, LOCK, LOCKU, OPEN, | 10219 | | OPEN_CONFIRM, OPEN_DOWNGRADE, READ, | 10220 | | RELEASE_LOCKOWNER, RENEW, SETATTR, | 10221 | | WRITE | 10222 | NFS4ERR_ATTRNOTSUPP | CREATE, NVERIFY, OPEN, SETATTR, VERIFY | 10223 | NFS4ERR_BADCHAR | CREATE, LINK, LOOKUP, NVERIFY, OPEN, | 10224 | | REMOVE, RENAME, SECINFO, SETATTR, | 10225 | | VERIFY | 10226 | NFS4ERR_BADHANDLE | ACCESS, CB_GETATTR, CB_RECALL, CLOSE, | 10227 | | COMMIT, CREATE, GETATTR, GETFH, LINK, | 10228 | | LOCK, LOCKT, LOCKU, LOOKUP, LOOKUPP, | 10229 | | NVERIFY, OPEN, OPENATTR, OPEN_CONFIRM, | 10230 | | OPEN_DOWNGRADE, PUTFH, READ, READDIR, | 10231 | | READLINK, REMOVE, RENAME, RESTOREFH, | 10232 | | SAVEFH, SECINFO, SETATTR, VERIFY, | 10233 | | WRITE | 10234 | NFS4ERR_BADNAME | CREATE, LINK, LOOKUP, OPEN, REMOVE, | 10235 | | RENAME, SECINFO | 10236 | NFS4ERR_BADOWNER | CREATE, OPEN, SETATTR | 10237 | NFS4ERR_BADTYPE | CREATE | 10238 | NFS4ERR_BADXDR | ACCESS, CB_GETATTR, CB_ILLEGAL, | 10239 | | CB_RECALL, CLOSE, COMMIT, CREATE, | 10240 | | DELEGPURGE, DELEGRETURN, GETATTR, | 10241 | | ILLEGAL, LINK, LOCK, LOCKT, LOCKU, | 10242 | | LOOKUP, NVERIFY, OPEN, OPENATTR, | 10243 | | OPEN_CONFIRM, OPEN_DOWNGRADE, PUTFH, | 10244 | | READ, READDIR, RELEASE_LOCKOWNER, | 10245 | | REMOVE, RENAME, RENEW, SECINFO, | 10246 | | SETATTR, SETCLIENTID, | 10247 | | SETCLIENTID_CONFIRM, VERIFY, WRITE | 10248 | NFS4ERR_BAD_COOKIE | READDIR | 10249 | NFS4ERR_BAD_RANGE | LOCK, LOCKT, LOCKU | 10250 | NFS4ERR_BAD_SEQID | CLOSE, LOCK, LOCKU, OPEN, | 10251 | | OPEN_CONFIRM, OPEN_DOWNGRADE | 10252 | NFS4ERR_BAD_STATEID | CB_RECALL, CLOSE, DELEGRETURN, LOCK, | 10253 | | LOCKU, OPEN, OPEN_CONFIRM, | 10254 | | OPEN_DOWNGRADE, READ, SETATTR, WRITE | 10255 | NFS4ERR_CB_PATH_DOWN | RENEW | 10256 | NFS4ERR_CLID_INUSE | SETCLIENTID, SETCLIENTID_CONFIRM | 10257 | NFS4ERR_DEADLOCK | LOCK | 10258 | NFS4ERR_DELAY | ACCESS, CB_GETATTR, CB_RECALL, CLOSE, | 10259 | | CREATE, GETATTR, LINK, LOCK, LOCKT, | 10260 | | LOOKUPP, NVERIFY, OPEN, OPENATTR, | 10261 | | OPEN_DOWNGRADE, PUTFH, PUTPUBFH, | 10262 | | PUTROOTFH, READ, READDIR, READLINK, | 10263 | | REMOVE, RENAME, SECINFO, SETATTR, | 10264 | | SETCLIENTID, SETCLIENTID_CONFIRM, | 10265 | | VERIFY, WRITE | 10266 | NFS4ERR_DENIED | LOCK, LOCKT | 10267 | NFS4ERR_DQUOT | CREATE, LINK, OPEN, OPENATTR, RENAME, | 10268 | | SETATTR, WRITE | 10269 | NFS4ERR_EXIST | CREATE, LINK, OPEN, RENAME | 10270 | NFS4ERR_EXPIRED | CLOSE, DELEGRETURN, LOCK, LOCKU, OPEN, | 10271 | | OPEN_CONFIRM, OPEN_DOWNGRADE, READ, | 10272 | | RELEASE_LOCKOWNER, RENEW, SETATTR, | 10273 | | WRITE | 10274 | NFS4ERR_FBIG | OPEN, SETATTR, WRITE | 10275 | NFS4ERR_FHEXPIRED | ACCESS, CLOSE, COMMIT, CREATE, | 10276 | | GETATTR, GETFH, LINK, LOCK, LOCKT, | 10277 | | LOCKU, LOOKUP, LOOKUPP, NVERIFY, OPEN, | 10278 | | OPENATTR, OPEN_CONFIRM, | 10279 | | OPEN_DOWNGRADE, PUTFH, READ, READDIR, | 10280 | | READLINK, REMOVE, RENAME, RESTOREFH, | 10281 | | SAVEFH, SECINFO, SETATTR, VERIFY, | 10282 | | WRITE | 10283 | NFS4ERR_FILE_OPEN | LINK, REMOVE, RENAME | 10284 | NFS4ERR_GRACE | GETATTR, LOCK, LOCKT, LOCKU, NVERIFY, | 10285 | | OPEN, READ, REMOVE, RENAME, SETATTR, | 10286 | | VERIFY, WRITE | 10287 | NFS4ERR_INVAL | ACCESS, CB_GETATTR, CLOSE, COMMIT, | 10288 | | CREATE, DELEGRETURN, GETATTR, LINK, | 10289 | | LOCK, LOCKT, LOCKU, LOOKUP, NVERIFY, | 10290 | | OPEN, OPEN_CONFIRM, OPEN_DOWNGRADE, | 10291 | | READ, READDIR, READLINK, REMOVE, | 10292 | | RENAME, SECINFO, SETATTR, SETCLIENTID, | 10293 | | VERIFY, WRITE | 10294 | NFS4ERR_IO | ACCESS, COMMIT, CREATE, GETATTR, LINK, | 10295 | | LOOKUP, LOOKUPP, NVERIFY, OPEN, | 10296 | | OPENATTR, READ, READDIR, READLINK, | 10297 | | REMOVE, RENAME, SETATTR, VERIFY, WRITE | 10298 | NFS4ERR_ISDIR | CLOSE, COMMIT, LINK, LOCK, LOCKT, | 10299 | | LOCKU, OPEN, OPEN_CONFIRM, READ, | 10300 | | READLINK, SETATTR, WRITE | 10301 | NFS4ERR_LEASE_MOVED | CLOSE, DELEGPURGE, DELEGRETURN, LOCK, | 10302 | | LOCKT, LOCKU, OPEN_CONFIRM, | 10303 | | OPEN_DOWNGRADE, READ, | 10304 | | RELEASE_LOCKOWNER, RENEW, SETATTR, | 10305 | | WRITE | 10306 | NFS4ERR_LOCKED | READ, SETATTR, WRITE | 10307 | NFS4ERR_LOCKS_HELD | CLOSE, OPEN_DOWNGRADE, | 10308 | | RELEASE_LOCKOWNER | 10309 | NFS4ERR_LOCK_NOTSUPP | LOCK | 10310 | NFS4ERR_LOCK_RANGE | LOCK, LOCKT, LOCKU | 10311 | NFS4ERR_MLINK | LINK | 10312 | NFS4ERR_MOVED | ACCESS, CLOSE, COMMIT, CREATE, | 10313 | | DELEGRETURN, GETATTR, GETFH, LINK, | 10314 | | LOCK, LOCKT, LOCKU, LOOKUP, LOOKUPP, | 10315 | | NVERIFY, OPEN, OPENATTR, OPEN_CONFIRM, | 10316 | | OPEN_DOWNGRADE, PUTFH, READ, READDIR, | 10317 | | READLINK, REMOVE, RENAME, RESTOREFH, | 10318 | | SAVEFH, SECINFO, SETATTR, VERIFY, | 10319 | | WRITE | 10320 | NFS4ERR_NAMETOOLONG | CREATE, LINK, LOOKUP, OPEN, REMOVE, | 10321 | | RENAME, SECINFO | 10322 | NFS4ERR_NOENT | LINK, LOOKUP, LOOKUPP, OPEN, OPENATTR, | 10323 | | REMOVE, RENAME, SECINFO | 10324 | NFS4ERR_NOFILEHANDLE | ACCESS, CLOSE, COMMIT, CREATE, | 10325 | | DELEGRETURN, GETATTR, GETFH, LINK, | 10326 | | LOCK, LOCKT, LOCKU, LOOKUP, LOOKUPP, | 10327 | | NVERIFY, OPEN, OPENATTR, OPEN_CONFIRM, | 10328 | | OPEN_DOWNGRADE, READ, READDIR, | 10329 | | READLINK, REMOVE, RENAME, SAVEFH, | 10330 | | SECINFO, SETATTR, VERIFY, WRITE | 10331 | NFS4ERR_NOSPC | CREATE, LINK, OPEN, OPENATTR, RENAME, | 10332 | | SETATTR, WRITE | 10333 | NFS4ERR_NOTDIR | CREATE, LINK, LOOKUP, LOOKUPP, OPEN, | 10334 | | READDIR, REMOVE, RENAME, SECINFO | 10335 | NFS4ERR_NOTEMPTY | REMOVE, RENAME | 10336 | NFS4ERR_NOTSUP | OPEN, READLINK | 10337 | NFS4ERR_NOTSUPP | DELEGPURGE, DELEGRETURN, LINK, | 10338 | | OPENATTR | 10339 | NFS4ERR_NOT_SAME | READDIR, VERIFY | 10340 | NFS4ERR_NO_GRACE | LOCK, OPEN | 10341 | NFS4ERR_NXIO | WRITE | 10342 | NFS4ERR_OLD_STATEID | CLOSE, DELEGRETURN, LOCK, LOCKU, OPEN, | 10343 | | OPEN_CONFIRM, OPEN_DOWNGRADE, READ, | 10344 | | SETATTR, WRITE | 10345 | NFS4ERR_OPENMODE | LOCK, READ, SETATTR, WRITE | 10346 | NFS4ERR_OP_ILLEGAL | CB_ILLEGAL, ILLEGAL | 10347 | NFS4ERR_PERM | CREATE, OPEN, SETATTR | 10348 | NFS4ERR_RECLAIM_BAD | LOCK, OPEN | 10349 | NFS4ERR_RECLAIM_CONFLICT | LOCK, OPEN | 10350 | NFS4ERR_RESOURCE | ACCESS, CLOSE, COMMIT, CREATE, | 10351 | | DELEGPURGE, DELEGRETURN, GETATTR, | 10352 | | GETFH, LINK, LOCK, LOCKT, LOCKU, | 10353 | | LOOKUP, LOOKUPP, OPEN, OPENATTR, | 10354 | | OPEN_CONFIRM, OPEN_DOWNGRADE, READ, | 10355 | | READDIR, READLINK, RELEASE_LOCKOWNER, | 10356 | | REMOVE, RENAME, RENEW, RESTOREFH, | 10357 | | SAVEFH, SECINFO, SETATTR, SETCLIENTID, | 10358 | | SETCLIENTID_CONFIRM, VERIFY, WRITE | 10359 | NFS4ERR_RESTOREFH | RESTOREFH | 10360 | NFS4ERR_ROFS | COMMIT, CREATE, LINK, OPEN, OPENATTR, | 10361 | | OPEN_DOWNGRADE, REMOVE, RENAME, | 10362 | | SETATTR, WRITE | 10363 | NFS4ERR_SAME | NVERIFY | 10364 | NFS4ERR_SERVERFAULT | ACCESS, CB_GETATTR, CB_RECALL, CLOSE, | 10365 | | COMMIT, CREATE, DELEGPURGE, | 10366 | | DELEGRETURN, GETATTR, GETFH, LINK, | 10367 | | LOCK, LOCKT, LOCKU, LOOKUP, LOOKUPP, | 10368 | | NVERIFY, OPEN, OPENATTR, OPEN_CONFIRM, | 10369 | | OPEN_DOWNGRADE, PUTFH, PUTPUBFH, | 10370 | | PUTROOTFH, READ, READDIR, READLINK, | 10371 | | RELEASE_LOCKOWNER, REMOVE, RENAME, | 10372 | | RENEW, RESTOREFH, SAVEFH, SECINFO, | 10373 | | SETATTR, SETCLIENTID, | 10374 | | SETCLIENTID_CONFIRM, VERIFY, WRITE | 10375 | NFS4ERR_SHARE_DENIED | OPEN | 10376 | NFS4ERR_STALE | ACCESS, CLOSE, COMMIT, CREATE, | 10377 | | DELEGRETURN, GETATTR, GETFH, LINK, | 10378 | | LOCK, LOCKT, LOCKU, LOOKUP, LOOKUPP, | 10379 | | NVERIFY, OPEN, OPENATTR, OPEN_CONFIRM, | 10380 | | OPEN_DOWNGRADE, PUTFH, READ, READDIR, | 10381 | | READLINK, REMOVE, RENAME, RESTOREFH, | 10382 | | SAVEFH, SECINFO, SETATTR, VERIFY, | 10383 | | WRITE | 10384 | NFS4ERR_STALE_CLIENTID | DELEGPURGE, LOCK, LOCKT, OPEN, | 10385 | | RELEASE_LOCKOWNER, RENEW, | 10386 | | SETCLIENTID_CONFIRM | 10387 | NFS4ERR_STALE_STATEID | CLOSE, DELEGRETURN, LOCK, LOCKU, | 10388 | | OPEN_CONFIRM, OPEN_DOWNGRADE, READ, | 10389 | | SETATTR, WRITE | 10390 | NFS4ERR_SYMLINK | COMMIT, LOOKUP, LOOKUPP, OPEN, READ, | 10391 | | WRITE | 10392 | NFS4ERR_TOOSMALL | READDIR | 10393 | NFS4ERR_WRONGSEC | LINK, LOOKUP, LOOKUPP, OPEN, PUTFH, | 10394 | | PUTPUBFH, PUTROOTFH, RENAME, RESTOREFH | 10395 | NFS4ERR_XDEV | LINK, RENAME | 10396 +--------------------------+----------------------------------------+ 10397 Table 11 10399 14. NFSv4 Requests 10401 For the NFSv4 RPC program, there are two traditional RPC procedures: 10402 NULL and COMPOUND. All other functionality is defined as a set of 10403 operations and these operations are defined in normal XDR/RPC syntax 10404 and semantics. However, these operations are encapsulated within the 10405 COMPOUND procedure. This requires that the client combine one or 10406 more of the NFSv4 operations into a single request. 10408 The NFS4_CALLBACK program is used to provide server to client 10409 signaling and is constructed in a similar fashion as the NFSv4 10410 program. The procedures CB_NULL and CB_COMPOUND are defined in the 10411 same way as NULL and COMPOUND are within the NFS program. The 10412 CB_COMPOUND request also encapsulates the remaining operations of the 10413 NFS4_CALLBACK program. There is no predefined RPC program number for 10414 the NFS4_CALLBACK program. It is up to the client to specify a 10415 program number in the "transient" program range. The program and 10416 port number of the NFS4_CALLBACK program are provided by the client 10417 as part of the SETCLIENTID/SETCLIENTID_CONFIRM sequence. The program 10418 and port can be changed by another SETCLIENTID/SETCLIENTID_CONFIRM 10419 sequence, and it is possible to use the sequence to change them 10420 within a client incarnation without removing relevant leased client 10421 state. 10423 14.1. Compound Procedure 10425 The COMPOUND procedure provides the opportunity for better 10426 performance within high latency networks. The client can avoid 10427 cumulative latency of multiple RPCs by combining multiple dependent 10428 operations into a single COMPOUND procedure. A compound operation 10429 may provide for protocol simplification by allowing the client to 10430 combine basic procedures into a single request that is customized for 10431 the client's environment. 10433 The CB_COMPOUND procedure precisely parallels the features of 10434 COMPOUND as described above. 10436 The basic structure of the COMPOUND procedure is: 10438 +-----+--------------+--------+-----------+-----------+-----------+-- 10439 | tag | minorversion | numops | op + args | op + args | op + args | 10440 +-----+--------------+--------+-----------+-----------+-----------+-- 10442 and the reply's structure is: 10444 +------------+-----+--------+-----------------------+-- 10445 |last status | tag | numres | status + op + results | 10446 +------------+-----+--------+-----------------------+-- 10448 The numops and numres fields, used in the depiction above, represent 10449 the count for the counted array encoding use to signify the number of 10450 arguments or results encoded in the request and response. As per the 10451 XDR encoding, these counts must match exactly the number of operation 10452 arguments or results encoded. 10454 14.2. Evaluation of a Compound Request 10456 The server will process the COMPOUND procedure by evaluating each of 10457 the operations within the COMPOUND procedure in order. Each 10458 component operation consists of a 32 bit operation code, followed by 10459 the argument of length determined by the type of operation. The 10460 results of each operation are encoded in sequence into a reply 10461 buffer. The results of each operation are preceded by the opcode and 10462 a status code (normally zero). If an operation results in a non-zero 10463 status code, the status will be encoded and evaluation of the 10464 compound sequence will halt and the reply will be returned. Note 10465 that evaluation stops even in the event of "non error" conditions 10466 such as NFS4ERR_SAME. 10468 There are no atomicity requirements for the operations contained 10469 within the COMPOUND procedure. The operations being evaluated as 10470 part of a COMPOUND request may be evaluated simultaneously with other 10471 COMPOUND requests that the server receives. 10473 It is the client's responsibility for recovering from any partially 10474 completed COMPOUND procedure. Partially completed COMPOUND 10475 procedures may occur at any point due to errors such as 10476 NFS4ERR_RESOURCE and NFS4ERR_DELAY. This may occur even given an 10477 otherwise valid operation string. Further, a server reboot which 10478 occurs in the middle of processing a COMPOUND procedure may leave the 10479 client with the difficult task of determining how far COMPOUND 10480 processing has proceeded. Therefore, the client should avoid overly 10481 complex COMPOUND procedures in the event of the failure of an 10482 operation within the procedure. 10484 Each operation assumes a "current" and "saved" filehandle that is 10485 available as part of the execution context of the compound request. 10486 Operations may set, change, or return the current filehandle. The 10487 "saved" filehandle is used for temporary storage of a filehandle 10488 value and as operands for the RENAME and LINK operations. 10490 14.3. Synchronous Modifying Operations 10492 NFSv4 operations that modify the filesystem are synchronous. When an 10493 operation is successfully completed at the server, the client can 10494 depend that any data associated with the request is now on stable 10495 storage (the one exception is in the case of the file data in a WRITE 10496 operation with the UNSTABLE option specified). 10498 This implies that any previous operations within the same compound 10499 request are also reflected in stable storage. This behavior enables 10500 the client's ability to recover from a partially executed compound 10501 request which may resulted from the failure of the server. For 10502 example, if a compound request contains operations A and B and the 10503 server is unable to send a response to the client, depending on the 10504 progress the server made in servicing the request the result of both 10505 operations may be reflected in stable storage or just operation A may 10506 be reflected. The server must not have just the results of operation 10507 B in stable storage. 10509 14.4. Operation Values 10511 The operations encoded in the COMPOUND procedure are identified by 10512 operation values. To avoid overlap with the RPC procedure numbers, 10513 operations 0 (zero) and 1 are not defined. Operation 2 is not 10514 defined but reserved for future use with minor versioning. 10516 15. NFSv4 Procedures 10518 15.1. Procedure 0: NULL - No Operation 10520 15.1.1. SYNOPSIS 10522 10524 15.1.2. ARGUMENT 10526 void; 10528 15.1.3. RESULT 10530 void; 10532 15.1.4. DESCRIPTION 10534 Standard NULL procedure. Void argument, void response. This 10535 procedure has no functionality associated with it. Because of this 10536 it is sometimes used to measure the overhead of processing a service 10537 request. Therefore, the server should ensure that no unnecessary 10538 work is done in servicing this procedure. 10540 15.2. Procedure 1: COMPOUND - Compound Operations 10542 15.2.1. SYNOPSIS 10544 compoundargs -> compoundres 10546 15.2.2. ARGUMENT 10548 union nfs_argop4 switch (nfs_opnum4 argop) { 10549 case : ; 10550 ... 10551 }; 10553 struct COMPOUND4args { 10554 comptag4 tag; 10555 uint32_t minorversion; 10556 nfs_argop4 argarray<>; 10557 }; 10559 15.2.3. RESULT 10561 union nfs_resop4 switch (nfs_opnum4 resop) { 10562 case : ; 10563 ... 10564 }; 10566 struct COMPOUND4res { 10567 nfsstat4 status; 10568 comptag4 tag; 10569 nfs_resop4 resarray<>; 10570 }; 10572 15.2.4. DESCRIPTION 10574 The COMPOUND procedure is used to combine one or more of the NFS 10575 operations into a single RPC request. The main NFS RPC program has 10576 two main procedures: NULL and COMPOUND. All other operations use the 10577 COMPOUND procedure as a wrapper. 10579 The COMPOUND procedure is used to combine individual operations into 10580 a single RPC request. The server interprets each of the operations 10581 in turn. If an operation is executed by the server and the status of 10582 that operation is NFS4_OK, then the next operation in the COMPOUND 10583 procedure is executed. The server continues this process until there 10584 are no more operations to be executed or one of the operations has a 10585 status value other than NFS4_OK. 10587 In the processing of the COMPOUND procedure, the server may find that 10588 it does not have the available resources to execute any or all of the 10589 operations within the COMPOUND sequence. In this case, the error 10590 NFS4ERR_RESOURCE will be returned for the particular operation within 10591 the COMPOUND procedure where the resource exhaustion occurred. This 10592 assumes that all previous operations within the COMPOUND sequence 10593 have been evaluated successfully. The results for all of the 10594 evaluated operations must be returned to the client. 10596 The server will generally choose between two methods of decoding the 10597 client's request. The first would be the traditional one-pass XDR 10598 decode, in which decoding of the entire COMPOUND precedes execution 10599 of any operation within it. If there is an XDR decoding error in 10600 this case, an RPC XDR decode error would be returned. The second 10601 method would be to make an initial pass to decode the basic COMPOUND 10602 request and then to XDR decode each of the individual operations, as 10603 the server is ready to execute it. In this case, the server may 10604 encounter an XDR decode error during such an operation decode, after 10605 previous operations within the COMPOUND have been executed. In this 10606 case, the server would return the error NFS4ERR_BADXDR to signify the 10607 decode error. 10609 The COMPOUND arguments contain a "minorversion" field. The initial 10610 and default value for this field is 0 (zero). This field will be 10611 used by future minor versions such that the client can communicate to 10612 the server what minor version is being requested. If the server 10613 receives a COMPOUND procedure with a minorversion field value that it 10614 does not support, the server MUST return an error of 10615 NFS4ERR_MINOR_VERS_MISMATCH and a zero length resultdata array. 10617 Contained within the COMPOUND results is a "status" field. If the 10618 results array length is non-zero, this status must be equivalent to 10619 the status of the last operation that was executed within the 10620 COMPOUND procedure. Therefore, if an operation incurred an error 10621 then the "status" value will be the same error value as is being 10622 returned for the operation that failed. 10624 Note that operations, 0 (zero) and 1 (one) are not defined for the 10625 COMPOUND procedure. Operation 2 is not defined but reserved for 10626 future definition and use with minor versioning. If the server 10627 receives a operation array that contains operation 2 and the 10628 minorversion field has a value of 0 (zero), an error of 10629 NFS4ERR_OP_ILLEGAL, as described in the next paragraph, is returned 10630 to the client. If an operation array contains an operation 2 and the 10631 minorversion field is non-zero and the server does not support the 10632 minor version, the server returns an error of 10633 NFS4ERR_MINOR_VERS_MISMATCH. Therefore, the 10634 NFS4ERR_MINOR_VERS_MISMATCH error takes precedence over all other 10635 errors. 10637 It is possible that the server receives a request that contains an 10638 operation that is less than the first legal operation (OP_ACCESS) or 10639 greater than the last legal operation (OP_RELEASE_LOCKOWNER). In 10640 this case, the server's response will encode the opcode OP_ILLEGAL 10641 rather than the illegal opcode of the request. The status field in 10642 the ILLEGAL return results will set to NFS4ERR_OP_ILLEGAL. The 10643 COMPOUND procedure's return results will also be NFS4ERR_OP_ILLEGAL. 10645 The definition of the "tag" in the request is left to the 10646 implementor. It may be used to summarize the content of the compound 10647 request for the benefit of packet sniffers and engineers debugging 10648 implementations. However, the value of "tag" in the response SHOULD 10649 be the same value as provided in the request. This applies to the 10650 tag field of the CB_COMPOUND procedure as well. 10652 15.2.4.1. Current Filehandle 10654 The current and saved filehandle are used throughout the protocol. 10655 Most operations implicitly use the current filehandle as a argument 10656 and many set the current filehandle as part of the results. The 10657 combination of client specified sequences of operations and current 10658 and saved filehandle arguments and results allows for greater 10659 protocol flexibility. The best or easiest example of current 10660 filehandle usage is a sequence like the following: 10662 PUTFH fh1 {fh1} 10663 LOOKUP "compA" {fh2} 10664 GETATTR {fh2} 10665 LOOKUP "compB" {fh3} 10666 GETATTR {fh3} 10667 LOOKUP "compC" {fh4} 10668 GETATTR {fh4} 10669 GETFH 10671 Figure 1 10673 In this example, the PUTFH (Section 15.22) operation explicitly sets 10674 the current filehandle value while the result of each LOOKUP 10675 operation sets the current filehandle value to the resultant file 10676 system object. Also, the client is able to insert GETATTR operations 10677 using the current filehandle as an argument. 10679 The PUTROOTFH (Section 15.24) and PUTPUBFH (Section 15.24) operations 10680 also set the current filehandle. The above example would replace 10681 "PUTFH fh1" with PUTROOTFH or PUTPUBFH with no filehandle argument in 10682 order to achieve the same effect (on the assumption that "compA" is 10683 directly below the root of the namespace). 10685 Along with the current filehandle, there is a saved filehandle. 10686 While the current filehandle is set as the result of operations like 10687 LOOKUP, the saved filehandle must be set directly with the use of the 10688 SAVEFH operation. The SAVEFH operations copies the current 10689 filehandle value to the saved value. The saved filehandle value is 10690 used in combination with the current filehandle value for the LINK 10691 and RENAME operations. The RESTOREFH operation will copy the saved 10692 filehandle value to the current filehandle value; as a result, the 10693 saved filehandle value may be used a sort of "scratch" area for the 10694 client's series of operations. 10696 15.2.4.2. Current Stateid 10698 The COMPOUND processing environment also have a current stateid and a 10699 saved stateid, which allows for the passing of stateids between 10700 operations. 10702 A "current stateid" is the stateid that is associated with the 10703 current filehandle. The current stateid may only be changed by an 10704 operation that modifies the current filehandle or returns a stateid. 10705 If an operation returns a stateid it MUST set the current stateid to 10706 the returned value. If an operation sets the current filehandle but 10707 does not return a stateid, the current stateid MUST be set to the 10708 all-zeros special stateid, i.e. (seqid, other) = (0, 0). If an 10709 operation uses a stateid as an argument but does not return a 10710 stateid, the current stateid MUST NOT be changed. E.g., PUTFH, 10711 PUTROOTFH, and PUTPUBFH will change the current server state from 10712 {ocfh, (osid)} to {cfh, (0, 0)} while LOCK will change the current 10713 state from {cfh, (osid} to {cfh, (nsid)}. Operations like LOOKUP 10714 that transform a current filehandle and component name into a new 10715 current filehandle will also change the current stateid to {0, 0}. 10716 The SAVEFH and RESTOREFH operations will save and restore both the 10717 current filehandle and the current stateid as a set. 10719 The following example is the common case of a simple READ operation 10720 with a supplied stateid showing that the PUTFH initializes the 10721 current stateid to (0, 0). The subsequent READ with stateid (sid1) 10722 leaves the current stateid unchanged, but does evaluate the the 10723 operation. 10725 PUTFH fh1 - -> {fh1, (0, 0)} 10726 READ (sid1), 0, 1024 {fh1, (0, 0)} -> {fh1, (0, 0)} 10728 Figure 2 10730 This next example performs an OPEN with the root filehandle and as a 10731 result generates stateid (sid1). The next operation specifies the 10732 READ with the argument stateid set such that (seqid, other) are equal 10733 to (1, 0), but the current stateid set by the previous operation is 10734 actually used when the operation is evaluated. This allows correct 10735 interaction with any existing, potentially conflicting, locks. 10737 PUTROOTFH - -> {fh1, (0, 0)} 10738 OPEN "compA" {fh1, (0, 0)} -> {fh2, (sid1)} 10739 READ (1, 0), 0, 1024 {fh2, (sid1)} -> {fh2, (sid1)} 10740 CLOSE (1, 0) {fh2, (sid1)} -> {fh2, (sid2)} 10742 Figure 3 10744 This next example is similar to the second in how it passes the 10745 stateid sid2 generated by the LOCK operation to the next READ 10746 operation. This allows the client to explicitly surround a single 10747 I/O operation with a lock and its appropriate stateid to guarantee 10748 correctness with other client locks. The example also shows how 10749 SAVEFH and RESTOREFH can save and later re-use a filehandle and 10750 stateid, passing them as the current filehandle and stateid to a READ 10751 operation. 10753 PUTFH fh1 - -> {fh1, (0, 0)} 10754 LOCK 0, 1024, (sid1) {fh1, (sid1)} -> {fh1, (sid2)} 10755 READ (1, 0), 0, 1024 {fh1, (sid2)} -> {fh1, (sid2)} 10756 LOCKU 0, 1024, (1, 0) {fh1, (sid2)} -> {fh1, (sid3)} 10757 SAVEFH {fh1, (sid3)} -> {fh1, (sid3)} 10759 PUTFH fh2 {fh1, (sid3)} -> {fh2, (0, 0)} 10760 WRITE (1, 0), 0, 1024 {fh2, (0, 0)} -> {fh2, (0, 0)} 10762 RESTOREFH {fh2, (0, 0)} -> {fh1, (sid3)} 10763 READ (1, 0), 1024, 1024 {fh1, (sid3)} -> {fh1, (sid3)} 10765 Figure 4 10767 The final example shows a disallowed use of the current stateid. The 10768 client is attempting to implicitly pass anonymous special stateid, 10769 (0,0) to the READ operation. The server MUST return 10770 NFS4ERR_BAD_STATEID in the reply to the READ operation. 10772 PUTFH fh1 - -> {fh1, (0, 0)} 10773 READ (1, 0), 0, 1024 {fh1, (0, 0)} -> NFS4ERR_BAD_STATEID 10775 Figure 5 10777 15.2.5. IMPLEMENTATION 10779 Since an error of any type may occur after only a portion of the 10780 operations have been evaluated, the client must be prepared to 10781 recover from any failure. If the source of an NFS4ERR_RESOURCE error 10782 was a complex or lengthy set of operations, it is likely that if the 10783 number of operations were reduced the server would be able to 10784 evaluate them successfully. Therefore, the client is responsible for 10785 dealing with this type of complexity in recovery. 10787 The client SHOULD NOT construct a COMPOUND which mixes operations for 10788 different client IDs. 10790 15.3. Operation 3: ACCESS - Check Access Rights 10792 15.3.1. SYNOPSIS 10794 (cfh), accessreq -> supported, accessrights 10796 15.3.2. ARGUMENT 10798 const ACCESS4_READ = 0x00000001; 10799 const ACCESS4_LOOKUP = 0x00000002; 10800 const ACCESS4_MODIFY = 0x00000004; 10801 const ACCESS4_EXTEND = 0x00000008; 10802 const ACCESS4_DELETE = 0x00000010; 10803 const ACCESS4_EXECUTE = 0x00000020; 10805 struct ACCESS4args { 10806 /* CURRENT_FH: object */ 10807 uint32_t access; 10808 }; 10810 15.3.3. RESULT 10812 struct ACCESS4resok { 10813 uint32_t supported; 10814 uint32_t access; 10815 }; 10817 union ACCESS4res switch (nfsstat4 status) { 10818 case NFS4_OK: 10819 ACCESS4resok resok4; 10820 default: 10821 void; 10822 }; 10824 15.3.4. DESCRIPTION 10826 ACCESS determines the access rights that a user, as identified by the 10827 credentials in the RPC request, has with respect to the file system 10828 object specified by the current filehandle. The client encodes the 10829 set of access rights that are to be checked in the bit mask "access". 10830 The server checks the permissions encoded in the bit mask. If a 10831 status of NFS4_OK is returned, two bit masks are included in the 10832 response. The first, "supported", represents the access rights for 10833 which the server can verify reliably. The second, "access", 10834 represents the access rights available to the user for the filehandle 10835 provided. On success, the current filehandle retains its value. 10837 Note that the supported field will contain only as many values as 10838 were originally sent in the arguments. For example, if the client 10839 sends an ACCESS operation with only the ACCESS4_READ value set and 10840 the server supports this value, the server will return only 10841 ACCESS4_READ even if it could have reliably checked other values. 10843 The results of this operation are necessarily advisory in nature. A 10844 return status of NFS4_OK and the appropriate bit set in the bit mask 10845 does not imply that such access will be allowed to the file system 10846 object in the future. This is because access rights can be revoked 10847 by the server at any time. 10849 The following access permissions may be requested: 10851 ACCESS4_READ: Read data from file or read a directory. 10853 ACCESS4_LOOKUP: Look up a name in a directory (no meaning for non- 10854 directory objects). 10856 ACCESS4_MODIFY: Rewrite existing file data or modify existing 10857 directory entries. 10859 ACCESS4_EXTEND: Write new data or add directory entries. 10861 ACCESS4_DELETE: Delete an existing directory entry. 10863 ACCESS4_EXECUTE: Execute file (no meaning for a directory). 10865 On success, the current filehandle retains its value. 10867 15.3.5. IMPLEMENTATION 10869 In general, it is not sufficient for the client to attempt to deduce 10870 access permissions by inspecting the uid, gid, and mode fields in the 10871 file attributes or by attempting to interpret the contents of the ACL 10872 attribute. This is because the server may perform uid or gid mapping 10873 or enforce additional access control restrictions. It is also 10874 possible that the server may not be in the same ID space as the 10875 client. In these cases (and perhaps others), the client cannot 10876 reliably perform an access check with only current file attributes. 10878 In the NFSv2 protocol, the only reliable way to determine whether an 10879 operation was allowed was to try it and see if it succeeded or 10880 failed. Using the ACCESS operation in the NFSv4 protocol, the client 10881 can ask the server to indicate whether or not one or more classes of 10882 operations are permitted. The ACCESS operation is provided to allow 10883 clients to check before doing a series of operations which will 10884 result in an access failure. The OPEN operation provides a point 10885 where the server can verify access to the file object and method to 10886 return that information to the client. The ACCESS operation is still 10887 useful for directory operations or for use in the case the UNIX API 10888 "access" is used on the client. 10890 The information returned by the server in response to an ACCESS call 10891 is not permanent. It was correct at the exact time that the server 10892 performed the checks, but not necessarily afterward. The server can 10893 revoke access permission at any time. 10895 The client should use the effective credentials of the user to build 10896 the authentication information in the ACCESS request used to 10897 determine access rights. It is the effective user and group 10898 credentials that are used in subsequent read and write operations. 10900 Many implementations do not directly support the ACCESS4_DELETE 10901 permission. Operating systems like UNIX will ignore the 10902 ACCESS4_DELETE bit if set on an access request on a non-directory 10903 object. In these systems, delete permission on a file is determined 10904 by the access permissions on the directory in which the file resides, 10905 instead of being determined by the permissions of the file itself. 10906 Therefore, the mask returned enumerating which access rights can be 10907 determined will have the ACCESS4_DELETE value set to 0. This 10908 indicates to the client that the server was unable to check that 10909 particular access right. The ACCESS4_DELETE bit in the access mask 10910 returned will then be ignored by the client. 10912 15.4. Operation 4: CLOSE - Close File 10914 15.4.1. SYNOPSIS 10916 (cfh), seqid, open_stateid -> open_stateid 10918 15.4.2. ARGUMENT 10920 struct CLOSE4args { 10921 /* CURRENT_FH: object */ 10922 seqid4 seqid; 10923 stateid4 open_stateid; 10924 }; 10926 15.4.3. RESULT 10928 union CLOSE4res switch (nfsstat4 status) { 10929 case NFS4_OK: 10930 stateid4 open_stateid; 10931 default: 10932 void; 10933 }; 10935 15.4.4. DESCRIPTION 10937 The CLOSE operation releases share reservations for the regular or 10938 named attribute file as specified by the current filehandle. The 10939 share reservations and other state information released at the server 10940 as a result of this CLOSE is only associated with the supplied 10941 stateid. The sequence id provides for the correct ordering. State 10942 associated with other OPENs is not affected. 10944 If byte-range locks are held, the client SHOULD release all locks 10945 before issuing a CLOSE. The server MAY free all outstanding locks on 10946 CLOSE but some servers may not support the CLOSE of a file that still 10947 has byte-range locks held. The server MUST return failure if any 10948 locks would exist after the CLOSE. 10950 On success, the current filehandle retains its value. 10952 15.4.5. IMPLEMENTATION 10954 Even though CLOSE returns a stateid, this stateid is not useful to 10955 the client and should be treated as deprecated. CLOSE "shuts down" 10956 the state associated with all OPENs for the file by a single open- 10957 owner. As noted above, CLOSE will either release all file locking 10958 state or return an error. Therefore, the stateid returned by CLOSE 10959 is not useful for operations that follow. 10961 15.5. Operation 5: COMMIT - Commit Cached Data 10963 15.5.1. SYNOPSIS 10965 (cfh), offset, count -> verifier 10967 15.5.2. ARGUMENT 10969 struct COMMIT4args { 10970 /* CURRENT_FH: file */ 10971 offset4 offset; 10972 count4 count; 10973 }; 10975 15.5.3. RESULT 10977 struct COMMIT4resok { 10978 verifier4 writeverf; 10979 }; 10981 union COMMIT4res switch (nfsstat4 status) { 10982 case NFS4_OK: 10983 COMMIT4resok resok4; 10984 default: 10985 void; 10986 }; 10988 15.5.4. DESCRIPTION 10990 The COMMIT operation forces or flushes data to stable storage for the 10991 file specified by the current filehandle. The flushed data is that 10992 which was previously written with a WRITE operation which had the 10993 stable field set to UNSTABLE4. 10995 The offset specifies the position within the file where the flush is 10996 to begin. An offset value of 0 (zero) means to flush data starting 10997 at the beginning of the file. The count specifies the number of 10998 bytes of data to flush. If count is 0 (zero), a flush from offset to 10999 the end of the file is done. 11001 The server returns a write verifier upon successful completion of the 11002 COMMIT. The write verifier is used by the client to determine if the 11003 server has restarted or rebooted between the initial WRITE(s) and the 11004 COMMIT. The client does this by comparing the write verifier 11005 returned from the initial writes and the verifier returned by the 11006 COMMIT operation. The server must vary the value of the write 11007 verifier at each server event or instantiation that may lead to a 11008 loss of uncommitted data. Most commonly this occurs when the server 11009 is rebooted; however, other events at the server may result in 11010 uncommitted data loss as well. 11012 On success, the current filehandle retains its value. 11014 15.5.5. IMPLEMENTATION 11016 The COMMIT operation is similar in operation and semantics to the 11017 POSIX fsync() [36] system call that synchronizes a file's state with 11018 the disk (file data and metadata is flushed to disk or stable 11019 storage). COMMIT performs the same operation for a client, flushing 11020 any unsynchronized data and metadata on the server to the server's 11021 disk or stable storage for the specified file. Like fsync(), it may 11022 be that there is some modified data or no modified data to 11023 synchronize. The data may have been synchronized by the server's 11024 normal periodic buffer synchronization activity. COMMIT should 11025 return NFS4_OK, unless there has been an unexpected error. 11027 COMMIT differs from fsync() in that it is possible for the client to 11028 flush a range of the file (most likely triggered by a buffer- 11029 reclamation scheme on the client before file has been completely 11030 written). 11032 The server implementation of COMMIT is reasonably simple. If the 11033 server receives a full file COMMIT request, that is starting at 11034 offset 0 and count 0, it should do the equivalent of fsync()'ing the 11035 file. Otherwise, it should arrange to have the cached data in the 11036 range specified by offset and count to be flushed to stable storage. 11037 In both cases, any metadata associated with the file must be flushed 11038 to stable storage before returning. It is not an error for there to 11039 be nothing to flush on the server. This means that the data and 11040 metadata that needed to be flushed have already been flushed or lost 11041 during the last server failure. 11043 The client implementation of COMMIT is a little more complex. There 11044 are two reasons for wanting to commit a client buffer to stable 11045 storage. The first is that the client wants to reuse a buffer. In 11046 this case, the offset and count of the buffer are sent to the server 11047 in the COMMIT request. The server then flushes any cached data based 11048 on the offset and count, and flushes any metadata associated with the 11049 file. It then returns the status of the flush and the write 11050 verifier. The other reason for the client to generate a COMMIT is 11051 for a full file flush, such as may be done at close. In this case, 11052 the client would gather all of the buffers for this file that contain 11053 uncommitted data, do the COMMIT operation with an offset of 0 and 11054 count of 0, and then free all of those buffers. Any other dirty 11055 buffers would be sent to the server in the normal fashion. 11057 After a buffer is written by the client with the stable parameter set 11058 to UNSTABLE4, the buffer must be considered as modified by the client 11059 until the buffer has either been flushed via a COMMIT operation or 11060 written via a WRITE operation with stable parameter set to FILE_SYNC4 11061 or DATA_SYNC4. This is done to prevent the buffer from being freed 11062 and reused before the data can be flushed to stable storage on the 11063 server. 11065 When a response is returned from either a WRITE or a COMMIT operation 11066 and it contains a write verifier that is different than previously 11067 returned by the server, the client will need to retransmit all of the 11068 buffers containing uncommitted cached data to the server. How this 11069 is to be done is up to the implementor. If there is only one buffer 11070 of interest, then it should probably be sent back over in a WRITE 11071 request with the appropriate stable parameter. If there is more than 11072 one buffer, it might be worthwhile retransmitting all of the buffers 11073 in WRITE requests with the stable parameter set to UNSTABLE4 and then 11074 retransmitting the COMMIT operation to flush all of the data on the 11075 server to stable storage. The timing of these retransmissions is 11076 left to the implementor. 11078 The above description applies to page-cache-based systems as well as 11079 buffer-cache-based systems. In those systems, the virtual memory 11080 system will need to be modified instead of the buffer cache. 11082 15.6. Operation 6: CREATE - Create a Non-Regular File Object 11084 15.6.1. SYNOPSIS 11086 (cfh), name, type, attrs -> (cfh), change_info, attrs_set 11088 15.6.2. ARGUMENT 11090 union createtype4 switch (nfs_ftype4 type) { 11091 case NF4LNK: 11092 linktext4 linkdata; 11093 case NF4BLK: 11094 case NF4CHR: 11095 specdata4 devdata; 11096 case NF4SOCK: 11097 case NF4FIFO: 11098 case NF4DIR: 11099 void; 11100 default: 11101 void; /* server should return NFS4ERR_BADTYPE */ 11102 }; 11104 struct CREATE4args { 11105 /* CURRENT_FH: directory for creation */ 11106 createtype4 objtype; 11107 component4 objname; 11108 fattr4 createattrs; 11109 }; 11111 15.6.3. RESULT 11113 struct CREATE4resok { 11114 change_info4 cinfo; 11115 bitmap4 attrset; /* attributes set */ 11116 }; 11118 union CREATE4res switch (nfsstat4 status) { 11119 case NFS4_OK: 11120 CREATE4resok resok4; 11121 default: 11122 void; 11123 }; 11125 15.6.4. DESCRIPTION 11127 The CREATE operation creates a non-regular file object in a directory 11128 with a given name. The OPEN operation MUST be used to create a 11129 regular file. 11131 The objname specifies the name for the new object. The objtype 11132 determines the type of object to be created: directory, symlink, etc. 11134 If an object of the same name already exists in the directory, the 11135 server will return the error NFS4ERR_EXIST. 11137 For the directory where the new file object was created, the server 11138 returns change_info4 information in cinfo. With the atomic field of 11139 the change_info4 struct, the server will indicate if the before and 11140 after change attributes were obtained atomically with respect to the 11141 file object creation. 11143 If the objname is of zero length, NFS4ERR_INVAL will be returned. 11144 The objname is also subject to the normal UTF-8, character support, 11145 and name checks. See Section 12.3 for further discussion. 11147 If the objname has a length of 0 (zero), or if objname does not obey 11148 the UTF-8 definition, the error NFS4ERR_INVAL will be returned. 11150 The current filehandle is replaced by that of the new object. 11152 The createattrs specifies the initial set of attributes for the 11153 object. The set of attributes may include any writable attribute 11154 valid for the object type. When the operation is successful, the 11155 server will return to the client an attribute mask signifying which 11156 attributes were successfully set for the object. 11158 If createattrs includes neither the owner attribute nor an ACL with 11159 an ACE for the owner, and if the server's filesystem both supports 11160 and requires an owner attribute (or an owner ACE) then the server 11161 MUST derive the owner (or the owner ACE). This would typically be 11162 from the principal indicated in the RPC credentials of the call, but 11163 the server's operating environment or filesystem semantics may 11164 dictate other methods of derivation. Similarly, if createattrs 11165 includes neither the group attribute nor a group ACE, and if the 11166 server's filesystem both supports and requires the notion of a group 11167 attribute (or group ACE), the server MUST derive the group attribute 11168 (or the corresponding owner ACE) for the file. This could be from 11169 the RPC call's credentials, such as the group principal if the 11170 credentials include it (such as with AUTH_SYS), from the group 11171 identifier associated with the principal in the credentials (e.g., 11172 POSIX systems have a user database [37] that has the group identifier 11173 for every user identifier), inherited from directory the object is 11174 created in, or whatever else the server's operating environment or 11175 filesystem semantics dictate. This applies to the OPEN operation 11176 too. 11178 Conversely, it is possible the client will specify in createattrs an 11179 owner attribute or group attribute or ACL that the principal 11180 indicated the RPC call's credentials does not have permissions to 11181 create files for. The error to be returned in this instance is 11182 NFS4ERR_PERM. This applies to the OPEN operation too. 11184 15.6.5. IMPLEMENTATION 11186 If the client desires to set attribute values after the create, a 11187 SETATTR operation can be added to the COMPOUND request so that the 11188 appropriate attributes will be set. 11190 15.7. Operation 7: DELEGPURGE - Purge Delegations Awaiting Recovery 11192 15.7.1. SYNOPSIS 11194 clientid -> 11196 15.7.2. ARGUMENT 11198 struct DELEGPURGE4args { 11199 clientid4 clientid; 11200 }; 11202 15.7.3. RESULT 11204 struct DELEGPURGE4res { 11205 nfsstat4 status; 11206 }; 11208 15.7.4. DESCRIPTION 11210 Purges all of the delegations awaiting recovery for a given client. 11211 This is useful for clients which do not commit delegation information 11212 to stable storage to indicate that conflicting requests need not be 11213 delayed by the server awaiting recovery of delegation information. 11215 This operation should be used by clients that record delegation 11216 information on stable storage on the client. In this case, 11217 DELEGPURGE should be issued immediately after doing delegation 11218 recovery on all delegations known to the client. Doing so will 11219 notify the server that no additional delegations for the client will 11220 be recovered allowing it to free resources, and avoid delaying other 11221 clients who make requests that conflict with the unrecovered 11222 delegations. The set of delegations known to the server and the 11223 client may be different. The reason for this is that a client may 11224 fail after making a request which resulted in delegation but before 11225 it received the results and committed them to the client's stable 11226 storage. 11228 The server MAY support DELEGPURGE, but if it does not, it MUST NOT 11229 support CLAIM_DELEGATE_PREV. 11231 15.8. Operation 8: DELEGRETURN - Return Delegation 11233 15.8.1. SYNOPSIS 11235 (cfh), stateid -> 11237 15.8.2. ARGUMENT 11239 struct DELEGRETURN4args { 11240 /* CURRENT_FH: delegated file */ 11241 stateid4 deleg_stateid; 11242 }; 11244 15.8.3. RESULT 11246 struct DELEGRETURN4res { 11247 nfsstat4 status; 11248 }; 11250 15.8.4. DESCRIPTION 11252 Returns the delegation represented by the current filehandle and 11253 stateid. 11255 Delegations may be returned when recalled or voluntarily (i.e., 11256 before the server has recalled them). In either case the client must 11257 properly propagate state changed under the context of the delegation 11258 to the server before returning the delegation. 11260 15.9. Operation 9: GETATTR - Get Attributes 11262 15.9.1. SYNOPSIS 11264 (cfh), attrbits -> attrbits, attrvals 11266 15.9.2. ARGUMENT 11268 struct GETATTR4args { 11269 /* CURRENT_FH: directory or file */ 11270 bitmap4 attr_request; 11271 }; 11273 15.9.3. RESULT 11275 struct GETATTR4resok { 11276 fattr4 obj_attributes; 11277 }; 11279 union GETATTR4res switch (nfsstat4 status) { 11280 case NFS4_OK: 11281 GETATTR4resok resok4; 11282 default: 11283 void; 11284 }; 11286 15.9.4. DESCRIPTION 11288 The GETATTR operation will obtain attributes for the filesystem 11289 object specified by the current filehandle. The client sets a bit in 11290 the bitmap argument for each attribute value that it would like the 11291 server to return. The server returns an attribute bitmap that 11292 indicates the attribute values for which it was able to return, 11293 followed by the attribute values ordered lowest attribute number 11294 first. 11296 The server MUST return a value for each attribute that the client 11297 requests if the attribute is supported by the server. If the server 11298 does not support an attribute or cannot approximate a useful value 11299 then it MUST NOT return the attribute value and MUST NOT set the 11300 attribute bit in the result bitmap. The server MUST return an error 11301 if it supports an attribute on the target but cannot obtain its 11302 value. In that case no attribute values will be returned. 11304 File systems which are absent should be treated as having support for 11305 a very small set of attributes as described in GETATTR Within an 11306 Absent File System (Section 7.3.1), even if previously, when the file 11307 system was present, more attributes were supported. 11309 All servers MUST support the REQUIRED attributes as specified in the 11310 section File Attributes (Section 5), for all file systems, with the 11311 exception of absent file systems. 11313 On success, the current filehandle retains its value. 11315 15.9.5. IMPLEMENTATION 11317 Suppose there is a OPEN_DELEGATE_WRITE delegation held by another 11318 client for file in question and size and/or change are among the set 11319 of attributes being interrogated. The server has two choices. 11321 First, the server can obtain the actual current value of these 11322 attributes from the client holding the delegation by using the 11323 CB_GETATTR callback. Second, the server, particularly when the 11324 delegated client is unresponsive, can recall the delegation in 11325 question. The GETATTR MUST NOT proceed until one of the following 11326 occurs: 11328 o The requested attribute values are returned in the response to 11329 CB_GETATTR. 11331 o The OPEN_DELEGATE_WRITE delegation is returned. 11333 o The OPEN_DELEGATE_WRITE delegation is revoked. 11335 Unless one of the above happens very quickly, one or more 11336 NFS4ERR_DELAY errors will be returned if while a delegation is 11337 outstanding. 11339 15.10. Operation 10: GETFH - Get Current Filehandle 11341 15.10.1. SYNOPSIS 11343 (cfh) -> filehandle 11345 15.10.2. ARGUMENT 11347 /* CURRENT_FH: */ 11348 void; 11350 15.10.3. RESULT 11352 struct GETFH4resok { 11353 nfs_fh4 object; 11354 }; 11356 union GETFH4res switch (nfsstat4 status) { 11357 case NFS4_OK: 11358 GETFH4resok resok4; 11359 default: 11360 void; 11361 }; 11363 15.10.4. DESCRIPTION 11365 This operation returns the current filehandle value. 11367 On success, the current filehandle retains its value. 11369 15.10.5. IMPLEMENTATION 11371 Operations that change the current filehandle like LOOKUP or CREATE 11372 do not automatically return the new filehandle as a result. For 11373 instance, if a client needs to lookup a directory entry and obtain 11374 its filehandle then the following request is needed. 11376 PUTFH (directory filehandle) 11377 LOOKUP (entry name) 11378 GETFH 11380 15.11. Operation 11: LINK - Create Link to a File 11382 15.11.1. SYNOPSIS 11384 (sfh), (cfh), newname -> (cfh), change_info 11386 15.11.2. ARGUMENT 11388 struct LINK4args { 11389 /* SAVED_FH: source object */ 11390 /* CURRENT_FH: target directory */ 11391 component4 newname; 11392 }; 11394 15.11.3. RESULT 11396 struct LINK4resok { 11397 change_info4 cinfo; 11398 }; 11400 union LINK4res switch (nfsstat4 status) { 11401 case NFS4_OK: 11402 LINK4resok resok4; 11403 default: 11404 void; 11405 }; 11407 15.11.4. DESCRIPTION 11409 The LINK operation creates an additional newname for the file 11410 represented by the saved filehandle, as set by the SAVEFH operation, 11411 in the directory represented by the current filehandle. The existing 11412 file and the target directory must reside within the same filesystem 11413 on the server. On success, the current filehandle will continue to 11414 be the target directory. If an object exists in the target directory 11415 with the same name as newname, the server must return NFS4ERR_EXIST. 11417 For the target directory, the server returns change_info4 information 11418 in cinfo. With the atomic field of the change_info4 struct, the 11419 server will indicate if the before and after change attributes were 11420 obtained atomically with respect to the link creation. 11422 If the newname has a length of 0 (zero), or if newname does not obey 11423 the UTF-8 definition, the error NFS4ERR_INVAL will be returned. 11425 15.11.5. IMPLEMENTATION 11427 Changes to any property of the "hard" linked files are reflected in 11428 all of the linked files. When a link is made to a file, the 11429 attributes for the file should have a value for numlinks that is one 11430 greater than the value before the LINK operation. 11432 The statement "file and the target directory must reside within the 11433 same filesystem on the server" means that the fsid fields in the 11434 attributes for the objects are the same. If they reside on different 11435 filesystems, the error, NFS4ERR_XDEV, is returned. On some servers, 11436 the filenames, "." and "..", are illegal as newname. 11438 In the case that newname is already linked to the file represented by 11439 the saved filehandle, the server will return NFS4ERR_EXIST. 11441 Note that symbolic links are created with the CREATE operation. 11443 15.12. Operation 12: LOCK - Create Lock 11445 15.12.1. SYNOPSIS 11447 (cfh) locktype, reclaim, offset, length, locker -> stateid 11449 15.12.2. ARGUMENT 11451 enum nfs_lock_type4 { 11452 READ_LT = 1, 11453 WRITE_LT = 2, 11454 READW_LT = 3, /* blocking read */ 11455 WRITEW_LT = 4 /* blocking write */ 11456 }; 11457 /* 11458 * For LOCK, transition from open_owner to new lock_owner 11459 */ 11460 struct open_to_lock_owner4 { 11461 seqid4 open_seqid; 11462 stateid4 open_stateid; 11463 seqid4 lock_seqid; 11464 lock_owner4 lock_owner; 11465 }; 11467 /* 11468 * For LOCK, existing lock_owner continues to request file locks 11469 */ 11470 struct exist_lock_owner4 { 11471 stateid4 lock_stateid; 11472 seqid4 lock_seqid; 11473 }; 11475 union locker4 switch (bool new_lock_owner) { 11476 case TRUE: 11477 open_to_lock_owner4 open_owner; 11478 case FALSE: 11479 exist_lock_owner4 lock_owner; 11480 }; 11482 /* 11483 * LOCK/LOCKT/LOCKU: Record lock management 11484 */ 11485 struct LOCK4args { 11486 /* CURRENT_FH: file */ 11487 nfs_lock_type4 locktype; 11488 bool reclaim; 11489 offset4 offset; 11490 length4 length; 11491 locker4 locker; 11492 }; 11494 15.12.3. RESULT 11496 struct LOCK4denied { 11497 offset4 offset; 11498 length4 length; 11499 nfs_lock_type4 locktype; 11500 lock_owner4 owner; 11501 }; 11503 struct LOCK4resok { 11504 stateid4 lock_stateid; 11505 }; 11507 union LOCK4res switch (nfsstat4 status) { 11508 case NFS4_OK: 11509 LOCK4resok resok4; 11510 case NFS4ERR_DENIED: 11511 LOCK4denied denied; 11512 default: 11513 void; 11514 }; 11516 15.12.4. DESCRIPTION 11518 The LOCK operation requests a byte-range lock for the byte range 11519 specified by the offset and length parameters. The lock type is also 11520 specified to be one of the nfs_lock_type4s. If this is a reclaim 11521 request, the reclaim parameter will be TRUE; 11523 Bytes in a file may be locked even if those bytes are not currently 11524 allocated to the file. To lock the file from a specific offset 11525 through the end-of-file (no matter how long the file actually is) use 11526 a length field with all bits set to 1 (one). If the length is zero, 11527 or if a length which is not all bits set to one is specified, and 11528 length when added to the offset exceeds the maximum 64-bit unsigned 11529 integer value, the error NFS4ERR_INVAL will result. 11531 Some servers may only support locking for byte offsets that fit 11532 within 32 bits. If the client specifies a range that includes a byte 11533 beyond the last byte offset of the 32-bit range, but does not include 11534 the last byte offset of the 32-bit and all of the byte offsets beyond 11535 it, up to the end of the valid 64-bit range, such a 32-bit server 11536 MUST return the error NFS4ERR_BAD_RANGE. 11538 In the case that the lock is denied, the owner, offset, and length of 11539 a conflicting lock are returned. 11541 On success, the current filehandle retains its value. 11543 15.12.5. IMPLEMENTATION 11545 If the server is unable to determine the exact offset and length of 11546 the conflicting lock, the same offset and length that were provided 11547 in the arguments should be returned in the denied results. Section 9 11548 contains a full description of this and the other file locking 11549 operations. 11551 LOCK operations are subject to permission checks and to checks 11552 against the access type of the associated file. However, the 11553 specific right and modes required for various type of locks, reflect 11554 the semantics of the server-exported filesystem, and are not 11555 specified by the protocol. For example, Windows 2000 allows a write 11556 lock of a file open for READ, while a POSIX-compliant system does 11557 not. 11559 When the client makes a lock request that corresponds to a range that 11560 the lock-owner has locked already (with the same or different lock 11561 type), or to a sub-region of such a range, or to a region which 11562 includes multiple locks already granted to that lock-owner, in whole 11563 or in part, and the server does not support such locking operations 11564 (i.e., does not support POSIX locking semantics), the server will 11565 return the error NFS4ERR_LOCK_RANGE. In that case, the client may 11566 return an error, or it may emulate the required operations, using 11567 only LOCK for ranges that do not include any bytes already locked by 11568 that lock-owner and LOCKU of locks held by that lock-owner 11569 (specifying an exactly-matching range and type). Similarly, when the 11570 client makes a lock request that amounts to upgrading (changing from 11571 a read lock to a write lock) or downgrading (changing from write lock 11572 to a read lock) an existing record lock, and the server does not 11573 support such a lock, the server will return NFS4ERR_LOCK_NOTSUPP. 11574 Such operations may not perfectly reflect the required semantics in 11575 the face of conflicting lock requests from other clients. 11577 When a client holds an OPEN_DELEGATE_WRITE delegation, the client 11578 holding that delegation is assured that there are no opens by other 11579 clients. Thus, there can be no conflicting LOCK operations from such 11580 clients. Therefore, the client may be handling locking requests 11581 locally, without doing LOCK operations on the server. If it does 11582 that, it must be prepared to update the lock status on the server, by 11583 sending appropriate LOCK and LOCKU operations before returning the 11584 delegation. 11586 When one or more clients hold OPEN_DELEGATE_READ delegations, any 11587 LOCK operation where the server is implementing mandatory locking 11588 semantics MUST result in the recall of all such delegations. The 11589 LOCK operation may not be granted until all such delegations are 11590 returned or revoked. Except where this happens very quickly, one or 11591 more NFS4ERR_DELAY errors will be returned to requests made while the 11592 delegation remains outstanding. 11594 The locker argument specifies the lock-owner that is associated with 11595 the LOCK request. The locker4 structure is a switched union that 11596 indicates whether the client has already created byte-range locking 11597 state associated with the current open file and lock-owner. In the 11598 case in which it has, the argument is just a stateid representing the 11599 set of locks associated with that open file and lock-owner, together 11600 with a lock_seqid value that MAY be any value and MUST be ignored by 11601 the server. In the case where no byte-range locking state has been 11602 established, or the client does not have the stateid available, the 11603 argument contains the stateid of the open file with which this lock 11604 is to be associated, together with the lock-owner with which the lock 11605 is to be associated. The open_to_lock_owner case covers the very 11606 first lock done by a lock-owner for a given open file and offers a 11607 method to use the established state of the open_stateid to transition 11608 to the use of a lock stateid. 11610 15.13. Operation 13: LOCKT - Test For Lock 11612 15.13.1. SYNOPSIS 11614 (cfh) locktype, offset, length, owner -> {void, NFS4ERR_DENIED -> 11615 owner} 11617 15.13.2. ARGUMENT 11619 struct LOCKT4args { 11620 /* CURRENT_FH: file */ 11621 nfs_lock_type4 locktype; 11622 offset4 offset; 11623 length4 length; 11624 lock_owner4 owner; 11625 }; 11627 15.13.3. RESULT 11629 union LOCKT4res switch (nfsstat4 status) { 11630 case NFS4ERR_DENIED: 11631 LOCK4denied denied; 11632 case NFS4_OK: 11633 void; 11634 default: 11635 void; 11636 }; 11638 15.13.4. DESCRIPTION 11640 The LOCKT operation tests the lock as specified in the arguments. If 11641 a conflicting lock exists, the owner, offset, length, and type of the 11642 conflicting lock are returned; if no lock is held, nothing other than 11643 NFS4_OK is returned. Lock types READ_LT and READW_LT are processed 11644 in the same way in that a conflicting lock test is done without 11645 regard to blocking or non-blocking. The same is true for WRITE_LT 11646 and WRITEW_LT. 11648 The ranges are specified as for LOCK. The NFS4ERR_INVAL and 11649 NFS4ERR_BAD_RANGE errors are returned under the same circumstances as 11650 for LOCK. 11652 On success, the current filehandle retains its value. 11654 15.13.5. IMPLEMENTATION 11656 If the server is unable to determine the exact offset and length of 11657 the conflicting lock, the same offset and length that were provided 11658 in the arguments should be returned in the denied results. Section 9 11659 contains further discussion of the file locking mechanisms. 11661 LOCKT uses a lock_owner4 rather a stateid4, as is used in LOCK to 11662 identify the owner. This is because the client does not have to open 11663 the file to test for the existence of a lock, so a stateid may not be 11664 available. 11666 The test for conflicting locks SHOULD exclude locks for the current 11667 lock-owner. Note that since such locks are not examined the possible 11668 existence of overlapping ranges may not affect the results of LOCKT. 11669 If the server does examine locks that match the lock-owner for the 11670 purpose of range checking, NFS4ERR_LOCK_RANGE may be returned. In 11671 the event that it returns NFS4_OK, clients may do a LOCK and receive 11672 NFS4ERR_LOCK_RANGE on the LOCK request because of the flexibility 11673 provided to the server. 11675 When a client holds an OPEN_DELEGATE_WRITE delegation, it may choose 11676 (see Section 15.12.5)) to handle LOCK requests locally. In such a 11677 case, LOCKT requests will similarly be handled locally. 11679 15.14. Operation 14: LOCKU - Unlock File 11681 15.14.1. SYNOPSIS 11683 (cfh) type, seqid, stateid, offset, length -> stateid 11685 15.14.2. ARGUMENT 11687 struct LOCKU4args { 11688 /* CURRENT_FH: file */ 11689 nfs_lock_type4 locktype; 11690 seqid4 seqid; 11691 stateid4 lock_stateid; 11692 offset4 offset; 11693 length4 length; 11694 }; 11696 15.14.3. RESULT 11698 union LOCKU4res switch (nfsstat4 status) { 11699 case NFS4_OK: 11700 stateid4 lock_stateid; 11701 default: 11702 void; 11703 }; 11705 15.14.4. DESCRIPTION 11707 The LOCKU operation unlocks the byte-range lock specified by the 11708 parameters. The client may set the locktype field to any value that 11709 is legal for the nfs_lock_type4 enumerated type, and the server MUST 11710 accept any legal value for locktype. Any legal value for locktype 11711 has no effect on the success or failure of the LOCKU operation. 11713 The ranges are specified as for LOCK. The NFS4ERR_INVAL and 11714 NFS4ERR_BAD_RANGE errors are returned under the same circumstances as 11715 for LOCK. 11717 On success, the current filehandle retains its value. 11719 15.14.5. IMPLEMENTATION 11721 If the area to be unlocked does not correspond exactly to a lock 11722 actually held by the lock-owner the server may return the error 11723 NFS4ERR_LOCK_RANGE. This includes the case in which the area is not 11724 locked, where the area is a sub-range of the area locked, where it 11725 overlaps the area locked without matching exactly or the area 11726 specified includes multiple locks held by the lock-owner. In all of 11727 these cases, allowed by POSIX locking [35] semantics, a client 11728 receiving this error, should if it desires support for such 11729 operations, simulate the operation using LOCKU on ranges 11730 corresponding to locks it actually holds, possibly followed by LOCK 11731 requests for the sub-ranges not being unlocked. 11733 When a client holds an OPEN_DELEGATE_WRITE delegation, it may choose 11734 (see Section 15.12.5)) to handle LOCK requests locally. In such a 11735 case, LOCKU requests will similarly be handled locally. 11737 15.15. Operation 15: LOOKUP - Lookup Filename 11739 15.15.1. SYNOPSIS 11741 (cfh), component -> (cfh) 11743 15.15.2. ARGUMENT 11745 struct LOOKUP4args { 11746 /* CURRENT_FH: directory */ 11747 component4 objname; 11748 }; 11750 15.15.3. RESULT 11752 struct LOOKUP4res { 11753 /* CURRENT_FH: object */ 11754 nfsstat4 status; 11755 }; 11757 15.15.4. DESCRIPTION 11759 This operation LOOKUPs or finds a filesystem object using the 11760 directory specified by the current filehandle. LOOKUP evaluates the 11761 component and if the object exists the current filehandle is replaced 11762 with the component's filehandle. 11764 If the component cannot be evaluated either because it does not exist 11765 or because the client does not have permission to evaluate the 11766 component, then an error will be returned and the current filehandle 11767 will be unchanged. 11769 If the component is of zero length, NFS4ERR_INVAL will be returned. 11770 The component is also subject to the normal UTF-8, character support, 11771 and name checks. See Section 12.3 for further discussion. 11773 15.15.5. IMPLEMENTATION 11775 If the client wants to achieve the effect of a multi-component 11776 lookup, it may construct a COMPOUND request such as (and obtain each 11777 filehandle): 11779 PUTFH (directory filehandle) 11780 LOOKUP "pub" 11781 GETFH 11782 LOOKUP "foo" 11783 GETFH 11784 LOOKUP "bar" 11785 GETFH 11787 NFSv4 servers depart from the semantics of previous NFS versions in 11788 allowing LOOKUP requests to cross mountpoints on the server. The 11789 client can detect a mountpoint crossing by comparing the fsid 11790 attribute of the directory with the fsid attribute of the directory 11791 looked up. If the fsids are different then the new directory is a 11792 server mountpoint. UNIX clients that detect a mountpoint crossing 11793 will need to mount the server's filesystem. This needs to be done to 11794 maintain the file object identity checking mechanisms common to UNIX 11795 clients. 11797 Servers that limit NFS access to "shares" or "exported" filesystems 11798 should provide a pseudo-filesystem into which the exported 11799 filesystems can be integrated, so that clients can browse the 11800 server's name space. The clients' view of a pseudo filesystem will 11801 be limited to paths that lead to exported filesystems. 11803 Note: previous versions of the protocol assigned special semantics to 11804 the names "." and "..". NFSv4 assigns no special semantics to these 11805 names. The LOOKUPP operator must be used to lookup a parent 11806 directory. 11808 Note that this operation does not follow symbolic links. The client 11809 is responsible for all parsing of filenames including filenames that 11810 are modified by symbolic links encountered during the lookup process. 11812 If the current filehandle supplied is not a directory but a symbolic 11813 link, the error NFS4ERR_SYMLINK is returned as the error. For all 11814 other non-directory file types, the error NFS4ERR_NOTDIR is returned. 11816 15.16. Operation 16: LOOKUPP - Lookup Parent Directory 11818 15.16.1. SYNOPSIS 11820 (cfh) -> (cfh) 11822 15.16.2. ARGUMENT 11824 /* CURRENT_FH: object */ 11825 void; 11827 15.16.3. RESULT 11829 struct LOOKUPP4res { 11830 /* CURRENT_FH: directory */ 11831 nfsstat4 status; 11832 }; 11834 15.16.4. DESCRIPTION 11836 The current filehandle is assumed to refer to a regular directory or 11837 a named attribute directory. LOOKUPP assigns the filehandle for its 11838 parent directory to be the current filehandle. If there is no parent 11839 directory an NFS4ERR_NOENT error must be returned. Therefore, 11840 NFS4ERR_NOENT will be returned by the server when the current 11841 filehandle is at the root or top of the server's file tree. 11843 15.16.5. IMPLEMENTATION 11845 As for LOOKUP, LOOKUPP will also cross mountpoints. 11847 If the current filehandle is not a directory or named attribute 11848 directory, the error NFS4ERR_NOTDIR is returned. 11850 15.17. Operation 17: NVERIFY - Verify Difference in Attributes 11852 15.17.1. SYNOPSIS 11854 (cfh), fattr -> - 11856 15.17.2. ARGUMENT 11858 struct NVERIFY4args { 11859 /* CURRENT_FH: object */ 11860 fattr4 obj_attributes; 11861 }; 11863 15.17.3. RESULT 11865 struct NVERIFY4res { 11866 nfsstat4 status; 11867 }; 11869 15.17.4. DESCRIPTION 11871 This operation is used to prefix a sequence of operations to be 11872 performed if one or more attributes have changed on some filesystem 11873 object. If all the attributes match then the error NFS4ERR_SAME must 11874 be returned. 11876 On success, the current filehandle retains its value. 11878 15.17.5. IMPLEMENTATION 11880 This operation is useful as a cache validation operator. If the 11881 object to which the attributes belong has changed then the following 11882 operations may obtain new data associated with that object. For 11883 instance, to check if a file has been changed and obtain new data if 11884 it has: 11886 PUTFH (public) 11887 LOOKUP "foobar" 11888 NVERIFY attrbits attrs 11889 READ 0 32767 11891 In the case that a recommended attribute is specified in the NVERIFY 11892 operation and the server does not support that attribute for the 11893 filesystem object, the error NFS4ERR_ATTRNOTSUPP is returned to the 11894 client. 11896 When the attribute rdattr_error or any write-only attribute (e.g., 11897 time_modify_set) is specified, the error NFS4ERR_INVAL is returned to 11898 the client. 11900 15.18. Operation 18: OPEN - Open a Regular File 11902 15.18.1. SYNOPSIS 11904 (cfh), seqid, share_access, share_deny, owner, openhow, claim -> 11905 (cfh), stateid, cinfo, rflags, attrset, delegation 11907 15.18.2. ARGUMENT 11909 /* 11910 * Various definitions for OPEN 11911 */ 11912 enum createmode4 { 11913 UNCHECKED4 = 0, 11914 GUARDED4 = 1, 11915 EXCLUSIVE4 = 2 11916 }; 11918 union createhow4 switch (createmode4 mode) { 11919 case UNCHECKED4: 11920 case GUARDED4: 11921 fattr4 createattrs; 11922 case EXCLUSIVE4: 11923 verifier4 createverf; 11924 }; 11926 enum opentype4 { 11927 OPEN4_NOCREATE = 0, 11928 OPEN4_CREATE = 1 11929 }; 11931 union openflag4 switch (opentype4 opentype) { 11932 case OPEN4_CREATE: 11933 createhow4 how; 11934 default: 11935 void; 11936 }; 11938 /* Next definitions used for OPEN delegation */ 11939 enum limit_by4 { 11940 NFS_LIMIT_SIZE = 1, 11941 NFS_LIMIT_BLOCKS = 2 11942 /* others as needed */ 11943 }; 11945 struct nfs_modified_limit4 { 11946 uint32_t num_blocks; 11947 uint32_t bytes_per_block; 11949 }; 11951 union nfs_space_limit4 switch (limit_by4 limitby) { 11952 /* limit specified as file size */ 11953 case NFS_LIMIT_SIZE: 11954 uint64_t filesize; 11955 /* limit specified by number of blocks */ 11956 case NFS_LIMIT_BLOCKS: 11957 nfs_modified_limit4 mod_blocks; 11958 } ; 11960 enum open_delegation_type4 { 11961 OPEN_DELEGATE_NONE = 0, 11962 OPEN_DELEGATE_READ = 1, 11963 OPEN_DELEGATE_WRITE = 2 11964 }; 11966 enum open_claim_type4 { 11967 CLAIM_NULL = 0, 11968 CLAIM_PREVIOUS = 1, 11969 CLAIM_DELEGATE_CUR = 2, 11970 CLAIM_DELEGATE_PREV = 3 11971 }; 11973 struct open_claim_delegate_cur4 { 11974 stateid4 delegate_stateid; 11975 component4 file; 11976 }; 11978 union open_claim4 switch (open_claim_type4 claim) { 11979 /* 11980 * No special rights to file. 11981 * Ordinary OPEN of the specified file. 11982 */ 11983 case CLAIM_NULL: 11984 /* CURRENT_FH: directory */ 11985 component4 file; 11986 /* 11987 * Right to the file established by an 11988 * open previous to server reboot. File 11989 * identified by filehandle obtained at 11990 * that time rather than by name. 11991 */ 11992 case CLAIM_PREVIOUS: 11993 /* CURRENT_FH: file being reclaimed */ 11994 open_delegation_type4 delegate_type; 11996 /* 11997 * Right to file based on a delegation 11998 * granted by the server. File is 11999 * specified by name. 12000 */ 12001 case CLAIM_DELEGATE_CUR: 12002 /* CURRENT_FH: directory */ 12003 open_claim_delegate_cur4 delegate_cur_info; 12005 /* 12006 * Right to file based on a delegation 12007 * granted to a previous boot instance 12008 * of the client. File is specified by name. 12009 */ 12010 case CLAIM_DELEGATE_PREV: 12011 /* CURRENT_FH: directory */ 12012 component4 file_delegate_prev; 12013 }; 12015 /* 12016 * OPEN: Open a file, potentially receiving an open delegation 12017 */ 12018 struct OPEN4args { 12019 seqid4 seqid; 12020 uint32_t share_access; 12021 uint32_t share_deny; 12022 open_owner4 owner; 12023 openflag4 openhow; 12024 open_claim4 claim; 12025 }; 12027 15.18.3. RESULT 12029 struct open_read_delegation4 { 12030 stateid4 stateid; /* Stateid for delegation*/ 12031 bool recall; /* Pre-recalled flag for 12032 delegations obtained 12033 by reclaim (CLAIM_PREVIOUS) */ 12035 nfsace4 permissions; /* Defines users who don't 12036 need an ACCESS call to 12037 open for read */ 12038 }; 12040 struct open_write_delegation4 { 12041 stateid4 stateid; /* Stateid for delegation */ 12042 bool recall; /* Pre-recalled flag for 12043 delegations obtained 12044 by reclaim 12045 (CLAIM_PREVIOUS) */ 12047 nfs_space_limit4 12048 space_limit; /* Defines condition that 12049 the client must check to 12050 determine whether the 12051 file needs to be flushed 12052 to the server on close. */ 12054 nfsace4 permissions; /* Defines users who don't 12055 need an ACCESS call as 12056 part of a delegated 12057 open. */ 12058 }; 12060 union open_delegation4 12061 switch (open_delegation_type4 delegation_type) { 12062 case OPEN_DELEGATE_NONE: 12063 void; 12064 case OPEN_DELEGATE_READ: 12065 open_read_delegation4 read; 12066 case OPEN_DELEGATE_WRITE: 12067 open_write_delegation4 write; 12068 }; 12070 /* 12071 * Result flags 12072 */ 12074 /* Client must confirm open */ 12075 const OPEN4_RESULT_CONFIRM = 0x00000002; 12076 /* Type of file locking behavior at the server */ 12077 const OPEN4_RESULT_LOCKTYPE_POSIX = 0x00000004; 12079 struct OPEN4resok { 12080 stateid4 stateid; /* Stateid for open */ 12081 change_info4 cinfo; /* Directory Change Info */ 12082 uint32_t rflags; /* Result flags */ 12083 bitmap4 attrset; /* attribute set for create*/ 12084 open_delegation4 delegation; /* Info on any open 12085 delegation */ 12086 }; 12088 union OPEN4res switch (nfsstat4 status) { 12089 case NFS4_OK: 12090 /* CURRENT_FH: opened file */ 12091 OPEN4resok resok4; 12093 default: 12094 void; 12095 }; 12097 15.18.4. WARNING TO CLIENT IMPLEMENTORS 12099 OPEN resembles LOOKUP in that it generates a filehandle for the 12100 client to use. Unlike LOOKUP though, OPEN creates server state on 12101 the filehandle. In normal circumstances, the client can only release 12102 this state with a CLOSE operation. CLOSE uses the current filehandle 12103 to determine which file to close. Therefore the client MUST follow 12104 every OPEN operation with a GETFH operation in the same COMPOUND 12105 procedure. This will supply the client with the filehandle such that 12106 CLOSE can be used appropriately. 12108 Simply waiting for the lease on the file to expire is insufficient 12109 because the server may maintain the state indefinitely as long as 12110 another client does not attempt to make a conflicting access to the 12111 same file. 12113 15.18.5. DESCRIPTION 12115 The OPEN operation creates and/or opens a regular file in a directory 12116 with the provided name. If the file does not exist at the server and 12117 creation is desired, specification of the method of creation is 12118 provided by the openhow parameter. The client has the choice of 12119 three creation methods: UNCHECKED4, GUARDED4, or EXCLUSIVE4. 12121 If the current filehandle is a named attribute directory, OPEN will 12122 then create or open a named attribute file. Note that exclusive 12123 create of a named attribute is not supported. If the createmode is 12124 EXCLUSIVE4 and the current filehandle is a named attribute directory, 12125 the server will return EINVAL. 12127 UNCHECKED4 means that the file should be created if a file of that 12128 name does not exist and encountering an existing regular file of that 12129 name is not an error. For this type of create, createattrs specifies 12130 the initial set of attributes for the file. The set of attributes 12131 may include any writable attribute valid for regular files. When an 12132 UNCHECKED4 create encounters an existing file, the attributes 12133 specified by createattrs are not used, except that when an size of 12134 zero is specified, the existing file is truncated. If GUARDED4 is 12135 specified, the server checks for the presence of a duplicate object 12136 by name before performing the create. If a duplicate exists, an 12137 error of NFS4ERR_EXIST is returned as the status. If the object does 12138 not exist, the request is performed as described for UNCHECKED4. For 12139 each of these cases (UNCHECKED4 and GUARDED4) where the operation is 12140 successful, the server will return to the client an attribute mask 12141 signifying which attributes were successfully set for the object. 12143 EXCLUSIVE4 specifies that the server is to follow exclusive creation 12144 semantics, using the verifier to ensure exclusive creation of the 12145 target. The server should check for the presence of a duplicate 12146 object by name. If the object does not exist, the server creates the 12147 object and stores the verifier with the object. If the object does 12148 exist and the stored verifier matches the client provided verifier, 12149 the server uses the existing object as the newly created object. If 12150 the stored verifier does not match, then an error of NFS4ERR_EXIST is 12151 returned. No attributes may be provided in this case, since the 12152 server may use an attribute of the target object to store the 12153 verifier. If the server uses an attribute to store the exclusive 12154 create verifier, it will signify which attribute by setting the 12155 appropriate bit in the attribute mask that is returned in the 12156 results. 12158 For the target directory, the server returns change_info4 information 12159 in cinfo. With the atomic field of the change_info4 struct, the 12160 server will indicate if the before and after change attributes were 12161 obtained atomically with respect to the link creation. 12163 Upon successful creation, the current filehandle is replaced by that 12164 of the new object. 12166 The OPEN operation provides for Windows share reservation capability 12167 with the use of the share_access and share_deny fields of the OPEN 12168 arguments. The client specifies at OPEN the required share_access 12169 and share_deny modes. For clients that do not directly support 12170 SHAREs (i.e., UNIX), the expected deny value is DENY_NONE. In the 12171 case that there is a existing SHARE reservation that conflicts with 12172 the OPEN request, the server returns the error NFS4ERR_SHARE_DENIED. 12173 For a complete SHARE request, the client must provide values for the 12174 owner and seqid fields for the OPEN argument. For additional 12175 discussion of SHARE semantics see Section 9.9. 12177 In the case that the client is recovering state from a server 12178 failure, the claim field of the OPEN argument is used to signify that 12179 the request is meant to reclaim state previously held. 12181 The "claim" field of the OPEN argument is used to specify the file to 12182 be opened and the state information which the client claims to 12183 possess. There are four basic claim types which cover the various 12184 situations for an OPEN. They are as follows: 12186 CLAIM_NULL: For the client, this is a new OPEN request and there is 12187 no previous state associate with the file for the client. 12189 CLAIM_PREVIOUS: The client is claiming basic OPEN state for a file 12190 that was held previous to a server reboot. Generally used when a 12191 server is returning persistent filehandles; the client may not 12192 have the file name to reclaim the OPEN. 12194 CLAIM_DELEGATE_CUR: The client is claiming a delegation for OPEN as 12195 granted by the server. Generally this is done as part of 12196 recalling a delegation. 12198 CLAIM_DELEGATE_PREV: The client is claiming a delegation granted to 12199 a previous client instance; used after the client reboots. The 12200 server MAY support CLAIM_DELEGATE_PREV. If it does support 12201 CLAIM_DELEGATE_PREV, SETCLIENTID_CONFIRM MUST NOT remove the 12202 client's delegation state, and the server MUST support the 12203 DELEGPURGE operation. 12205 For OPEN requests whose claim type is other than CLAIM_PREVIOUS 12206 (i.e., requests other than those devoted to reclaiming opens after a 12207 server reboot) that reach the server during its grace or lease 12208 expiration period, the server returns an error of NFS4ERR_GRACE. 12210 For any OPEN request, the server may return an open delegation, which 12211 allows further opens and closes to be handled locally on the client 12212 as described in Section 10.4. Note that delegation is up to the 12213 server to decide. The client should never assume that delegation 12214 will or will not be granted in a particular instance. It should 12215 always be prepared for either case. A partial exception is the 12216 reclaim (CLAIM_PREVIOUS) case, in which a delegation type is claimed. 12217 In this case, delegation will always be granted, although the server 12218 may specify an immediate recall in the delegation structure. 12220 The rflags returned by a successful OPEN allow the server to return 12221 information governing how the open file is to be handled. 12223 OPEN4_RESULT_CONFIRM indicates that the client MUST execute an 12224 OPEN_CONFIRM operation before using the open file. 12225 OPEN4_RESULT_LOCKTYPE_POSIX indicates the server's file locking 12226 behavior supports the complete set of Posix locking techniques [35]. 12227 From this the client can choose to manage file locking state in a way 12228 to handle a mis-match of file locking management. 12230 If the component is of zero length, NFS4ERR_INVAL will be returned. 12231 The component is also subject to the normal UTF-8, character support, 12232 and name checks. See Section 12.3 for further discussion. 12234 When an OPEN is done and the specified open-owner already has the 12235 resulting filehandle open, the result is to "OR" together the new 12236 share and deny status together with the existing status. In this 12237 case, only a single CLOSE need be done, even though multiple OPENs 12238 were completed. When such an OPEN is done, checking of share 12239 reservations for the new OPEN proceeds normally, with no exception 12240 for the existing OPEN held by the same owner. In this case, the 12241 stateid returned as an "other" field that matches that of the 12242 previous open while the "seqid" field is incremented to reflect the 12243 change status due to the new open. 12245 If the underlying filesystem at the server is only accessible in a 12246 read-only mode and the OPEN request has specified ACCESS_WRITE or 12247 ACCESS_BOTH, the server will return NFS4ERR_ROFS to indicate a read- 12248 only filesystem. 12250 As with the CREATE operation, the server MUST derive the owner, owner 12251 ACE, group, or group ACE if any of the four attributes are required 12252 and supported by the server's filesystem. For an OPEN with the 12253 EXCLUSIVE4 createmode, the server has no choice, since such OPEN 12254 calls do not include the createattrs field. Conversely, if 12255 createattrs is specified, and includes owner or group (or 12256 corresponding ACEs) that the principal in the RPC call's credentials 12257 does not have authorization to create files for, then the server may 12258 return NFS4ERR_PERM. 12260 In the case of a OPEN which specifies a size of zero (e.g., 12261 truncation) and the file has named attributes, the named attributes 12262 are left as is. They are not removed. 12264 15.18.6. IMPLEMENTATION 12266 The OPEN operation contains support for EXCLUSIVE4 create. The 12267 mechanism is similar to the support in NFSv3 [14]. As in NFSv3, this 12268 mechanism provides reliable exclusive creation. Exclusive create is 12269 invoked when the how parameter is EXCLUSIVE4. In this case, the 12270 client provides a verifier that can reasonably be expected to be 12271 unique. A combination of a client identifier, perhaps the client 12272 network address, and a unique number generated by the client, perhaps 12273 the RPC transaction identifier, may be appropriate. 12275 If the object does not exist, the server creates the object and 12276 stores the verifier in stable storage. For filesystems that do not 12277 provide a mechanism for the storage of arbitrary file attributes, the 12278 server may use one or more elements of the object meta-data to store 12279 the verifier. The verifier must be stored in stable storage to 12280 prevent erroneous failure on retransmission of the request. It is 12281 assumed that an exclusive create is being performed because exclusive 12282 semantics are critical to the application. Because of the expected 12283 usage, exclusive CREATE does not rely solely on the normally volatile 12284 duplicate request cache for storage of the verifier. The duplicate 12285 request cache in volatile storage does not survive a crash and may 12286 actually flush on a long network partition, opening failure windows. 12287 In the UNIX local filesystem environment, the expected storage 12288 location for the verifier on creation is the meta-data (time stamps) 12289 of the object. For this reason, an exclusive object create may not 12290 include initial attributes because the server would have nowhere to 12291 store the verifier. 12293 If the server cannot support these exclusive create semantics, 12294 possibly because of the requirement to commit the verifier to stable 12295 storage, it should fail the OPEN request with the error, 12296 NFS4ERR_NOTSUPP. 12298 During an exclusive CREATE request, if the object already exists, the 12299 server reconstructs the object's verifier and compares it with the 12300 verifier in the request. If they match, the server treats the 12301 request as a success. The request is presumed to be a duplicate of 12302 an earlier, successful request for which the reply was lost and that 12303 the server duplicate request cache mechanism did not detect. If the 12304 verifiers do not match, the request is rejected with the status, 12305 NFS4ERR_EXIST. 12307 Once the client has performed a successful exclusive create, it must 12308 issue a SETATTR to set the correct object attributes. Until it does 12309 so, it should not rely upon any of the object attributes, since the 12310 server implementation may need to overload object meta-data to store 12311 the verifier. The subsequent SETATTR must not occur in the same 12312 COMPOUND request as the OPEN. This separation will guarantee that 12313 the exclusive create mechanism will continue to function properly in 12314 the face of retransmission of the request. 12316 Use of the GUARDED4 attribute does not provide exactly-once 12317 semantics. In particular, if a reply is lost and the server does not 12318 detect the retransmission of the request, the operation can fail with 12319 NFS4ERR_EXIST, even though the create was performed successfully. 12320 The client would use this behavior in the case that the application 12321 has not requested an exclusive create but has asked to have the file 12322 truncated when the file is opened. In the case of the client timing 12323 out and retransmitting the create request, the client can use 12324 GUARDED4 to prevent against a sequence like: create, write, create 12325 (retransmitted) from occurring. 12327 For SHARE reservations, the client must specify a value for 12328 share_access that is one of READ, WRITE, or BOTH. For share_deny, 12329 the client must specify one of NONE, READ, WRITE, or BOTH. If the 12330 client fails to do this, the server must return NFS4ERR_INVAL. 12332 Based on the share_access value (READ, WRITE, or BOTH) the client 12333 should check that the requester has the proper access rights to 12334 perform the specified operation. This would generally be the results 12335 of applying the ACL access rules to the file for the current 12336 requester. However, just as with the ACCESS operation, the client 12337 should not attempt to second-guess the server's decisions, as access 12338 rights may change and may be subject to server administrative 12339 controls outside the ACL framework. If the requester is not 12340 authorized to READ or WRITE (depending on the share_access value), 12341 the server must return NFS4ERR_ACCESS. Note that since the NFS 12342 version 4 protocol does not impose any requirement that READs and 12343 WRITEs issued for an open file have the same credentials as the OPEN 12344 itself, the server still must do appropriate access checking on the 12345 READs and WRITEs themselves. 12347 If the component provided to OPEN is a symbolic link, the error 12348 NFS4ERR_SYMLINK will be returned to the client. If the current 12349 filehandle is not a directory, the error NFS4ERR_NOTDIR will be 12350 returned. 12352 If a COMPOUND contains an OPEN which establishes a 12353 OPEN_DELEGATE_WRITE delegation, then a subsequent GETATTR inside that 12354 COMPOUND SHOULD not result in a CB_GETATTR to the client. The server 12355 SHOULD understand the GETATTR to be for the same client ID and avoid 12356 querying the client, which will not be able to respond. This 12357 sequence of OPEN, GETATTR SHOULD be understood as an atomic retrieval 12358 of the initial size and change attribute. Further, the client SHOULD 12359 NOT construct a COMPOUND which mixes operations for different client 12360 IDs. 12362 15.18.7. Warning to Client Implementors 12364 OPEN resembles LOOKUP in that it generates a filehandle for the 12365 client to use. Unlike LOOKUP though, OPEN creates server state on 12366 the filehandle. In normal circumstances, the client can only release 12367 this state with a CLOSE operation. CLOSE uses the current filehandle 12368 to determine which file to close. Therefore, the client MUST follow 12369 every OPEN operation with a GETFH operation in the same COMPOUND 12370 procedure. This will supply the client with the filehandle such that 12371 CLOSE can be used appropriately. 12373 Simply waiting for the lease on the file to expire is insufficient 12374 because the server may maintain the state indefinitely as long as 12375 another client does not attempt to make a conflicting access to the 12376 same file. 12378 15.19. Operation 19: OPENATTR - Open Named Attribute Directory 12380 15.19.1. SYNOPSIS 12382 (cfh) createdir -> (cfh) 12384 15.19.2. ARGUMENT 12386 struct OPENATTR4args { 12387 /* CURRENT_FH: object */ 12388 bool createdir; 12389 }; 12391 15.19.3. RESULT 12393 struct OPENATTR4res { 12394 /* CURRENT_FH: named attr directory */ 12395 nfsstat4 status; 12396 }; 12398 15.19.4. DESCRIPTION 12400 The OPENATTR operation is used to obtain the filehandle of the named 12401 attribute directory associated with the current filehandle. The 12402 result of the OPENATTR will be a filehandle to an object of type 12403 NF4ATTRDIR. From this filehandle, READDIR and LOOKUP operations can 12404 be used to obtain filehandles for the various named attributes 12405 associated with the original filesystem object. Filehandles returned 12406 within the named attribute directory will have a type of 12407 NF4NAMEDATTR. 12409 The createdir argument allows the client to signify if a named 12410 attribute directory should be created as a result of the OPENATTR 12411 operation. Some clients may use the OPENATTR operation with a value 12412 of FALSE for createdir to determine if any named attributes exist for 12413 the object. If none exist, then NFS4ERR_NOENT will be returned. If 12414 createdir has a value of TRUE and no named attribute directory 12415 exists, one is created. The creation of a named attribute directory 12416 assumes that the server has implemented named attribute support in 12417 this fashion and is not required to do so by this definition. 12419 15.19.5. IMPLEMENTATION 12421 If the server does not support named attributes for the current 12422 filehandle, an error of NFS4ERR_NOTSUPP will be returned to the 12423 client. 12425 15.20. Operation 20: OPEN_CONFIRM - Confirm Open 12427 15.20.1. SYNOPSIS 12429 (cfh), seqid, stateid -> stateid 12431 15.20.2. ARGUMENT 12433 struct OPEN_CONFIRM4args { 12434 /* CURRENT_FH: opened file */ 12435 stateid4 open_stateid; 12436 seqid4 seqid; 12437 }; 12439 15.20.3. RESULT 12441 struct OPEN_CONFIRM4resok { 12442 stateid4 open_stateid; 12443 }; 12445 union OPEN_CONFIRM4res switch (nfsstat4 status) { 12446 case NFS4_OK: 12447 OPEN_CONFIRM4resok resok4; 12448 default: 12449 void; 12450 }; 12452 15.20.4. DESCRIPTION 12454 This operation is used to confirm the sequence id usage for the first 12455 time that a open-owner is used by a client. The stateid returned 12456 from the OPEN operation is used as the argument for this operation 12457 along with the next sequence id for the open-owner. The sequence id 12458 passed to the OPEN_CONFIRM must be 1 (one) greater than the seqid 12459 passed to the OPEN operation. If the server receives an unexpected 12460 sequence id with respect to the original open, then the server 12461 assumes that the client will not confirm the original OPEN and all 12462 state associated with the original OPEN is released by the server. 12464 On success, the current filehandle retains its value. 12466 15.20.5. IMPLEMENTATION 12468 A given client might generate many open_owner4 data structures for a 12469 given client ID. The client will periodically either dispose of its 12470 open_owner4s or stop using them for indefinite periods of time. The 12471 latter situation is why the NFSv4 protocol does not have an explicit 12472 operation to exit an open_owner4: such an operation is of no use in 12473 that situation. Instead, to avoid unbounded memory use, the server 12474 needs to implement a strategy for disposing of open_owner4s that have 12475 no current open state for any files and have not been used recently. 12476 The time period used to determine when to dispose of open_owner4s is 12477 an implementation choice. The time period should certainly be no 12478 less than the lease time plus any grace period the server wishes to 12479 implement beyond a lease time. The OPEN_CONFIRM operation allows the 12480 server to safely dispose of unused open_owner4 data structures. 12482 In the case that a client issues an OPEN operation and the server no 12483 longer has a record of the open_owner4, the server needs to ensure 12484 that this is a new OPEN and not a replay or retransmission. 12486 Servers must not require confirmation on OPENs that grant delegations 12487 or are doing reclaim operations. See Section 9.1.9 for details. The 12488 server can easily avoid this by noting whether it has disposed of one 12489 open_owner4 for the given client ID. If the server does not support 12490 delegation, it might simply maintain a single bit that notes whether 12491 any open_owner4 (for any client) has been disposed of. 12493 The server must hold unconfirmed OPEN state until one of three events 12494 occur. First, the client sends an OPEN_CONFIRM request with the 12495 appropriate sequence id and stateid within the lease period. In this 12496 case, the OPEN state on the server goes to confirmed, and the 12497 open_owner4 on the server is fully established. 12499 Second, the client sends another OPEN request with a sequence id that 12500 is incorrect for the open_owner4 (out of sequence). In this case, 12501 the server assumes the second OPEN request is valid and the first one 12502 is a replay. The server cancels the OPEN state of the first OPEN 12503 request, establishes an unconfirmed OPEN state for the second OPEN 12504 request, and responds to the second OPEN request with an indication 12505 that an OPEN_CONFIRM is needed. The process then repeats itself. 12506 While there is a potential for a denial of service attack on the 12507 client, it is mitigated if the client and server require the use of a 12508 security flavor based on Kerberos V5, LIPKEY, or some other flavor 12509 that uses cryptography. 12511 What if the server is in the unconfirmed OPEN state for a given 12512 open_owner4, and it receives an operation on the open_owner4 that has 12513 a stateid but the operation is not OPEN, or it is OPEN_CONFIRM but 12514 with the wrong stateid? Then, even if the seqid is correct, the 12515 server returns NFS4ERR_BAD_STATEID, because the server assumes the 12516 operation is a replay: if the server has no established OPEN state, 12517 then there is no way, for example, a LOCK operation could be valid. 12519 Third, neither of the two aforementioned events occur for the 12520 open_owner4 within the lease period. In this case, the OPEN state is 12521 canceled and disposal of the open_owner4 can occur. 12523 15.21. Operation 21: OPEN_DOWNGRADE - Reduce Open File Access 12525 15.21.1. SYNOPSIS 12527 (cfh), stateid, seqid, access, deny -> stateid 12529 15.21.2. ARGUMENT 12531 struct OPEN_DOWNGRADE4args { 12532 /* CURRENT_FH: opened file */ 12533 stateid4 open_stateid; 12534 seqid4 seqid; 12535 uint32_t share_access; 12536 uint32_t share_deny; 12537 }; 12539 15.21.3. RESULT 12541 struct OPEN_DOWNGRADE4resok { 12542 stateid4 open_stateid; 12543 }; 12545 union OPEN_DOWNGRADE4res switch(nfsstat4 status) { 12546 case NFS4_OK: 12547 OPEN_DOWNGRADE4resok resok4; 12548 default: 12549 void; 12550 }; 12552 15.21.4. DESCRIPTION 12554 This operation is used to adjust the share_access and share_deny bits 12555 for a given open. This is necessary when a given openowner opens the 12556 same file multiple times with different share_access and share_deny 12557 flags. In this situation, a close of one of the opens may change the 12558 appropriate share_access and share_deny flags to remove bits 12559 associated with opens no longer in effect. 12561 The share_access and share_deny bits specified in this operation 12562 replace the current ones for the specified open file. The 12563 share_access and share_deny bits specified must be exactly equal to 12564 the union of the share_access and share_deny bits specified for some 12565 subset of the OPENs in effect for current openowner on the current 12566 file. If that constraint is not respected, the error NFS4ERR_INVAL 12567 should be returned. Since share_access and share_deny bits are 12568 subsets of those already granted, it is not possible for this request 12569 to be denied because of conflicting share reservations. 12571 As the OPEN_DOWNGRADE may change a file to be not-open-for-write and 12572 a write byte-range lock might be held, the server may have to reject 12573 the OPEN_DOWNGRADE with a NFS4ERR_LOCKS_HELD. 12575 On success, the current filehandle retains its value. 12577 15.22. Operation 22: PUTFH - Set Current Filehandle 12579 15.22.1. SYNOPSIS 12581 filehandle -> (cfh) 12583 15.22.2. ARGUMENT 12585 struct PUTFH4args { 12586 nfs_fh4 object; 12587 }; 12589 15.22.3. RESULT 12591 struct PUTFH4res { 12592 /* CURRENT_FH: */ 12593 nfsstat4 status; 12594 }; 12596 15.22.4. DESCRIPTION 12598 Replaces the current filehandle with the filehandle provided as an 12599 argument. Clears the current stateid. 12601 If the security mechanism used by the requester does not meet the 12602 requirements of the filehandle provided to this operation, the server 12603 MUST return NFS4ERR_WRONGSEC. 12605 See Section 15.2.4.1 for more details on the current filehandle. 12607 See Section 15.2.4.2 for more details on the current stateid. 12609 15.22.5. IMPLEMENTATION 12611 Commonly used as the first operator in an NFS request to set the 12612 context for following operations. 12614 15.23. Operation 23: PUTPUBFH - Set Public Filehandle 12616 15.23.1. SYNOPSIS 12618 - -> (cfh) 12620 15.23.2. ARGUMENT 12622 void; 12624 15.23.3. RESULT 12626 struct PUTPUBFH4res { 12627 /* CURRENT_FH: public fh */ 12628 nfsstat4 status; 12629 }; 12631 15.23.4. DESCRIPTION 12633 Replaces the current filehandle with the filehandle that represents 12634 the public filehandle of the server's name space. This filehandle 12635 may be different from the "root" filehandle which may be associated 12636 with some other directory on the server. 12638 The public filehandle represents the concepts embodied in [23], [24], 12639 [38]. The intent for NFSv4 is that the public filehandle 12640 (represented by the PUTPUBFH operation) be used as a method of 12641 providing WebNFS server compatibility with NFSv2 and NFSv3. 12643 The public filehandle and the root filehandle (represented by the 12644 PUTROOTFH operation) should be equivalent. If the public and root 12645 filehandles are not equivalent, then the public filehandle MUST be a 12646 descendant of the root filehandle. 12648 15.23.5. IMPLEMENTATION 12650 Used as the first operator in an NFS request to set the context for 12651 following operations. 12653 With the NFSv2 and 3 public filehandle, the client is able to specify 12654 whether the path name provided in the LOOKUP should be evaluated as 12655 either an absolute path relative to the server's root or relative to 12656 the public filehandle. [38] contains further discussion of the 12657 functionality. With NFSv4, that type of specification is not 12658 directly available in the LOOKUP operation. The reason for this is 12659 because the component separators needed to specify absolute vs. 12660 relative are not allowed in NFSv4. Therefore, the client is 12661 responsible for constructing its request such that the use of either 12662 PUTROOTFH or PUTPUBFH are used to signify absolute or relative 12663 evaluation of an NFS URL respectively. 12665 Note that there are warnings mentioned in [38] with respect to the 12666 use of absolute evaluation and the restrictions the server may place 12667 on that evaluation with respect to how much of its namespace has been 12668 made available. These same warnings apply to NFSv4. It is likely, 12669 therefore that because of server implementation details, an NFSv3 12670 absolute public filehandle lookup may behave differently than an 12671 NFSv4 absolute resolution. 12673 There is a form of security negotiation as described in [39] that 12674 uses the public filehandle a method of employing SNEGO. This method 12675 is not available with NFSv4 as filehandles are not overloaded with 12676 special meaning and therefore do not provide the same framework as 12677 NFSv2 and NFSv3. Clients should therefore use the security 12678 negotiation mechanisms described in this RFC. 12680 15.24. Operation 24: PUTROOTFH - Set Root Filehandle 12682 15.24.1. SYNOPSIS 12684 - -> (cfh) 12686 15.24.2. ARGUMENT 12688 void; 12690 15.24.3. RESULT 12692 struct PUTROOTFH4res { 12693 /* CURRENT_FH: root fh */ 12694 nfsstat4 status; 12695 }; 12697 15.24.4. DESCRIPTION 12699 Replaces the current filehandle with the filehandle that represents 12700 the root of the server's name space. From this filehandle a LOOKUP 12701 operation can locate any other filehandle on the server. This 12702 filehandle may be different from the "public" filehandle which may be 12703 associated with some other directory on the server. 12705 PUTROOTFH also clears the current stateid. 12707 See Section 15.2.4.1 for more details on the current filehandle. 12709 See Section 15.2.4.2 for more details on the current stateid. 12711 15.24.5. IMPLEMENTATION 12713 Commonly used as the first operator in an NFS request to set the 12714 context for following operations. 12716 15.25. Operation 25: READ - Read from File 12718 15.25.1. SYNOPSIS 12720 (cfh), stateid, offset, count -> eof, data 12722 15.25.2. ARGUMENT 12724 struct READ4args { 12725 /* CURRENT_FH: file */ 12726 stateid4 stateid; 12727 offset4 offset; 12728 count4 count; 12729 }; 12731 15.25.3. RESULT 12733 struct READ4resok { 12734 bool eof; 12735 opaque data<>; 12736 }; 12738 union READ4res switch (nfsstat4 status) { 12739 case NFS4_OK: 12740 READ4resok resok4; 12741 default: 12742 void; 12743 }; 12745 15.25.4. DESCRIPTION 12747 The READ operation reads data from the regular file identified by the 12748 current filehandle. 12750 The client provides an offset of where the READ is to start and a 12751 count of how many bytes are to be read. An offset of 0 (zero) means 12752 to read data starting at the beginning of the file. If offset is 12753 greater than or equal to the size of the file, the status, NFS4_OK, 12754 is returned with a data length set to 0 (zero) and eof is set to 12755 TRUE. The READ is subject to access permissions checking. 12757 If the client specifies a count value of 0 (zero), the READ succeeds 12758 and returns 0 (zero) bytes of data again subject to access 12759 permissions checking. The server may choose to return fewer bytes 12760 than specified by the client. The client needs to check for this 12761 condition and handle the condition appropriately. 12763 The stateid value for a READ request represents a value returned from 12764 a previous byte-range lock or share reservation request or the 12765 stateid associated with a delegation. The stateid is used by the 12766 server to verify that the associated share reservation and any byte- 12767 range locks are still valid and to update lease timeouts for the 12768 client. 12770 If the read ended at the end-of-file (formally, in a correctly formed 12771 READ request, if offset + count is equal to the size of the file), or 12772 the read request extends beyond the size of the file (if offset + 12773 count is greater than the size of the file), eof is returned as TRUE; 12774 otherwise it is FALSE. A successful READ of an empty file will 12775 always return eof as TRUE. 12777 If the current filehandle is not a regular file, an error will be 12778 returned to the client. In the case the current filehandle 12779 represents a directory, NFS4ERR_ISDIR is return; otherwise, 12780 NFS4ERR_INVAL is returned. 12782 For a READ with a stateid value of all bits 0, the server MAY allow 12783 the READ to be serviced subject to mandatory file locks or the 12784 current share deny modes for the file. For a READ with a stateid 12785 value of all bits 1, the server MAY allow READ operations to bypass 12786 locking checks at the server. 12788 On success, the current filehandle retains its value. 12790 15.25.5. IMPLEMENTATION 12792 If the server returns a "short read" (i.e., fewer data than requested 12793 and eof is set to FALSE), the client should send another READ to get 12794 the remaining data. A server may return less data than requested 12795 under several circumstances. The file may have been truncated by 12796 another client or perhaps on the server itself, changing the file 12797 size from what the requesting client believes to be the case. This 12798 would reduce the actual amount of data available to the client. It 12799 is possible that the server reduce the transfer size and so return a 12800 short read result. Server resource exhaustion may also occur in a 12801 short read. 12803 If mandatory byte-range locking is in effect for the file, and if the 12804 byte-range corresponding to the data to be read from the file is 12805 WRITE_LT locked by an owner not associated with the stateid, the 12806 server will return the NFS4ERR_LOCKED error. The client should try 12807 to get the appropriate READ_LT via the LOCK operation before 12808 reattempting the READ. When the READ completes, the client should 12809 release the byte-range lock via LOCKU. 12811 If another client has an OPEN_DELEGATE_WRITE delegation for the file 12812 being read, the delegation must be recalled, and the operation cannot 12813 proceed until that delegation is returned or revoked. Except where 12814 this happens very quickly, one or more NFS4ERR_DELAY errors will be 12815 returned to requests made while the delegation remains outstanding. 12816 Normally, delegations will not be recalled as a result of a READ 12817 operation since the recall will occur as a result of an earlier OPEN. 12818 However, since it is possible for a READ to be done with a special 12819 stateid, the server needs to check for this case even though the 12820 client should have done an OPEN previously. 12822 15.26. Operation 26: READDIR - Read Directory 12824 15.26.1. SYNOPSIS 12826 (cfh), cookie, cookieverf, dircount, maxcount, attr_request -> 12827 cookieverf { cookie, name, attrs } 12829 15.26.2. ARGUMENT 12831 struct READDIR4args { 12832 /* CURRENT_FH: directory */ 12833 nfs_cookie4 cookie; 12834 verifier4 cookieverf; 12835 count4 dircount; 12836 count4 maxcount; 12837 bitmap4 attr_request; 12838 }; 12840 15.26.3. RESULT 12842 struct entry4 { 12843 nfs_cookie4 cookie; 12844 component4 name; 12845 fattr4 attrs; 12846 entry4 *nextentry; 12847 }; 12849 struct dirlist4 { 12850 entry4 *entries; 12851 bool eof; 12852 }; 12854 struct READDIR4resok { 12855 verifier4 cookieverf; 12856 dirlist4 reply; 12857 }; 12859 union READDIR4res switch (nfsstat4 status) { 12860 case NFS4_OK: 12861 READDIR4resok resok4; 12862 default: 12863 void; 12864 }; 12866 15.26.4. DESCRIPTION 12868 The READDIR operation retrieves a variable number of entries from a 12869 filesystem directory and returns client requested attributes for each 12870 entry along with information to allow the client to request 12871 additional directory entries in a subsequent READDIR. 12873 The arguments contain a cookie value that represents where the 12874 READDIR should start within the directory. A value of 0 (zero) for 12875 the cookie is used to start reading at the beginning of the 12876 directory. For subsequent READDIR requests, the client specifies a 12877 cookie value that is provided by the server on a previous READDIR 12878 request. 12880 The cookieverf value should be set to 0 (zero) when the cookie value 12881 is 0 (zero) (first directory read). On subsequent requests, it 12882 should be a cookieverf as returned by the server. The cookieverf 12883 must match that returned by the READDIR in which the cookie was 12884 acquired. If the server determines that the cookieverf is no longer 12885 valid for the directory, the error NFS4ERR_NOT_SAME must be returned. 12887 The dircount portion of the argument is a hint of the maximum number 12888 of bytes of directory information that should be returned. This 12889 value represents the length of the names of the directory entries and 12890 the cookie value for these entries. This length represents the XDR 12891 encoding of the data (names and cookies) and not the length in the 12892 native format of the server. 12894 The maxcount value of the argument is the maximum number of bytes for 12895 the result. This maximum size represents all of the data being 12896 returned within the READDIR4resok structure and includes the XDR 12897 overhead. The server may return less data. If the server is unable 12898 to return a single directory entry within the maxcount limit, the 12899 error NFS4ERR_TOOSMALL will be returned to the client. 12901 Finally, attr_request represents the list of attributes to be 12902 returned for each directory entry supplied by the server. 12904 On successful return, the server's response will provide a list of 12905 directory entries. Each of these entries contains the name of the 12906 directory entry, a cookie value for that entry, and the associated 12907 attributes as requested. The "eof" flag has a value of TRUE if there 12908 are no more entries in the directory. 12910 The cookie value is only meaningful to the server and is used as a 12911 "bookmark" for the directory entry. As mentioned, this cookie is 12912 used by the client for subsequent READDIR operations so that it may 12913 continue reading a directory. The cookie is similar in concept to a 12914 READ offset but should not be interpreted as such by the client. 12915 Ideally, the cookie value should not change if the directory is 12916 modified since the client may be caching these values. 12918 In some cases, the server may encounter an error while obtaining the 12919 attributes for a directory entry. Instead of returning an error for 12920 the entire READDIR operation, the server can instead return the 12921 attribute 'fattr4_rdattr_error'. With this, the server is able to 12922 communicate the failure to the client and not fail the entire 12923 operation in the instance of what might be a transient failure. 12924 Obviously, the client must request the fattr4_rdattr_error attribute 12925 for this method to work properly. If the client does not request the 12926 attribute, the server has no choice but to return failure for the 12927 entire READDIR operation. 12929 For some filesystem environments, the directory entries "." and ".." 12930 have special meaning and in other environments, they may not. If the 12931 server supports these special entries within a directory, they should 12932 not be returned to the client as part of the READDIR response. To 12933 enable some client environments, the cookie values of 0, 1, and 2 are 12934 to be considered reserved. Note that the UNIX client will use these 12935 values when combining the server's response and local representations 12936 to enable a fully formed UNIX directory presentation to the 12937 application. 12939 For READDIR arguments, cookie values of 1 and 2 SHOULD NOT be used 12940 and for READDIR results cookie values of 0, 1, and 2 MUST NOT be 12941 returned. 12943 On success, the current filehandle retains its value. 12945 15.26.5. IMPLEMENTATION 12947 The server's filesystem directory representations can differ greatly. 12948 A client's programming interfaces may also be bound to the local 12949 operating environment in a way that does not translate well into the 12950 NFS protocol. Therefore the use of the dircount and maxcount fields 12951 are provided to allow the client the ability to provide guidelines to 12952 the server. If the client is aggressive about attribute collection 12953 during a READDIR, the server has an idea of how to limit the encoded 12954 response. The dircount field provides a hint on the number of 12955 entries based solely on the names of the directory entries. Since it 12956 is a hint, it may be possible that a dircount value is zero. In this 12957 case, the server is free to ignore the dircount value and return 12958 directory information based on the specified maxcount value. 12960 The cookieverf may be used by the server to help manage cookie values 12961 that may become stale. It should be a rare occurrence that a server 12962 is unable to continue properly reading a directory with the provided 12963 cookie/cookieverf pair. The server should make every effort to avoid 12964 this condition since the application at the client may not be able to 12965 properly handle this type of failure. 12967 The use of the cookieverf will also protect the client from using 12968 READDIR cookie values that may be stale. For example, if the file 12969 system has been migrated, the server may or may not be able to use 12970 the same cookie values to service READDIR as the previous server 12971 used. With the client providing the cookieverf, the server is able 12972 to provide the appropriate response to the client. This prevents the 12973 case where the server may accept a cookie value but the underlying 12974 directory has changed and the response is invalid from the client's 12975 context of its previous READDIR. 12977 Since some servers will not be returning "." and ".." entries as has 12978 been done with previous versions of the NFS protocol, the client that 12979 requires these entries be present in READDIR responses must fabricate 12980 them. 12982 15.27. Operation 27: READLINK - Read Symbolic Link 12984 15.27.1. SYNOPSIS 12986 (cfh) -> linktext 12988 15.27.2. ARGUMENT 12990 /* CURRENT_FH: symlink */ 12991 void; 12993 15.27.3. RESULT 12995 struct READLINK4resok { 12996 linktext4 link; 12997 }; 12999 union READLINK4res switch (nfsstat4 status) { 13000 case NFS4_OK: 13001 READLINK4resok resok4; 13002 default: 13003 void; 13004 }; 13006 15.27.4. DESCRIPTION 13008 READLINK reads the data associated with a symbolic link. The data is 13009 a UTF-8 string that is opaque to the server. That is, whether 13010 created by an NFS client or created locally on the server, the data 13011 in a symbolic link is not interpreted when created, but is simply 13012 stored. 13014 On success, the current filehandle retains its value. 13016 15.27.5. IMPLEMENTATION 13018 A symbolic link is nominally a pointer to another file. The data is 13019 not necessarily interpreted by the server, just stored in the file. 13020 It is possible for a client implementation to store a path name that 13021 is not meaningful to the server operating system in a symbolic link. 13022 A READLINK operation returns the data to the client for 13023 interpretation. If different implementations want to share access to 13024 symbolic links, then they must agree on the interpretation of the 13025 data in the symbolic link. 13027 The READLINK operation is only allowed on objects of type NF4LNK. 13028 The server should return the error, NFS4ERR_INVAL, if the object is 13029 not of type, NF4LNK. 13031 15.28. Operation 28: REMOVE - Remove Filesystem Object 13033 15.28.1. SYNOPSIS 13035 (cfh), filename -> change_info 13037 15.28.2. ARGUMENT 13039 struct REMOVE4args { 13040 /* CURRENT_FH: directory */ 13041 component4 target; 13042 }; 13044 15.28.3. RESULT 13046 struct REMOVE4resok { 13047 change_info4 cinfo; 13048 }; 13050 union REMOVE4res switch (nfsstat4 status) { 13051 case NFS4_OK: 13052 REMOVE4resok resok4; 13053 default: 13054 void; 13055 }; 13057 15.28.4. DESCRIPTION 13059 The REMOVE operation removes (deletes) a directory entry M named by 13060 filename from the directory corresponding to the current filehandle. 13061 If the entry in the directory was the last reference to the 13062 corresponding filesystem object, the object may be destroyed. 13064 For the directory where the filename was removed, the server returns 13065 change_info4 information in cinfo. With the atomic field of the 13066 change_info4 struct, the server will indicate if the before and after 13067 change attributes were obtained atomically with respect to the 13068 removal. 13070 If the target is of zero length, NFS4ERR_INVAL will be returned. The 13071 target is also subject to the normal UTF-8, character support, and 13072 name checks. See Section 12.3 for further discussion. 13074 On success, the current filehandle retains its value. 13076 15.28.5. IMPLEMENTATION 13078 NFSv3 required a different operator RMDIR for directory removal and 13079 REMOVE for non-directory removal. This allowed clients to skip 13080 checking the file type when being passed a non-directory delete 13081 system call (e.g., unlink() [40] in POSIX) to remove a directory, as 13082 well as the converse (e.g., a rmdir() on a non-directory) because 13083 they knew the server would check the file type. NFSv4 REMOVE can be 13084 used to delete any directory entry independent of its file type. The 13085 implementor of an NFSv4 client's entry points from the unlink() and 13086 rmdir() system calls should first check the file type against the 13087 types the system call is allowed to remove before issuing a REMOVE. 13088 Alternatively, the implementor can produce a COMPOUND call that 13089 includes a LOOKUP/VERIFY sequence to verify the file type before a 13090 REMOVE operation in the same COMPOUND call. 13092 The concept of last reference is server specific. However, if the 13093 numlinks field in the previous attributes of the object had the value 13094 1, the client should not rely on referring to the object via a 13095 filehandle. Likewise, the client should not rely on the resources 13096 (disk space, directory entry, and so on) formerly associated with the 13097 object becoming immediately available. Thus, if a client needs to be 13098 able to continue to access a file after using REMOVE to remove it, 13099 the client should take steps to make sure that the file will still be 13100 accessible. The usual mechanism used is to RENAME the file from its 13101 old name to a new hidden name. 13103 If the server finds that the file is still open when the REMOVE 13104 arrives: 13106 o The server SHOULD NOT delete the file's directory entry if the 13107 file was opened with OPEN4_SHARE_DENY_WRITE or 13108 OPEN4_SHARE_DENY_BOTH. 13110 o If the file was not opened with OPEN4_SHARE_DENY_WRITE or 13111 OPEN4_SHARE_DENY_BOTH, the server SHOULD delete the file's 13112 directory entry. However, until last CLOSE of the file, the 13113 server MAY continue to allow access to the file via its 13114 filehandle. 13116 15.29. Operation 29: RENAME - Rename Directory Entry 13118 15.29.1. SYNOPSIS 13120 (sfh), oldname, (cfh), newname -> source_change_info, 13121 target_change_info 13123 15.29.2. ARGUMENT 13125 struct RENAME4args { 13126 /* SAVED_FH: source directory */ 13127 component4 oldname; 13128 /* CURRENT_FH: target directory */ 13129 component4 newname; 13130 }; 13132 15.29.3. RESULT 13134 struct RENAME4resok { 13135 change_info4 source_cinfo; 13136 change_info4 target_cinfo; 13137 }; 13139 union RENAME4res switch (nfsstat4 status) { 13140 case NFS4_OK: 13141 RENAME4resok resok4; 13142 default: 13143 void; 13144 }; 13146 15.29.4. DESCRIPTION 13148 The RENAME operation renames the object identified by oldname in the 13149 source directory corresponding to the saved filehandle, as set by the 13150 SAVEFH operation, to newname in the target directory corresponding to 13151 the current filehandle. The operation is required to be atomic to 13152 the client. Source and target directories must reside on the same 13153 filesystem on the server. On success, the current filehandle will 13154 continue to be the target directory. 13156 If the target directory already contains an entry with the name, 13157 newname, the source object must be compatible with the target: either 13158 both are non-directories or both are directories and the target must 13159 be empty. If compatible, the existing target is removed before the 13160 rename occurs (See Section 15.28 for client and server actions 13161 whenever a target is removed). If they are not compatible or if the 13162 target is a directory but not empty, the server will return the 13163 error, NFS4ERR_EXIST. 13165 If oldname and newname both refer to the same file (they might be 13166 hard links of each other), then RENAME should perform no action and 13167 return success. 13169 For both directories involved in the RENAME, the server returns 13170 change_info4 information. With the atomic field of the change_info4 13171 struct, the server will indicate if the before and after change 13172 attributes were obtained atomically with respect to the rename. 13174 If the oldname refers to a named attribute and the saved and current 13175 filehandles refer to different filesystem objects, the server will 13176 return NFS4ERR_XDEV just as if the saved and current filehandles 13177 represented directories on different filesystems. 13179 If the oldname or newname is of zero length, NFS4ERR_INVAL will be 13180 returned. The oldname and newname are also subject to the normal 13181 UTF-8, character support, and name checks. See Section 12.3 for 13182 further discussion. 13184 15.29.5. IMPLEMENTATION 13186 The RENAME operation must be atomic to the client. The statement 13187 "source and target directories must reside on the same filesystem on 13188 the server" means that the fsid fields in the attributes for the 13189 directories are the same. If they reside on different filesystems, 13190 the error, NFS4ERR_XDEV, is returned. 13192 Based on the value of the fh_expire_type attribute for the object, 13193 the filehandle may or may not expire on a RENAME. However, server 13194 implementors are strongly encouraged to attempt to keep filehandles 13195 from expiring in this fashion. 13197 On some servers, the file names "." and ".." are illegal as either 13198 oldname or newname, and will result in the error NFS4ERR_BADNAME. In 13199 addition, on many servers the case of oldname or newname being an 13200 alias for the source directory will be checked for. Such servers 13201 will return the error NFS4ERR_INVAL in these cases. 13203 If either of the source or target filehandles are not directories, 13204 the server will return NFS4ERR_NOTDIR. 13206 15.30. Operation 30: RENEW - Renew a Lease 13208 15.30.1. SYNOPSIS 13210 clientid -> () 13212 15.30.2. ARGUMENT 13214 struct RENEW4args { 13215 clientid4 clientid; 13216 }; 13218 15.30.3. RESULT 13220 struct RENEW4res { 13221 nfsstat4 status; 13222 }; 13224 15.30.4. DESCRIPTION 13226 The RENEW operation is used by the client to renew leases which it 13227 currently holds at a server. In processing the RENEW request, the 13228 server renews all leases associated with the client. The associated 13229 leases are determined by the clientid provided via the SETCLIENTID 13230 operation. 13232 15.30.5. IMPLEMENTATION 13234 When the client holds delegations, it needs to use RENEW to detect 13235 when the server has determined that the callback path is down. When 13236 the server has made such a determination, only the RENEW operation 13237 will renew the lease on delegations. If the server determines the 13238 callback path is down, it returns NFS4ERR_CB_PATH_DOWN. Even though 13239 it returns NFS4ERR_CB_PATH_DOWN, the server MUST renew the lease on 13240 the byte-range locks and share reservations that the client has 13241 established on the server. If for some reason the lock and share 13242 reservation lease cannot be renewed, then the server MUST return an 13243 error other than NFS4ERR_CB_PATH_DOWN, even if the callback path is 13244 also down. In the event that the server has conditions such that is 13245 could return either NFS4ERR_CB_PATH_DOWN or NFS4ERR_LEASE_MOVED, 13246 NFS4ERR_LEASE_MOVED MUST be handled first. 13248 The client that issues RENEW MUST choose the principal, RPC security 13249 flavor, and if applicable, GSS-API mechanism and service via one of 13250 the following algorithms: 13252 o The client uses the same principal, RPC security flavor -- and if 13253 the flavor was RPCSEC_GSS -- the same mechanism and service that 13254 was used when the client id was established via 13255 SETCLIENTID_CONFIRM. 13257 o The client uses any principal, RPC security flavor mechanism and 13258 service combination that currently has an OPEN file on the server. 13259 I.e., the same principal had a successful OPEN operation, the file 13260 is still open by that principal, and the flavor, mechanism, and 13261 service of RENEW match that of the previous OPEN. 13263 The server MUST reject a RENEW that does not use one the 13264 aforementioned algorithms, with the error NFS4ERR_ACCESS. 13266 15.31. Operation 31: RESTOREFH - Restore Saved Filehandle 13268 15.31.1. SYNOPSIS 13270 (sfh) -> (cfh) 13272 15.31.2. ARGUMENT 13274 /* SAVED_FH: */ 13275 void; 13277 15.31.3. RESULT 13279 struct RESTOREFH4res { 13280 /* CURRENT_FH: value of saved fh */ 13281 nfsstat4 status; 13282 }; 13284 15.31.4. DESCRIPTION 13286 Set the current filehandle to the value in the saved filehandle. If 13287 there is no saved filehandle then return the error NFS4ERR_RESTOREFH. 13289 15.31.5. IMPLEMENTATION 13291 Operations like OPEN and LOOKUP use the current filehandle to 13292 represent a directory and replace it with a new filehandle. Assuming 13293 the previous filehandle was saved with a SAVEFH operator, the 13294 previous filehandle can be restored as the current filehandle. This 13295 is commonly used to obtain post-operation attributes for the 13296 directory, e.g., 13297 PUTFH (directory filehandle) 13298 SAVEFH 13299 GETATTR attrbits (pre-op dir attrs) 13300 CREATE optbits "foo" attrs 13301 GETATTR attrbits (file attributes) 13302 RESTOREFH 13303 GETATTR attrbits (post-op dir attrs) 13305 15.32. Operation 32: SAVEFH - Save Current Filehandle 13307 15.32.1. SYNOPSIS 13309 (cfh) -> (sfh) 13311 15.32.2. ARGUMENT 13313 /* CURRENT_FH: */ 13314 void; 13316 15.32.3. RESULT 13318 struct SAVEFH4res { 13319 /* SAVED_FH: value of current fh */ 13320 nfsstat4 status; 13321 }; 13323 15.32.4. DESCRIPTION 13325 Save the current filehandle. If a previous filehandle was saved then 13326 it is no longer accessible. The saved filehandle can be restored as 13327 the current filehandle with the RESTOREFH operator. 13329 On success, the current filehandle retains its value. 13331 15.32.5. IMPLEMENTATION 13333 15.33. Operation 33: SECINFO - Obtain Available Security 13335 15.33.1. SYNOPSIS 13337 (cfh), name -> { secinfo } 13339 15.33.2. ARGUMENT 13341 struct SECINFO4args { 13342 /* CURRENT_FH: directory */ 13343 component4 name; 13344 }; 13346 15.33.3. RESULT 13348 /* 13349 * From RFC 2203 13350 */ 13351 enum rpc_gss_svc_t { 13352 RPC_GSS_SVC_NONE = 1, 13353 RPC_GSS_SVC_INTEGRITY = 2, 13354 RPC_GSS_SVC_PRIVACY = 3 13355 }; 13357 struct rpcsec_gss_info { 13358 sec_oid4 oid; 13359 qop4 qop; 13360 rpc_gss_svc_t service; 13361 }; 13363 /* RPCSEC_GSS has a value of '6' - See RFC 2203 */ 13364 union secinfo4 switch (uint32_t flavor) { 13365 case RPCSEC_GSS: 13366 rpcsec_gss_info flavor_info; 13367 default: 13368 void; 13369 }; 13371 typedef secinfo4 SECINFO4resok<>; 13373 union SECINFO4res switch (nfsstat4 status) { 13374 case NFS4_OK: 13375 SECINFO4resok resok4; 13376 default: 13377 void; 13378 }; 13380 15.33.4. DESCRIPTION 13382 The SECINFO operation is used by the client to obtain a list of valid 13383 RPC authentication flavors for a specific directory filehandle, file 13384 name pair. SECINFO should apply the same access methodology used for 13385 LOOKUP when evaluating the name. Therefore, if the requester does 13386 not have the appropriate access to LOOKUP the name then SECINFO must 13387 behave the same way and return NFS4ERR_ACCESS. 13389 The result will contain an array which represents the security 13390 mechanisms available, with an order corresponding to server's 13391 preferences, the most preferred being first in the array. The client 13392 is free to pick whatever security mechanism it both desires and 13393 supports, or to pick in the server's preference order the first one 13394 it supports. The array entries are represented by the secinfo4 13395 structure. The field 'flavor' will contain a value of AUTH_NONE, 13396 AUTH_SYS (as defined in [3]), or RPCSEC_GSS (as defined in [4]). 13398 For the flavors AUTH_NONE and AUTH_SYS, no additional security 13399 information is returned. For a return value of RPCSEC_GSS, a 13400 security triple is returned that contains the mechanism object id (as 13401 defined in [6]), the quality of protection (as defined in [6]) and 13402 the service type (as defined in [4]). It is possible for SECINFO to 13403 return multiple entries with flavor equal to RPCSEC_GSS with 13404 different security triple values. 13406 On success, the current filehandle retains its value. 13408 If the name has a length of 0 (zero), or if name does not obey the 13409 UTF-8 definition, the error NFS4ERR_INVAL will be returned. 13411 15.33.5. IMPLEMENTATION 13413 The SECINFO operation is expected to be used by the NFS client when 13414 the error value of NFS4ERR_WRONGSEC is returned from another NFS 13415 operation. This signifies to the client that the server's security 13416 policy is different from what the client is currently using. At this 13417 point, the client is expected to obtain a list of possible security 13418 flavors and choose what best suits its policies. 13420 As mentioned, the server's security policies will determine when a 13421 client request receives NFS4ERR_WRONGSEC. The operations which may 13422 receive this error are: LINK, LOOKUP, LOOKUPP, OPEN, PUTFH, PUTPUBFH, 13423 PUTROOTFH, RENAME, RESTOREFH, and indirectly READDIR. LINK and 13424 RENAME will only receive this error if the security used for the 13425 operation is inappropriate for saved filehandle. With the exception 13426 of READDIR, these operations represent the point at which the client 13427 can instantiate a filehandle into the "current filehandle" at the 13428 server. The filehandle is either provided by the client (PUTFH, 13429 PUTPUBFH, PUTROOTFH) or generated as a result of a name to filehandle 13430 translation (LOOKUP and OPEN). RESTOREFH is different because the 13431 filehandle is a result of a previous SAVEFH. Even though the 13432 filehandle, for RESTOREFH, might have previously passed the server's 13433 inspection for a security match, the server will check it again on 13434 RESTOREFH to ensure that the security policy has not changed. 13436 If the client wants to resolve an error return of NFS4ERR_WRONGSEC, 13437 the following will occur: 13439 o For LOOKUP and OPEN, the client will use SECINFO with the same 13440 current filehandle and name as provided in the original LOOKUP or 13441 OPEN to enumerate the available security triples. 13443 o For LINK, PUTFH, RENAME, and RESTOREFH, the client will use 13444 SECINFO and provide the parent directory filehandle and object 13445 name which corresponds to the filehandle originally provided by 13446 the PUTFH RESTOREFH, or for LINK and RENAME, the SAVEFH. 13448 o For LOOKUPP, PUTROOTFH and PUTPUBFH, the client will be unable to 13449 use the SECINFO operation since SECINFO requires a current 13450 filehandle and none exist for these two operations. Therefore, 13451 the client must iterate through the security triples available at 13452 the client and reattempt the PUTROOTFH or PUTPUBFH operation. In 13453 the unfortunate event none of the MANDATORY security triples are 13454 supported by the client and server, the client SHOULD try using 13455 others that support integrity. Failing that, the client can try 13456 using AUTH_NONE, but because such forms lack integrity checks, 13457 this puts the client at risk. Nonetheless, the server SHOULD 13458 allow the client to use whatever security form the client requests 13459 and the server supports, since the risks of doing so are on the 13460 client. 13462 The READDIR operation will not directly return the NFS4ERR_WRONGSEC 13463 error. However, if the READDIR request included a request for 13464 attributes, it is possible that the READDIR request's security triple 13465 does not match that of a directory entry. If this is the case and 13466 the client has requested the rdattr_error attribute, the server will 13467 return the NFS4ERR_WRONGSEC error in rdattr_error for the entry. 13469 See Section 17 for a discussion on the recommendations for security 13470 flavor used by SECINFO. 13472 15.34. Operation 34: SETATTR - Set Attributes 13474 15.34.1. SYNOPSIS 13476 (cfh), stateid, attrmask, attr_vals -> attrsset 13478 15.34.2. ARGUMENT 13480 struct SETATTR4args { 13481 /* CURRENT_FH: target object */ 13482 stateid4 stateid; 13483 fattr4 obj_attributes; 13484 }; 13486 15.34.3. RESULT 13488 struct SETATTR4res { 13489 nfsstat4 status; 13490 bitmap4 attrsset; 13491 }; 13493 15.34.4. DESCRIPTION 13495 The SETATTR operation changes one or more of the attributes of a 13496 filesystem object. The new attributes are specified with a bitmap 13497 and the attributes that follow the bitmap in bit order. 13499 The stateid argument for SETATTR is used to provide byte-range 13500 locking context that is necessary for SETATTR requests that set the 13501 size attribute. Since setting the size attribute modifies the file's 13502 data, it has the same locking requirements as a corresponding WRITE. 13503 Any SETATTR that sets the size attribute is incompatible with a share 13504 reservation that specifies OPEN4_SHARE_DENY_WRITE. The area between 13505 the old end-of-file and the new end-of-file is considered to be 13506 modified just as would have been the case had the area in question 13507 been specified as the target of WRITE, for the purpose of checking 13508 conflicts with byte-range locks, for those cases in which a server is 13509 implementing mandatory byte-range locking behavior. A valid stateid 13510 SHOULD always be specified. When the file size attribute is not set, 13511 the special stateid consisting of all bits zero MAY be passed. 13513 On either success or failure of the operation, the server will return 13514 the attrsset bitmask to represent what (if any) attributes were 13515 successfully set. The attrsset in the response is a subset of the 13516 bitmap4 that is part of the obj_attributes in the argument. 13518 On success, the current filehandle retains its value. 13520 15.34.5. IMPLEMENTATION 13522 If the request specifies the owner attribute to be set, the server 13523 SHOULD allow the operation to succeed if the current owner of the 13524 object matches the value specified in the request. Some servers may 13525 be implemented in a way as to prohibit the setting of the owner 13526 attribute unless the requester has privilege to do so. If the server 13527 is lenient in this one case of matching owner values, the client 13528 implementation may be simplified in cases of creation of an object 13529 (e.g., an exclusive create via OPEN) followed by a SETATTR. 13531 The file size attribute is used to request changes to the size of a 13532 file. A value of zero causes the file to be truncated, a value less 13533 than the current size of the file causes data from new size to the 13534 end of the file to be discarded, and a size greater than the current 13535 size of the file causes logically zeroed data bytes to be added to 13536 the end of the file. Servers are free to implement this using holes 13537 or actual zero data bytes. Clients should not make any assumptions 13538 regarding a server's implementation of this feature, beyond that the 13539 bytes returned will be zeroed. Servers MUST support extending the 13540 file size via SETATTR. 13542 SETATTR is not guaranteed atomic. A failed SETATTR may partially 13543 change a file's attributes, hence the reason why the reply always 13544 includes the status and the list of attributes that were set. 13546 If the object whose attributes are being changed has a file 13547 delegation that is held by a client other than the one doing the 13548 SETATTR, the delegation(s) must be recalled, and the operation cannot 13549 proceed to actually change an attribute until each such delegation is 13550 returned or revoked. In all cases in which delegations are recalled, 13551 the server is likely to return one or more NFS4ERR_DELAY errors while 13552 the delegation(s) remains outstanding, although it might not do that 13553 if the delegations are returned quickly. 13555 Changing the size of a file with SETATTR indirectly changes the 13556 time_modify and change attributes. A client must account for this as 13557 size changes can result in data deletion. 13559 The attributes time_access_set and time_modify_set are write-only 13560 attributes constructed as a switched union so the client can direct 13561 the server in setting the time values. If the switched union 13562 specifies SET_TO_CLIENT_TIME4, the client has provided an nfstime4 to 13563 be used for the operation. If the switch union does not specify 13564 SET_TO_CLIENT_TIME4, the server is to use its current time for the 13565 SETATTR operation. 13567 If server and client times differ, programs that compare client time 13568 to file times can break. A time maintenance protocol should be used 13569 to limit client/server time skew. 13571 Use of a COMPOUND containing a VERIFY operation specifying only the 13572 change attribute, immediately followed by a SETATTR, provides a means 13573 whereby a client may specify a request that emulates the 13574 functionality of the SETATTR guard mechanism of NFSv3. Since the 13575 function of the guard mechanism is to avoid changes to the file 13576 attributes based on stale information, delays between checking of the 13577 guard condition and the setting of the attributes have the potential 13578 to compromise this function, as would the corresponding delay in the 13579 NFSv4 emulation. Therefore, NFSv4 servers should take care to avoid 13580 such delays, to the degree possible, when executing such a request. 13582 If the server does not support an attribute as requested by the 13583 client, the server should return NFS4ERR_ATTRNOTSUPP. 13585 A mask of the attributes actually set is returned by SETATTR in all 13586 cases. That mask MUST NOT include attribute bits not requested to be 13587 set by the client. If the attribute masks in the request and reply 13588 are equal, the status field in the reply MUST be NFS4_OK. 13590 15.35. Operation 35: SETCLIENTID - Negotiate Client ID 13592 15.35.1. SYNOPSIS 13594 client, callback, callback_ident -> clientid, setclientid_confirm 13596 15.35.2. ARGUMENT 13598 struct SETCLIENTID4args { 13599 nfs_client_id4 client; 13600 cb_client4 callback; 13601 uint32_t callback_ident; 13602 }; 13604 15.35.3. RESULT 13606 struct SETCLIENTID4resok { 13607 clientid4 clientid; 13608 verifier4 setclientid_confirm; 13609 }; 13611 union SETCLIENTID4res switch (nfsstat4 status) { 13612 case NFS4_OK: 13613 SETCLIENTID4resok resok4; 13614 case NFS4ERR_CLID_INUSE: 13615 clientaddr4 client_using; 13616 default: 13617 void; 13618 }; 13620 15.35.4. DESCRIPTION 13622 The client uses the SETCLIENTID operation to notify the server of its 13623 intention to use a particular client identifier, callback, and 13624 callback_ident for subsequent requests that entail creating lock, 13625 share reservation, and delegation state on the server. Upon 13626 successful completion the server will return a shorthand client ID 13627 which, if confirmed via a separate step, will be used in subsequent 13628 file locking and file open requests. Confirmation of the client ID 13629 must be done via the SETCLIENTID_CONFIRM operation to return the 13630 client ID and setclientid_confirm values, as verifiers, to the 13631 server. The reason why two verifiers are necessary is that it is 13632 possible to use SETCLIENTID and SETCLIENTID_CONFIRM to modify the 13633 callback and callback_ident information but not the shorthand client 13634 ID. In that event, the setclientid_confirm value is effectively the 13635 only verifier. 13637 The callback information provided in this operation will be used if 13638 the client is provided an open delegation at a future point. 13639 Therefore, the client must correctly reflect the program and port 13640 numbers for the callback program at the time SETCLIENTID is used. 13642 The callback_ident value is used by the server on the callback. The 13643 client can leverage the callback_ident to eliminate the need for more 13644 than one callback RPC program number, while still being able to 13645 determine which server is initiating the callback. 13647 15.35.5. IMPLEMENTATION 13649 To understand how to implement SETCLIENTID, make the following 13650 notations. Let: 13652 x be the value of the client.id subfield of the SETCLIENTID4args 13653 structure. 13655 v be the value of the client.verifier subfield of the 13656 SETCLIENTID4args structure. 13658 c be the value of the client ID field returned in the 13659 SETCLIENTID4resok structure. 13661 k represent the value combination of the fields callback and 13662 callback_ident fields of the SETCLIENTID4args structure. 13664 s be the setclientid_confirm value returned in the SETCLIENTID4resok 13665 structure. 13667 { v, x, c, k, s } be a quintuple for a client record. A client 13668 record is confirmed if there has been a SETCLIENTID_CONFIRM 13669 operation to confirm it. Otherwise it is unconfirmed. An 13670 unconfirmed record is established by a SETCLIENTID call. 13672 Since SETCLIENTID is a non-idempotent operation, let us assume that 13673 the server is implementing the duplicate request cache (DRC). 13675 When the server gets a SETCLIENTID { v, x, k } request, it processes 13676 it in the following manner. 13678 o It first looks up the request in the DRC. If there is a hit, it 13679 returns the result cached in the DRC. The server does NOT remove 13680 client state (locks, shares, delegations) nor does it modify any 13681 recorded callback and callback_ident information for client { x }. 13683 For any DRC miss, the server takes the client id string x, and 13684 searches for client records for x that the server may have 13685 recorded from previous SETCLIENTID calls. For any confirmed 13686 record with the same id string x, if the recorded principal does 13687 not match that of SETCLIENTID call, then the server returns a 13688 NFS4ERR_CLID_INUSE error. 13690 For brevity of discussion, the remaining description of the 13691 processing assumes that there was a DRC miss, and that where the 13692 server has previously recorded a confirmed record for client x, 13693 the aforementioned principal check has successfully passed. 13695 o The server checks if it has recorded a confirmed record for { v, 13696 x, c, l, s }, where l may or may not equal k. If so, and since 13697 the id verifier v of the request matches that which is confirmed 13698 and recorded, the server treats this as a probable callback 13699 information update and records an unconfirmed { v, x, c, k, t } 13700 and leaves the confirmed { v, x, c, l, s } in place, such that t 13701 != s. It does not matter if k equals l or not. Any pre-existing 13702 unconfirmed { v, x, c, *, * } is removed. 13704 The server returns { c, t }. It is indeed returning the old 13705 clientid4 value c, because the client apparently only wants to 13706 update callback value k to value l. It's possible this request is 13707 one from the Byzantine router that has stale callback information, 13708 but this is not a problem. The callback information update is 13709 only confirmed if followed up by a SETCLIENTID_CONFIRM { c, t }. 13711 The server awaits confirmation of k via SETCLIENTID_CONFIRM { c, t 13712 }. 13714 The server does NOT remove client (lock/share/delegation) state 13715 for x. 13717 o The server has previously recorded a confirmed { u, x, c, l, s } 13718 record such that v != u, l may or may not equal k, and has not 13719 recorded any unconfirmed { *, x, *, *, * } record for x. The 13720 server records an unconfirmed { v, x, d, k, t } (d != c, t != s). 13722 The server returns { d, t }. 13724 The server awaits confirmation of { d, k } via SETCLIENTID_CONFIRM 13725 { d, t }. 13727 The server does NOT remove client (lock/share/delegation) state 13728 for x. 13730 o The server has previously recorded a confirmed { u, x, c, l, s } 13731 record such that v != u, l may or may not equal k, and recorded an 13732 unconfirmed { w, x, d, m, t } record such that c != d, t != s, m 13733 may or may not equal k, m may or may not equal l, and k may or may 13734 not equal l. Whether w == v or w != v makes no difference. The 13735 server simply removes the unconfirmed { w, x, d, m, t } record and 13736 replaces it with an unconfirmed { v, x, e, k, r } record, such 13737 that e != d, e != c, r != t, r != s. 13739 The server returns { e, r }. 13741 The server awaits confirmation of { e, k } via SETCLIENTID_CONFIRM 13742 { e, r }. 13744 The server does NOT remove client (lock/share/delegation) state 13745 for x. 13747 o The server has no confirmed { *, x, *, *, * } for x. It may or 13748 may not have recorded an unconfirmed { u, x, c, l, s }, where l 13749 may or may not equal k, and u may or may not equal v. Any 13750 unconfirmed record { u, x, c, l, * }, regardless whether u == v or 13751 l == k, is replaced with an unconfirmed record { v, x, d, k, t } 13752 where d != c, t != s. 13754 The server returns { d, t }. 13756 The server awaits confirmation of { d, k } via SETCLIENTID_CONFIRM 13757 { d, t }. The server does NOT remove client (lock/share/ 13758 delegation) state for x. 13760 The server generates the clientid and setclientid_confirm values and 13761 must take care to ensure that these values are extremely unlikely to 13762 ever be regenerated. 13764 15.36. Operation 36: SETCLIENTID_CONFIRM - Confirm Client ID 13766 15.36.1. SYNOPSIS 13768 clientid, verifier -> - 13770 15.36.2. ARGUMENT 13772 struct SETCLIENTID_CONFIRM4args { 13773 clientid4 clientid; 13774 verifier4 setclientid_confirm; 13775 }; 13777 15.36.3. RESULT 13779 struct SETCLIENTID_CONFIRM4res { 13780 nfsstat4 status; 13781 }; 13783 15.36.4. DESCRIPTION 13785 This operation is used by the client to confirm the results from a 13786 previous call to SETCLIENTID. The client provides the server 13787 supplied (from a SETCLIENTID response) client ID. The server 13788 responds with a simple status of success or failure. 13790 15.36.5. IMPLEMENTATION 13792 The client must use the SETCLIENTID_CONFIRM operation to confirm the 13793 following two distinct cases: 13795 o The client's use of a new shorthand client identifier (as returned 13796 from the server in the response to SETCLIENTID), a new callback 13797 value (as specified in the arguments to SETCLIENTID) and a new 13798 callback_ident (as specified in the arguments to SETCLIENTID) 13799 value. The client's use of SETCLIENTID_CONFIRM in this case also 13800 confirms the removal of any of the client's previous relevant 13801 leased state. Relevant leased client state includes byte-range 13802 locks, share reservations, and where the server does not support 13803 the CLAIM_DELEGATE_PREV claim type, delegations. If the server 13804 supports CLAIM_DELEGATE_PREV, then SETCLIENTID_CONFIRM MUST NOT 13805 remove delegations for this client; relevant leased client state 13806 would then just include byte-range locks and share reservations. 13808 o The client's re-use of an old, previously confirmed, shorthand 13809 client identifier, a new callback value, and a new callback_ident 13810 value. The client's use of SETCLIENTID_CONFIRM in this case MUST 13811 NOT result in the removal of any previous leased state (locks, 13812 share reservations, and delegations) 13814 We use the same notation and definitions for v, x, c, k, s, and 13815 unconfirmed and confirmed client records as introduced in the 13816 description of the SETCLIENTID operation. The arguments to 13817 SETCLIENTID_CONFIRM are indicated by the notation { c, s }, where c 13818 is a value of type clientid4, and s is a value of type verifier4 13819 corresponding to the setclientid_confirm field. 13821 As with SETCLIENTID, SETCLIENTID_CONFIRM is a non-idempotent 13822 operation, and we assume that the server is implementing the 13823 duplicate request cache (DRC). 13825 When the server gets a SETCLIENTID_CONFIRM { c, s } request, it 13826 processes it in the following manner. 13828 o It first looks up the request in the DRC. If there is a hit, it 13829 returns the result cached in the DRC. The server does not remove 13830 any relevant leased client state nor does it modify any recorded 13831 callback and callback_ident information for client { x } as 13832 represented by the shorthand value c. 13834 For a DRC miss, the server checks for client records that match the 13835 shorthand value c. The processing cases are as follows: 13837 o The server has recorded an unconfirmed { v, x, c, k, s } record 13838 and a confirmed { v, x, c, l, t } record, such that s != t. If 13839 the principals of the records do not match that of the 13840 SETCLIENTID_CONFIRM, the server returns NFS4ERR_CLID_INUSE, and no 13841 relevant leased client state is removed and no recorded callback 13842 and callback_ident information for client { x } is changed. 13843 Otherwise, the confirmed { v, x, c, l, t } record is removed and 13844 the unconfirmed { v, x, c, k, s } is marked as confirmed, thereby 13845 modifying recorded and confirmed callback and callback_ident 13846 information for client { x }. 13848 The server does not remove any relevant leased client state. 13850 The server returns NFS4_OK. 13852 o The server has not recorded an unconfirmed { v, x, c, *, * } and 13853 has recorded a confirmed { v, x, c, *, s }. If the principals of 13854 the record and of SETCLIENTID_CONFIRM do not match, the server 13855 returns NFS4ERR_CLID_INUSE without removing any relevant leased 13856 client state and without changing recorded callback and 13857 callback_ident values for client { x }. 13859 If the principals match, then what has likely happened is that the 13860 client never got the response from the SETCLIENTID_CONFIRM, and 13861 the DRC entry has been purged. Whatever the scenario, since the 13862 principals match, as well as { c, s } matching a confirmed record, 13863 the server leaves client x's relevant leased client state intact, 13864 leaves its callback and callback_ident values unmodified, and 13865 returns NFS4_OK. 13867 o The server has not recorded a confirmed { *, *, c, *, * }, and has 13868 recorded an unconfirmed { *, x, c, k, s }. Even if this is a 13869 retry from client, nonetheless the client's first 13870 SETCLIENTID_CONFIRM attempt was not received by the server. Retry 13871 or not, the server doesn't know, but it processes it as if were a 13872 first try. If the principal of the unconfirmed { *, x, c, k, s } 13873 record mismatches that of the SETCLIENTID_CONFIRM request the 13874 server returns NFS4ERR_CLID_INUSE without removing any relevant 13875 leased client state. 13877 Otherwise, the server records a confirmed { *, x, c, k, s }. If 13878 there is also a confirmed { *, x, d, *, t }, the server MUST 13879 remove the client x's relevant leased client state, and overwrite 13880 the callback state with k. The confirmed record { *, x, d, *, t } 13881 is removed. 13883 Server returns NFS4_OK. 13885 o The server has no record of a confirmed or unconfirmed { *, *, c, 13886 *, s }. The server returns NFS4ERR_STALE_CLIENTID. The server 13887 does not remove any relevant leased client state, nor does it 13888 modify any recorded callback and callback_ident information for 13889 any client. 13891 The server needs to cache unconfirmed { v, x, c, k, s } client 13892 records and await for some time their confirmation. As should be 13893 clear from the record processing discussions for SETCLIENTID and 13894 SETCLIENTID_CONFIRM, there are cases where the server does not 13895 deterministically remove unconfirmed client records. To avoid 13896 running out of resources, the server is not required to hold 13897 unconfirmed records indefinitely. One strategy the server might use 13898 is to set a limit on how many unconfirmed client records it will 13899 maintain, and then when the limit would be exceeded, remove the 13900 oldest record. Another strategy might be to remove an unconfirmed 13901 record when some amount of time has elapsed. The choice of the 13902 amount of time is fairly arbitrary but it is surely no higher than 13903 the server's lease time period. Consider that leases need to be 13904 renewed before the lease time expires via an operation from the 13905 client. If the client cannot issue a SETCLIENTID_CONFIRM after a 13906 SETCLIENTID before a period of time equal to that of a lease expires, 13907 then the client is unlikely to be able maintain state on the server 13908 during steady state operation. 13910 If the client does send a SETCLIENTID_CONFIRM for an unconfirmed 13911 record that the server has already deleted, the client will get 13912 NFS4ERR_STALE_CLIENTID back. If so, the client should then start 13913 over, and send SETCLIENTID to reestablish an unconfirmed client 13914 record and get back an unconfirmed client ID and setclientid_confirm 13915 verifier. The client should then send the SETCLIENTID_CONFIRM to 13916 confirm the client ID. 13918 SETCLIENTID_CONFIRM does not establish or renew a lease. However, if 13919 SETCLIENTID_CONFIRM removes relevant leased client state, and that 13920 state does not include existing delegations, the server MUST allow 13921 the client a period of time no less than the value of lease_time 13922 attribute, to reclaim, (via the CLAIM_DELEGATE_PREV claim type of the 13923 OPEN operation) its delegations before removing unreclaimed 13924 delegations. 13926 15.37. Operation 37: VERIFY - Verify Same Attributes 13928 15.37.1. SYNOPSIS 13930 (cfh), fattr -> - 13932 15.37.2. ARGUMENT 13934 struct VERIFY4args { 13935 /* CURRENT_FH: object */ 13936 fattr4 obj_attributes; 13937 }; 13939 15.37.3. RESULT 13941 struct VERIFY4res { 13942 nfsstat4 status; 13943 }; 13945 15.37.4. DESCRIPTION 13947 The VERIFY operation is used to verify that attributes have a value 13948 assumed by the client before proceeding with following operations in 13949 the compound request. If any of the attributes do not match then the 13950 error NFS4ERR_NOT_SAME must be returned. The current filehandle 13951 retains its value after successful completion of the operation. 13953 15.37.5. IMPLEMENTATION 13955 One possible use of the VERIFY operation is the following compound 13956 sequence. With this the client is attempting to verify that the file 13957 being removed will match what the client expects to be removed. This 13958 sequence can help prevent the unintended deletion of a file. 13960 PUTFH (directory filehandle) 13961 LOOKUP (file name) 13962 VERIFY (filehandle == fh) 13963 PUTFH (directory filehandle) 13964 REMOVE (file name) 13966 This sequence does not prevent a second client from removing and 13967 creating a new file in the middle of this sequence but it does help 13968 avoid the unintended result. 13970 In the case that a recommended attribute is specified in the VERIFY 13971 operation and the server does not support that attribute for the 13972 filesystem object, the error NFS4ERR_ATTRNOTSUPP is returned to the 13973 client. 13975 When the attribute rdattr_error or any write-only attribute (e.g., 13976 time_modify_set) is specified, the error NFS4ERR_INVAL is returned to 13977 the client. 13979 15.38. Operation 38: WRITE - Write to File 13981 15.38.1. SYNOPSIS 13983 (cfh), stateid, offset, stable, data -> count, committed, writeverf 13985 15.38.2. ARGUMENT 13987 enum stable_how4 { 13988 UNSTABLE4 = 0, 13989 DATA_SYNC4 = 1, 13990 FILE_SYNC4 = 2 13991 }; 13993 struct WRITE4args { 13994 /* CURRENT_FH: file */ 13995 stateid4 stateid; 13996 offset4 offset; 13997 stable_how4 stable; 13998 opaque data<>; 13999 }; 14001 15.38.3. RESULT 14003 struct WRITE4resok { 14004 count4 count; 14005 stable_how4 committed; 14006 verifier4 writeverf; 14007 }; 14009 union WRITE4res switch (nfsstat4 status) { 14010 case NFS4_OK: 14011 WRITE4resok resok4; 14012 default: 14013 void; 14014 }; 14016 15.38.4. DESCRIPTION 14018 The WRITE operation is used to write data to a regular file. The 14019 target file is specified by the current filehandle. The offset 14020 specifies the offset where the data should be written. An offset of 14021 0 (zero) specifies that the write should start at the beginning of 14022 the file. The count, as encoded as part of the opaque data 14023 parameter, represents the number of bytes of data that are to be 14024 written. If the count is 0 (zero), the WRITE will succeed and return 14025 a count of 0 (zero) subject to permissions checking. The server may 14026 choose to write fewer bytes than requested by the client. 14028 Part of the write request is a specification of how the write is to 14029 be performed. The client specifies with the stable parameter the 14030 method of how the data is to be processed by the server. If stable 14031 is FILE_SYNC4, the server must commit the data written plus all 14032 filesystem metadata to stable storage before returning results. This 14033 corresponds to the NFS version 2 protocol semantics. Any other 14034 behavior constitutes a protocol violation. If stable is DATA_SYNC4, 14035 then the server must commit all of the data to stable storage and 14036 enough of the metadata to retrieve the data before returning. The 14037 server implementor is free to implement DATA_SYNC4 in the same 14038 fashion as FILE_SYNC4, but with a possible performance drop. If 14039 stable is UNSTABLE4, the server is free to commit any part of the 14040 data and the metadata to stable storage, including all or none, 14041 before returning a reply to the client. There is no guarantee 14042 whether or when any uncommitted data will subsequently be committed 14043 to stable storage. The only guarantees made by the server are that 14044 it will not destroy any data without changing the value of verf and 14045 that it will not commit the data and metadata at a level less than 14046 that requested by the client. 14048 The stateid value for a WRITE request represents a value returned 14049 from a previous byte-range lock or share reservation request or the 14050 stateid associated with a delegation. The stateid is used by the 14051 server to verify that the associated share reservation and any byte- 14052 range locks are still valid and to update lease timeouts for the 14053 client. 14055 Upon successful completion, the following results are returned. The 14056 count result is the number of bytes of data written to the file. The 14057 server may write fewer bytes than requested. If so, the actual 14058 number of bytes written starting at location, offset, is returned. 14060 The server also returns an indication of the level of commitment of 14061 the data and metadata via committed. If the server committed all 14062 data and metadata to stable storage, committed should be set to 14063 FILE_SYNC4. If the level of commitment was at least as strong as 14064 DATA_SYNC4, then committed should be set to DATA_SYNC4. Otherwise, 14065 committed must be returned as UNSTABLE4. If stable was FILE4_SYNC, 14066 then committed must also be FILE_SYNC4: anything else constitutes a 14067 protocol violation. If stable was DATA_SYNC4, then committed may be 14068 FILE_SYNC4 or DATA_SYNC4: anything else constitutes a protocol 14069 violation. If stable was UNSTABLE4, then committed may be either 14070 FILE_SYNC4, DATA_SYNC4, or UNSTABLE4. 14072 The final portion of the result is the write verifier. The write 14073 verifier is a cookie that the client can use to determine whether the 14074 server has changed instance (boot) state between a call to WRITE and 14075 a subsequent call to either WRITE or COMMIT. This cookie must be 14076 consistent during a single instance of the NFSv4 protocol service and 14077 must be unique between instances of the NFSv4 protocol server, where 14078 uncommitted data may be lost. 14080 If a client writes data to the server with the stable argument set to 14081 UNSTABLE4 and the reply yields a committed response of DATA_SYNC4 or 14082 UNSTABLE4, the client will follow up some time in the future with a 14083 COMMIT operation to synchronize outstanding asynchronous data and 14084 metadata with the server's stable storage, barring client error. It 14085 is possible that due to client crash or other error that a subsequent 14086 COMMIT will not be received by the server. 14088 For a WRITE with a stateid value of all bits 0, the server MAY allow 14089 the WRITE to be serviced subject to mandatory file locks or the 14090 current share deny modes for the file. For a WRITE with a stateid 14091 value of all bits 1, the server MUST NOT allow the WRITE operation to 14092 bypass locking checks at the server and are treated exactly the same 14093 as if a stateid of all bits 0 were used. 14095 On success, the current filehandle retains its value. 14097 15.38.5. IMPLEMENTATION 14099 It is possible for the server to write fewer bytes of data than 14100 requested by the client. In this case, the server should not return 14101 an error unless no data was written at all. If the server writes 14102 less than the number of bytes specified, the client should issue 14103 another WRITE to write the remaining data. 14105 It is assumed that the act of writing data to a file will cause the 14106 time_modified of the file to be updated. However, the time_modified 14107 of the file should not be changed unless the contents of the file are 14108 changed. Thus, a WRITE request with count set to 0 should not cause 14109 the time_modified of the file to be updated. 14111 The definition of stable storage has been historically a point of 14112 contention. The following expected properties of stable storage may 14113 help in resolving design issues in the implementation. Stable 14114 storage is persistent storage that survives: 14116 1. Repeated power failures. 14118 2. Hardware failures (of any board, power supply, etc.). 14120 3. Repeated software crashes, including reboot cycle. 14122 This definition does not address failure of the stable storage module 14123 itself. 14125 The verifier is defined to allow a client to detect different 14126 instances of an NFSv4 protocol server over which cached, uncommitted 14127 data may be lost. In the most likely case, the verifier allows the 14128 client to detect server reboots. This information is required so 14129 that the client can safely determine whether the server could have 14130 lost cached data. If the server fails unexpectedly and the client 14131 has uncommitted data from previous WRITE requests (done with the 14132 stable argument set to UNSTABLE4 and in which the result committed 14133 was returned as UNSTABLE4 as well) it may not have flushed cached 14134 data to stable storage. The burden of recovery is on the client and 14135 the client will need to retransmit the data to the server. 14137 A suggested verifier would be to use the time that the server was 14138 booted or the time the server was last started (if restarting the 14139 server without a reboot results in lost buffers). 14141 The committed field in the results allows the client to do more 14142 effective caching. If the server is committing all WRITE requests to 14143 stable storage, then it should return with committed set to 14144 FILE_SYNC4, regardless of the value of the stable field in the 14145 arguments. A server that uses an NVRAM accelerator may choose to 14146 implement this policy. The client can use this to increase the 14147 effectiveness of the cache by discarding cached data that has already 14148 been committed on the server. 14150 Some implementations may return NFS4ERR_NOSPC instead of 14151 NFS4ERR_DQUOT when a user's quota is exceeded. In the case that the 14152 current filehandle is a directory, the server will return 14153 NFS4ERR_ISDIR. If the current filehandle is not a regular file or a 14154 directory, the server will return NFS4ERR_INVAL. 14156 If mandatory file locking is on for the file, and corresponding 14157 record of the data to be written file is read or write locked by an 14158 owner that is not associated with the stateid, the server will return 14159 NFS4ERR_LOCKED. If so, the client must check if the owner 14160 corresponding to the stateid used with the WRITE operation has a 14161 conflicting read lock that overlaps with the region that was to be 14162 written. If the stateid's owner has no conflicting read lock, then 14163 the client should try to get the appropriate write byte-range lock 14164 via the LOCK operation before re-attempting the WRITE. When the 14165 WRITE completes, the client should release the byte-range lock via 14166 LOCKU. 14168 If the stateid's owner had a conflicting read lock, then the client 14169 has no choice but to return an error to the application that 14170 attempted the WRITE. The reason is that since the stateid's owner 14171 had a read lock, the server either attempted to temporarily 14172 effectively upgrade this read lock to a write lock, or the server has 14173 no upgrade capability. If the server attempted to upgrade the read 14174 lock and failed, it is pointless for the client to re-attempt the 14175 upgrade via the LOCK operation, because there might be another client 14176 also trying to upgrade. If two clients are blocked trying upgrade 14177 the same lock, the clients deadlock. If the server has no upgrade 14178 capability, then it is pointless to try a LOCK operation to upgrade. 14180 15.39. Operation 39: RELEASE_LOCKOWNER - Release Lockowner State 14182 15.39.1. SYNOPSIS 14184 lock-owner -> () 14186 15.39.2. ARGUMENT 14188 struct RELEASE_LOCKOWNER4args { 14189 lock_owner4 lock_owner; 14190 }; 14192 15.39.3. RESULT 14194 struct RELEASE_LOCKOWNER4res { 14195 nfsstat4 status; 14196 }; 14198 15.39.4. DESCRIPTION 14200 This operation is used to notify the server that the lock_owner is no 14201 longer in use by the client. This allows the server to release 14202 cached state related to the specified lock_owner. If file locks, 14203 associated with the lock_owner, are held at the server, the error 14204 NFS4ERR_LOCKS_HELD will be returned and no further action will be 14205 taken. 14207 15.39.5. IMPLEMENTATION 14209 The client may choose to use this operation to ease the amount of 14210 server state that is held. Depending on behavior of applications at 14211 the client, it may be important for the client to use this operation 14212 since the server has certain obligations with respect to holding a 14213 reference to a lock_owner as long as the associated file is open. 14215 Therefore, if the client knows for certain that the lock_owner will 14216 no longer be used under the context of the associated open_owner4, it 14217 should use RELEASE_LOCKOWNER. 14219 15.40. Operation 10044: ILLEGAL - Illegal operation 14221 15.40.1. SYNOPSIS 14223 -> () 14225 15.40.2. ARGUMENT 14227 void; 14229 15.40.3. RESULT 14231 struct ILLEGAL4res { 14232 nfsstat4 status; 14233 }; 14235 15.40.4. DESCRIPTION 14237 This operation is a placeholder for encoding a result to handle the 14238 case of the client sending an operation code within COMPOUND that is 14239 not supported. See Section 15.2.4 for more details. 14241 The status field of ILLEGAL4res MUST be set to NFS4ERR_OP_ILLEGAL. 14243 15.40.5. IMPLEMENTATION 14245 A client will probably not send an operation with code OP_ILLEGAL but 14246 if it does, the response will be ILLEGAL4res just as it would be with 14247 any other invalid operation code. Note that if the server gets an 14248 illegal operation code that is not OP_ILLEGAL, and if the server 14249 checks for legal operation codes during the XDR decode phase, then 14250 the ILLEGAL4res would not be returned. 14252 16. NFSv4 Callback Procedures 14254 The procedures used for callbacks are defined in the following 14255 sections. In the interest of clarity, the terms "client" and 14256 "server" refer to NFS clients and servers, despite the fact that for 14257 an individual callback RPC, the sense of these terms would be 14258 precisely the opposite. 14260 16.1. Procedure 0: CB_NULL - No Operation 14262 16.1.1. SYNOPSIS 14264 14266 16.1.2. ARGUMENT 14268 void; 14270 16.1.3. RESULT 14272 void; 14274 16.1.4. DESCRIPTION 14276 Standard NULL procedure. Void argument, void response. Even though 14277 there is no direct functionality associated with this procedure, the 14278 server will use CB_NULL to confirm the existence of a path for RPCs 14279 from server to client. 14281 16.2. Procedure 1: CB_COMPOUND - Compound Operations 14283 16.2.1. SYNOPSIS 14285 compoundargs -> compoundres 14287 16.2.2. ARGUMENT 14289 enum nfs_cb_opnum4 { 14290 OP_CB_GETATTR = 3, 14291 OP_CB_RECALL = 4, 14292 OP_CB_ILLEGAL = 10044 14293 }; 14295 union nfs_cb_argop4 switch (unsigned argop) { 14296 case OP_CB_GETATTR: 14297 CB_GETATTR4args opcbgetattr; 14298 case OP_CB_RECALL: 14299 CB_RECALL4args opcbrecall; 14300 case OP_CB_ILLEGAL: void; 14301 }; 14302 struct CB_COMPOUND4args { 14303 comptag4 tag; 14304 uint32_t minorversion; 14305 uint32_t callback_ident; 14306 nfs_cb_argop4 argarray<>; 14307 }; 14309 16.2.3. RESULT 14311 union nfs_cb_resop4 switch (unsigned resop) { 14312 case OP_CB_GETATTR: CB_GETATTR4res opcbgetattr; 14313 case OP_CB_RECALL: CB_RECALL4res opcbrecall; 14314 case OP_CB_ILLEGAL: CB_ILLEGAL4res opcbillegal; 14315 }; 14317 struct CB_COMPOUND4res { 14318 nfsstat4 status; 14319 comptag4 tag; 14320 nfs_cb_resop4 resarray<>; 14321 }; 14323 16.2.4. DESCRIPTION 14325 The CB_COMPOUND procedure is used to combine one or more of the 14326 callback procedures into a single RPC request. The main callback RPC 14327 program has two main procedures: CB_NULL and CB_COMPOUND. All other 14328 operations use the CB_COMPOUND procedure as a wrapper. 14330 In the processing of the CB_COMPOUND procedure, the client may find 14331 that it does not have the available resources to execute any or all 14332 of the operations within the CB_COMPOUND sequence. In this case, the 14333 error NFS4ERR_RESOURCE will be returned for the particular operation 14334 within the CB_COMPOUND procedure where the resource exhaustion 14335 occurred. This assumes that all previous operations within the 14336 CB_COMPOUND sequence have been evaluated successfully. 14338 Contained within the CB_COMPOUND results is a 'status' field. This 14339 status must be equivalent to the status of the last operation that 14340 was executed within the CB_COMPOUND procedure. Therefore, if an 14341 operation incurred an error then the 'status' value will be the same 14342 error value as is being returned for the operation that failed. 14344 For the definition of the "tag" field, see Section 15.2. 14346 The value of callback_ident is supplied by the client during 14347 SETCLIENTID. The server must use the client supplied callback_ident 14348 during the CB_COMPOUND to allow the client to properly identify the 14349 server. 14351 Illegal operation codes are handled in the same way as they are 14352 handled for the COMPOUND procedure. 14354 16.2.5. IMPLEMENTATION 14356 The CB_COMPOUND procedure is used to combine individual operations 14357 into a single RPC request. The client interprets each of the 14358 operations in turn. If an operation is executed by the client and 14359 the status of that operation is NFS4_OK, then the next operation in 14360 the CB_COMPOUND procedure is executed. The client continues this 14361 process until there are no more operations to be executed or one of 14362 the operations has a status value other than NFS4_OK. 14364 16.2.6. Operation 3: CB_GETATTR - Get Attributes 14366 16.2.6.1. SYNOPSIS 14368 fh, attr_request -> attrmask, attr_vals 14370 16.2.6.2. ARGUMENT 14372 struct CB_GETATTR4args { 14373 nfs_fh4 fh; 14374 bitmap4 attr_request; 14375 }; 14377 16.2.6.3. RESULT 14379 struct CB_GETATTR4resok { 14380 fattr4 obj_attributes; 14381 }; 14383 union CB_GETATTR4res switch (nfsstat4 status) { 14384 case NFS4_OK: 14385 CB_GETATTR4resok resok4; 14386 default: 14387 void; 14388 }; 14390 16.2.6.4. DESCRIPTION 14392 The CB_GETATTR operation is used by the server to obtain the current 14393 modified state of a file that has been OPEN_DELEGATE_WRITE delegated. 14394 The attributes size and change are the only ones guaranteed to be 14395 serviced by the client. See Section 10.4.3 for a full description of 14396 how the client and server are to interact with the use of CB_GETATTR. 14398 If the filehandle specified is not one for which the client holds a 14399 OPEN_DELEGATE_WRITE delegation, an NFS4ERR_BADHANDLE error is 14400 returned. 14402 16.2.6.5. IMPLEMENTATION 14404 The client returns attrmask bits and the associated attribute values 14405 only for the change attribute, and attributes that it may change 14406 (time_modify, and size). 14408 16.2.7. Operation 4: CB_RECALL - Recall an Open Delegation 14410 16.2.7.1. SYNOPSIS 14412 stateid, truncate, fh -> () 14414 16.2.7.2. ARGUMENT 14416 struct CB_RECALL4args { 14417 stateid4 stateid; 14418 bool truncate; 14419 nfs_fh4 fh; 14420 }; 14422 16.2.7.3. RESULT 14424 struct CB_RECALL4res { 14425 nfsstat4 status; 14426 }; 14428 16.2.7.4. DESCRIPTION 14430 The CB_RECALL operation is used to begin the process of recalling an 14431 open delegation and returning it to the server. 14433 The truncate flag is used to optimize recall for a file which is 14434 about to be truncated to zero. When it is set, the client is freed 14435 of obligation to propagate modified data for the file to the server, 14436 since this data is irrelevant. 14438 If the handle specified is not one for which the client holds an open 14439 delegation, an NFS4ERR_BADHANDLE error is returned. 14441 If the stateid specified is not one corresponding to an open 14442 delegation for the file specified by the filehandle, an 14443 NFS4ERR_BAD_STATEID is returned. 14445 16.2.7.5. IMPLEMENTATION 14447 The client should reply to the callback immediately. Replying does 14448 not complete the recall except when an error was returned. The 14449 recall is not complete until the delegation is returned using a 14450 DELEGRETURN. 14452 16.2.8. Operation 10044: CB_ILLEGAL - Illegal Callback Operation 14454 16.2.8.1. SYNOPSIS 14456 -> () 14458 16.2.8.2. ARGUMENT 14460 void; 14462 16.2.8.3. RESULT 14464 /* 14465 * CB_ILLEGAL: Response for illegal operation numbers 14466 */ 14467 struct CB_ILLEGAL4res { 14468 nfsstat4 status; 14469 }; 14471 16.2.8.4. DESCRIPTION 14473 This operation is a placeholder for encoding a result to handle the 14474 case of the client sending an operation code within COMPOUND that is 14475 not supported. See Section 15.2.4 for more details. 14477 The status field of CB_ILLEGAL4res MUST be set to NFS4ERR_OP_ILLEGAL. 14479 16.2.8.5. IMPLEMENTATION 14481 A server will probably not send an operation with code OP_CB_ILLEGAL 14482 but if it does, the response will be CB_ILLEGAL4res just as it would 14483 be with any other invalid operation code. Note that if the client 14484 gets an illegal operation code that is not OP_ILLEGAL, and if the 14485 client checks for legal operation codes during the XDR decode phase, 14486 then the CB_ILLEGAL4res would not be returned. 14488 17. Security Considerations 14490 NFS has historically used a model where, from an authentication 14491 perspective, the client was the entire machine, or at least the 14492 source IP address of the machine. The NFS server relied on the NFS 14493 client to make the proper authentication of the end-user. The NFS 14494 server in turn shared its files only to specific clients, as 14495 identified by the client's source IP address. Given this model, the 14496 AUTH_SYS RPC security flavor simply identified the end-user using the 14497 client to the NFS server. When processing NFS responses, the client 14498 ensured that the responses came from the same IP address and port 14499 number that the request was sent to. While such a model is easy to 14500 implement and simple to deploy and use, it is certainly not a safe 14501 model. Thus, NFSv4 mandates that implementations support a security 14502 model that uses end to end authentication, where an end-user on a 14503 client mutually authenticates (via cryptographic schemes that do not 14504 expose passwords or keys in the clear on the network) to a principal 14505 on an NFS server. Consideration should also be given to the 14506 integrity and privacy of NFS requests and responses. The issues of 14507 end to end mutual authentication, integrity, and privacy are 14508 discussed as part of Section 3. 14510 Note that while NFSv4 mandates an end to end mutual authentication 14511 model, the "classic" model of machine authentication via IP address 14512 checking and AUTH_SYS identification can still be supported with the 14513 caveat that the AUTH_SYS flavor is neither MANDATORY nor RECOMMENDED 14514 by this specification, and so interoperability via AUTH_SYS is not 14515 assured. 14517 For reasons of reduced administration overhead, better performance 14518 and/or reduction of CPU utilization, users of NFSv4 implementations 14519 may choose to not use security mechanisms that enable integrity 14520 protection on each remote procedure call and response. The use of 14521 mechanisms without integrity leaves the customer vulnerable to an 14522 attacker in between the NFS client and server that modifies the RPC 14523 request and/or the response. While implementations are free to 14524 provide the option to use weaker security mechanisms, there are two 14525 operations in particular that warrant the implementation overriding 14526 user choices. 14528 The first such operation is SECINFO. It is recommended that the 14529 client issue the SECINFO call such that it is protected with a 14530 security flavor that has integrity protection, such as RPCSEC_GSS 14531 with a security triple that uses either rpc_gss_svc_integrity or 14532 rpc_gss_svc_privacy (rpc_gss_svc_privacy includes integrity 14533 protection) service. Without integrity protection encapsulating 14534 SECINFO and therefore its results, an attacker in the middle could 14535 modify results such that the client might select a weaker algorithm 14536 in the set allowed by server, making the client and/or server 14537 vulnerable to further attacks. 14539 The second operation that should definitely use integrity protection 14540 is any GETATTR for the fs_locations attribute. The attack has two 14541 steps. First the attacker modifies the unprotected results of some 14542 operation to return NFS4ERR_MOVED. Second, when the client follows 14543 up with a GETATTR for the fs_locations attribute, the attacker 14544 modifies the results to cause the client migrate its traffic to a 14545 server controlled by the attacker. 14547 Because the operations SETCLIENTID/SETCLIENTID_CONFIRM are 14548 responsible for the release of client state, it is imperative that 14549 the principal used for these operations is checked against and match 14550 the previous use of these operations. See Section 9.1.1 for further 14551 discussion. 14553 18. IANA Considerations 14555 This section uses terms that are defined in [41]. 14557 18.1. Named Attribute Definitions 14559 IANA will create a registry called the "NFSv4 Named Attribute 14560 Definitions Registry". 14562 The NFSv4 protocol supports the association of a file with zero or 14563 more named attributes. The name space identifiers for these 14564 attributes are defined as string names. The protocol does not define 14565 the specific assignment of the name space for these file attributes. 14566 An IANA registry will promote interoperability where common interests 14567 exist. While application developers are allowed to define and use 14568 attributes as needed, they are encouraged to register the attributes 14569 with IANA. 14571 Such registered named attributes are presumed to apply to all minor 14572 versions of NFSv4, including those defined subsequently to the 14573 registration. Where the named attribute is intended to be limited 14574 with regard to the minor versions for which they are not be used, the 14575 assignment in registry will clearly state the applicable limits. 14577 All assignments to the registry are made on a First Come First Served 14578 basis, per section 4.1 of [41]. The policy for each assignment is 14579 Specification Required, per section 4.1 of [41]. 14581 Under the NFSv4 specification, the name of a named attribute can in 14582 theory be up to 2^32 - 1 bytes in length, but in practice NFSv4 14583 clients and servers will be unable to a handle string that long. 14584 IANA should reject any assignment request with a named attribute that 14585 exceeds 128 UTF-8 characters. To give IESG the flexibility to set up 14586 bases of assignment of Experimental Use and Standards Action, the 14587 prefixes of "EXPE" and "STDS" are Reserved. The zero length named 14588 attribute name is Reserved. 14590 The prefix "PRIV" is allocated for Private Use. A site that wants to 14591 make use of unregistered named attributes without risk of conflicting 14592 with an assignment in IANA's registry should use the prefix "PRIV" in 14593 all of its named attributes. 14595 Because some NFSv4 clients and servers have case insensitive 14596 semantics, the fifteen additional lower case and mixed case 14597 permutations of each of "EXPE", "PRIV", and "STDS", are Reserved 14598 (e.g. "expe", "expE", "exPe", etc. are Reserved). Similarly, IANA 14599 must not allow two assignments that would conflict if both named 14600 attributes were converted to a common case. 14602 The registry of named attributes is a list of assignments, each 14603 containing three fields for each assignment. 14605 1. A US-ASCII string name that is the actual name of the attribute. 14606 This name must be unique. This string name can be 1 to 128 UTF-8 14607 characters long. 14609 2. A reference to the specification of the named attribute. The 14610 reference can consume up to 256 bytes (or more if IANA permits). 14612 3. The point of contact of the registrant. The point of contact can 14613 consume up to 256 bytes (or more if IANA permits). 14615 18.1.1. Initial Registry 14617 There is no initial registry. 14619 18.1.2. Updating Registrations 14621 The registrant is always permitted to update the point of contact 14622 field. To make any other change will require Expert Review or IESG 14623 Approval. 14625 18.2. ONC RPC Network Identifiers (netids) 14627 Section 2.2 discussed the r_netid field and the corresponding r_addr 14628 field of a clientaddr4 structure. The NFSv4 protocol depends on the 14629 syntax and semantics of these fields to effectively communicate 14630 callback information between client and server. Therefore, an IANA 14631 registry has been created to include the values defined in this 14632 document and to allow for future expansion based on transport usage/ 14633 availability. Additions to this ONC RPC Network Identifier registry 14634 must be done with the publication of an RFC. 14636 The initial values for this registry are as follows (some of this 14637 text is replicated from section 2.2 for clarity): 14639 The Network Identifier (or r_netid for short) is used to specify a 14640 transport protocol and associated universal address (or r_addr for 14641 short). The syntax of the Network Identifier is a US-ASCII string. 14642 The initial definitions for r_netid are: 14644 "tcp": TCP over IP version 4 14646 "udp": UDP over IP version 4 14648 "tcp6": TCP over IP version 6 14650 "udp6": UDP over IP version 6 14652 Note: the '"' marks are used for delimiting the strings for this 14653 document and are not part of the Network Identifier string. 14655 For the "tcp" and "udp" Network Identifiers the Universal Address or 14656 r_addr (for IPv4) is a US-ASCII string and is of the form: 14658 h1.h2.h3.h4.p1.p2 14660 The prefix, "h1.h2.h3.h4", is the standard textual form for 14661 representing an IPv4 address, which is always four octets long. 14662 Assuming big-endian ordering, h1, h2, h3, and h4, are respectively, 14663 the first through fourth octets each converted to ASCII-decimal. 14664 Assuming big-endian ordering, p1 and p2 are, respectively, the first 14665 and second octets each converted to ASCII-decimal. For example, if a 14666 host, in big-endian order, has an address of 0x0A010307 and there is 14667 a service listening on, in big endian order, port 0x020F (decimal 14668 527), then complete universal address is "10.1.3.7.2.15". 14670 For the "tcp6" and "udp6" Network Identifiers the Universal Address 14671 or r_addr (for IPv6) is a US-ASCII string and is of the form: 14673 x1:x2:x3:x4:x5:x6:x7:x8.p1.p2 14675 The suffix "p1.p2" is the service port, and is computed the same way 14676 as with universal addresses for "tcp" and "udp". The prefix, "x1:x2: 14677 x3:x4:x5:x6:x7:x8", is the standard textual form for representing an 14678 IPv6 address as defined in Section 2.2 of [18]. Additionally, the 14679 two alternative forms specified in Section 2.2 of [18] are also 14680 acceptable. 14682 18.2.1. Initial Registry 14684 There is no initial registry. 14686 18.2.2. Updating Registrations 14688 The registrant is always permitted to update the point of contact 14689 field. To make any other change will require Expert Review or IESG 14690 Approval. 14692 19. References 14694 19.1. Normative References 14696 [1] Bradner, S., "Key words for use in RFCs to Indicate Requirement 14697 Levels", March 1997. 14699 [2] Haynes, T. and D. Noveck, "NFSv4 Version 0 XDR Description", 14700 draft-ietf-nfsv4-rfc3530bis-dot-x-02 (work in progress), 14701 Feb 2011. 14703 [3] Thurlow, R., "RPC: Remote Procedure Call Protocol Specification 14704 Version 2", RFC 5531, May 2009. 14706 [4] Eisler, M., Chiu, A., and L. Ling, "RPCSEC_GSS Protocol 14707 Specification", RFC 2203, September 1997. 14709 [5] Eisler, M., "LIPKEY - A Low Infrastructure Public Key Mechanism 14710 Using SPKM", RFC 2847, June 2000. 14712 [6] Linn, J., "Generic Security Service Application Program 14713 Interface Version 2, Update 1", RFC 2743, January 2000. 14715 [7] International Organization for Standardization, "Information 14716 Technology - Universal Multiple-octet coded Character Set (UCS) 14717 - Part 1: Architecture and Basic Multilingual Plane", 14718 ISO Standard 10646-1, May 1993. 14720 [8] Alvestrand, H., "IETF Policy on Character Sets and Languages", 14721 BCP 18, RFC 2277, January 1998. 14723 [9] Hoffman, P. and M. Blanchet, "Preparation of Internationalized 14724 Strings ("stringprep")", RFC 3454, December 2002. 14726 [10] Klensin, J., "Internationalized Domain Names in Applications 14727 (IDNA): Protocol", draft-ietf-idnabis-protocol-18 (work in 14728 progress), January 2010. 14730 19.2. Informative References 14732 [11] Shepler, S., Callaghan, B., Robinson, D., Thurlow, R., Beame, 14733 C., Eisler, M., and D. Noveck, "Network File System (NFS) 14734 version 4 Protocol", RFC 3530, April 2003. 14736 [12] Shepler, S., Callaghan, B., Robinson, D., Thurlow, R., Beame, 14737 C., Eisler, M., and D. Noveck, "Network File System (NFS) 14738 version 4 Protocol", RFC 3010, December 2000. 14740 [13] Nowicki, B., "NFS: Network File System Protocol specification", 14741 RFC 1094, March 1989. 14743 [14] Callaghan, B., Pawlowski, B., and P. Staubach, "NFS Version 3 14744 Protocol Specification", RFC 1813, June 1995. 14746 [15] Eisler, M., "XDR: External Data Representation Standard", 14747 RFC 4506, May 2006. 14749 [16] Linn, J., "The Kerberos Version 5 GSS-API Mechanism", RFC 1964, 14750 June 1996. 14752 [17] Srinivasan, R., "Binding Protocols for ONC RPC Version 2", 14753 RFC 1833, August 1995. 14755 [18] Hinden, R. and S. Deering, "IP Version 6 Addressing 14756 Architecture", RFC 2373, July 1998. 14758 [19] Reynolds, J., "Assigned Numbers: RFC 1700 is Replaced by an On- 14759 line Database", RFC 3232, January 2002. 14761 [20] Floyd, S. and V. Jacobson, "The Synchronization of Periodic 14762 Routing Messages", IEEE/ACM Transactions on Networking 2(2), 14763 pp. 122-136, April 1994. 14765 [21] Eisler, M., "NFS Version 2 and Version 3 Security Issues and 14766 the NFS Protocol's Use of RPCSEC_GSS and Kerberos V5", 14767 RFC 2623, June 1999. 14769 [22] Adams, C., "The Simple Public-Key GSS-API Mechanism (SPKM)", 14770 RFC 2025, October 1996. 14772 [23] Callaghan, B., "WebNFS Client Specification", RFC 2054, 14773 October 1996. 14775 [24] Callaghan, B., "WebNFS Server Specification", RFC 2055, 14776 October 1996. 14778 [25] IESG, "IESG Processing of RFC Errata for the IETF Stream", 14779 July 2008. 14781 [26] The Open Group, "Section 'read()' of System Interfaces of The 14782 Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 14783 Edition", 2004. 14785 [27] The Open Group, "Section 'readdir()' of System Interfaces of 14786 The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 14787 2004 Edition", 2004. 14789 [28] The Open Group, "Section 'write()' of System Interfaces of The 14790 Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 14791 Edition", 2004. 14793 [29] Shepler, S., "NFS Version 4 Design Considerations", RFC 2624, 14794 June 1999. 14796 [30] Simonsen, K., "Character Mnemonics and Character Sets", 14797 RFC 1345, June 1992. 14799 [31] Shepler, S., Eisler, M., and D. Noveck, "Network File System 14800 (NFS) Version 4 Minor Version 1 Protocol", RFC 5661, 14801 January 2010. 14803 [32] The Open Group, "Protocols for Interworking: XNFS, Version 3W, 14804 ISBN 1-85912-184-5", February 1998. 14806 [33] Postel, J., "Transmission Control Protocol", STD 7, RFC 793, 14807 September 1981. 14809 [34] Juszczak, C., "Improving the Performance and Correctness of an 14810 NFS Server", USENIX Conference Proceedings , June 1990. 14812 [35] The Open Group, "Section 'fcntl()' of System Interfaces of The 14813 Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 14814 Edition, HTML Version (www.opengroup.org), ISBN 1931624232", 14815 2004. 14817 [36] The Open Group, "Section 'fsync()' of System Interfaces of The 14818 Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 14819 Edition, HTML Version (www.opengroup.org), ISBN 1931624232", 14820 2004. 14822 [37] The Open Group, "Section 'getpwnam()' of System Interfaces of 14823 The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 14824 2004 Edition, HTML Version (www.opengroup.org), ISBN 14825 1931624232", 2004. 14827 [38] Callaghan, B., "NFS URL Scheme", RFC 2224, October 1997. 14829 [39] Chiu, A., Eisler, M., and B. Callaghan, "Security Negotiation 14830 for WebNFS", RFC 2755, January 2000. 14832 [40] The Open Group, "Section 'unlink()' of System Interfaces of The 14833 Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 14834 Edition, HTML Version (www.opengroup.org), ISBN 1931624232", 14835 2004. 14837 [41] Narten, T. and H. Alvestrand, "Guidelines for Writing an IANA 14838 Considerations Section in RFCs", BCP 26, RFC 5226, May 2008. 14840 Appendix A. Acknowledgments 14842 A bis is certainly built on the shoulders of the first attempt. 14843 Spencer Shepler, Brent Callaghan, David Robinson, Robert Thurlow, 14844 Carl Beame, Mike Eisler, and David Noveck are responsible for a great 14845 deal of the effort in this work. 14847 Rob Thurlow clarified how a client should contact a new server if a 14848 migration has occurred. 14850 David Black, Nico Williams, Mike Eisler, Trond Myklebust, and James 14851 Lentini read many drafts of Section 12 and contributed numerous 14852 useful suggestions, without which the necessary revision of that 14853 section for this document would not have been possible. 14855 Peter Staubach read almost all of the drafts of Section 12 leading to 14856 the published result and his numerous comments were always useful and 14857 contributed substantially to improving the quality of the final 14858 result. 14860 James Lentini graciously read the rewrite of Section 7 and his 14861 comments were vital in improving the quality of that effort. 14863 Rob Thurlow, Sorin Faibish, James Lentini, Bruce Fields, and Trond 14864 Myklebust were faithful attendants of the biweekly triage meeting and 14865 accepted many an action item. 14867 Bruce Fields was a good sounding board for both the Third Edge 14868 Condition and Courtsey Locks in general. 14870 Appendix B. RFC Editor Notes 14872 [RFC Editor: please remove this section prior to publishing this 14873 document as an RFC] 14875 [RFC Editor: prior to publishing this document as an RFC, please 14876 replace all occurrences of RFCTBD10 with RFCxxxx where xxxx is the 14877 RFC number of this document] 14879 Authors' Addresses 14881 Thomas Haynes (editor) 14882 NetApp 14883 9110 E 66th St 14884 Tulsa, OK 74133 14885 USA 14887 Phone: +1 918 307 1415 14888 Email: thomas@netapp.com 14889 URI: http://www.tulsalabs.com 14891 David Noveck (editor) 14892 EMC Corporation 14893 32 Coslin Drive 14894 Southborough, MA 01772 14895 US 14897 Phone: +1 508 305 8404 14898 Email: novecd@emc.com