NFSv4 T. Haynes, Ed. Internet-Draft NetApp Obsoletes: 3530 (if approved) D. Noveck, Ed. Intended status: Standards Track EMC Expires:November 9, 2013 May 08,February 17, 2014 August 16, 2013 Network File System (NFS) Version 4 Protocoldraft-ietf-nfsv4-rfc3530bis-26.txtdraft-ietf-nfsv4-rfc3530bis-27.txt Abstract The Network File System (NFS) version 4 is a distributedfilesystemfile system protocol whichowesbuilds on the heritagetoof NFS protocol version 2, RFC 1094, and version 3, RFC 1813. Unlike earlier versions, the NFS version 4 protocol supports traditional file access while integrating support for file locking and the mount protocol. In addition, support for strong security (and its negotiation), compound operations, client caching, and internationalization have been added. Of course, attention has been applied to making NFS version 4 operate well in an Internet environment. This document, together with the companion XDR description document, RFCNFSv4XDR, obsoletes RFC 3530 as the definition of the NFS version 4 protocol. Requirements Language The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119]. Status of this Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire onNovember 9, 2013.February 17, 2014. Copyright Notice Copyright (c) 2013 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The person(s) controlling the copyright in some of this material may not have granted the IETF Trust the right to allow modifications of such material outside the IETF Standards Process. Without obtaining an adequate license from the person(s) controlling the copyright in such materials, this document may not be modified outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process, except to format it for publication as an RFC or to translate it into languages other than English. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . .98 1.1. NFS Version 4 Goals . . . . . . . . . . . . . . . . . .98 1.2.Inconsistencies of this Document withDefinitions in the companion document NFS Version 4 Protocol are Authoritative . . . . . . . . . . . .10. . . 8 1.3. Overview of NFSv4 Features . . . . . . . . . . . . . . .109 1.3.1. RPC and Security . . . . . . . . . . . . . . . . . .109 1.3.2. Procedure and Operation Structure . . . . . . . . .109 1.3.3. Filesystem Model . . . . . . . . . . . . . . . . . .1110 1.3.4. OPEN and CLOSE . . . . . . . . . . . . . . . . . . .1312 1.3.5. File Locking . . . . . . . . . . . . . . . . . . . .1312 1.3.6. Client Caching and Delegation . . . . . . . . . . .1412 1.4. General Definitions . . . . . . . . . . . . . . . . . .1413 1.5. Changes since RFC 3530 . . . . . . . . . . . . . . . . .1615 1.6. Changes since RFC 3010 . . . . . . . . . . . . . . . . .1716 2. Protocol Data Types . . . . . . . . . . . . . . . . . . . . .1817 2.1. Basic Data Types . . . . . . . . . . . . . . . . . . . .1817 2.2. Structured Data Types . . . . . . . . . . . . . . . . .2019 3. RPC and Security Flavor . . . . . . . . . . . . . . . . . . .2423 3.1. Ports and Transports . . . . . . . . . . . . . . . . . .2523 3.1.1. Client Retransmission Behavior . . . . . . . . . . .2624 3.2. Security Flavors . . . . . . . . . . . . . . . . . . . .2625 3.2.1. Security mechanisms for NFSv4 . . . . . . . . . . .2725 3.3. Security Negotiation . . . . . . . . . . . . . . . . . .2826 3.3.1. SECINFO . . . . . . . . . . . . . . . . . . . . . .2827 3.3.2. Security Error . . . . . . . . . . . . . . . . . . .2927 3.3.3. Callback RPC Authentication . . . . . . . . . . . .2927 4. Filehandles . . . . . . . . . . . . . . . . . . . . . . . . .3028 4.1. Obtaining the First Filehandle . . . . . . . . . . . . .3028 4.1.1. Root Filehandle . . . . . . . . . . . . . . . . . .3129 4.1.2. Public Filehandle . . . . . . . . . . . . . . . . .3129 4.2. Filehandle Types . . . . . . . . . . . . . . . . . . . .3130 4.2.1. General Properties of a Filehandle . . . . . . . . .3230 4.2.2. Persistent Filehandle . . . . . . . . . . . . . . .3231 4.2.3. Volatile Filehandle . . . . . . . . . . . . . . . .3331 4.2.4. One Method of Constructing a Volatile Filehandle . .3432 4.3. Client Recovery from Filehandle Expiration . . . . . . .3433 5.FileAttributes . . . . . . . . . . . . . . . . . . . . . . .35. . 34 5.1. REQUIRED Attributes . . . . . . . . . . . . . . . . . .3635 5.2. RECOMMENDED Attributes . . . . . . . . . . . . . . . . .3735 5.3. Named Attributes . . . . . . . . . . . . . . . . . . . .3736 5.4. Classification of Attributes . . . . . . . . . . . . . .3937 5.5. Set-Only and Get-Only Attributes . . . . . . . . . . . .3938 5.6. REQUIRED Attributes - List and Definition References . .4038 5.7. RECOMMENDED Attributes - List and Definition References . . . . . . . . . . . . . . . . . . . . . . .4139 5.8. Attribute Definitions . . . . . . . . . . . . . . . . .4240 5.8.1. Definitions of REQUIRED Attributes . . . . . . . . .4240 5.8.2. Definitions of Uncategorized RECOMMENDED Attributes . . . . . . . . . . . . . . . . . . . . .4442 5.9. Interpreting owner and owner_group . . . . . . . . . . .5048 5.10. Character Case Attributes . . . . . . . . . . . . . . .5351 6. Access Control Attributes . . . . . . . . . . . . . . . . . .5351 6.1. Goals . . . . . . . . . . . . . . . . . . . . . . . . .5351 6.2. File Attributes Discussion . . . . . . . . . . . . . . .5452 6.2.1. Attribute 12: acl . . . . . . . . . . . . . . . . .5452 6.2.2. Attribute 33: mode . . . . . . . . . . . . . . . . .6867 6.3. Common Methods . . . . . . . . . . . . . . . . . . . . .6967 6.3.1. Interpreting an ACL . . . . . . . . . . . . . . . .6967 6.3.2. Computing a Mode Attribute from an ACL . . . . . . .7068 6.4. Requirements . . . . . . . . . . . . . . . . . . . . . .7169 6.4.1. Setting the mode and/or ACL Attributes . . . . . . .7270 6.4.2. Retrieving the mode and/or ACL Attributes . . . . .7371 6.4.3. Creating New Objects . . . . . . . . . . . . . . . .7371 7.Multi-Server NamespaceNFS Server Name Space . . . . . . . . . . . . . . . . . . .75. 73 7.1.Location AttributesServer Exports . . . . . . . . . . . . . . . . . .75. . . 73 7.2.File System Presence or AbsenceBrowsing Exports . . . . . . . . . . . .76 7.3. Getting Attributes for an Absent File System. . . . . .77 7.3.1. GETATTR Within an Absent File System. . 73 7.3. Server Pseudo Filesystem . . . . . .77 7.3.2. READDIR and Absent File Systems. . . . . . . . . .7874 7.4.Uses of Location Information .Multiple Roots . . . . . . . . . . . . .78 7.4.1. File System Replication. . . . . . . . 74 7.5. Filehandle Volatility . . . . . .79 7.4.2. File System Migration. . . . . . . . . . . 75 7.6. Exported Root . . . .80 7.4.3. Referrals. . . . . . . . . . . . . . . . . 75 7.7. Mount Point Crossing . . . .81 7.5. Location Entries and Server Identity. . . . . . . . . .81 7.6. Additional Client-Side Considerations. . . . 75 7.8. Security Policy and Name Space Presentation . . . . .82 7.7. Effecting File System Transitions. 76 8. Multi-Server Namespace . . . . . . . . . .83 7.7.1. File System Transitions and Simultaneous Access. .84 7.7.2. Filehandles and File System Transitions. . . . . .85 7.7.3. Fileids and File System Transitions. 76 8.1. Location Attributes . . . . . . .85 7.7.4. Fsids and File System Transitions. . . . . . . . .86 7.7.5. The Change Attribute and File System Transitions. .87 7.7.6. Lock State and77 8.2. File SystemTransitionsPresence or Absence . . . . . . .87 7.7.7. Write Verifiers and File System Transitions. . . .89 7.7.8. Readdir Cookies and Verifiers and. 77 8.3. Getting Attributes for an Absent File SystemTransitions. . . . . . 78 8.3.1. GETATTR Within an Absent File System . . . . . . . . 78 8.3.2. READDIR and Absent File Systems . . . . . .89 7.7.9. File System Data and File System Transitions. . . .90 7.8. Effecting File System Referrals79 8.4. Uses of Location Information . . . . . . . . . . . .91 7.8.1. Referral Example (LOOKUP). . 80 8.4.1. File System Replication . . . . . . . . . . .91 7.8.2. Referral Example (READDIR). . . 81 8.4.2. File System Migration . . . . . . . . . .95 7.9. The Attribute fs_locations. . . . . 81 8.4.3. Referrals . . . . . . . . . .98 7.9.1. Inferring Transition Modes. . . . . . . . . . . 82 8.5. Location Entries and Server Identity . .99 8. NFS Server Name Space. . . . . . . . 83 8.6. Additional Client-Side Considerations . . . . . . . . . 83 8.7. Effecting File System Referrals . . .101 8.1. Server Exports. . . . . . . . . 84 8.7.1. Referral Example (LOOKUP) . . . . . . . . . . . .101 8.2. Browsing Exports. 85 8.7.2. Referral Example (READDIR) . . . . . . . . . . . . . 89 8.8. The Attribute fs_locations . . . . . .101 8.3. Server Pseudo Filesystem. . . . . . . . . 91 8.8.1. Inferring Transition Modes . . . . . . .101 8.4. Multiple Roots. . . . . . 93 9. File Locking and Share Reservations . . . . . . . . . . . . . 94 9.1. Opens and Byte-Range Locks . .102 8.5. Filehandle Volatility. . . . . . . . . . . . . 95 9.1.1. Client ID . . . .102 8.6. Exported Root. . . . . . . . . . . . . . . . . 96 9.1.2. Server Release of Client ID . . . .102 8.7. Mount Point Crossing. . . . . . . . 99 9.1.3. Stateid Definition . . . . . . . . . .103 8.8. Security Policy and Name Space Presentation. . . . . .103 9. File Locking and Share Reservations. 99 9.1.4. lock-owner . . . . . . . . . . . .104 9.1. Opens and Byte-Range Locks. . . . . . . . . 105 9.1.5. Use of the Stateid and Locking . . . . . .105 9.1.1. Client ID. . . . . 106 9.1.6. Sequencing of Lock Requests . . . . . . . . . . . .. . . . 105 9.1.2. Server Release of Client ID . . . . . . . . . . . . 108 9.1.3. Stateid Definition .108 9.1.7. Recovery from Replayed Requests . . . . . . . . . . 109 9.1.8. Interactions of multiple sequence values . . . . . . 1099.1.4. lock-owner . . . . . . . . . . . . . . . . . . . . . 115 9.1.5. Use of the Stateid and Locking . . . . . . . . . . . 116 9.1.6. Sequencing of Lock Requests . . . . . . . . . . . . 118 9.1.7. Recovery from Replayed Requests . . . . . . . . . . 119 9.1.8. Interactions of multiple sequence values . . . . . . 1199.1.9. Releasing state-owner State . . . . . . . . . . . .120110 9.1.10. Use of Open Confirmation . . . . . . . . . . . . . .121111 9.2. Lock Ranges . . . . . . . . . . . . . . . . . . . . . .122112 9.3. Upgrading and Downgrading Locks . . . . . . . . . . . .122113 9.4. Blocking Locks . . . . . . . . . . . . . . . . . . . . .123113 9.5. Lease Renewal . . . . . . . . . . . . . . . . . . . . .124114 9.6. Crash Recovery . . . . . . . . . . . . . . . . . . . . .125115 9.6.1. Client Failure and Recovery . . . . . . . . . . . .125115 9.6.2. Server Failure and Recovery . . . . . . . . . . . .125116 9.6.3. Network Partitions and Recovery . . . . . . . . . .127117 9.7. Recovery from a Lock Request Timeout or Abort . . . . .135125 9.8. Server Revocation of Locks . . . . . . . . . . . . . . .135125 9.9. Share Reservations . . . . . . . . . . . . . . . . . . .136127 9.10. OPEN/CLOSE Operations . . . . . . . . . . . . . . . . .137127 9.10.1. Close and Retention of State Information . . . . . .138128 9.11. Open Upgrade and Downgrade . . . . . . . . . . . . . . .139129 9.12. Short and Long Leases . . . . . . . . . . . . . . . . .139130 9.13. Clocks, Propagation Delay, and Calculating Lease Expiration . . . . . . . . . . . . . . . . . . . . . . .140130 9.14. Migration, Replication and State . . . . . . . . . . . .140131 9.14.1. Migration and State . . . . . . . . . . . . . . . .141131 9.14.2. Replication and State . . . . . . . . . . . . . . .142132 9.14.3. Notification of Migrated Lease . . . . . . . . . . .142132 9.14.4. Migration and the Lease_time Attribute . . . . . . .143133 10. Client-Side Caching . . . . . . . . . . . . . . . . . . . . .143134 10.1. Performance Challenges for Client-Side Caching . . . . .144134 10.2. Delegation and Callbacks . . . . . . . . . . . . . . . .145135 10.2.1. Delegation Recovery . . . . . . . . . . . . . . . .147137 10.3. Data Caching . . . . . . . . . . . . . . . . . . . . . .151141 10.3.1. Data Caching and OPENs . . . . . . . . . . . . . . .151142 10.3.2. Data Caching and File Locking . . . . . . . . . . .152143 10.3.3. Data Caching and Mandatory File Locking . . . . . .154144 10.3.4. Data Caching and File Identity . . . . . . . . . . .154145 10.4. Open Delegation . . . . . . . . . . . . . . . . . . . .155146 10.4.1. Open Delegation and Data Caching . . . . . . . . . .158148 10.4.2. Open Delegation and File Locks . . . . . . . . . . .159149 10.4.3. Handling of CB_GETATTR . . . . . . . . . . . . . . .159150 10.4.4. Recall of Open Delegation . . . . . . . . . . . . .162153 10.4.5. OPEN Delegation Race with CB_RECALL . . . . . . . .164155 10.4.6. Clients that Fail to Honor Delegation Recalls . . .165155 10.4.7. Delegation Revocation . . . . . . . . . . . . . . .166156 10.5. Data Caching and Revocation . . . . . . . . . . . . . .166157 10.5.1. Revocation Recovery for Write Open Delegation . . .167157 10.6. Attribute Caching . . . . . . . . . . . . . . . . . . .168158 10.7. Data and Metadata Caching and Memory Mapped Files . . .170160 10.8. Name Caching . . . . . . . . . . . . . . . . . . . . . .172162 10.9. Directory Caching . . . . . . . . . . . . . . . . . . .173163 11. Minor Versioning . . . . . . . . . . . . . . . . . . . . . .174164 12. Internationalization . . . . . . . . . . . . . . . . . . . .176167 12.1.Use of UTF-8 . . . . . . . . . . . . . . . . . .Introduction . . . .177 12.1.1. Relation to Stringprep. . . . . . . . . . . . . . .177 12.1.2. Normalization, Equivalence, and Confusability. . .178167 12.2. StringType Overview . . . . . . . . . . . . . . . . . . 181 12.2.1. Overall String Class Divisions . . . . .Encoding . . . . . .181 12.2.2. Divisions by Typedef Parent types. . . . . . . . .182 12.2.3. Individual Types and Their Handling . . .. . . . .183167 12.3.Errors Related to Strings . . . . . . . . . . . . . . . 184 12.4. Types with Pre-processing to Resolve Mixture Issues . . 185 12.4.1. Processing of Principal Strings .Normalization . . . . . . . . .185 12.4.2. Processing of Server Id Strings. . . . . . . . . .186 12.5. String Types without Internationalization Processing. .186 12.6.168 12.4. Types with Processing Defined by Other Internet Areas .187 12.7. String Types with NFS-specific Processing . . . . . . . 188 12.7.1. Handling of File Name Components . . . . . . . . . . 188 12.7.2. Processing of Link Text . . . . . .168 12.5. UTF-8 Related Errors . . . . . . . .197 12.7.3. Processing of Principal Prefixes. . . . . . . . . .198169 13. Error Values . . . . . . . . . . . . . . . . . . . . . . . .199170 13.1. Error Definitions . . . . . . . . . . . . . . . . . . .199170 13.1.1. General Errors . . . . . . . . . . . . . . . . . . .201172 13.1.2. Filehandle Errors . . . . . . . . . . . . . . . . .202173 13.1.3. Compound Structure Errors . . . . . . . . . . . . .204174 13.1.4. File System Errors . . . . . . . . . . . . . . . . .204175 13.1.5. State Management Errors . . . . . . . . . . . . . .206177 13.1.6. Security Errors . . . . . . . . . . . . . . . . . .207178 13.1.7. Name Errors . . . . . . . . . . . . . . . . . . . .208179 13.1.8. Locking Errors . . . . . . . . . . . . . . . . . . .209179 13.1.9. Reclaim Errors . . . . . . . . . . . . . . . . . . .210181 13.1.10. Client Management Errors . . . . . . . . . . . . . .211181 13.1.11. Attribute Handling Errors . . . . . . . . . . . . .211182 13.2. Operations and their valid errors . . . . . . . . . . .212182 13.3. Callback operations and their valid errors . . . . . . .219189 13.4. Errors and the operations that use them . . . . . . . .219190 14. NFSv4 Requests . . . . . . . . . . . . . . . . . . . . . . .224194 14.1. Compound Procedure . . . . . . . . . . . . . . . . . . .224195 14.2. Evaluation of a Compound Request . . . . . . . . . . . .225195 14.3. Synchronous Modifying Operations . . . . . . . . . . . .226196 14.4. Operation Values . . . . . . . . . . . . . . . . . . . .226196 15. NFSv4 Procedures . . . . . . . . . . . . . . . . . . . . . .226197 15.1. Procedure 0: NULL - No Operation . . . . . . . . . . . .226197 15.2. Procedure 1: COMPOUND - Compound Operations . . . . . .227197 15.3. Operation 3: ACCESS - Check Access Rights . . . . . . .230201 15.4. Operation 4: CLOSE - Close File . . . . . . . . . . . .233204 15.5. Operation 5: COMMIT - Commit Cached Data . . . . . . . .234205 15.6. Operation 6: CREATE - Create a Non-Regular File Object .237207 15.7. Operation 7: DELEGPURGE - Purge Delegations Awaiting Recovery . . . . . . . . . . . . . . . . . . . . . . . .239210 15.8. Operation 8: DELEGRETURN - Return Delegation . . . . . .241211 15.9. Operation 9: GETATTR - Get Attributes . . . . . . . . .241212 15.10. Operation 10: GETFH - Get Current Filehandle . . . . . .243214 15.11. Operation 11: LINK - Create Link to a File . . . . . . .244215 15.12. Operation 12: LOCK - Create Lock . . . . . . . . . . . .246216 15.13. Operation 13: LOCKT - Test For Lock . . . . . . . . . .250220 15.14. Operation 14: LOCKU - Unlock File . . . . . . . . . . .252222 15.15. Operation 15: LOOKUP - Lookup Filename . . . . . . . . .253223 15.16. Operation 16: LOOKUPP - Lookup Parent Directory . . . .255225 15.17. Operation 17: NVERIFY - Verify Difference in Attributes . . . . . . . . . . . . . . . . . . . . . . .256226 15.18. Operation 18: OPEN - Open a Regular File . . . . . . . .257227 15.19. Operation 19: OPENATTR - Open Named Attribute Directory . . . . . . . . . . . . . . . . . . . . . . .267237 15.20. Operation 20: OPEN_CONFIRM - Confirm Open . . . . . . .268238 15.21. Operation 21: OPEN_DOWNGRADE - Reduce Open File Access .270240 15.22. Operation 22: PUTFH - Set Current Filehandle . . . . . .271241 15.23. Operation 23: PUTPUBFH - Set Public Filehandle . . . . .272242 15.24. Operation 24: PUTROOTFH - Set Root Filehandle . . . . .273243 15.25. Operation 25: READ - Read from File . . . . . . . . . .274244 15.26. Operation 26: READDIR - Read Directory . . . . . . . . .276246 15.27. Operation 27: READLINK - Read Symbolic Link . . . . . .280250 15.28. Operation 28: REMOVE - Remove Filesystem Object . . . .281251 15.29. Operation 29: RENAME - Rename Directory Entry . . . . .283253 15.30. Operation 30: RENEW - Renew a Lease . . . . . . . . . .285255 15.31. Operation 31: RESTOREFH - Restore Saved Filehandle . . .286256 15.32. Operation 32: SAVEFH - Save Current Filehandle . . . . .287257 15.33. Operation 33: SECINFO - Obtain Available Security . . .288258 15.34. Operation 34: SETATTR - Set Attributes . . . . . . . . .292262 15.35. Operation 35: SETCLIENTID - Negotiate Client ID . . . .294264 15.36. Operation 36: SETCLIENTID_CONFIRM - Confirm Client ID .298268 15.37. Operation 37: VERIFY - Verify Same Attributes . . . . .301271 15.38. Operation 38: WRITE - Write to File . . . . . . . . . .303273 15.39. Operation 39: RELEASE_LOCKOWNER - Release Lockowner State . . . . . . . . . . . . . . . . . . . . . . . . .307277 15.40. Operation 10044: ILLEGAL - Illegal operation . . . . . .308278 16. NFSv4 Callback Procedures . . . . . . . . . . . . . . . . . .309279 16.1. Procedure 0: CB_NULL - No Operation . . . . . . . . . .309279 16.2. Procedure 1: CB_COMPOUND - Compound Operations . . . . .309279 16.2.6. Operation 3: CB_GETATTR - Get Attributes . . . . . .311281 16.2.7. Operation 4: CB_RECALL - Recall an Open Delegation .312282 16.2.8. Operation 10044: CB_ILLEGAL - Illegal Callback Operation . . . . . . . . . . . . . . . . . . . . .313283 17. Security Considerations . . . . . . . . . . . . . . . . . . .314284 18. IANA Considerations . . . . . . . . . . . . . . . . . . . . .316286 18.1. Named Attribute Definitions . . . . . . . . . . . . . .316286 18.1.1. Initial Registry . . . . . . . . . . . . . . . . . .317287 18.1.2. Updating Registrations . . . . . . . . . . . . . . .317287 19. References . . . . . . . . . . . . . . . . . . . . . . . . .317287 19.1. Normative References . . . . . . . . . . . . . . . . . .317287 19.2. Informative References . . . . . . . . . . . . . . . . .318288 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . .321291 Appendix B. RFC Editor Notes . . . . . . . . . . . . . . . . . .322292 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . .322292 1. Introduction 1.1. NFS Version 4 Goals The Network Filesystem version 4 (NFSv4) protocol is a further revision of the NFS protocol defined already by versions 2 [RFC1094] and 3 [RFC1813]. It retains the essential characteristics of previous versions: design for easy recovery, independent of transport protocols, operating systems andfilesystems,file systems, simplicity, and good performance. The NFSv4 revision has the following goals: o Improved access and good performance on the Internet. The protocol is designed to transit firewalls easily, perform well where latency is high and bandwidth is low, and scale to very large numbers of clients per server. o Strong security with negotiation built into the protocol. The protocol builds on the work of theONCRPCOpen Network Computing (ONC) Remote Procedure Call (RPC) working group in supporting the RPCSEC_GSSprotocol.protocol (see both [RFC2203] and [RFC5403]). Additionally, the NFS version 4 protocol provides a mechanism to allow clients and servers the ability to negotiate security and require clients and servers to support a minimal set of security schemes. o Good cross-platform interoperability. The protocol features afilesystemfile system model that provides a useful, common set of features that does not unduly favor onefilesystemfile system or operating system over another. o Designed for protocol extensions. The protocol is designed to accept standard extensions that do not compromise backward compatibility. This document, together with the companion XDR description document [I-D.ietf-nfsv4-rfc3530bis-dot-x], obsoletes RFC 3530 [RFC3530] as the authoritative document describing NFSv4. It does not introduce any over-the-wire protocol changes, in the sense that previously valid requestsrequestsremain valid.However, some requests previously defined as invalid, although not generally rejected, are now explicitly allowed, in that internationalization handling has been generalized and liberalized.1.2.Inconsistencies of this Document withDefinitions in the companion document NFS Version 4 Protocol are Authoritative [I-D.ietf-nfsv4-rfc3530bis-dot-x], NFS Version 4 Protocol, contains the definitions in XDR description language of the constructs used by the protocol. Inside this document, several of the constructs are reproduced for purposes of explanation. The reader is warned of the possibility of errors in the reproduced constructs outside of [I-D.ietf-nfsv4-rfc3530bis-dot-x]. For any part of the document that is inconsistent with [I-D.ietf-nfsv4-rfc3530bis-dot-x], [I-D.ietf-nfsv4-rfc3530bis-dot-x] is to be considered authoritative. 1.3. Overview of NFSv4 Features To provide a reasonable context for the reader, the major features of NFSv4 protocol will be reviewed in brief. This will be done to provide an appropriate context for both the reader who is familiar with the previous versions of the NFS protocol and the readerthatwho is new to the NFS protocols. For the reader new to the NFS protocols, some fundamental knowledge is still expected. The reader should be familiar with the XDR and RPC protocols as described in [RFC5531] and [RFC4506]. A basic knowledge offilesystemsfile systems and distributedfilesystemsfile systems is expected as well. 1.3.1. RPC and Security As with previous versions of NFS, the External Data Representation (XDR) andRemote Procedure Call (RPC)RPC mechanisms used for the NFSv4 protocol are those defined in [RFC5531] and [RFC4506]. To meet end to end security requirements, the RPCSEC_GSS framework (both version 1 in [RFC2203] and version 2 in [RFC5403]) will be used to extend the basic RPC security. With the use of RPCSEC_GSS, various mechanisms can be provided to offer authentication, integrity, and privacy to the NFS version 4 protocol. Kerberos V5 will be used as described in [RFC4121] to provide one security framework. With the use of RPCSEC_GSS, other mechanisms may also be specified and used for NFS version 4 security. To enable in-band security negotiation, the NFSv4 protocol has added a new operation which provides the client with a method of querying the server about its policies regarding which security mechanisms must be used for access to the server'sfilesystemfile system resources. With this, the client can securely match the security mechanism that meets the policies specified at both the client and server. 1.3.2. Procedure and Operation Structure A significant departure from the previous versions of the NFS protocol is the introduction of the COMPOUND procedure. For the NFSv4 protocol, there are two RPC procedures, NULL and COMPOUND. The COMPOUND procedure is defined in terms of operations and these operations correspond more closely to the traditional NFS procedures. With the use of the COMPOUND procedure, the client is able to build simple or complex requests. These COMPOUND requests allow for a reduction in the number of RPCs needed for logicalfilesystemfile system operations. For example, without previous contact with a server a client will be able to read data from a file in one request by combining LOOKUP, OPEN, and READ operations in a single COMPOUND RPC. With previous versions of the NFS protocol, this type of single request was not possible. The model used for COMPOUND is very simple. There is no logical OR or ANDing of operations. The operations combined within a COMPOUND request are evaluated in order by the server. Once an operation returns a failing result, the evaluation ends and the results of all evaluated operations are returned to the client. The NFSv4 protocol continues to have the client refer to a file or directory at the server by a "filehandle". The COMPOUND procedure has a method of passing a filehandle from one operation to another within the sequence of operations. There is a concept of a "current filehandle" and "saved filehandle". Most operations use the "current filehandle" as thefilesystemfile system object to operate upon. The "saved filehandle" is used as temporary filehandle storage within a COMPOUND procedure as well as an additional operand for certain operations. 1.3.3. Filesystem Model The generalfilesystemfile system model used for the NFSv4 protocol is the same as previous versions. The serverfilesystemfile system is hierarchical with the regular files contained within being treated as opaque byte streams. In a slight departure, file and directory names are encoded with UTF-8 to deal with the basics of internationalization. The NFSv4 protocol does not require a separate protocol to provide for the initial mapping between path name and filehandle. Instead of using the older MOUNT protocol for this mapping, the server provides a ROOT filehandle that represents the logical root or top of thefilesystemfile system tree provided by the server. The server provides multiplefilesystemsfile systems by gluing them together with pseudofilesystems.file systems. These pseudofilesystemsfile systems provide for potential gaps in the path names between realfilesystems.file systems. 1.3.3.1. Filehandle Types In previous versions of the NFS protocol, the filehandle provided by the server was guaranteed to be valid or persistent for the lifetime of thefilesystemfile system object to which it referred. For some server implementations, this persistence requirement has been difficult to meet. For the NFSv4 protocol, this requirement has been relaxed by introducing another type of filehandle, volatile. With persistent and volatile filehandle types, the server implementation can match the abilities of thefilesystemfile system at the server along with the operating environment. The client will have knowledge of the type of filehandle being provided by the server and can be prepared to deal with the semantics of each. 1.3.3.2. Attribute Types The NFSv4 protocol has a rich and extensible file object attribute structure, which is divided into REQUIRED, RECOMMENDED, and named attributes (see Section 5). Several (but not all) of the REQUIRED attributes are derived from the attributes of NFSv3 (see definition of the fattr3 data type in [RFC1813]). An example of a REQUIRED attribute is the file object's type (Section 5.8.1.2) so that regular files can be distinguished from directories (also known as folders in some operating environments) and other types of objects. REQUIRED attributes are discussed in Section 5.1. An example of the RECOMMENDED attributes is anacl.acl (Section 6.2.1). This attribute defines an Access Control List (ACL) on a fileobject ((Section 6).object. An ACL provides file access control beyond the model used in NFSv3. The ACL definition allows for specification of specific sets of permissions for individual users and groups. In addition, ACL inheritance allows propagation of access permissions and restriction down a directory tree as file system objects are created. RECOMMENDED attributes are discussed in Section 5.2. A named attribute is an opaque byte stream that is associated with a directory or file and referred to by a string name. Named attributes are meant to be used by client applications as a method to associate application-specific data with a regular file or directory. NFSv4.1 modifies named attributes relative to NFSv4.0 by tightening the allowed operations in order to prevent the development of non- interoperable implementations. Named attributes are discussed in Section 5.3. 1.3.3.3. Multi-server Namespace NFSv4 contains a number of features to allow implementation of namespaces that cross server boundaries and that allow and facilitate a non-disruptive transfer of support for individual file systems between servers. They are all based upon attributes that allow one file system to specify alternate or new locations for that file system. These attributes may be used together with the concept of absent file systems, which provide specifications for additional locations but no actual file system content. This allows a number of important facilities: o Location attributes may be used with absent file systems to implement referrals whereby one server may direct the client to a file system provided by another server. This allows extensive multi-server namespaces to be constructed. o Location attributes may be provided for present file systems to provide the locations of alternate file system instances or replicas to be used in the event that the current file system instance becomes unavailable. o Location attributes may be provided when a previously present file system becomes absent. This allows non-disruptive migration of file systems to alternate servers. 1.3.4. OPEN and CLOSE The NFSv4 protocol introduces OPEN and CLOSE operations. The OPEN operation provides a single point where file lookup, creation, and share semantics can be combined. The CLOSE operation also provides for the release of state accumulated by OPEN. 1.3.5. File Locking With the NFSv4 protocol, the support for byte range file locking is part of the NFS protocol. The file locking support is structured so that an RPC callback mechanism is not required. This is a departure from the previous versions of the NFS file locking protocol, Network Lock Manager (NLM). The state associated with file locks is maintained at the server under a lease-based model. The server defines a single lease period for all state held by a NFS client. If the client does not renew its lease within the defined period, all state associated with the client's lease may be released by the server. The client may renew its lease with use of the RENEW operation or implicitly by use of other operations (primarily READ). 1.3.6. Client Caching and Delegation The file, attribute, and directory caching for the NFSv4 protocol is similar to previous versions. Attributes and directory information are cached for a duration determined by the client. At the end of a predefined timeout, the client will query the server to see if the relatedfilesystemfile system object has been updated. For file data, the client checks its cache validity when the file is opened. A query is sent to the server to determine if the file has been changed. Based on this information, the client determines if the data cache for the file should kept or released. Also, when the file is closed, any modified data is written to the server. If an application wants to serialize access to file data, file locking of the file data ranges in question should be used. The major addition to NFSv4 in the area of caching is the ability of the server to delegate certain responsibilities to the client. When the server grants a delegation for a file to a client, the client is guaranteed certain semantics with respect to the sharing of that file with other clients. At OPEN, the server may provide the client either a OPEN_DELEGATE_READ or OPEN_DELEGATE_WRITE delegation for the file. If the client is granted a OPEN_DELEGATE_READ delegation, it is assured that no other client has the ability to write to the file for the duration of the delegation. If the client is granted a OPEN_DELEGATE_WRITE delegation, the client is assured that no other client has read or write access to the file. Delegations can be recalled by the server. If another client requests access to the file in such a way that the access conflicts with the granted delegation, the server is able to notify the initial client and recall the delegation. This requires that a callback path exist between the server and client. If this callback path does not exist, then delegations cannot be granted. The essence of a delegation is that it allows the client to locally service operations such as OPEN, CLOSE, LOCK, LOCKU, READ, or WRITE without immediate interaction with the server. 1.4. General Definitions The following definitions are provided for the purpose of providing an appropriate context for the reader. Absent File System: A file system is "absent" when a namespace component does not have a backing file system. Byte: In this document, a byte is an octet, i.e., a datum exactly 8 bits in length. Client: The client is the entity that accesses the NFS server's resources. The client may be an application that contains the logic to access the NFS server directly. The client may also be the traditional operating system client that provides remotefilesystemfile system services for a set of applications. With reference to byte-range locking, the client is also the entity that maintains a set of locks on behalf of one or more applications. This client is responsible for crash or failure recovery for those locks it manages. Note that multiple clients may share the same transport and connection and multiple clients may exist on the same network node. Client ID: A 64-bit quantity used as a unique, short-hand reference to a client supplied Verifier and ID. The server is responsible for supplying the Client ID. File System: The file system is the collection of objects on a server that share the same fsid attribute (see Section 5.8.1.9). Lease: An interval of time defined by the server for which the client is irrevocably granted a lock. At the end of a lease period the lock may be revoked if the lease has not been extended. The lock must be revoked if a conflicting lock has been granted after the lease interval. All leases granted by a server have the same fixed interval. Note that the fixed interval was chosen to alleviate the expense a server would have in maintaining state about variable length leases across server failures. Lock: The term "lock" is used to refer to both record (byte-range) locks as well as share reservations unless specifically stated otherwise. Server: The "Server" is the entity responsible for coordinating client access to a set offilesystems.file systems. Stable Storage: NFSv4 servers must be able to recover without data loss from multiple power failures (including cascading power failures, that is, several power failures in quick succession), operating system failures, and hardware failure of components other than the storage medium itself (for example, disk, nonvolatile RAM). Some examples of stable storage that are allowable for an NFS server include: (1) Media commit of data, that is, the modified data has been successfully written to the disk media, for example, the disk platter. (2) An immediate reply disk drive with battery-backed on-drive intermediate storage or uninterruptible power system (UPS). (3) Server commit of data with battery-backed intermediate storage and recovery software. (4) Cache commit with uninterruptible power system (UPS) and recovery software. Stateid: A stateid is a 128-bit quantity returned by a server that uniquely identifies the open and locking states provided by the server for a specific open-owner or lock-owner/open-owner pair for a specific file and type of lock. Verifier: A 64-bit quantity generated by the client that the server can use to determine if the client has restarted and lost all previous lock state. 1.5. Changes since RFC 3530 The main changes from RFC 3530 [RFC3530] are: o The XDR definition has been moved to a companion document [I-D.ietf-nfsv4-rfc3530bis-dot-x] o Updates for the latest IETF intellectual property statements o There is a restructured and more complete explanation of multi- server namespace features.In particular, this explanation explicitly describes handling of inter-server referrals, even where neither migration nor replication is involved. o More liberal handling of internationalization for file names and user and group names, with the elimination of restrictions imposed by stringprep, with the recognition that rules for the forms of these name are the province of the receiving entity.o Updating handling of domain names to reflectIDNAInternationalized Domain Names in Applications (IDNA) [RFC5891]. oRestructuring of string types to more appropriately reflect the reality of required string processing. oThe previously required LIPKEY and SPKM-3 security mechanisms have been removed. o Some clarification on a client re-establishing callback information to the new server if state has been migrated. o A third edge case was added for Courtesy locks and network partitions. o The definition of stateid was strengthened. 1.6. Changes since RFC 3010 This definition of the NFSv4 protocol replaces or obsoletes the definition present in [RFC3010]. While portions of the two documents have remained the same, there have been substantive changes in others. The changes made between [RFC3010] and this document represent implementation experience and further review of the protocol. While some modifications were made for ease of implementation or clarification, most updates represent errors or situations where the [RFC3010] definition were untenable. The following list is not all inclusive of all changes but presents some of the most notable changes or additions made: o The state model has added an open_owner4 identifier. This was done to accommodate Posix based clients and the model they use for file locking. For Posix clients, an open_owner4 would correspond to a file descriptor potentially shared amongst a set of processes and the lock_owner4 identifier would correspond to a process that is locking a file. o Clarifications and error conditions were added for the handling of the owner and group attributes. Since these attributes are string based (as opposed to the numeric uid/gid of previous versions of NFS), translations may not be available and hence the changes made. o Clarifications for the ACL and mode attributes to address evaluation and partial support. o For identifiers that are defined as XDR opaque, limits were set on their size. o Added the mounted_on_fileid attribute to allow Posix clients to correctly construct local mounts. o Modified the SETCLIENTID/SETCLIENTID_CONFIRM operations to deal correctly with confirmation details along with adding the ability to specify new client callback information. Also added clarification of the callback information itself. o Added a new operation RELEASE_LOCKOWNER to enable notifying the server that a lock_owner4 will no longer be used by the client. o RENEW operation changes to identify the client correctly and allow for additional error returns. o Verify error return possibilities for all operations. o Remove use of the pathname4 data type from LOOKUP and OPEN in favor of having the client construct a sequence of LOOKUP operations to achieve the same effect.o Clarification of the internationalization issues and adoption of the new stringprep profile framework.2. Protocol Data Types The syntax and semantics to describe the data types of the NFS version 4 protocol are defined in the XDR [RFC4506] and RPC [RFC5531] documents. The next sections build upon the XDR data types to define types and structures specific to this protocol. 2.1. Basic Data Types These are the base NFSv4 data types.+----------------------+--------------------------------------------++-----------------+-------------------------------------------------+ | Data Type | Definition |+----------------------+--------------------------------------------++-----------------+-------------------------------------------------+ | int32_t | typedef int int32_t; | | uint32_t | typedef unsigned int uint32_t; | | int64_t | typedef hyper int64_t; | | uint64_t | typedef unsigned hyper uint64_t; | | attrlist4 | typedef opaque attrlist4<>; | | | Used for file/directory attributes. | | bitmap4 | typedef uint32_t bitmap4<>; | | | Used in attribute array encoding. | | changeid4 | typedef uint64_t changeid4; | | | Used in the definition of change_info4. | | clientid4 | typedef uint64_t clientid4; | | | Shorthand reference to client| | |identification. | | count4 | typedef uint32_t count4; | | | Various count parameters (READ, WRITE,| | |COMMIT). | | length4 | typedef uint64_t length4; | | | Describes LOCK lengths. | | mode4 | typedef uint32_t mode4; | | | Mode attribute data type. | | nfs_cookie4 | typedef uint64_t nfs_cookie4; | | | Opaque cookie value for READDIR. | | nfs_fh4 | typedef opaque nfs_fh4<NFS4_FHSIZE>; | | | Filehandle definition. | | nfs_ftype4 | enum nfs_ftype4; | | | Various defined file types. | | nfsstat4 | enum nfsstat4; | | | Return value for operations. | | offset4 | typedef uint64_t offset4; | | | Various offset designations (READ, WRITE, LOCK, | | |LOCK,COMMIT). | | qop4 | typedef uint32_t qop4; | | | Quality of protection designation in| | |SECINFO. | | sec_oid4 | typedef opaque sec_oid4<>; | | | Security Object Identifier. The sec_oid4 data | | |datatype is not really opaque. Instead it contains | | |it containsan ASN.1 OBJECT IDENTIFIER as| | |used by GSS-API | | | in the mech_type argument to | | |toGSS_Init_sec_context. See [RFC2743] for | | |fordetails. | | seqid4 | typedef uint32_t seqid4; | | | Sequence identifier used for file locking. | | utf8string | typedef opaque utf8string<>; | | | UTF-8 encoding for strings. | |utf8_expectedutf8str_cis | typedef utf8stringutf8_expected;utf8str_cis; | | |String expected to beCase-insensitive UTF-8but no | | | validationstring. | |utf8val_RECOMMENDED4utf8str_cs | typedef utf8stringutf8val_RECOMMENDED4;utf8str_cs; | | |String SHOULD be sentCase-sensitive UTF-8and SHOULD be | | | validatedstring. | |utf8val_REQUIRED4utf8str_mixed | typedef utf8stringutf8val_REQUIRED4;utf8str_mixed; | | |String MUST be sentUTF-8 strings with a case-sensitive prefix andMUST be| | |validateda case-insensitive suffix. | |ascii_REQUIRED4component4 | typedefutf8string ascii_REQUIRED4; | | | String MUST be sent as ASCII and thus isutf8str_cs component4; | | |automatically UTF-8Represents pathname components. | |comptag4linktext4 | typedefutf8_expected comptag4;utf8str_cs linktext4; | | |Tag should be UTF-8 butSymbolic link contents ("symbolic link" isnot checked| |component4|typedef utf8val_RECOMMENDED4 component4;defined in an Open Group [openg_symlink] | | |Represents path name components.standard). | |linktext4ascii_REQUIRED4 | typedefutf8val_RECOMMENDED4 linktext4;utf8string ascii_REQUIRED4; | | |Symbolic link contents.String MUST be sent as ASCII and thus is | | | automatically UTF-8. | | pathname4 | typedef component4 pathname4<>; | | | Represents path name for fs_locations. | | nfs_lockid4 | typedef uint64_t nfs_lockid4; | | verifier4 | typedef opaque| | |verifier4[NFS4_VERIFIER_SIZE]; | | | Verifier used for various operations (COMMIT, | | |(COMMIT,CREATE, OPEN, READDIR, WRITE) | | | NFS4_VERIFIER_SIZE is defined as 8. |+----------------------+--------------------------------------------++-----------------+-------------------------------------------------+ End of Base Data Types Table 1 2.2. Structured Data Types 2.2.1. nfstime4 struct nfstime4 { int64_t seconds; uint32_t nseconds; }; The nfstime4 structure gives the number of seconds and nanoseconds since midnight or 0 hour January 1, 1970 Coordinated Universal Time (UTC). Values greater than zero for the seconds field denote dates after the 0 hour January 1, 1970. Values less than zero for the seconds field denote dates before the 0 hour January 1, 1970. In both cases, the nseconds field is to be added to the seconds field for the final time representation. For example, if the time to be represented is one-half second before 0 hour January 1, 1970, the seconds field would have a value of negative one (-1) and the nseconds fields would have a value of one-half second (500000000). Values greater than 999,999,999 for nseconds are considered invalid. This data type is used to pass time and date information. A server converts to and from its local representation of time when processing time values, preserving as much accuracy as possible. If the precision of timestamps stored for afilesystemfile system object is less than defined, loss of precision can occur. An adjunct time maintenance protocol is recommended to reduce client and server time skew. 2.2.2. time_how4 enum time_how4 { SET_TO_SERVER_TIME4 = 0, SET_TO_CLIENT_TIME4 = 1 }; 2.2.3. settime4 union settime4 switch (time_how4 set_it) { case SET_TO_CLIENT_TIME4: nfstime4 time; default: void; }; The above definitions are used as the attribute definitions to set time values. If set_it is SET_TO_SERVER_TIME4, then the server uses its local representation of time for the time value. 2.2.4. specdata4 struct specdata4 { uint32_t specdata1; /* major device number */ uint32_t specdata2; /* minor device number */ }; This data type represents additional information for the device file types NF4CHR and NF4BLK. 2.2.5. fsid4 struct fsid4 { uint64_t major; uint64_t minor; }; This type is thefilesystemfile system identifier that is used as a mandatory attribute. 2.2.6. fs_location4 struct fs_location4 {utf8val_REQUIRED4utf8str_cis server<>; pathname4 rootpath; }; 2.2.7. fs_locations4 struct fs_locations4 { pathname4 fs_root; fs_location4 locations<>; }; The fs_location4 and fs_locations4 data types are used for the fs_locations recommended attribute which is used for migration and replication support. 2.2.8. fattr4 struct fattr4 { bitmap4 attrmask; attrlist4 attr_vals; }; The fattr4 structure is used to represent file and directory attributes. The bitmap is a counted array of 32 bit integers used to contain bit values. The position of the integer in the array that contains bit n can be computed from the expression (n / 32) and its bit within that integer is (n mod 32). 0 1 +-----------+-----------+-----------+-- | count | 31 .. 0 | 63 .. 32 | +-----------+-----------+-----------+-- 2.2.9. change_info4 struct change_info4 { bool atomic; changeid4 before; changeid4 after; }; This structure is used with the CREATE, LINK, REMOVE, RENAME operations to let the client know the value of the change attribute for the directory in which the targetfilesystemfile system object resides. 2.2.10. clientaddr4 struct clientaddr4 { /* see struct rpcb in RFC 1833 */ string r_netid<>; /* network id */ string r_addr<>; /* universal address */ }; The clientaddr4 structure is used as part of the SETCLIENTID operation to either specify the address of the client that is using a client ID or as part of the callback registration. The r_netid and r_addr fields respectively contain a netid and uaddr. The netid and uaddr concepts are defined in [RFC5665]. The netid and uaddr formats for TCP over IPv4 and TCP over IPv6 are defined in [RFC5665], specifically Tables 2 and 3 and Sections 5.2.3.3 and 5.2.3.4. 2.2.11. cb_client4 struct cb_client4 { unsigned int cb_program; clientaddr4 cb_location; }; This structure is used by the client to inform the server of its call back address; includes the program number and client address. 2.2.12. nfs_client_id4 struct nfs_client_id4 { verifier4 verifier; opaque id<NFS4_OPAQUE_LIMIT>; }; This structure is part of the arguments to the SETCLIENTID operation.NFS4_OPAQUE_LIMIT is defined as 1024.2.2.13. open_owner4 struct open_owner4 { clientid4 clientid; opaque owner<NFS4_OPAQUE_LIMIT>; }; This structure is used to identify the owner of open state.NFS4_OPAQUE_LIMIT is defined as 1024.2.2.14. lock_owner4 struct lock_owner4 { clientid4 clientid; opaque owner<NFS4_OPAQUE_LIMIT>; }; This structure is used to identify the owner of file locking state.NFS4_OPAQUE_LIMIT is defined as 1024.2.2.15. open_to_lock_owner4 struct open_to_lock_owner4 { seqid4 open_seqid; stateid4 open_stateid; seqid4 lock_seqid; lock_owner4 lock_owner; }; This structure is used for the first LOCK operation done for an open_owner4. It provides both the open_stateid and lock_owner such that the transition is made from a valid open_stateid sequence to that of the new lock_stateid sequence. Using this mechanism avoids the confirmation of the lock_owner/lock_seqid pair since it is tied to established state in the form of the open_stateid/open_seqid. 2.2.16. stateid4 struct stateid4 { uint32_t seqid; opaqueother[12];other[NFS4_OTHER_SIZE]; }; This structure is used for the various state sharing mechanisms between the client and server. For the client, this data structure is read-only. The server is required to increment the seqid field monotonically at each transition of the stateid. This is important since the client will inspect the seqid in OPEN stateids to determine the order of OPEN processing done by the server. 3. RPC and Security Flavor The NFSv4 protocol is aRemote Procedure Call (RPC)RPC application that uses RPC version 2 and thecorresponding eXternal Data Representation (XDR)XDR as defined in [RFC5531] and [RFC4506]. The RPCSEC_GSS securityflavorflavors as defined in[RFC2203]version 1 ([RFC2203]) and version 2 ([RFC5403]) MUST be implemented as the mechanism to deliver stronger security for the NFSv4 protocol. However, deployment of RPCSEC_GSS is optional. 3.1. Ports and Transports Historically, NFSv2 and NFSv3 servers have resided on port 2049. The registered port 2049 [RFC3232] for the NFS protocol SHOULD be the default configuration. Using the registered port for NFS services means the NFS client will not need to use the RPC binding protocols as described in [RFC1833]; this will allow NFS to transit firewalls. Where an NFSv4 implementation supports operation over the IP network protocol, the supportedtransportstransport layer between NFS and IP MUST beamong the IETF-approved congestion controlan IETF standardised transportprotocols, whichprotocol that is specified to avoid network congestion; such transports include TCP and SCTP. To enhance the possibilities for interoperability, an NFSv4 implementation MUST support operation over the TCP transport protocol, at least until such time as a standards track RFC revises this requirement to use a differentIETF-approved congestion controlIETF standardised transportprotocol.protocol with appropriate congestion control. If TCP is used as the transport, the client and server SHOULD use persistent connections. This will prevent the weakening of TCP's congestion control via short lived connections and will improve performance for theWANWide Area Network (WAN) environment by eliminating the need for SYN handshakes. To date, all NFSv4 implementations are TCP based, i.e., there are none for SCTP nor UDP. UDP by itself is not sufficient as a transport for NFSv4, neither is UDP in combination with some other mechanism (e.g., DCCP [RFC4340], NORM [RFC5740]). As noted in Section 17, the authentication model for NFSv4 has moved from machine-based to principal-based. However, this modification of the authentication model does not imply a technical requirement to move the TCP connection management model from whole machine-based to one based on a per user model. In particular, NFS over TCP client implementations have traditionally multiplexed traffic for multiple users over a common TCP connection between an NFS client and server. This has been true, regardless of whether the NFS client is using AUTH_SYS, AUTH_DH, RPCSEC_GSS or any other flavor. Similarly, NFS over TCP server implementations have assumed such a model and thus scale the implementation of TCP connection management in proportion to the number of expected client machines. It is intended that NFSv4 will not modify this connection management model. NFSv4 clients that violate this assumption can expect scaling issues on the server and hence reduced service.Note that for various timers, the client and server should avoid inadvertent synchronization of those timers. For further discussion of the general issue refer to [Floyd].3.1.1. Client Retransmission Behavior When processing a NFSv4 request received over a reliable transport such as TCP, the NFSv4 server MUST NOT silently drop the request, except if the established transport connection has been broken. Given such a contract between NFSv4 clients and servers, clients MUST NOT retry a request unless one or both of the following are true: o The transport connection has been broken o The procedure being retried is the NULL procedure Since reliable transports, such as TCP, do not always synchronously inform a peer when the other peer has broken the connection (for example, when an NFS server reboots), the NFSv4 client may want to actively "probe" the connection to see if has been broken. Use of the NULL procedure is one recommended way to do so. So, when a client experiences a remote procedure call timeout (of some arbitrary implementation specific amount), rather than retrying the remote procedure call, it could instead issue a NULL procedure call to the server. If the server has died, the transport connection break will eventually be indicated to the NFSv4 client. The client can then reconnect, and then retry the original request. If the NULL procedure call gets a response, the connection has not broken. The client can decide to wait longer for the original request's response, or it can break the transport connection and reconnect before re- sending the original request. For callbacks from the server to the client, the same rules apply, but the server doing the callback becomes the client, and the client receiving the callback becomes the server. 3.2. Security Flavors Traditional RPC implementations have included AUTH_NONE, AUTH_SYS, AUTH_DH, and AUTH_KRB4 as security flavors. With [RFC2203] an additional security flavor of RPCSEC_GSS has been introduced which uses the functionality of GSS-API [RFC2743]. This allows for the use of various security mechanisms by the RPC layer without the additional implementation overhead of adding RPC security flavors. For NFSv4, the RPCSEC_GSS security flavor MUST be used to enable the mandatory security mechanism. Other flavors, such as, AUTH_NONE, AUTH_SYS, and AUTH_DH MAY be implemented as well. 3.2.1. Security mechanisms for NFSv4 RPCSEC_GSS, via GSS-API, normalizes access to mechanisms that provide security services. Therefore, NFSv4 clients and servers MUST support the Kerberos V5 security mechanism. The use of RPCSEC_GSS requires selection of mechanism, quality of protection (QOP), and service (authentication, integrity, privacy). For the mandated security mechanisms, NFSv4 specifies that a QOP of zero is used, leaving it up to the mechanism or the mechanism's configuration to map QOP zero to an appropriate level of protection. Each mandated mechanism specifies a minimum set of cryptographic algorithms for implementing integrity and privacy. NFSv4 clients and servers MUST be implemented on operating environments that comply with the REQUIRED cryptographic algorithms of each REQUIRED mechanism. 3.2.1.1. Kerberos V5 as asecurity tripleSecurity Triple The Kerberos V5 GSS-API mechanism as described in [RFC4121] MUST be implemented with the RPCSEC_GSS services as specified in the following table: column descriptions: 1 == number of pseudo flavor 2 == name of pseudo flavor 3 == mechanism's OID 4 == RPCSEC_GSS service 5 == NFSv4 clients MUST support 6 == NFSv4 servers MUST support 1 2 3 4 5 6 ------------------------------------------------------------------ 390003 krb5 1.2.840.113554.1.2.2 rpc_gss_svc_none yes yes 390004 krb5i 1.2.840.113554.1.2.2 rpc_gss_svc_integrity yes yes 390005 krb5p 1.2.840.113554.1.2.2 rpc_gss_svc_privacy no yes Note that the pseudo flavor is presented here as a mapping aid to the implementor. Because this NFS protocol includes a method to negotiate security and it understands the GSS-API mechanism, the pseudo flavor is not needed. The pseudo flavor is needed for NFSv3 since the security negotiation is done via the MOUNT protocol as described in [RFC2623]. At the time this document was specified, the Advanced Encryption Standard (AES) with HMAC-SHA1 was a REQUIRED algorithm set for Kerberos V5. In contrast, when NFSv4.0 was first specified in [RFC3530], weaker algorithm sets were REQUIRED for Kerberos V5, and were REQUIRED in the NFSv4.0 specification, because the Kerberos V5 specification at the time did not specify stronger algorithms. The NFSv4 specification does not specify REQUIRED algorithms for Kerberos V5, and instead, the implementor is expected to track the evolution of the Kerberos V5 standard if and when stronger algorithms are specified. 3.2.1.1.1. Security Considerations for Cryptographic Algorithms in Kerberos V5 When deploying NFSv4, the strength of the security achieved depends on the existing Kerberos V5 infrastructure. The algorithms of Kerberos V5 are not directly exposed to or selectable by the client or server, so there is some due diligence required by the user of NFSv4 to ensure that security is acceptable where needed. Guidance is provided in [RFC6649] as to why weak algorithms should be disabled by default. 3.3. Security Negotiation With the NFSv4 server potentially offering multiple security mechanisms, the client needs a method to determine or negotiate which mechanism is to be used for its communication with the server. The NFS server may have multiple points within itsfilesystemfile system name space that are available for use by NFS clients. In turn the NFS server may be configured such that each of these entry points may have different or multiple security mechanisms in use. The security negotiation between client and server SHOULD be done with a secure channel to eliminate the possibility of a third party intercepting the negotiation sequence and forcing the client and server to choose a lower level of security than required or desired. See Section 17 for further discussion. 3.3.1. SECINFO The new SECINFO operation will allow the client to determine, on a per filehandle basis, what security triple (see [RFC2743]) is to be used for server access. In general, the client will not have to use the SECINFO operation except during initial communication with the server or when the client crosses policy boundaries at the server. It is possible that the server's policies change during the client's interaction therefore forcing the client to negotiate a new security triple. 3.3.2. Security Error Based on the assumption that each NFSv4 client and server MUST support a minimum set of security (i.e., Kerberos-V5 under RPCSEC_GSS), the NFS client will start its communication with the server with one of the minimal security triples. During communication with the server, the client may receive an NFS error of NFS4ERR_WRONGSEC. This error allows the server to notify the client that the security triple currently being used is not appropriate for access to the server'sfilesystemfile system resources. The client is then responsible for determining what security triples are available at the server and choose one which is appropriate for the client. See Section 15.33 for further discussion of how the client will respond to the NFS4ERR_WRONGSEC error and use SECINFO. 3.3.3. Callback RPC Authentication Except as noted elsewhere in this section, the callback RPC (described later) MUST mutually authenticate the NFS server to the principal that acquired the client ID (also described later), using the security flavor the original SETCLIENTID operation used. For AUTH_NONE, there are no principals, so this is a non-issue. AUTH_SYS has no notions of mutual authentication or a server principal, so the callback from the server simply uses the AUTH_SYS credential that the user used when he set up the delegation. For AUTH_DH, one commonly used convention is that the server uses the credential corresponding to this AUTH_DH principal: unix.host@domain where host and domain are variables corresponding to the name of server host and directory services domain in which it lives such as a Network Information System domain or a DNS domain. Regardless of what security mechanism under RPCSEC_GSS is being used, the NFS server MUST identify itself in GSS-API via a GSS_C_NT_HOSTBASED_SERVICE name type. GSS_C_NT_HOSTBASED_SERVICE names are of the form: service@hostname For NFS, the "service" element is nfs Implementations of security mechanisms will convert nfs@hostname to various different forms. For Kerberos V5, the following form is RECOMMENDED: nfs/hostname For Kerberos V5, nfs/hostname would be a server principal in the Kerberos Key Distribution Center database. This is the same principal the client acquired a GSS-API context for when it issued the SETCLIENTID operation, therefore, the realm name for the server principal must be the same for the callback as it was for the SETCLIENTID. 4. Filehandles The filehandle in the NFS protocol is a per server unique identifier for afilesystemfile system object. The contents of the filehandle are opaque to the client. Therefore, the server is responsible for translating the filehandle to an internal representation of thefilesystemfile system object. 4.1. Obtaining the First Filehandle The operations of the NFS protocol are defined in terms of one or more filehandles. Therefore, the client needs a filehandle to initiate communication with the server. With the NFSv2 protocol [RFC1094] and the NFSv3 protocol [RFC1813], there exists an ancillary protocol to obtain this first filehandle. The MOUNT protocol, RPC program number 100005, provides the mechanism of translating a string basedfilesystemfile system path name to a filehandle which can then be used by the NFS protocols. The MOUNT protocol has deficiencies in the area of security and use via firewalls. This is one reason that the use of the public filehandle was introduced in [RFC2054] and [RFC2055]. With the use of the public filehandle in combination with the LOOKUP operation in the NFSv2 and NFSv3 protocols, it has been demonstrated that the MOUNT protocol is unnecessary for viable interaction between NFS client and server. Therefore, the NFSv4 protocol will not use an ancillary protocol for translation from string based path names to a filehandle. Two special filehandles will be used as starting points for the NFS client. 4.1.1. Root Filehandle The first of the special filehandles is the ROOT filehandle. The ROOT filehandle is the "conceptual" root of thefilesystemfile system name space at the NFS server. The client uses or starts with the ROOT filehandle by employing the PUTROOTFH operation. The PUTROOTFH operation instructs the server to set the "current" filehandle to the ROOT of the server's file tree. Once this PUTROOTFH operation is used, the client can then traverse the entirety of the server's file tree with the LOOKUP operation. A complete discussion of the server name space is in Section8.7. 4.1.2. Public Filehandle The second special filehandle is the PUBLIC filehandle. Unlike the ROOT filehandle, the PUBLIC filehandle may be bound or represent an arbitraryfilesystemfile system object at the server. The server is responsible for this binding. It may be that the PUBLIC filehandle and the ROOT filehandle refer to the samefilesystemfile system object. However, it is up to the administrative software at the server and the policies of the server administrator to define the binding of the PUBLIC filehandle and serverfilesystemfile system object. The client may not make any assumptions about this binding. The client uses the PUBLIC filehandle via the PUTPUBFH operation. 4.2. Filehandle Types In the NFSv2 and NFSv3 protocols, there was one type of filehandle with a single set of semantics. This type of filehandle is termed "persistent" in NFS Version 4. The semantics of a persistent filehandle remain the same as before. A new type of filehandle introduced in NFS Version 4 is the "volatile" filehandle, which attempts to accommodate certain server environments. The volatile filehandle type was introduced to address server functionality or implementation issues which make correct implementation of a persistent filehandle infeasible. Some server environments do not provide afilesystemfile system level invariant that can be used to construct a persistent filehandle. The underlying serverfilesystemfile system may not provide the invariant or the server'sfilesystemfile system programming interfaces may not provide access to the needed invariant. Volatile filehandles may ease the implementation of server functionality such as hierarchical storage management orfilesystemfile system reorganization or migration. However, the volatile filehandle increases the implementation burden for the client. Since the client will need to handle persistent and volatile filehandles differently, a file attribute is defined which may be used by the client to determine the filehandle types being returned by the server. 4.2.1. General Properties of a Filehandle The filehandle contains all the information the server needs to distinguish an individual file. To the client, the filehandle is opaque. The client stores filehandles for use in a later request and can compare two filehandles from the same server for equality by doing a byte-by-byte comparison. However, the client MUST NOT otherwise interpret the contents of filehandles. If two filehandles from the same server are equal, they MUST refer to the samefile.file system object. Servers SHOULD try to maintain a one-to-one correspondence between filehandles andfilesfile system objects but this is not required. Clients MUST use filehandle comparisons only to improve performance, not for correct behavior. All clients need to be prepared for situations in which it cannot be determined whether two filehandles denote the same object and in such cases, avoid making invalid assumptions which might cause incorrect behavior. Further discussion of filehandle and attribute comparison in the context of data caching is presented in Section 10.3.4. As an example, in the case that two different path names when traversed at the server terminate at the samefilesystemfile system object, the server SHOULD return the same filehandle for each path. This can occur if a hard link is used to create two file names which refer to the same underlying file object and associated data. For example, if paths /a/b/c and /a/d/c refer to the same file, the server SHOULD return the same filehandle for both path names traversals. 4.2.2. Persistent Filehandle A persistent filehandle is defined as having a fixed value for the lifetime of thefilesystemfile system object to which it refers. Once the server creates the filehandle for afilesystemfile system object, the server MUST accept the same filehandle for the object for the lifetime of the object. If the server restarts or reboots the NFS server must honor the same filehandle value as it did in the server's previous instantiation. Similarly, if thefilesystemfile system is migrated, the new NFS server must honor the same filehandle as the old NFS server. The persistent filehandle will be become stale or invalid when thefilesystemfile system object is removed. When the server is presented with a persistent filehandle that refers to a deleted object, it MUST return an error of NFS4ERR_STALE. A filehandle may become stale when thefilesystemfile system containing the object is no longer available. The file system may become unavailable if it exists on removable media and the media is no longer available at the server or thefilesystemfile system in whole has been destroyed or thefilesystemfile system has simply been removed from the server's name space (i.e., unmounted in a UNIX environment). 4.2.3. Volatile Filehandle A volatile filehandle does not share the same longevity characteristics of a persistent filehandle. The server may determine that a volatile filehandle is no longer valid at many different points in time. If the server can definitively determine that a volatile filehandle refers to an object that has been removed, the server should return NFS4ERR_STALE to the client (as is the case for persistent filehandles). In all other cases where the server determines that a volatile filehandle can no longer be used, it should return an error of NFS4ERR_FHEXPIRED. The mandatory attribute "fh_expire_type" is used by the client to determine what type of filehandle the server is providing for a particularfilesystem.file system. This attribute is a bitmask with the following values: FH4_PERSISTENT: The value of FH4_PERSISTENT is used to indicate a persistent filehandle, which is valid until the object is removed from thefilesystem.file system. The server will not return NFS4ERR_FHEXPIRED for this filehandle. FH4_PERSISTENT is defined as a value in which none of the bits specified below are set. FH4_VOLATILE_ANY: The filehandle may expire at any time, except as specifically excluded (i.e., FH4_NOEXPIRE_WITH_OPEN). FH4_NOEXPIRE_WITH_OPEN: May only be set when FH4_VOLATILE_ANY is set. If this bit is set, then the meaning of FH4_VOLATILE_ANY is qualified to exclude any expiration of the filehandle when it is open. FH4_VOL_MIGRATION: The filehandle will expire as a result of migration. If FH4_VOLATILE_ANY is set, FH4_VOL_MIGRATION is redundant. FH4_VOL_RENAME: The filehandle will expire during rename. This includes a rename by the requesting client or a rename by any other client. If FH4_VOLATILE_ANY is set, FH4_VOL_RENAME is redundant. Servers which provide volatile filehandles that may expire while open (i.e., if FH4_VOL_MIGRATION or FH4_VOL_RENAME is set or if FH4_VOLATILE_ANY is set and FH4_NOEXPIRE_WITH_OPEN not set), should deny a RENAME or REMOVE that would affect an OPEN file of any of the components leading to the OPEN file. In addition, the server should deny all RENAME or REMOVE requests during the grace period upon server restart. Note that the bits FH4_VOL_MIGRATION and FH4_VOL_RENAME allow the client to determine that expiration has occurred whenever a specific event occurs, without an explicit filehandle expiration error from the server. FH4_VOLATILE_ANY does not provide this form of information. In situations where the server will expire many, but not all filehandles upon migration (e.g., all but those that are open), FH4_VOLATILE_ANY (in this case with FH4_NOEXPIRE_WITH_OPEN) is a better choice since the client may not assume that all filehandles will expire when migration occurs, and it is likely that additional expirations will occur (as a result of file CLOSE) that are separated in time from the migration event itself. 4.2.4. One Method of Constructing a Volatile Filehandle A volatile filehandle, while opaque to the client could contain: [volatile bit = 1 | server boot time | slot | generation number] o slot is an index in the server volatile filehandle table o generation number is the generation number for the table entry/ slot When the client presents a volatile filehandle, the server makes the following checks, which assume that the check for the volatile bit has passed. If the server boot time is less than the current server boot time, return NFS4ERR_FHEXPIRED. If slot is out of range, return NFS4ERR_BADHANDLE. If the generation number does not match, return NFS4ERR_FHEXPIRED. When the server reboots, the table is gone (it is volatile). If volatile bit is 0, then it is a persistent filehandle with a different structure following it. 4.3. Client Recovery from Filehandle Expiration If possible, the clientSHOULDshould recover from the receipt of an NFS4ERR_FHEXPIRED error. The client must take on additional responsibility so that it may prepare itself to recover from the expiration of a volatile filehandle. If the server returns persistent filehandles, the client does not need these additional steps. For volatile filehandles, most commonly the client will need to store the component names leading up to and including thefilesystemfile system object in question. With these names, the client should be able to recover by finding a filehandle in the name space that is still available or by starting at the root of the server'sfilesystemfile system name space. If the expired filehandle refers to an object that has been removed from thefilesystem,file system, obviously the client will not be able to recover from the expired filehandle. It is also possible that the expired filehandle refers to a file that has been renamed. If the file was renamed by another client, again it is possible that the original client will not be able to recover. However, in the case that the client itself is renaming the file and the file is open, it is possible that the client may be able to recover. The client can determine the new path name based on the processing of the rename request. The client can then regenerate the new filehandle based on the new path name. The client could also use the compound operation mechanism to construct a set of operations like: RENAME A B LOOKUP B GETFH Note that the COMPOUND procedure does not provide atomicity. This example only reduces the overhead of recovering from an expired filehandle. 5.FileAttributes To meet the requirements of extensibility and increased interoperability with non-UNIX platforms, attributes need to be handled in a flexible manner. The NFSv3 fattr3 structure contains a fixed list of attributes that not all clients and servers are able to support or care about. The fattr3 structure cannot be extended as new needs arise and it provides no way to indicate non-support. With the NFSv4.0 protocol, the client is able to query what attributes the server supports and construct requests with only those supported attributes (or a subset thereof). To this end, attributes are divided into three groups: REQUIRED, RECOMMENDED, and named. Both REQUIRED and RECOMMENDED attributes are supported in the NFSv4.0 protocol by a specific and well-defined encoding and are identified by number. They are requested by setting a bit in the bit vector sent in the GETATTR request; the server response includes a bit vector to list what attributes were returned in the response. New REQUIRED or RECOMMENDED attributes may be added to the NFSv4 protocol as part of a new minor version by publishing a Standards Track RFC which allocates a new attribute number value and defines the encoding for the attribute. See Section 11 for further discussion. Named attributes are accessed by thenewOPENATTR operation, which accesses a hidden directory of attributes associated with a file system object. OPENATTR takes a filehandle for the object and returns the filehandle for the attribute hierarchy. The filehandle for the named attributes is a directory object accessible by LOOKUP or READDIR and contains files whose names represent the named attributes and whose data bytes are the value of the attribute. For example: +----------+-----------+---------------------------------+ | LOOKUP | "foo" | ; look up file | | GETATTR | attrbits | | | OPENATTR | | ; access foo's named attributes | | LOOKUP | "x11icon" | ; look up specific attribute | | READ | 0,4096 | ; read stream of bytes | +----------+-----------+---------------------------------+ Named attributes are intended for data needed by applications rather than by an NFS client implementation. NFS implementors are strongly encouraged to define their new attributes as RECOMMENDED attributes by bringing them to the IETF Standards Track process. The set of attributes that are classified as REQUIRED is deliberately small since servers need to do whatever it takes to support them. A server should support as many of the RECOMMENDED attributes as possible but, by their definition, the server is not required to support all of them. Attributes are deemed REQUIRED if the data is both needed by a large number of clients and is not otherwise reasonably computable by the client when support is not provided on the server. Note that the hidden directory returned by OPENATTR is a convenience for protocol processing. The client should not make any assumptions about the server's implementation of named attributes and whether or not the underlying file system at the server has a named attribute directory. Therefore, operations such as SETATTR and GETATTR on the named attribute directory are undefined. 5.1. REQUIRED Attributes These MUST be supported by every NFSv4.0 client and server in order to ensure a minimum level of interoperability. The server MUST store and return these attributes, and the client MUST be able to function with an attribute set limited to these attributes. With just the REQUIRED attributes some client functionality may be impaired or limited in some ways. A client may ask for any of these attributes to be returned by setting a bit in the GETATTR request, and the servermustMUST return their value. 5.2. RECOMMENDED Attributes These attributes are understood well enough to warrant support in the NFSv4.0 protocol. However, they may not be supported on all clients and servers. A client MAY ask for any of these attributes to be returned by setting a bit in the GETATTR request but must handle the case where the server does not return them. A client MAY ask for the set of attributes the server supports and SHOULD NOT request attributes the server does not support. A server should be tolerant of requests for unsupported attributes and simply not return them rather than considering the request an error. It is expected that servers will support all attributes they comfortably can and only fail to support attributes that are difficult to support in their operating environments. A server should provide attributes whenever they don't have to "tell lies" to the client. For example, a file modification time should be either an accurate time or should not be supported by the server. At times this will be difficult for clients, but a client is better positioned to decide whether and how to fabricate or construct an attribute or whether to do without the attribute. 5.3. Named Attributes These attributes are not supported by direct encoding in the NFSv4 protocol but are accessed by string names rather than numbers and correspond to an uninterpreted stream of bytes that are stored with the file system object. The name space for these attributes may be accessed by using the OPENATTR operation. The OPENATTR operation returns a filehandle for a virtual "named attribute directory", and further perusal and modification of the name space may be done using operations that work on more typical directories. In particular, READDIR may be used to get a list of such named attributes, and LOOKUP and OPEN may select a particular attribute. Creation of a new named attribute may be the result of an OPEN specifying file creation. Once an OPEN is done, named attributes may be examined and changed by normal READ and WRITE operations using the filehandles and stateids returned by OPEN. Named attributes and the named attribute directory may have their own (non-named) attributes. Each of these objects must have all of the REQUIRED attributes and may have additional RECOMMENDED attributes. However, the set of attributes for named attributes and the named attribute directory need not be, and typically will not be, as large as that for other objects in that file system. Named attributes might be the target of delegations. However, since granting of delegations is at the server's discretion, a server need not support delegations on named attributes. It is RECOMMENDED that servers support arbitrary named attributes. A client should not depend on the ability to store any named attributes in the server's file system. If a server does support named attributes, a client that is also able to handle them should be able to copy a file's data and metadata with complete transparency from one location to another; this would imply that names allowed for regular directory entries are valid for named attribute names as well. In NFSv4.0, the structure of named attribute directories is restricted in a number of ways, in order to prevent the development of non-interoperable implementations in which some servers support a fully general hierarchical directory structure for named attributes while others support a limited but adequate structure for named attributes. In such an environment, clients or applications might come to depend on non-portable extensions. The restrictions are: o CREATE is not allowed in a named attribute directory. Thus, such objects as symbolic links and special files are not allowed to be named attributes. Further, directories may not be created in a named attribute directory, so no hierarchical structure of named attributes for a single object is allowed. o If OPENATTR is done on a named attribute directory or on a named attribute, the server MUST return an error. o Doing a RENAME of a named attribute to a different named attribute directory or to an ordinary (i.e., non-named-attribute) directory is not allowed. o Creating hard links between named attribute directories or between named attribute directories and ordinary directories is not allowed. Names of attributes will not be controlled by this document or other IETF Standards Track documents. See Section 18 for further discussion. 5.4. Classification of Attributes Each of the REQUIRED and RECOMMENDED attributes can be classified in one of three categories: per server (i.e., the value of the attribute will be the same for all file objects that share the same server), per file system (i.e., the value of the attribute will be the same for some or all file objects that share the same fsid attribute (Section 5.8.1.9) and server owner), or per file system object. Note that it is possible that some per file system attributes may vary within the file system. Note that it is possible that some per file system attributes may vary within the file system, depending on the value of the "homogeneous" (Section 5.8.2.16) attribute. Note that the attributes time_access_set and time_modify_set are not listed in this section because they are write-only attributes corresponding to time_access and time_modify, and are used in a special instance of SETATTR. o The per-server attribute is: lease_time o The per-file system attributes are: supported_attrs, fh_expire_type, link_support, symlink_support, unique_handles, aclsupport, cansettime, case_insensitive, case_preserving, chown_restricted, files_avail, files_free, files_total, fs_locations, homogeneous, maxfilesize, maxname, maxread, maxwrite, no_trunc, space_avail, space_free, space_total, time_delta, o The per-file system object attributes are: type, change, size, named_attr, fsid, rdattr_error, filehandle, acl, archive, fileid, hidden, maxlink, mimetype, mode, numlinks, owner, owner_group, rawdev, space_used, system, time_access, time_backup, time_create, time_metadata, time_modify, mounted_on_fileid For quota_avail_hard, quota_avail_soft, and quota_used, see their definitions below for the appropriate classification. 5.5. Set-Only and Get-Only Attributes Some REQUIRED and RECOMMENDED attributes are set-only; i.e., they can be set via SETATTR but not retrieved via GETATTR. Similarly, some REQUIRED and RECOMMENDED attributes are get-only; i.e., they can be retrieved via GETATTR but not set via SETATTR. If a client attempts to set a get-only attribute or get a set-only attribute, the server MUST return NFS4ERR_INVAL. 5.6. REQUIRED Attributes - List and Definition References The list of REQUIRED attributes appears in Table 2. The meaning of the columns of the table are: o Name: The name of attribute o Id: The number assigned to the attribute. In the event of conflicts between the assigned number and [I-D.ietf-nfsv4-rfc3530bis-dot-x], the latter islikelyauthoritative, but in such an event, it should be resolved with Errata to this document and/or [I-D.ietf-nfsv4-rfc3530bis-dot-x]. See [ISEG_errata] for the Errata process. o Data Type: The XDR data type of the attribute. o Acc: Access allowed to the attribute. R means read-only (GETATTR may retrieve, SETATTR may not set). W means write-only (SETATTR may set, GETATTR may not retrieve). R W means read/write (GETATTR may retrieve, SETATTR may set). o Defined in: The section of this specification that describes the attribute. +-----------------+----+------------+-----+------------------+ | Name | Id | Data Type | Acc | Defined in: | +-----------------+----+------------+-----+------------------+ | supported_attrs | 0 | bitmap4 | R | Section 5.8.1.1 | | type | 1 | nfs_ftype4 | R | Section 5.8.1.2 | | fh_expire_type | 2 | uint32_t | R | Section 5.8.1.3 | | change | 3 | uint64_t | R | Section 5.8.1.4 | | size | 4 | uint64_t | R W | Section 5.8.1.5 | | link_support | 5 | bool | R | Section 5.8.1.6 | | symlink_support | 6 | bool | R | Section 5.8.1.7 | | named_attr | 7 | bool | R | Section 5.8.1.8 | | fsid | 8 | fsid4 | R | Section 5.8.1.9 | | unique_handles | 9 | bool | R | Section 5.8.1.10 | | lease_time | 10 | nfs_lease4 | R | Section 5.8.1.11 | | rdattr_error | 11 |enumnfsstat4 | R | Section 5.8.1.12 | | filehandle | 19 | nfs_fh4 | R | Section 5.8.1.13 | +-----------------+----+------------+-----+------------------+ Table 2 5.7. RECOMMENDED Attributes - List and Definition References The RECOMMENDED attributes are defined in Table 3. The meanings of the column headers are the same as Table 2; see Section 5.6 for the meanings. +-------------------+----+--------------+-----+------------------+ | Name | Id | Data Type | Acc | Defined in: | +-------------------+----+--------------+-----+------------------+ | acl | 12 | nfsace4<> | R W | Section 6.2.1 | | aclsupport | 13 | uint32_t | R | Section 6.2.1.2 | | archive | 14 | bool | R W | Section 5.8.2.1 | | cansettime | 15 | bool | R | Section 5.8.2.2 | | case_insensitive | 16 | bool | R | Section 5.8.2.3 | | case_preserving | 17 | bool | R | Section 5.8.2.4 | | chown_restricted | 18 | bool | R | Section 5.8.2.5 | | fileid | 20 | uint64_t | R | Section 5.8.2.6 | | files_avail | 21 | uint64_t | R | Section 5.8.2.7 | | files_free | 22 | uint64_t | R | Section 5.8.2.8 | | files_total | 23 | uint64_t | R | Section 5.8.2.9 | | fs_locations | 24 | fs_locations | R | Section 5.8.2.10 | | hidden | 25 | bool | R W | Section 5.8.2.11 | | homogeneous | 26 | bool | R | Section 5.8.2.12 | | maxfilesize | 27 | uint64_t | R | Section 5.8.2.13 | | maxlink | 28 | uint32_t | R | Section 5.8.2.14 | | maxname | 29 | uint32_t | R | Section 5.8.2.15 | | maxread | 30 | uint64_t | R | Section 5.8.2.16 | | maxwrite | 31 | uint64_t | R | Section 5.8.2.17 | | mimetype | 32 | utf8<> | R W | Section 5.8.2.18 | | mode | 33 | mode4 | R W | Section 6.2.2 | | mounted_on_fileid | 55 | uint64_t | R | Section 5.8.2.19 | | no_trunc | 34 | bool | R | Section 5.8.2.20 | | numlinks | 35 | uint32_t | R | Section 5.8.2.21 | | owner | 36 | utf8<> | R W | Section 5.8.2.22 | | owner_group | 37 | utf8<> | R W | Section 5.8.2.23 | | quota_avail_hard | 38 | uint64_t | R | Section 5.8.2.24 | | quota_avail_soft | 39 | uint64_t | R | Section 5.8.2.25 | | quota_used | 40 | uint64_t | R | Section 5.8.2.26 | | rawdev | 41 | specdata4 | R | Section 5.8.2.27 | | space_avail | 42 | uint64_t | R | Section 5.8.2.28 | | space_free | 43 | uint64_t | R | Section 5.8.2.29 | | space_total | 44 | uint64_t | R | Section 5.8.2.30 | | space_used | 45 | uint64_t | R | Section 5.8.2.31 | | system | 46 | bool | R W | Section 5.8.2.32 | | time_access | 47 | nfstime4 | R | Section 5.8.2.33 | | time_access_set | 48 | settime4 | W | Section 5.8.2.34 | | time_backup | 49 | nfstime4 | R W | Section 5.8.2.35 | | time_create | 50 | nfstime4 | R W | Section 5.8.2.36 | | time_delta | 51 | nfstime4 | R | Section 5.8.2.37 | | time_metadata | 52 | nfstime4 | R | Section 5.8.2.38 | | time_modify | 53 | nfstime4 | R | Section 5.8.2.39 | | time_modify_set | 54 | settime4 | W | Section 5.8.2.40 | +-------------------+----+--------------+-----+------------------+ Table 3 5.8. Attribute Definitions 5.8.1. Definitions of REQUIRED Attributes 5.8.1.1. Attribute 0: supported_attrs The bit vector that would retrieve all REQUIRED and RECOMMENDED attributes that are supported for this object. The scope of this attribute applies to all objects with a matching fsid. 5.8.1.2. Attribute 1: type Designates the type of an object in terms of one of a number of special constants: o NF4REG designates a regular file. o NF4DIR designates a directory. o NF4BLK designates a block device special file. o NF4CHR designates a character device special file. o NF4LNK designates a symbolic link. o NF4SOCK designates a named socket special file. o NF4FIFO designates a fifo special file. o NF4ATTRDIR designates a named attribute directory. o NF4NAMEDATTR designates a named attribute. Within the explanatory text and operation descriptions, the following phrases will be used with the meanings given below: o The phrase "is a directory" means that the object's type attribute is NF4DIR or NF4ATTRDIR. o The phrase "is a special file" means that the object's type attribute is NF4BLK, NF4CHR, NF4SOCK, or NF4FIFO. o The phrase "is an regular file" means that the object's type attribute is NF4REG or NF4NAMEDATTR. 5.8.1.3. Attribute 2: fh_expire_type Server uses this to specify filehandle expiration behavior to the client. See Section 4 for additional description. 5.8.1.4. Attribute 3: change A value created by the server that the client can use to determine if file data, directory contents, or attributes of the object have been modified. The servermayMAY return the object's time_metadata attribute for this attribute's value but only if the file system object cannot be updated more frequently than the resolution of time_metadata. 5.8.1.5. Attribute 4: size The size of the object in bytes. 5.8.1.6. Attribute 5: link_support TRUE, if the object's file system supports hard links. 5.8.1.7. Attribute 6: symlink_support TRUE, if the object's file system supports symbolic links. 5.8.1.8. Attribute 7: named_attr TRUE, if this object has named attributes. In other words, object has a non-empty named attribute directory. 5.8.1.9. Attribute 8: fsid Unique file system identifier for the file system holding this object. The fsid attribute has major and minor components, each of which are of data type uint64_t. 5.8.1.10. Attribute 9: unique_handles TRUE, if two distinct filehandles are guaranteed to refer to two different file system objects. 5.8.1.11. Attribute 10: lease_time Duration of the lease at server in seconds. 5.8.1.12. Attribute 11: rdattr_error Error returned from an attempt to retrieve attributes during a READDIR operation. 5.8.1.13. Attribute 19: filehandle The filehandle of this object (primarily for READDIR requests). 5.8.2. Definitions of Uncategorized RECOMMENDED Attributes The definitions of most of the RECOMMENDED attributes follow. Collections that share a common category are defined in other sections. 5.8.2.1. Attribute 14: archive TRUE, if this file has been archived since the time of last modification (deprecated in favor of time_backup). 5.8.2.2. Attribute 15: cansettime TRUE, if the server is able to change the times for a file system object as specified in a SETATTR operation. 5.8.2.3. Attribute 16: case_insensitive TRUE, if file name comparisons on this file system are case insensitive. 5.8.2.4. Attribute 17: case_preserving TRUE, if file name case on this file system is preserved. 5.8.2.5. Attribute 18: chown_restricted If TRUE, the server will reject any request to change either the owner or the group associated with a file if the caller is not a privileged user (for example, "root" in UNIX operating environments or in Windows 2000, the "Take Ownership" privilege). 5.8.2.6. Attribute 20: fileid A number uniquely identifying the file within the file system. 5.8.2.7. Attribute 21: files_avail File slots available to this user on the file system containing this object -- this should be the smallest relevant limit. 5.8.2.8. Attribute 22: files_free Free file slots on the file system containing this object - this should be the smallest relevant limit. 5.8.2.9. Attribute 23: files_total Total file slots on the file system containing this object. 5.8.2.10. Attribute 24: fs_locations Locations where this file system may be found. If the server returns NFS4ERR_MOVED as an error, this attribute MUST be supported. The server specifies the root path for a given server by returning a path consisting of zero path components. 5.8.2.11. Attribute 25: hidden TRUE, if the file is considered hidden with respect to the Windows API. 5.8.2.12. Attribute 26: homogeneous TRUE, if this object's file system is homogeneous, i.e., all objects in the file system (all objects on the server with the same fsid) have common values for all per-file-system attributes. 5.8.2.13. Attribute 27: maxfilesize Maximum supported file size for the file system of this object. 5.8.2.14. Attribute 28: maxlink Maximum number of links for this object. 5.8.2.15. Attribute 29: maxname Maximum file name size supported for this object. 5.8.2.16. Attribute 30: maxread Maximum amount of data the READ operation will return for this object. 5.8.2.17. Attribute 31: maxwrite Maximum amount of data the WRITE operation will accept for this object. This attribute SHOULD be supported if the file is writable. Lack of this attribute can lead to the client either wasting bandwidth or not receiving the best performance. 5.8.2.18. Attribute 32: mimetype MIME body type/subtype of this object. 5.8.2.19. Attribute 55: mounted_on_fileid Like fileid, but if the target filehandle is the root of a file system, this attribute represents the fileid of the underlying directory. UNIX-based operating environments connect a file system into the namespace by connecting (mounting) the file system onto the existing file object (the mount point, usually a directory) of an existing file system. When the mount point's parent directory is read via an API like readdir(), the return results are directory entries, each with a component name and a fileid. The fileid of the mount point's directory entry will be different from the fileid that the stat() system call returns. The stat() system call is returning the fileid of the root of the mounted file system, whereas readdir() is returning the fileid that stat() would have returned before any file systems were mounted on the mount point. Unlike NFSv3, NFSv4.0 allows a client's LOOKUP request to cross other file systems. The client detects the file system crossing whenever the filehandle argument of LOOKUP has an fsid attribute different from that of the filehandle returned by LOOKUP. A UNIX-based client will consider this a "mount point crossing". UNIX has a legacy scheme for allowing a process to determine its current working directory. This relies on readdir() of a mount point's parent and stat() of the mount point returning fileids as previously described. The mounted_on_fileid attribute corresponds to the fileid that readdir() would have returned as described previously. While the NFSv4.0 client could simply fabricate a fileid corresponding to what mounted_on_fileid provides (and if the server does not support mounted_on_fileid, the client has no choice), there is a risk that the client will generate a fileid that conflicts with one that is already assigned to another object in the file system. Instead, if the server can provide the mounted_on_fileid, the potential for client operational problems in this area is eliminated. If the server detects that there is no mounted point at the target file object, then the value for mounted_on_fileid that it returns is the same as that of the fileid attribute. The mounted_on_fileid attribute is RECOMMENDED, so the server SHOULD provide it if possible, and for a UNIX-based server, this is straightforward. Usually, mounted_on_fileid will be requested during a READDIR operation, in which case it is trivial (at least for UNIX- based servers) to return mounted_on_fileid since it is equal to the fileid of a directory entry returned by readdir(). If mounted_on_fileid is requested in a GETATTR operation, the server should obey an invariant that has it returning a value that is equal to the file object's entry in the object's parent directory, i.e., what readdir() would have returned. Some operating environments allow a series of two or more file systems to be mounted onto a single mount point. In this case, for the server to obey the aforementioned invariant, it will need to find the base mount point, and not the intermediate mount points. 5.8.2.20. Attribute 34: no_trunc If this attribute is TRUE, then if the client uses a file name longer than name_max, an error will be returned instead of the name being truncated. 5.8.2.21. Attribute 35: numlinks Number of hard links to this object. 5.8.2.22. Attribute 36: owner The string name of the owner of this object. 5.8.2.23. Attribute 37: owner_group The string name of the group ownership of this object. 5.8.2.24. Attribute 38: quota_avail_hard The value in bytes that represents the amount of additional disk space beyond the current allocation that can be allocated to this file or directory before further allocations will be refused. It is understood that this space may be consumed by allocations to other files or directories. 5.8.2.25. Attribute 39: quota_avail_soft The value in bytes that represents the amount of additional disk space that can be allocated to this file or directory before the user may reasonably be warned. It is understood that this space may be consumed by allocations to other files or directories though thereis a rulemay exist server side rules as to which other files or directories. 5.8.2.26. Attribute 40: quota_used The value in bytes that represents the amount ofdiscdisk space used by this file or directory and possibly a number of other similar files or directories, where the set of "similar" meets at least the criterion that allocating space to any file or directory in the set will reduce the "quota_avail_hard" of every other file or directory in the set. Note that there may be a number of distinct but overlapping sets of files or directories for which a quota_used value is maintained, e.g., "all files with a given owner", "all files with a given group owner", etc. The server is at liberty to choose any of those sets when providing the content of the quota_used attribute, but should do so in a repeatable way. The rule may be configured per file system or may be "choose the set with the smallest quota". 5.8.2.27. Attribute 41: rawdev Raw device number of file of type NF4BLK or NF4CHR. The device number is split into major and minor numbers. If the file's type attribute is not NF4BLK or NF4CHR, the value returned SHOULD NOT be considered useful. 5.8.2.28. Attribute 42: space_avail Disk space in bytes available to this user on the file system containing this object -- this should be the smallest relevant limit. 5.8.2.29. Attribute 43: space_free Free disk space in bytes on the file system containing this object -- this should be the smallest relevant limit. 5.8.2.30. Attribute 44: space_total Total disk space in bytes on the file system containing this object. 5.8.2.31. Attribute 45: space_used Number of file system bytes allocated to this object. 5.8.2.32. Attribute 46: system This attribute is TRUE if this file is a "system" file with respect to the Windows operating environment. 5.8.2.33. Attribute 47: time_access The time_access attribute represents the time of last access to the object by a READ operation sent to the server. The notion of what is an "access" depends on the server's operating environment and/or the server's file system semantics. For example, for servers obeying Portable Operating System Interface (POSIX) semantics, time_access would be updated only by the READ and READDIR operations and not any of the operations that modify the content of the object [16], [17], [read_api], [readdir_api], [write_api]. Of course, setting the corresponding time_access_set attribute is another way to modify the time_access attribute. Whenever the file object resides on a writable file system, the server should make its best efforts to record time_access into stable storage. However, to mitigate the performance effects of doing so, and most especially whenever the server is satisfying the read of the object's content from its cache, the server MAY cache access time updates and lazily write them to stable storage. It is also acceptable to give administrators of the server the option to disable time_access updates. 5.8.2.34. Attribute 48: time_access_set Sets the time of last access to the object. SETATTR use only. 5.8.2.35. Attribute 49: time_backup The time of last backup of the object. 5.8.2.36. Attribute 50: time_create The time of creation of the object. This attribute does not have any relation to the traditional UNIX file attribute "ctime" or "change time". 5.8.2.37. Attribute 51: time_delta Smallest useful server time granularity. 5.8.2.38. Attribute 52: time_metadata The time of last metadata modification of the object. 5.8.2.39. Attribute 53: time_modify The time of last modification to the object. 5.8.2.40. Attribute 54: time_modify_set Sets the time of last modification to the object. SETATTR use only. 5.9. Interpreting owner and owner_group The RECOMMENDED attributes "owner" and "owner_group" (and also users and groups within the "acl" attribute) are represented in terms of a UTF-8 string. To avoid a representation that is tied to a particular underlying implementation at the client or server, the use of the UTF-8 string has been chosen. Note that section 6.1 of RFC 2624 [RFC2624] provides additional rationale. It is expected that the client and server will have their own local representation of owner and owner_group that is used for local storage or presentation to the end user. Therefore, it is expected that when these attributes are transferred between the client and server, the local representation is translated to a syntax of the form "user@dns_domain". This will allow for a client and server that do not use the same local representation the ability to translate to a common syntax that can be interpreted by both. Similarly, security principals may be represented in different ways by different security mechanisms. Servers normally translate these representations into a common format, generally that used by local storage, to serve as a means of identifying the users corresponding to these security principals. When these local identifiers are translated to the form of the owner attribute, associated with files created by such principals, they identify, in a common format, the users associated with each corresponding set of security principals. The translation used to interpret owner and group strings is not specified as part of the protocol. This allows various solutions to be employed. For example, a local translation table may be consulted that maps a numeric identifier to the user@dns_domain syntax. A name service may also be used to accomplish the translation. A server may provide a more general service, not limited by any particular translation (which would only translate a limited set of possible strings) by storing the owner and owner_group attributes in local storage without any translation or it may augment a translation method by storing the entire string for attributes for which no translation is available while using the local representation for those cases in which a translation is available. Servers that do not provide support for all possible values of the owner and owner_group attributes SHOULD return an error (NFS4ERR_BADOWNER) when a string is presented that has no translation, as the value to be set for a SETATTR of the owner, owner_group, or acl attributes. When a server does accept an owner or owner_group value as valid on a SETATTR (and similarly for the owner and group strings in an acl), it is promising to return that same string (for which see below) when a corresponding GETATTR is done. For some internationalization-related exceptions where this is not possible, see below. Configuration changes (including changes from the mapping of the string to the local representation) and ill- constructed name translations (those that contain aliasing) may make that promise impossible to honor. Servers should make appropriate efforts to avoid a situation in which these attributes have their values changed when no real change to ownership has occurred. The "dns_domain" portion of the owner string is meant to be a DNS domain name. For example, user@example.org. Servers should accept as valid a set of users for at least one domain. A server may treat other domains as having no valid translations. A more general service is provided when a server is capable of accepting users for multiple domains, or for all domains, subject to security constraints. As an implementation guide, both clients and servers may provide a means to configure the "dns_domain" portion of the owner string. For example, the DNS domain name might be "lab.example.org", but the user names are defined in "example.org". In the absence of such a configuration, or as a default, the current DNS domain name of the server should be the value used for the "dns_domain". As mentioned above, it is desirable that a server when accepting a string of the form user@domain or group@domain in an attribute, return this same string when that corresponding attribute is fetched. Internationalization issues (for a general discussion of which see Section 12) may make this impossible and the client needs to take note of the following situations: o The string representing the domain may be converted to equivalentU-label,U-label (see [RFC5890]), if presented using a form other than a a U-label. See Section12.612.4 for details. o The user or group may be returned in a different form, due to normalization issues, although it will always be a canonically equivalent string.See Section 12.7.3 for details.In the case where there is no translation available to the client or server, the attribute value will be constructed without the "@". Therefore, the absence of the "@" from the owner or owner_group attribute signifies that no translation was available at the sender and that the receiver of the attribute should not use that string as a basis for translation into its own internal format. Even though the attribute value cannot be translated, it may still be useful. In the case of a client, the attribute string may be used for local display of ownership. To provide a greater degree of compatibility with NFSv3, which identified users and groups by 32-bit unsigned user identifiers and group identifiers, owner and group strings that consist of ASCII- encoded decimal numeric values with no leading zeros can be given a special interpretation by clients and servers that choose to provide such support. The receiver may treat such a user or group string as representing the same user as would be represented by an NFSv3 uid or gid having the corresponding numeric value. A server SHOULD reject such a numeric value if the security mechanism is kerberized. I.e., in such a scenario, the client will already need to form "user@domain" strings. For any other security mechanism, the server SHOULD accept such numeric values. As an implementation note, the server could make such an acceptance be configurable. If the server does not support numeric values or if it is configured off, then it MUST return an NFS4ERR_BADOWNER error. If the security mechanism is kerberized and the client attempts to use the special form, then the server SHOULD return an NFS4ERR_BADOWNER error when there is a valid translation for the user or owner designated in this way. In that case, the client must use the appropriate user@domain string and not the special form for compatibility. The client MUST always accept numeric values if the security mechanism is not RPCSEC_GSS. A client can determine if a server supports numeric identifiers by first attempting to provide a numeric identifier. If this attempt rejected with an NFS4ERR_BADOWNER error, the the client should only use named identifiers of the form "user@ dns_domain". The owner string "nobody" may be used to designate an anonymous user, which will be associated with a file created by a security principal that cannot be mapped through normal means to the owner attribute. 5.10. Character Case Attributes With respect to the case_insensitive and case_preserving attributes, eachUCS-4Universal Multiple-octet coded Character Set-4 (UCS-4) [ISO.10646-1.1993] character (which UTF-8 encodes) has a "long descriptive name" RFC1345 [RFC1345] which may or may not include the word "CAPITAL" or "SMALL". The presence of SMALL or CAPITAL allows an NFS server to implement unambiguous and efficient table driven mappings for case insensitive comparisons, and non-case-preserving storage, although there are variations that occur additional characters with a name including "SMALL" or "CAPITAL" are added in a subsequent version of Unicode.For general character handling and internationalization issues, see Section 12. For details regarding case mapping, see the section Case-based Mapping Used for Component4 Strings.6. Access Control Attributes Access Control Lists (ACLs) are file attributes that specify fine grained access control. This chapter covers the "acl", "aclsupport", "mode", file attributes, and their interactions. Note that file attributes may apply to any file system object. 6.1. Goals ACLs and modes represent two well established models for specifying permissions. This chapter specifies requirements that attempt to meet the following goals: o If a server supports the mode attribute, it should provide reasonable semantics to clients that only set and retrieve the mode attribute. o If a server supports ACL attributes, it should provide reasonable semantics to clients that only set and retrieve those attributes. o On servers that support the mode attribute, if ACL attributes have never been set on an object, via inheritance or explicitly, the behavior should be traditional UNIX-like behavior. o On servers that support the mode attribute, if the ACL attributes have been previously set on an object, either explicitly or via inheritance: * Setting only the mode attribute should effectively control the traditional UNIX-like permissions of read, write, and execute on owner, owner_group, and other. * Setting only the mode attribute should provide reasonable security. For example, setting a mode of 000 should be enough to ensure that future opens for read or write by any principal fail, regardless of a previously existing or inherited ACL. o When a mode attribute is set on an object, the ACL attributes may need to be modified so as to not conflict with the new mode. In such cases, it is desirable that the ACL keep as much information as possible. This includes information about inheritance, AUDIT and ALARM ACEs, and permissions granted and denied that do not conflict with the new mode. 6.2. File Attributes Discussion 6.2.1. Attribute 12: acl The NFSv4.0 ACL attribute contains an array of access control entries (ACEs) that are associated with the file system object. Although the client can read and write the acl attribute, the server is responsible for using the ACL to perform access control. The client can use the OPEN or ACCESS operations to check access without modifying or reading data or metadata. The NFS ACE structure is defined as follows: typedef uint32_t acetype4; typedef uint32_t aceflag4; typedef uint32_t acemask4; struct nfsace4 { acetype4 type; aceflag4 flag; acemask4 access_mask;utf8val_REQUIRED4utf8str_mixed who; }; To determine if a request succeeds, the server processes each nfsace4 entry in order. Only ACEs which have a "who" that matches the requester are considered. Each ACE is processed until all of the bits of the requester's access have been ALLOWED. Once a bit (see below) has been ALLOWED by an ACCESS_ALLOWED_ACE, it is no longer considered in the processing of later ACEs. If an ACCESS_DENIED_ACE is encountered where the requester's access still has unALLOWED bits in common with the "access_mask" of the ACE, the request is denied. When the ACL is fully processed, if there are bits in the requester's mask that have not been ALLOWED or DENIED, access is denied. Unlike the ALLOW and DENY ACE types, the ALARM and AUDIT ACE types do not affect a requester's access, and instead are for triggering events as a result of a requester's access attempt. Therefore, AUDIT and ALARM ACEs are processed only after processing ALLOW and DENY ACEs. The NFSv4.0 ACL model is quite rich. Some server platforms may provide access control functionality that goes beyond the UNIX-style mode attribute, but which is not as rich as the NFS ACL model. So that users can take advantage of this more limited functionality, the server may support the acl attributes by mapping between its ACL model and the NFSv4.0 ACL model. Servers must ensure that the ACL they actually store or enforce is at least as strict as the NFSv4 ACL that was set. It is tempting to accomplish this by rejecting any ACL that falls outside the small set that can be represented accurately. However, such an approach can render ACLs unusable without special client-side knowledge of the server's mapping, which defeats the purpose of having a common NFSv4 ACL protocol. Therefore servers should accept every ACL that they can without compromising security. To help accomplish this, servers may make a special exception, in the case of unsupported permission bits, to the rule that bits not ALLOWED or DENIED by an ACL must be denied. For example, a UNIX- style server might choose to silently allow read attribute permissions even though an ACL does not explicitly allow those permissions. (An ACL that explicitly denies permission to read attributes should still be rejected.) The situation is complicated by the fact that a server may have multiple modules that enforce ACLs. For example, the enforcement for NFSv4.0 access may be different from, but not weaker than, the enforcement for local access, and both may be different from the enforcement for access through other protocols such asSMB.Server Message Block (SMB). So it may be useful for a server to accept an ACL even if not all of its modules are able to support it. The guiding principle with regard to NFSv4 access is that the server must not accept ACLs that appear to make access to the file more restrictive than it really is. 6.2.1.1. ACE Type The constants used for the type field (acetype4) are as follows: const ACE4_ACCESS_ALLOWED_ACE_TYPE = 0x00000000; const ACE4_ACCESS_DENIED_ACE_TYPE = 0x00000001; const ACE4_SYSTEM_AUDIT_ACE_TYPE = 0x00000002; const ACE4_SYSTEM_ALARM_ACE_TYPE = 0x00000003; All fourbutbit types are permitted in the acl attribute. +------------------------------+--------------+---------------------+ | Value | Abbreviation | Description | +------------------------------+--------------+---------------------+ | ACE4_ACCESS_ALLOWED_ACE_TYPE | ALLOW | Explicitly grants | | | | the access defined | | | | in acemask4 to the | | | | file or directory. | | ACE4_ACCESS_DENIED_ACE_TYPE | DENY | Explicitly denies | | | | the access defined | | | | in acemask4 to the | | | | file or directory. | | ACE4_SYSTEM_AUDIT_ACE_TYPE | AUDIT | LOG (in a system | | | | dependent way) any | | | | access attempt to a | | | | file or directory | | | | which uses any of | | | | the access methods | | | | specified in | | | | acemask4. | | ACE4_SYSTEM_ALARM_ACE_TYPE | ALARM | Generate a system | | | | ALARM (system | | | | dependent) when any | | | | access attempt is | | | | made to a file or | | | | directory for the | | | | access methods | | | | specified in | | | | acemask4. | +------------------------------+--------------+---------------------+ The "Abbreviation" column denotes how the types will be referred to throughout the rest of this chapter. 6.2.1.2. Attribute 13: aclsupport A server need not support all of the above ACE types. This attribute indicates which ACE types are supported for the current file system. The bitmask constants used to represent the above definitions within the aclsupport attribute are as follows: const ACL4_SUPPORT_ALLOW_ACL = 0x00000001; const ACL4_SUPPORT_DENY_ACL = 0x00000002; const ACL4_SUPPORT_AUDIT_ACL = 0x00000004; const ACL4_SUPPORT_ALARM_ACL = 0x00000008; Servers which support either the ALLOW or DENY ACE type SHOULD support both ALLOW and DENY ACE types. Clients should not attempt to set an ACE unless the server claims support for that ACE type. If the server receives a request to set an ACE that it cannot store, it MUST reject the request with NFS4ERR_ATTRNOTSUPP. If the server receives a request to set an ACE that it can store but cannot enforce, the server SHOULD reject the request with NFS4ERR_ATTRNOTSUPP. Support for any of the ACL attributes is optional (albeit, RECOMMENDED). 6.2.1.3. ACE Access Mask The bitmask constants used for the access mask field are as follows: const ACE4_READ_DATA = 0x00000001; const ACE4_LIST_DIRECTORY = 0x00000001; const ACE4_WRITE_DATA = 0x00000002; const ACE4_ADD_FILE = 0x00000002; const ACE4_APPEND_DATA = 0x00000004; const ACE4_ADD_SUBDIRECTORY = 0x00000004; const ACE4_READ_NAMED_ATTRS = 0x00000008; const ACE4_WRITE_NAMED_ATTRS = 0x00000010; const ACE4_EXECUTE = 0x00000020; const ACE4_DELETE_CHILD = 0x00000040; const ACE4_READ_ATTRIBUTES = 0x00000080; const ACE4_WRITE_ATTRIBUTES = 0x00000100; const ACE4_DELETE = 0x00010000; const ACE4_READ_ACL = 0x00020000; const ACE4_WRITE_ACL = 0x00040000; const ACE4_WRITE_OWNER = 0x00080000; const ACE4_SYNCHRONIZE = 0x00100000; Note that some masks have coincident values, for example, ACE4_READ_DATA and ACE4_LIST_DIRECTORY. The mask entries ACE4_LIST_DIRECTORY, ACE4_ADD_FILE, and ACE4_ADD_SUBDIRECTORY are intended to be used with directory objects, while ACE4_READ_DATA, ACE4_WRITE_DATA, and ACE4_APPEND_DATA are intended to be used with non-directory objects. 6.2.1.3.1. Discussion of Mask Attributes ACE4_READ_DATA Operation(s) affected: READ OPEN Discussion: Permission to read the data of the file. Servers SHOULD allow a user the ability to read the data of the file when only the ACE4_EXECUTE access mask bit is allowed. ACE4_LIST_DIRECTORY Operation(s) affected: READDIR Discussion: Permission to list the contents of a directory. ACE4_WRITE_DATA Operation(s) affected: WRITE OPEN SETATTR of size Discussion: Permission to modify a file's data. ACE4_ADD_FILE Operation(s) affected: CREATE LINK OPEN RENAME Discussion: Permission to add a new file in a directory. The CREATE operation is affected when nfs_ftype4 is NF4LNK, NF4BLK, NF4CHR, NF4SOCK, or NF4FIFO. (NF4DIR is not listed because it is covered by ACE4_ADD_SUBDIRECTORY.) OPEN is affected when used to create a regular file. LINK and RENAME are always affected. ACE4_APPEND_DATA Operation(s) affected: WRITE OPEN SETATTR of size Discussion: The ability to modify a file's data, but only starting at EOF. This allows for the notion of append-only files, by allowing ACE4_APPEND_DATA and denying ACE4_WRITE_DATA to the same user or group. If a file has an ACL such as the one described above and a WRITE request is made for somewhere other than EOF, the server SHOULD return NFS4ERR_ACCESS. ACE4_ADD_SUBDIRECTORY Operation(s) affected: CREATE RENAME Discussion: Permission to create a subdirectory in a directory. The CREATE operation is affected when nfs_ftype4 is NF4DIR. The RENAME operation is always affected. ACE4_READ_NAMED_ATTRS Operation(s) affected: OPENATTR Discussion: Permission to read the named attributes of a file or to lookup the named attributes directory. OPENATTR is affected when it is not used to create a named attribute directory. This is when 1.) createdir is TRUE, but a named attribute directory already exists, or 2.) createdir is FALSE. ACE4_WRITE_NAMED_ATTRS Operation(s) affected: OPENATTR Discussion: Permission to write the named attributes of a file or to create a named attribute directory. OPENATTR is affected when it is used to create a named attribute directory. This is when createdir is TRUE and no named attribute directory exists. The ability to check whether or not a named attribute directory exists depends on the ability to look it up, therefore, users also need the ACE4_READ_NAMED_ATTRS permission in order to create a named attribute directory. ACE4_EXECUTE Operation(s) affected: READ Discussion: Permission to execute a file. Servers SHOULD allow a user the ability to read the data of the file when only the ACE4_EXECUTE access mask bit is allowed. This is because there is no way to execute a file without reading the contents. Though a server may treat ACE4_EXECUTE and ACE4_READ_DATA bits identically when deciding to permit a READ operation, it SHOULD still allow the two bits to be set independently in ACLs, and MUST distinguish between them when replying to ACCESS operations. In particular, servers SHOULD NOT silently turn on one of the two bits when the other is set, as that would make it impossible for the client to correctly enforce the distinction between read and execute permissions. As an example, following a SETATTR of the following ACL: nfsuser:ACE4_EXECUTE:ALLOW A subsequent GETATTR of ACL for that file SHOULD return: nfsuser:ACE4_EXECUTE:ALLOW Rather than: nfsuser:ACE4_EXECUTE/ACE4_READ_DATA:ALLOW ACE4_EXECUTE Operation(s) affected: LOOKUP OPEN REMOVE RENAME LINK CREATE Discussion: Permission to traverse/search a directory. ACE4_DELETE_CHILD Operation(s) affected: REMOVE RENAME Discussion: Permission to delete a file or directory within a directory. See Section 6.2.1.3.2 for information on how ACE4_DELETE and ACE4_DELETE_CHILD interact. ACE4_READ_ATTRIBUTES Operation(s) affected: GETATTR of file system object attributes VERIFY NVERIFY READDIR Discussion: The ability to read basic attributes (non-ACLs) of a file. On a UNIX system, basic attributes can be thought of as the stat level attributes. Allowing this access mask bit would mean the entity can execute "ls -l" and stat. If a READDIR operation requests attributes, this mask must be allowed for the READDIR to succeed. ACE4_WRITE_ATTRIBUTES Operation(s) affected: SETATTR of time_access_set, time_backup, time_create, time_modify_set, mimetype, hidden, system Discussion: Permission to change the times associated with a file or directory to an arbitrary value. Also permission to change the mimetype, hidden and system attributes. A user having ACE4_WRITE_DATA or ACE4_WRITE_ATTRIBUTES will be allowed to set the times associated with a file to the current server time. ACE4_DELETE Operation(s) affected: REMOVE Discussion: Permission to delete the file or directory. See Section 6.2.1.3.2 for information on ACE4_DELETE and ACE4_DELETE_CHILD interact. ACE4_READ_ACL Operation(s) affected: GETATTR of acl NVERIFY VERIFY Discussion: Permission to read the ACL. ACE4_WRITE_ACL Operation(s) affected: SETATTR of acl and mode Discussion: Permission to write the acl and mode attributes. ACE4_WRITE_OWNER Operation(s) affected: SETATTR of owner and owner_group Discussion: Permission to write the owner and owner_group attributes. On UNIX systems, this is the ability to execute chown() and chgrp(). ACE4_SYNCHRONIZE Operation(s) affected: NONE Discussion: Permission to use the file object as a synchronization primitive for interprocess communication. This permission is not enforced or interpreted by the NFSv4.0 server on behalf of the client. Typically, the ACE4_SYNCHRONIZE permission is only meaningful on local file systems, i.e., file systems not accessed via NFSv4.0. The reason that the permission bit exists is that some operating environments, such as Windows, use ACE4_SYNCHRONIZE. For example, if a client copies a file that has ACE4_SYNCHRONIZE set from a local file system to an NFSv4.0 server, and then later copies the file from the NFSv4.0 server to a local file system, it is likely that if ACE4_SYNCHRONIZE was set in the original file, the client will want it set in the second copy. The first copy will not have the permission set unless the NFSv4.0 server has the means to set the ACE4_SYNCHRONIZE bit. The second copy will not have the permission set unless the NFSv4.0 server has the means to retrieve the ACE4_SYNCHRONIZE bit. Server implementations need not provide the granularity of control that is implied by this list of masks. For example, POSIX-based systems might not distinguish ACE4_APPEND_DATA (the ability to append to a file) from ACE4_WRITE_DATA (the ability to modify existing contents); both masks would be tied to a single "write" permission. When such a server returns attributes to the client, it would show both ACE4_APPEND_DATA and ACE4_WRITE_DATA if and only if the write permission is enabled. If a server receives a SETATTR request that it cannot accurately implement, it should err in the direction of more restricted access, except in the previously discussed cases of execute and read. For example, suppose a server cannot distinguish overwriting data from appending new data, as described in the previous paragraph. If a client submits an ALLOW ACE where ACE4_APPEND_DATA is set but ACE4_WRITE_DATA is not (or vice versa), the server should either turn off ACE4_APPEND_DATA or reject the request with NFS4ERR_ATTRNOTSUPP. 6.2.1.3.2. ACE4_DELETE vs. ACE4_DELETE_CHILD Two access mask bits govern the ability to delete a directory entry: ACE4_DELETE on the object itself (the "target"), and ACE4_DELETE_CHILD on the containing directory (the "parent"). Many systems also take the "sticky bit" (MODE4_SVTX) on a directory to allow unlink only to a user that owns either the target or the parent; on some such systems the decision also depends on whether the target is writable. Servers SHOULD allow unlink if either ACE4_DELETE is permitted on the target, or ACE4_DELETE_CHILD is permitted on the parent. (Note that this is true even if the parent or target explicitly denies one of these permissions.) If the ACLs in question neither explicitly ALLOW nor DENY either of the above, and if MODE4_SVTX is not set on the parent, then the server SHOULD allow the removal if and only if ACE4_ADD_FILE is permitted. In the case where MODE4_SVTX is set, the server may also require the remover to own either the parent or the target, or may require the target to be writable. This allows servers to support something close to traditional UNIX- like semantics, with ACE4_ADD_FILE taking the place of the write bit. 6.2.1.4. ACE flag The bitmask constants used for the flag field are as follows: const ACE4_FILE_INHERIT_ACE = 0x00000001; const ACE4_DIRECTORY_INHERIT_ACE = 0x00000002; const ACE4_NO_PROPAGATE_INHERIT_ACE = 0x00000004; const ACE4_INHERIT_ONLY_ACE = 0x00000008; const ACE4_SUCCESSFUL_ACCESS_ACE_FLAG = 0x00000010; const ACE4_FAILED_ACCESS_ACE_FLAG = 0x00000020; const ACE4_IDENTIFIER_GROUP = 0x00000040; A server need not support any of these flags. If the server supports flags that are similar to, but not exactly the same as, these flags, the implementation may define a mapping between the protocol-defined flags and the implementation-defined flags. For example, suppose a client tries to set an ACE with ACE4_FILE_INHERIT_ACE set but not ACE4_DIRECTORY_INHERIT_ACE. If the server does not support any form of ACL inheritance, the server should reject the request with NFS4ERR_ATTRNOTSUPP. If the server supports a single "inherit ACE" flag that applies to both files and directories, the server may reject the request (i.e., requiring the client to set both the file and directory inheritance flags). The server may also accept the request and silently turn on the ACE4_DIRECTORY_INHERIT_ACE flag. 6.2.1.4.1. Discussion of Flag Bits ACE4_FILE_INHERIT_ACE Any non-directory file in any sub-directory will get this ACE inherited. ACE4_DIRECTORY_INHERIT_ACE Can be placed on a directory and indicates that this ACE should be added to each new directory created. If this flag is set in an ACE in an ACL attribute to be set on a non-directory file system object, the operation attempting to set the ACL SHOULD fail with NFS4ERR_ATTRNOTSUPP. ACE4_INHERIT_ONLY_ACE Can be placed on a directory but does not apply to the directory; ALLOW and DENY ACEs with this bit set do not affect access to the directory, and AUDIT and ALARM ACEs with this bit set do not trigger log or alarm events. Such ACEs only take effect once they are applied (with this bit cleared) to newly created files and directories as specified by the above two flags. If this flag is present on an ACE, but neither ACE4_DIRECTORY_INHERIT_ACE nor ACE4_FILE_INHERIT_ACE is present, then an operation attempting to set such an attribute SHOULD fail with NFS4ERR_ATTRNOTSUPP. ACE4_NO_PROPAGATE_INHERIT_ACE Can be placed on a directory. This flag tells the server that inheritance of this ACE should stop at newly created child directories. ACE4_SUCCESSFUL_ACCESS_ACE_FLAG ACE4_FAILED_ACCESS_ACE_FLAG The ACE4_SUCCESSFUL_ACCESS_ACE_FLAG (SUCCESS) and ACE4_FAILED_ACCESS_ACE_FLAG (FAILED) flag bits may be set only on ACE4_SYSTEM_AUDIT_ACE_TYPE (AUDIT) and ACE4_SYSTEM_ALARM_ACE_TYPE (ALARM) ACE types. If during the processing of the file's ACL, the server encounters an AUDIT or ALARM ACE that matches the principal attempting the OPEN, the server notes that fact, and the presence, if any, of the SUCCESS and FAILED flags encountered in the AUDIT or ALARM ACE. Once the server completes the ACL processing, it then notes if the operation succeeded or failed. If the operation succeeded, and if the SUCCESS flag was set for a matching AUDIT or ALARM ACE, then the appropriate AUDIT or ALARM event occurs. If the operation failed, and if the FAILED flag was set for the matching AUDIT or ALARM ACE, then the appropriate AUDIT or ALARM event occurs. Either or both of the SUCCESS or FAILED can be set, but if neither is set, the AUDIT or ALARM ACE is not useful. The previously described processing applies to ACCESS operations even when they return NFS4_OK. For the purposes of AUDIT and ALARM, we consider an ACCESS operation to be a "failure" if it fails to return a bit that was requested and supported. ACE4_IDENTIFIER_GROUP Indicates that the "who" refers to a GROUP as defined under UNIX or a GROUP ACCOUNT as defined under Windows. Clients and servers MUST ignore the ACE4_IDENTIFIER_GROUP flag on ACEs with a who value equal to one of the special identifiers outlined in Section 6.2.1.5. 6.2.1.5. ACE Who The "who" field of an ACE is an identifier that specifies the principal or principals to whom the ACE applies. It may refer to a user or a group, with the flag bit ACE4_IDENTIFIER_GROUP specifying which. There are several special identifiers which need to be understood universally, rather than in the context of a particular DNS domain. Some of these identifiers cannot be understood when an NFS client accesses the server, but have meaning when a local process accesses the file. The ability to display and modify these permissions is permitted over NFS, even if none of the access methods on the server understands the identifiers. +---------------+--------------------------------------------------+ | Who | Description | +---------------+--------------------------------------------------+ | OWNER | The owner of the file | | GROUP | The group associated with the file. | | EVERYONE | The world, including the owner and owning group. | | INTERACTIVE | Accessed from an interactive terminal. | | NETWORK | Accessed via the network. | | DIALUP | Accessed as a dialup user to the server. | | BATCH | Accessed from a batch job. | | ANONYMOUS | Accessed without any authentication. | | AUTHENTICATED | Any authenticated user (opposite of ANONYMOUS) | | SERVICE | Access from a system service. | +---------------+--------------------------------------------------+ Table 4 To avoid conflict, these special identifiers are distinguished by an appended "@" and should appear in the form "xxxx@" (with no domain name after the "@"). For example: ANONYMOUS@. The ACE4_IDENTIFIER_GROUP flag MUST be ignored on entries with these special identifiers. When encoding entries with these special identifiers, the ACE4_IDENTIFIER_GROUP flag SHOULD be set to zero. 6.2.1.5.1. Discussion of EVERYONE@ It is important to note that "EVERYONE@" is not equivalent to the UNIX "other" entity. This is because, by definition, UNIX "other" does not include the owner or owning group of a file. "EVERYONE@" means literally everyone, including the owner or owning group. 6.2.2. Attribute 33: mode The NFSv4.0 mode attribute is based on the UNIX mode bits. The following bits are defined: const MODE4_SUID = 0x800; /* set user id on execution */ const MODE4_SGID = 0x400; /* set group id on execution */ const MODE4_SVTX = 0x200; /* save text even after use */ const MODE4_RUSR = 0x100; /* read permission: owner */ const MODE4_WUSR = 0x080; /* write permission: owner */ const MODE4_XUSR = 0x040; /* execute permission: owner */ const MODE4_RGRP = 0x020; /* read permission: group */ const MODE4_WGRP = 0x010; /* write permission: group */ const MODE4_XGRP = 0x008; /* execute permission: group */ const MODE4_ROTH = 0x004; /* read permission: other */ const MODE4_WOTH = 0x002; /* write permission: other */ const MODE4_XOTH = 0x001; /* execute permission: other */ Bits MODE4_RUSR, MODE4_WUSR, and MODE4_XUSR apply to the principal identified in the owner attribute. Bits MODE4_RGRP, MODE4_WGRP, and MODE4_XGRP apply to principals identified in the owner_group attribute but who are not identified in the owner attribute. Bits MODE4_ROTH, MODE4_WOTH, MODE4_XOTH apply to any principal that does not match that in the owner attribute, and does not have a group matching that of the owner_group attribute. Bits within the mode other than those specified above are not defined by this protocol. A server MUST NOT return bits other than those defined above in a GETATTR or READDIR operation, and it MUST return NFS4ERR_INVAL if bits other than those defined above are set in a SETATTR, CREATE, OPEN, VERIFY or NVERIFY operation. 6.3. Common Methods The requirements in this section will be referred to in future sections, especially Section 6.4. 6.3.1. Interpreting an ACL 6.3.1.1. Server Considerations The server uses the algorithm described in Section 6.2.1 to determine whether an ACL allows access to an object. However, the ACL may not be the sole determiner of access. For example: o In the case of a file system exported as read-only, the server may deny write permissions even though an object's ACL grants it. o Server implementations MAY grant ACE4_WRITE_ACL and ACE4_READ_ACL permissions to prevent a situation from arising in which there is no valid way to ever modify the ACL. o All servers will allow a user the ability to read the data of the file when only the execute permission is granted (i.e., If the ACL denies the user the ACE4_READ_DATA access and allows the user ACE4_EXECUTE, the server will allow the user to read the data of the file). o Many servers have the notion of owner-override in which the owner of the object is allowed to override accesses that are denied by the ACL. This may be helpful, for example, to allow users continued access to open files on which the permissions have changed. o Many servers have the notion of a "superuser" that has privileges beyond an ordinary user. The superuser may be able to read or write data or metadata in ways that would not be permitted by the ACL. 6.3.1.2. Client Considerations Clients SHOULD NOT do their own access checks based on their interpretation the ACL, but rather use the OPEN and ACCESS operations to do access checks. This allows the client to act on the results of having the server determine whether or not access should be granted based on its interpretation of the ACL. Clients must be aware of situations in which an object's ACL will define a certain access even though the server will not enforce it. In general, but especially in these situations, the client needs to do its part in the enforcement of access as defined by the ACL. To do this, the client MAY send the appropriate ACCESS operation prior to servicing the request of the user or application in order to determine whether the user or application should be granted the access requested. For examples in which the ACL may define accesses that the server doesn't enforce see Section 6.3.1.1. 6.3.2. Computing a Mode Attribute from an ACL The following method can be used to calculate the MODE4_R*, MODE4_W* and MODE4_X* bits of a mode attribute, based upon an ACL. First, for each of the special identifiers OWNER@, GROUP@, and EVERYONE@, evaluate the ACL in order, considering only ALLOW and DENY ACEs for the identifier EVERYONE@ and for the identifier under consideration. The result of the evaluation will be an NFSv4 ACL mask showing exactly which bits are permitted to that identifier. Then translate the calculated mask for OWNER@, GROUP@, and EVERYONE@ into mode bits for, respectively, the user, group, and other, as follows: 1. Set the read bit (MODE4_RUSR, MODE4_RGRP, or MODE4_ROTH) if and only if ACE4_READ_DATA is set in the corresponding mask. 2. Set the write bit (MODE4_WUSR, MODE4_WGRP, or MODE4_WOTH) if and only if ACE4_WRITE_DATA and ACE4_APPEND_DATA are both set in the corresponding mask. 3. Set the execute bit (MODE4_XUSR, MODE4_XGRP, or MODE4_XOTH), if and only if ACE4_EXECUTE is set in the corresponding mask. 6.3.2.1. Discussion Some server implementations also add bits permitted to named users and groups to the group bits (MODE4_RGRP, MODE4_WGRP, and MODE4_XGRP). Implementations are discouraged from doing this, because it has been found to cause confusion for users who see members of a file's group denied access that the mode bits appear to allow. (The presence of DENY ACEs may also lead to such behavior, but DENY ACEs are expected to be more rarely used.) The same user confusion seen when fetching the mode also results if setting the mode does not effectively control permissions for the owner, group, and other users; this motivates some of the requirements that follow. 6.4. Requirements The server that supports both mode and ACL must take care to synchronize the MODE4_*USR, MODE4_*GRP, and MODE4_*OTH bits with the ACEs which have respective who fields of "OWNER@", "GROUP@", and "EVERYONE@" so that the client can see semantically equivalent access permissions exist whether the client asks for owner, owner_group and mode attributes, or for just the ACL.In this section, much is made of the methods in Section 6.3.2.Many requirements refer tothis section. ButSection 6.3.2, but note that the methods have behaviors specified with "SHOULD". This is intentional, to avoid invalidating existing implementations that compute the mode according to the withdrawn POSIX ACL draft(1003.1e draft 17),([P1003.1e]), rather than by actual permissions on owner, group, and other. 6.4.1. Setting the mode and/or ACL Attributes 6.4.1.1. Setting mode and not ACL When any of the nine low-order mode bits are changed because the mode attribute was set, and no ACL attribute is explicitly set, the acl attribute must be modified in accordance with the updated value of those bits. This must happen even if the value of the low-order bits is the same after the mode is set as before. Note that any AUDIT or ALARM ACEs are unaffected by changes to the mode. In cases in which the permissions bits are subject to change, the acl attribute MUST be modified such that the mode computed via the method in Section 6.3.2 yields the low-order nine bits (MODE4_R*, MODE4_W*, MODE4_X*) of the mode attribute as modified by the attribute change. The ACL attributes SHOULD also be modified such that: 1. If MODE4_RGRP is not set, entities explicitly listed in the ACL other than OWNER@ and EVERYONE@ SHOULD NOT be granted ACE4_READ_DATA. 2. If MODE4_WGRP is not set, entities explicitly listed in the ACL other than OWNER@ and EVERYONE@ SHOULD NOT be granted ACE4_WRITE_DATA or ACE4_APPEND_DATA. 3. If MODE4_XGRP is not set, entities explicitly listed in the ACL other than OWNER@ and EVERYONE@ SHOULD NOT be granted ACE4_EXECUTE. Access mask bits other than those listed above, appearing in ALLOW ACEs, MAY also be disabled. Note that ACEs with the flag ACE4_INHERIT_ONLY_ACE set do not affect the permissions of the ACL itself, nor do ACEs of the type AUDIT and ALARM. As such, it is desirable to leave these ACEs unmodified when modifying the ACL attributes. Also note that the requirement may be met by discarding the acl in favor of an ACL that represents the mode and only the mode. This is permitted, but it is preferable for a server to preserve as much of the ACL as possible without violating the above requirements. Discarding the ACL makes it effectively impossible for a file created with a mode attribute to inherit an ACL (see Section 6.4.3). 6.4.1.2. Setting ACL and not mode When setting the acl and not setting the mode attribute, the permission bits of the mode need to be derived from the ACL. In this case, the ACL attribute SHOULD be set as given. The nine low-order bits of the mode attribute (MODE4_R*, MODE4_W*, MODE4_X*) MUST be modified to match the result of the method Section 6.3.2. The three high-order bits of the mode (MODE4_SUID, MODE4_SGID, MODE4_SVTX) SHOULD remain unchanged. 6.4.1.3. Setting both ACL and mode When setting both the mode and the acl attribute in the same operation, the attributes MUST be applied in this order: mode, then ACL. The mode-related attribute is set as given, then the ACL attribute is set as given, possibly changing the final mode, as described above in Section 6.4.1.2. 6.4.2. Retrieving the mode and/or ACL Attributes This section applies only to servers that support both the mode and ACL attributes. Some server implementations may have a concept of "objects without ACLs", meaning that all permissions are granted and denied according to the mode attribute, and that no ACL attribute is stored for that object. If an ACL attribute is requested of such a server, the server SHOULD return an ACL that does not conflict with the mode; that is to say, the ACL returned SHOULD represent the nine low-order bits of the mode attribute (MODE4_R*, MODE4_W*, MODE4_X*) as described in Section 6.3.2. For other server implementations, the ACL attribute is always present for every object. Such servers SHOULD store at least the three high- order bits of the mode attribute (MODE4_SUID, MODE4_SGID, MODE4_SVTX). The server SHOULD return a mode attribute if one is requested, and the low-order nine bits of the mode (MODE4_R*, MODE4_W*, MODE4_X*) MUST match the result of applying the method in Section 6.3.2 to the ACL attribute. 6.4.3. Creating New Objects If a server supports any ACL attributes, it may use the ACL attributes on the parent directory to compute an initial ACL attribute for a newly created object. This will be referred to as the inherited ACL within this section. The act of adding one or more ACEs to the inherited ACL that are based upon ACEs in the parent directory's ACL will be referred to as inheriting an ACE within this section.Implementors should standardize on what the behavior of CREATE and OPEN must be depending onIn the presence or absence of the mode and ACLattributes.attributes, the behavior of CREATE and OPEN SHOULD be: 1. If just the mode is given in the call: In this case, inheritance SHOULD take place, but the mode MUST be applied to the inherited ACL as described in Section 6.4.1.1, thereby modifying the ACL. 2. If just the ACL is given in the call: In this case, inheritance SHOULD NOT take place, and the ACL as defined in the CREATE or OPEN will be set without modification, and the mode modified as in Section 6.4.1.2 3. If both mode and ACL are given in the call: In this case, inheritance SHOULD NOT take place, and both attributes will be set as described in Section 6.4.1.3. 4. If neither mode nor ACL are given in the call: In the case where an object is being created without any initial attributes at all, e.g., an OPEN operation with an opentype4 of OPEN4_CREATE and a createmode4 of EXCLUSIVE4, inheritance SHOULD NOT take place. Instead, the server SHOULD set permissions to deny all access to the newly created object. It is expected that the appropriate client will set the desired attributes in a subsequent SETATTR operation, and the server SHOULD allow that operation to succeed, regardless of what permissions the object is created with. For example, an empty ACL denies all permissions, but the server should allow the owner's SETATTR to succeed even though WRITE_ACL is implicitly denied. In other cases, inheritance SHOULD take place, and no modifications to the ACL will happen. The mode attribute, if supported, MUST be as computed in Section 6.3.2, with the MODE4_SUID, MODE4_SGID and MODE4_SVTX bits clear. If no inheritable ACEs exist on the parent directory, the rules for creating acl attributes are implementation defined. 6.4.3.1. The Inherited ACL If the object being created is not a directory, the inherited ACL SHOULD NOT inherit ACEs from the parent directory ACL unless the ACE4_FILE_INHERIT_FLAG is set. If the object being created is a directory, the inherited ACL should inherit all inheritable ACEs from the parent directory, those that have ACE4_FILE_INHERIT_ACE or ACE4_DIRECTORY_INHERIT_ACE flag set. If the inheritable ACE has ACE4_FILE_INHERIT_ACE set, but ACE4_DIRECTORY_INHERIT_ACE is clear, the inherited ACE on the newly created directory MUST have the ACE4_INHERIT_ONLY_ACE flag set to prevent the directory from being affected by ACEs meant for non- directories. When a new directory is created, the server MAY split any inherited ACE which is both inheritable and effective (in other words, which has neither ACE4_INHERIT_ONLY_ACE nor ACE4_NO_PROPAGATE_INHERIT_ACE set), into two ACEs, one with no inheritance flags, and one with ACE4_INHERIT_ONLY_ACE set. This makes it simpler to modify the effective permissions on the directory without modifying the ACE which is to be inherited to the new directory's children. 7.Multi-Server Namespace NFSv4 supports attributes that allowNFS Server Name Space 7.1. Server Exports On anamespace to extend beyondUNIX server theboundaries of a single server. It is RECOMMENDED that clients and servers support construction of such multi-server namespaces. Use of such multi-server namespaces is OPTIONAL, however, and for many purposes, single-server namespaces are perfectly acceptable. Use of multi-server namespaces can provide many advantages, however,name space describes all the files reachable byseparatingpathnames under the root directory or "/". On a Windows NT server the name space constitutes all the files on disks named by mapped disk letters. NFS server administrators rarely make the entire server's filesystem's logical position insystem name space available to NFS clients. More often portions of the name space are made available via an "export" feature. In previous versions of the NFS protocol, the root filehandle for each export is obtained through the MOUNT protocol; the client sends anamespace fromstring that identifies the(possibly changing) logisticalexport of name space andadministrative considerationsthe server returns the root filehandle for it. The MOUNT protocol supports an EXPORTS procedure thatresult in particular file systems being located on particular servers. 7.1. Location Attributeswill enumerate the server's exports. 7.2. Browsing Exports The NFSv4contains RECOMMENDED attributesprotocol provides a root filehandle thatallowclients can use to obtain filehandles for these exports via a multi-component LOOKUP. A common user experience is to use a graphical user interface (perhaps a filesystems on one server"Open" dialog window) to find a file via progressive browsing through a directory tree. The client must beassociated withable to move from oneor more instancesexport to another export via single-component, progressive LOOKUP operations. This style ofthat file system on other servers. These attributes specify such file system instancesbrowsing is not well supported byspecifyingthe NFSv2 and NFSv3 protocols. The client expects all LOOKUP operations to remain within a single serveraddress target (either asfile system. For example, the device attribute will not change. This prevents aDNSclient from taking namerepresenting one or more IP addresses or asspace paths that span exports. An automounter on the client can obtain aliteral IP address) together withsnapshot of thepathserver's name space using the EXPORTS procedure ofthat file system withintheassociated single-server namespace.MOUNT protocol. If it understands the server's pathname syntax, it can create an image of the server's name space on the client. Thefs_locations RECOMMENDED attribute allows specificationparts of thefile system locations wherename space that are not exported by thedata corresponding to a given file system may be found. 7.2. File System Presence or Absence A given locationserver are filled inan NFSv4 namespace (typically but not necessarily a multi-server namespace) can have a number of file system instance locations associatedwithit via the fs_locations attribute. There may also be an actual currenta "pseudo filesystem atsystem" thatlocation, accessible via normal namespace operations (e.g., LOOKUP). In this case,allows the user to browse from one mounted file system to another. There issaida drawback tobe "present" at that position in the namespace, and clients will typically use it, reserving usethis representation ofadditional locations specified viathelocation-related attributes to situations in whichserver's name space on theprincipal location is no longer available. When thereclient: it isno actual file system atstatic. If thenamespace location in question,server administrator adds a new export thefile system is said toclient will be"absent". An absent file system contains no files or directories other thanunaware of it. 7.3. Server Pseudo Filesystem NFSv4 servers avoid this name space inconsistency by presenting all theroot. Any referenceexports within the framework of a single server name space. An NFSv4 client uses LOOKUP and READDIR operations toit, exceptbrowse seamlessly from one export toaccess a small setanother. Portions ofattributes useful in determining alternate locations, will result in an error, NFS4ERR_MOVED. Note that ifthe serverever returns the error NFS4ERR_MOVED, it MUST support the fs_locations attribute. While the errornamesuggestsspace thatwe haveare not exported are bridged via acase of"pseudo file system" that provides a view of exported directories only. A pseudo file systemthat once was present, andhas a unique fsid and behaves like a normal, read onlybecome absent later, this is only one possibility. A position in the namespace may be permanently absent with the set offilesystem(s) designated bysystem. Based on thelocation attributes beingconstruction of theonly realization. Theserver's nameNFS4ERR_MOVED reflects an earlier, more limited conceptionspace, it is possible that multiple pseudo file systems may exist. For example, /a pseudo file system /a/b real file system /a/b/c pseudo file system /a/b/c/d real file system Each ofits function, but this error will be returned wheneverthereferencedpseudo file systems are considered separate entities and therefore will have a unique fsid. 7.4. Multiple Roots The DOS and Windows operating environments are sometimes described as having "multiple roots". Filesystems are commonly represented as disk letters. MacOS represents file systems as top level names. NFSv4 servers for these platforms can construct a pseudo file systemis absent, whether it has movedabove these root names so that disk letters ornot. Exceptvolume names are simply directory names in thecasepseudo root. 7.5. Filehandle Volatility The nature ofGETATTR-type operations (to be discussed later), when the current filehandle atthestart of an operation is within an absentserver's pseudo filesystem,system is thatoperationit isnot performed anda logical representation of file system(s) available from theerror NFS4ERR_MOVED is returned, to indicate thatserver. Therefore, the pseudo file system isabsent on the current server. Because a GETFH cannot succeed ifmost likely constructed dynamically when thecurrent filehandleserver iswithin an absent file system, filehandles within an absentfirst instantiated. It is expected that the pseudo file systemcannot be transferred to the client. When a client doesmay not havefilehandles withinanabsent file system,on disk counterpart from which persistent filehandles could be constructed. Even though it is preferable that theresult of obtaining them whenserver provide persistent filehandles for the pseudo filesystem was present, and havingsystem, the NFS client should expect that pseudo file systembecome absent subsequently. It shouldfilehandles are volatile. This can benoted that becauseconfirmed by checking thecheckassociated "fh_expire_type" attribute for those filehandles in question. If thecurrentfilehandles are volatile, the NFS client must be prepared to recover a filehandlebeing withinvalue (e.g., with a multi-component LOOKUP) when receiving anabsenterror of NFS4ERR_FHEXPIRED. 7.6. Exported Root If the server's root file systemhappens at the start of every operation, operations that change the current filehandle so that itiswithin an absent fileexported, one might conclude that a pseudo-file systemwillis notresult in an error.needed. Thisallows such combinations as PUTFH-GETATTR and LOOKUP-GETATTR towould beused to get attribute information, particularly location attribute information, as discussed below. 7.3. Getting Attributes for an Absent File System When awrong. Assume the following filesystemsystems on a server: / disk1 (exported) /a disk2 (not exported) /a/b disk3 (exported) Because disk2 isabsent, most attributes arenotavailable, but it is necessary to allow the client access to the small set of attributes that are available, and most particularly that which gives information aboutexported, disk3 cannot be reached with simple LOOKUPs. The server must bridge thecorrect current locations for thisgap with a pseudo-file system. 7.7. Mount Point Crossing The server filesystem, fs_locations. 7.3.1. GETATTR Within an Absent File System As mentioned above, an exception is made for GETATTR in that attributessystem environment may beobtained forconstructed in such afilehandle within an absentway that one filesystem. This exception only applies if the attribute masksystem containsat least the fs_locations attribute bit,a directory whichindicates the clientisinterested in'covered' or mounted upon by aresult regarding an absentsecond file system.If itFor example: /a/b (file system 1) /a/b/c/d (file system 2) The pseudo file system for this server may be constructed to look like: / (place holder/not exported) /a/b (file system 1) /a/b/c/d (file system 2) It isnot requested, GETATTR will result in an NFS4ERR_MOVED error. Whenthe server's responsibility to present the pseudo file system that is complete to the client. If the client sends aGETATTRlookup request for the path "/a/b/c/d", the server's response isdone on an absent file system,thesetfilehandle ofsupported attributes is very limited. Many attributes, including those that are normally REQUIRED, will not be available on an absentthe filesystem.system "/a/b/c/d". Inaddition toprevious versions of thefs_locations attribute,NFS protocol, thefollowing attributes SHOULD be available on absent file systems. Inserver would respond with thecasefilehandle ofRECOMMENDED attributes, they should be available at least todirectory "/a/b/c/d" within thesame degree that they are available on presentfilesystems. fsid: This attribute should be provided so that thesystem "/a/b". The NFS clientcanwill be able to determinefile system boundaries, including,if it crosses a server mount point by a change inparticular,theboundary between present and absent file systems. Thisvaluemust be different from any other fsid onof thecurrent server"fsid" attribute. 7.8. Security Policy andneed have no particular relationship to fsids on any particular destination to which the client might be directed. mounted_on_fileid: For objects at the topName Space Presentation The application ofan absent file system, this attributethe server's security policy needs to beavailable. Since the fileid is withincarefully considered by thepresent parent file system, there should be no needimplementor. One may choose toreferencelimit theabsentviewability of portions of the pseudo file system based on the server's perception of the client's ability toprovide this information. Other attributes SHOULD NOT be made available for absent file systems, even when it is possible to provide them. The server should not assume that more information is always better and should avoid gratuitously providing additional information. When a GETATTR operation includes a bit mask for the attribute fs_locations, but where the bit mask includes attributes that are not supported, GETATTR will not return an error, but will returnauthenticate itself properly. However, with themasksupport of multiple security mechanisms and theactual attributes supported withability to negotiate theresults. Handlingappropriate use ofVERIFY/NVERIFYthese mechanisms, the server issimilarunable toGETATTR in thatproperly determine ifthe attribute mask does not include fs_locations the error NFS4ERR_MOVEDa client willresult. It differs in that any appearance inbe able to authenticate itself. If, based on its policies, theattribute maskserver chooses to limit the contents ofan attribute not supported for an absent file system (and note that this will include some normally REQUIRED attributes) will also cause an NFS4ERR_MOVED result. 7.3.2. READDIR and Absent File Systems A READDIR performed whenthecurrent filehandle is within an absentpseudo filesystem will result in an NFS4ERR_MOVED error, since, unlikesystem, thecase of GETATTR, no such exception is made for READDIR. Attributes for an absent file systemserver maybe fetched via a READDIR for a directory in a presenteffectively hide filesystem, whensystems from a client thatdirectory containsmay otherwise have legitimate access. As suggested practice, theroot directoriesserver should apply the security policy ofone or more absent file systems. In this case,a shared resource in thehandling is as follows: o Ifserver's namespace to theattribute set requested includes fs_locations, then fetchingcomponents ofattributes proceeds normallythe resource's ancestors. For example: / /a/b /a/b/c The /a/b/c directory is a real file system andno NFS4ERR_MOVED indicationisreturned, even whentherdattr_error attributeshared resource. The security policy for /a/b/c isrequested. o If the attribute set requested does not include fs_locations, then ifKerberos with integrity. The server should apply therdattr_error attribute is requested, each directory entrysame security policy to /, /a, and /a/b. This allows for therootextension ofan absent file system will report NFS4ERR_MOVED asthevalueprotection of therdattr_error attribute. o Ifserver's namespace to theattribute set requested does not include eitherancestors of theattributes fs_locations or rdattr_error thenreal shared resource. For theoccurrencecase of therootuse ofan absent file system within the directory will resultmultiple, disjoint security mechanisms in theREADDIR failing with an NFS4ERR_MOVED error. o The unavailability of an attribute because ofserver's resources, the security for afile system's absence, even one that is ordinarily REQUIRED, does not resultparticular object inany error indication. The set of attributes returned fortheroot directory ofserver's namespace should be theabsent file system in that case is simply restricted to those actually available. 7.4. Uses of Location Information The location-bearing attributeunion offs_locations provides, together with the possibilityall security mechanisms ofabsent file systems,all direct descendants. 8. Multi-Server Namespace NFSv4 supports attributes that allow anumbernamespace to extend beyond the boundaries ofimportant facilities in providing reliable, manageable, and scalable data access. Whenafile systemsingle server. It ispresent, these attributes can provide alternative locations, to be used to access the same data,RECOMMENDED that clients and servers support construction of such multi-server namespaces. Use of such multi-server namespaces is OPTIONAL, however, and for many purposes, single-server namespaces are perfectly acceptable. Use of multi-server namespaces can provide many advantages, however, by separating a file system's logical position in a namespace from theevent of(possibly changing) logistical and administrative considerations that result in particular file systems being located on particular servers. 8.1. Location Attributes NFSv4 contains RECOMMENDED attributes that allow file systems on one serverfailures, communications problems,to be associated with one orother difficultiesmore instances of thatmake continued access to the currentfile systemimpossibleon other servers. These attributes specify such file system instances by specifying a server address target (either as a DNS name representing one orotherwise impractical. Under some circumstances, multiple alternative locations may be used simultaneously to provide higher-performance access tomore IP addresses or as a literal IP address) together with the path of that file systemin question. Provisionwithin the associated single-server namespace. The fs_locations RECOMMENDED attribute allows specification ofsuch alternatethe file system locationsis referred to as "replication" although there are cases in which replicated sets of data are not in fact present, andwhere thereplicas are instead different pathsdata corresponding tothe same data. Whena given file systemis present and becomes absent, clients canmay be found. 8.2. File System Presence or Absence A giventhe opportunity tolocation in an NFSv4 namespace (typically but not necessarily a multi-server namespace) can havecontinued access to their data, ata number of file system instance locations associated with it via the fs_locations attribute. There may also be analternate location.actual current file system at that location, accessible via normal namespace operations (e.g., LOOKUP). In this case,a continued attempt to use the data inthenow-absentfile systemwill result in an NFS4ERR_MOVED error and,is said to be "present" at thatpoint,position in thesuccessor locations (typically only one although multiple choices are possible) can be fetchednamespace, andused to continue access. Transferclients will typically use it, reserving use of additional locations specified via thefile system contentslocation-related attributes to situations in which thenewprincipal location isreferred to as "migration", but it should be kept in mind that there are cases in which this term can be used, like "replication", whenno longer available. When there is no actualdata migration per se. Where afile systemwas not previously present, specification of file system location provides a means by which file systems located on one server can be associated with a namespace defined by another server, thus allowing a general multi-serverat the namespacefacility. A designation of such a location,location inplace of an absentquestion, the filesystem, is called a "referral". Because client support for location-related attributes is OPTIONAL, a server may (butsystem isnot required to) take action to hide migration and referral events from such clients, by acting as a proxy, for example. 7.4.1. File System Replication The fs_locations attribute provides alternative locations,said to beused"absent". An absent file system contains no files or directories other than the root. Any reference to it, except to accessdata in placea small set ofor in addition to the current file system instance. On first access to a file system, the client should obtainattributes useful in determining alternate locations, will result in an error, NFS4ERR_MOVED. Note that if thevalue ofserver ever returns theset of alternate locations by interrogatingerror NFS4ERR_MOVED, it MUST support the fs_locations attribute.InWhile theeventerror name suggests thatserver failures, communications problems, or other difficulties make continued access to the currentwe have a case of a file systemimpossible or otherwise impractical, the client can usethat once was present, and has only become absent later, this is only one possibility. A position in thealternate locations as a way to get continued access to its data. Multiple locationsnamespace may beused simultaneously, to provide higher performance throughpermanently absent with theexploitationset ofmultiple paths between client and targetfilesystem.system(s) designated by the location attributes being the only realization. Thealternate locations may be physical replicasname NFS4ERR_MOVED reflects an earlier, more limited conception of its function, but this error will be returned whenever the(typically read-only)referenced file systemdata, or they may reflect alternate paths to the same serveris absent, whether it has moved orprovide for the use of various forms of server clusteringnot. Except inwhich multiple servers provide alternate waysthe case ofaccessingGETATTR-type operations (to be discussed later), when thesame physical file system. How these different modescurrent filehandle at the start offile system transition are representedan operation is withinthe fs_locations attributean absent file system, that operation is not performed andhowtheclient deals witherror NFS4ERR_MOVED is returned, to indicate that the file systemtransition issues will be discussed in detail below. Multiple server addresses, whether they are derived from a single entry with a DNS name representing a set of IP addresses or from multiple entries each with its own server address, may correspond tois absent on thesame actualcurrent server.7.4.2. File System Migration WhenBecause a GETFH cannot succeed if the current filehandle is within an absent file system, filehandles within an absent file systemis present and becomes absent, clients cancannot begiven the opportunity to have continued accesstransferred totheir data, at an alternate location, as specified bythefs_locations attribute. Typically,client. When a clientwill be accessing the file system in question, getdoes have filehandles within anNFS4ERR_MOVED error, and then use the fs_locations attribute to determineabsent file system, it is thenew locationresult of obtaining them when thedata. Such migration can be helpful in providing load balancing or general resource reallocation. The protocol does not specify howfile system was present, and having the file systemwill be moved between servers.become absent subsequently. Itis anticipated that a number of different server-to-server transfer mechanisms mightshould beused with the choice left to the server implementor. The NFSv4 protocol specifiesnoted that because themethod used to communicatecheck for themigration event between client and server. The new location may becurrent filehandle being within analternate communication path to the same server or, inabsent file system happens at thecase of various formsstart ofserver clustering, another server providing access toevery operation, operations that change thesame physical file system. The client's responsibilitiescurrent filehandle so that it is within an absent file system will not result indealing with this transition depend on the specific nature of the new access path as wellan error. This allows such combinations ashowPUTFH-GETATTR andwhether data was in fact migrated. These issues willLOOKUP-GETATTR to bediscussed in detail below. When an alternateused to get attribute information, particularly locationis designatedattribute information, asthe targetdiscussed below. 8.3. Getting Attributes formigration, it must designate the same data. Where file systems are writable, a change made on the original file system must be visible on all migration targets. Wherean Absent File System When a file system is absent, most attributes are notwritableavailable, butrepresents a read-only copy (possibly periodically updated) of a writable file system, similar requirements applyit is necessary to allow thepropagationclient access to the small set ofupdates. Any change visible inattributes that are available, and most particularly that which gives information about theoriginalcorrect current locations for this filesystem must already be effected on all migration targets, to avoid any possibility that a client,system, fs_locations. 8.3.1. GETATTR Within an Absent File System As mentioned above, an exception is made for GETATTR ineffectingthat attributes may be obtained for atransition tofilehandle within an absent file system. This exception only applies if themigration target, will see any reversionattribute mask contains at least the fs_locations attribute bit, which indicates the client is interested infile system state. 7.4.3. Referrals Referrals provide a way of placinga result regarding an absent filesystemsystem. If it is not requested, GETATTR will result in an NFS4ERR_MOVED error. When alocation within the namespace essentially without respect to its physical locationGETATTR is done ona given server. This allows a single server or aan absent file system, the set ofservers to present a multi-server namespacesupported attributes is very limited. Many attributes, including those thatencompassesare normally REQUIRED, will not be available on an absent filesystems locatedsystem. In addition to the fs_locations attribute, the following attributes SHOULD be available onmultiple servers. Some likely uses of this include establishmentabsent file systems. In the case ofsite-wide or organization-wide namespaces, or even knitting such together into a truly global namespace. Referrals occur when a client determines, upon first referencing a position inRECOMMENDED attributes, they should be available at least to thecurrent namespace,same degree thatit is part of a newthey are available on present filesystem andsystems. fsid: This attribute should be provided so that the client can determine file systemis absent. When this occurs, typically by receiving the error NFS4ERR_MOVED, the actual location or locations ofboundaries, including, in particular, the boundary between present and absent filesystem cansystems. This value must bedetermined by fetchingdifferent from any other fsid on thefs_locations attribute. The locations-related attribute may designate a single file system location or multiple file system locations,current server and need have no particular relationship tobe selected basedfsids on any particular destination to which theneeds ofclient might be directed. mounted_on_fileid: For objects at theclient. Usetop ofmulti-server namespaces is enabled by NFSv4 but is not required. The use of multi-server namespaces and their scope will depend on the applications used and system administration preferences. Multi-server namespaces can be established by a single server providing a large set of referralsan absent file system, this attribute needs toall ofbe available. Since theincludedfileid is within the present parent filesystems. Alternatively, a single multi-server namespace maysystem, there should beadministratively segmented with separate referral file systems (on separate servers) for each separately administered portion ofno need to reference thenamespace. The top-level referralabsent file systemor any segment may use replicated referral file systems for higher availability. Generally, multi-server namespaces are for the most part uniform, in that the same data made availabletoone client at a given location in the namespace isprovide this information. Other attributes SHOULD NOT be made available for absent file systems, even when it is possible toall clients atprovide them. The server should not assume thatlocation. 7.5. Location Entriesmore information is always better andServer Identity As mentioned above,should avoid gratuitously providing additional information. When asingle location entry may haveGETATTR operation includes aserver address target inbit mask for theform of a DNS name that may represent multiple IP addresses, while multiple location entries may have their own server address targetsattribute fs_locations, but where the bit mask includes attributes thatreferenceare not supported, GETATTR will not return an error, but will return thesame server. When multiple addresses formask of thesame server exist,actual attributes supported with theclient may assumeresults. Handling of VERIFY/NVERIFY is similar to GETATTR in that if the attribute mask does not include fs_locations the error NFS4ERR_MOVED will result. It differs in that any appearance in the attribute mask of an attribute not supported foreachan absent file system (and note that this will include some normally REQUIRED attributes) will also cause an NFS4ERR_MOVED result. 8.3.2. READDIR and Absent File Systems A READDIR performed when the current filehandle is within an absent file system will result in an NFS4ERR_MOVED error, since, unlike thenamespacecase ofa given server network address, there existGETATTR, no such exception is made for READDIR. Attributes for an absent filesystems at corresponding namespace locationssystem may be fetched via a READDIR foreach ofa directory in a present file system, when that directory contains theother server network addresses. It may doroot directories of one or more absent file systems. In this case, the handling is as follows: o If the attribute set requested includes fs_locations, then fetching of attributes proceeds normally and no NFS4ERR_MOVED indication is returned, eveninwhen theabsencerdattr_error attribute is requested. o If the attribute set requested does not include fs_locations, then if the rdattr_error attribute is requested, each directory entry for the root ofexplicit listing in fs_locations. Such correspondingan absent file systemlocations can be used as alternate locations, justwill report NFS4ERR_MOVED asthose explicitly specified viathefs_locationsvalue of the rdattr_error attribute. o Ifa single location entry designates multiple server IP addresses,theclient cannot assume that these addresses are multiple paths toattribute set requested does not include either of thesame server. In most cases, they will be, butattributes fs_locations or rdattr_error then theclient MUST verify that before acting on that assumption. When two server addresses are designated by a single location entry and they correspond to different servers, this normally indicates some sortoccurrence ofmisconfiguration, and sotheclient should avoid using such location entries when alternatives are available. When they are not, clients should pick oneroot ofIP addresses and use it, without using othersan absent file system within the directory will result in the READDIR failing with an NFS4ERR_MOVED error. o The unavailability of an attribute because of a file system's absence, even one thatareis ordinarily REQUIRED, does notdirected toresult in any error indication. The set of attributes returned for thesame server. 7.6. Additional Client-Side Considerations When clients make useroot directory ofservers that implement referrals, replication, and migration, care should be taken that a user who mounts a giventhe absent file system in thatincludescase is simply restricted to those actually available. 8.4. Uses of Location Information The location-bearing attribute of fs_locations provides, together with the possibility of absent file systems, areferral ornumber of important facilities in providing reliable, manageable, and scalable data access. When arelocatedfile systemcontinuesis present, these attributes can provide alternative locations, tosee a coherent picturebe used to access the same data, in the event of server failures, communications problems, or other difficulties thatuser-side file system despitemake continued access to thefact that it contains a number of server-sidecurrent filesystems thatsystem impossible or otherwise impractical. Under some circumstances, multiple alternative locations may beon different servers. One important issue is upward navigation fromused simultaneously to provide higher-performance access to theroot of a server- sidefile system in question. Provision of such alternate locations is referred toits parent (specifiedas"..""replication" although there are cases inUNIX),which replicated sets of data are not in fact present, and thecase in which it transitionsreplicas are instead different paths tothatthe same data. When a file systemas a result of referral, migration, or a transition as a result of replication. When the clientisat such a point,present andit needs to ascend tobecomes absent, clients can be given theparent, it must go backopportunity tothe parent as seen within the multi-server namespace rather than sendinghave continued access to their data, at an alternate location. In this case, aLOOKUPP operationcontinued attempt to use theserver, which would resultdata in theparent withinnow-absent file system will result in an NFS4ERR_MOVED error and, at thatserver's single-server namespace. In order to do this,point, theclient needssuccessor locations (typically only one although multiple choices are possible) can be fetched and used toremembercontinue access. Transfer of thefilehandles that represent suchfile systemroots and use these instead of issuing a LOOKUPP operationcontents to thecurrent server. This will allow the client to presentnew location is referred toapplications a consistent namespace, where upward navigation and downward navigation are consistent. Another issue concerns refresh of referral locations. When referrals are used extensively, they may changeasserver configurations change. It is expected"migration", but it should be kept in mind thatclients will cache information related to traversing referrals so that future client-side requeststhere areresolved locally without server communication. This is usually rootedcases inclient-side name look up caching. Clients should periodically purgewhich this term can be used, like "replication", when there is no actual datafor referral points in order to detect changes inmigration per se. Where a file system was not previously present, specification of file system locationinformation. A potential problem exists ifprovides aclient were to allow an open owner to have state on multiple filesystemsmeans by which file systems located onserver, in that it is unclear how the sequence numbersone server can be associated withopen owners are to be dealt with, in the event of transparent state migration.a namespace defined by another server, thus allowing a general multi-server namespace facility. Aclient can avoiddesignation of such asituation, if it ensures that any uselocation, in place of anopen ownerabsent file system, isconfined tocalled a "referral". Because client support for location-related attributes is OPTIONAL, asingle filesystem. A server MAY decline to migrate state associated with open owners that span multiple filesystems. In cases in which theserverchoosesmay (but is not required to) take action tomigratehide migration and referral events from suchstate,clients, by acting as a proxy, for example. 8.4.1. File System Replication The fs_locations attribute provides alternative locations, to be used to access data in place of or in addition to theserver MUST return NFS4ERR_BAD_STATEID whencurrent file system instance. On first access to a file system, the clientuses those stateids on the new server. The server MUST return NFS4ERR_STALE_STATEID whenshould obtain theclient uses those stateids onvalue of theold server, regardlessset ofwhether migration has occurredalternate locations by interrogating the fs_locations attribute. In the event that server failures, communications problems, ornot. 7.7. Effecting File System Transitions Transitions betweenother difficulties make continued access to the current file systeminstances, whether dueimpossible or otherwise impractical, the client can use the alternate locations as a way to get continued access to its data. Multiple locations may be used simultaneously, toswitchingprovide higher performance through the exploitation of multiple paths between client and target file system. The alternate locations may be physical replicasupon server unavailabilityof the (typically read-only) file system data, or they may reflect alternate paths toserver-initiated migration events, are best dealt with together. This is so even though, fortheserver, pragmatic considerations will normally force different implementation strategiessame server or provide forplanned and unplanned transitions. Even thoughtheprototypicalusecasesofreplication and migration contain distinctive setsvarious forms offeatures, when all possibilities for these operations are considered, there is an underlying unityserver clustering in which multiple servers provide alternate ways ofthese operations, fromaccessing theclient's point of view, that makes treating them together desirable. A numbersame physical file system. How these different modes ofmethodsfile system transition arepossible for servers to replicate datarepresented within the fs_locations attribute andto trackhow the clientstate in order to allow clients to transition betweendeals with file systeminstancestransition issues will be discussed in detail below. Multiple server addresses, whether they are derived from a single entry with aminimumDNS name representing a set ofdisruption. Such methods vary between those that use inter-server clustering techniquesIP addresses or from multiple entries each with its own server address, may correspond tolimitthechanges seen bysame actual server. 8.4.2. File System Migration When a file system is present and becomes absent, clients can be given theclient,opportunity tothose that are less aggressive, use more standard methods of replicatinghave continued access to their data,and impose a greater burden onat an alternate location, as specified by the fs_locations attribute. Typically, a clientto adapt towill be accessing thetransition. The NFSv4 protocol does not impose choices on clientsfile system in question, get an NFS4ERR_MOVED error, andservers with regardthen use the fs_locations attribute tothat spectrumdetermine the new location oftransition methods. In fact, there are many valid choices, depending on client and application requirements and their interaction with server implementation choices.the data. Such migration can be helpful in providing load balancing or general resource reallocation. TheNFSv4.0protocol does notprovidespecify how theserversfile system will be moved between servers. It is anticipated that ameansnumber ofcommunicatingdifferent server-to-server transfer mechanisms might be used with thetransition methods. Inchoice left to theNFSv4.1server implementor. The NFSv4 protocol[RFC5661], an additional attribute "fs_locations_info" is presented, which will definespecifies thespecific choices that can be made, how these choices are communicatedmethod used to communicate theclient, and how themigration event between clientis to deal with any discontinuities. In the sections below, references willand server. The new location may bemadean alternate communication path tovarious possible server implementation choices as a way of illustratingthetransition scenarios that clients may deal with. The intent here is not to define or limitsame serverimplementations but rather to illustrateor, in therangecase ofissues that clients may face. Again, as the NFSv4.0 protocol does not have an explicit meansvarious forms ofcommunicating these issues to the client, the intent isserver clustering, another server providing access todocumenttheproblems that can be facedsame physical file system. The client's responsibilities ina multi-server name space and allowdealing with this transition depend on theclient to usespecific nature of theinferred transitions available via fs_locationsnew access path as well as how andother attributes (see Section 7.9.1). In the discussion below, referenceswhether data was in fact migrated. These issues will bemade todiscussed in detail below. When an alternate location is designated as the target for migration, it must designate the same data. Where file systems are writable, a change made on the original file systemhavingmust be visible on all migration targets. Where aparticular property or to twofilesystems (typically the source and destination) belonging tosystem is not writable but represents acommon class of anyread-only copy (possibly periodically updated) ofseveral types. Twoa writable filesystems that belongsystem, similar requirements apply tosuch a class share some important aspectsthe propagation of updates. Any change visible in the original file systembehavior that clients may depend upon when present,must already be effected on all migration targets, toeasily effectavoid any possibility that a client, in effecting aseamlesstransitionbetweento the migration target, will see any reversion in file systeminstances. Conversely, where thestate. 8.4.3. Referrals Referrals provide a way of placing a filesystems do not belong to suchsystem in acommon class,location within theclient has to deal with various sorts of implementation discontinuities that may cause performance or other issues in effecting a transition. While fs_locations is available, default assumptions with regard to such classifications havenamespace essentially without respect tobe inferred (see Section 7.9.1 for details). In cases in which oneits physical location on a given server. This allows a single serveris expectedor a set of servers toaccept opaque values from the clientpresent a multi-server namespace thatoriginated from another server, the servers SHOULD encode the "opaque" values in big-endian byte order. If this is done, servers acting as replicas or immigratingencompasses file systemswill be able to parse values like stateids, directory cookies, filehandles, etc., even if their native byte order is different from thatlocated on multiple servers. Some likely uses ofother servers cooperatingthis include establishment of site-wide or organization-wide namespaces, or even knitting such together into a truly global namespace. Referrals occur when a client determines, upon first referencing a position in thereplication and migrationcurrent namespace, that it is part ofthea new filesystem. 7.7.1. File System Transitionssystem andSimultaneous Access When a singlethat the file systemmay be accessed at multiple locations, either because of an indicationis absent. When this occurs, typically by receiving the error NFS4ERR_MOVED, the actual location or locations of the file systemidentity as reportedcan be determined by fetching the fs_locationsattribute, the client will, depending on specific circumstances as discussed below, either: o Accessattribute. The locations-related attribute may designate a single file system location or multipleinstances simultaneously, each of which represents an alternate pathfile system locations, to be selected based on thesame data and metadata. o Accesses one instance (or setneeds ofinstances) and then transition to an alternative instance (or setthe client. Use ofinstances) as a resultmulti-server namespaces is enabled by NFSv4 but is not required. The use ofnetwork issues, server unresponsiveness, or server-directed migration. 7.7.2. Filehandlesmulti-server namespaces and their scope will depend on the applications used andFile System Transitions There are a number of ways in which filehandles can be handled across a filesystemtransition. Theseadministration preferences. Multi-server namespaces can bedivided into two broad classes depending upon whether the two file systems across which the transition happens share sufficient state to effect some sortestablished by a single server providing a large set ofcontinuityreferrals to all offile system handling. When there is no such cooperation in filehandle assignment,thetwoincluded file systems. Alternatively, a single multi-server namespace may be administratively segmented with separate referral file systemsare reported as being in different handle classes. In this case, all filehandles are assumed to expire as part(on separate servers) for each separately administered portion of the namespace. The top-level referral file systemtransition. Note that this behavior does not depend on fh_expire_type attribute and depends on the specification of the FH4_VOL_MIGRATION bit. When there is co-operation in filehandle assignment, the twoor any segment may use replicated referral file systems for higher availability. Generally, multi-server namespaces arereported as beingfor the most part uniform, in that the samehandle classes. In this case, persistent filehandles remain valid after the file system transition, while volatile filehandles (excluding those that are only volatile duedata made available to one client at a given location in theFH4_VOL_MIGRATION bit) are subjectnamespace is made available toexpiration on the target server. 7.7.3. Fileidsall clients at that location. 8.5. Location Entries andFile System Transitions The issue of continuity of fileidsServer Identity As mentioned above, a single location entry may have a server address target in theeventform of afile system transition needs to be addressed. The general expectation isDNS name thatin situations in whichmay represent multiple IP addresses, while multiple location entries may have their own server address targets that reference thetwosame server. When multiple addresses for the same server exist, the client may assume that for each file systeminstances are created byin the namespace of asingle vendor using some sortgiven server network address, there exist file systems at corresponding namespace locations for each of the other server network addresses. It may do this even in the absence of explicit listing in fs_locations. Such corresponding file systemimage copy, fileids willlocations can beconsistent acrossused as alternate locations, just as those explicitly specified via thetransition, while infs_locations attribute. If a single location entry designates multiple server IP addresses, theanalogous multi- vendor transitionsclient cannot assume that these addresses are multiple paths to the same server. In most cases, they willnot. This poses difficulties, especially forbe, but the clientwithout special knowledge of the transition mechanisms adopted by the server. NoteMUST verify thatalthough fileid is notbefore acting on that assumption. When two server addresses are designated by aREQUIRED attribute, many servers support fileidssingle location entry andmanythey correspond to different servers, this normally indicates some sort of misconfiguration, and so the client should avoid using such location entries when alternatives are available. When they are not, clientsprovide APIsshould pick one of IP addresses and use it, without using others thatdepend on fileids. It is importantare not directed tonote that whilethe same server. 8.6. Additional Client-Side Considerations When clientsthemselves may have no trouble withmake use of servers that implement referrals, replication, and migration, care should be taken that afileid changing asuser who mounts aresult ofgiven file system that includes a referral or a relocated file systemtransition event, applications do typically have accesscontinues to see a coherent picture of that user-side file system despite thefileid (e.g., via stat). The result isfact that it contains a number of server-side file systems thatan applicationmaywork perfectly well if therebe on different servers. One important issue isnoupward navigation from the root of a server- side file systeminstance transition or if any such transition is among instances created by a single vendor, yet be unabletodeal withits parent (specified as ".." in UNIX), in thesituationcase in which it transitions to that file system as a result of referral, migration, or amulti-vendortransitionoccurs at the wrong time. Providingas a result of replication. When thesame fileids inclient is at such amulti-vendor (multiple server vendors) environment has generally been heldpoint, and it needs tobe quite difficult. While there is workascend tobe done,the parent, itneedsmust go back tobe pointed out that this difficulty is partly self-imposed. Servers have typically identified fileid with inode number, i.e., withthe parent as seen within the multi-server namespace rather than sending aquantity usedLOOKUPP operation tofindthefileserver, which would result inquestion. This identification poses special difficulties for migration of athe parent within that server's single-server namespace. In order to do this, the client needs to remember the filehandles that represent such file systembetween vendors where assigningroots and use these instead of issuing a LOOKUPP operation to thesame indexcurrent server. This will allow the client to present to applications agiven fileconsistent namespace, where upward navigation and downward navigation are consistent. Another issue concerns refresh of referral locations. When referrals are used extensively, they maynot be possible. Note herechange as server configurations change. It is expected thata fileidclients will cache information related to traversing referrals so that future client-side requests are resolved locally without server communication. This isnot requiredusually rooted in client-side name look up caching. Clients should periodically purge this data for referral points in order tobe usefuldetect changes in location information. A potential problem exists if a client were tofind theallow an open owner to have state on multiple file systems on server, inquestion, onlythat it isunique withinunclear how thegiven file system. Servers preparedsequence numbers associated with open owners are toacceptbe dealt with, in the event of transparent state migration. A client can avoid such afileid assituation, if it ensures that any use of an open owner is confined to a singlepiece of metadata and store it apart from the value usedfile system. A server MAY decline toindex themigrate state associated with open owners that span multiple fileinformation can relatively easily maintain a fileid value across a migration event, allowing a truly transparent migration event.systems. Inany case, where servers can provide continuity of fileids, they should, andcases in which theclient should be ableserver chooses not tofind out thatmigrate suchcontinuity is available and take appropriate action. Information aboutstate, thecontinuity (or lack thereof) of fileids across a file system transition is represented by specifying whetherserver MUST return NFS4ERR_BAD_STATEID when thefile systems in question are ofclient uses those stateids on thesame fileid class. Note thatnew server. The server MUST return NFS4ERR_STALE_STATEID whenconsistent fileids do not exist across a transition (either because there is no continuity of fileids or because fileid is not a supported attributethe client uses those stateids ononethe old server, regardless ofinstances involved), and therewhether migration has occurred or not. 8.7. Effecting File System Referrals Referrals areno reliable filehandles across a transition event (either because thereeffected when an absent file system isno filehandle continuityencountered, and one orbecause the filehandlesmore alternate locations arevolatile),made available by the fs_locations attribute. The clientis inwill typically get an NFS4ERR_MOVED error, fetch the appropriate location information, and proceed to access the file system on aposition where it cannot verify that filesdifferent server, even though itwas accessing before the transition areretains its logical position within thesame objects. It is forced to assumeoriginal namespace. Referrals differ from migration events in thatno objectthey happen only when the client hasbeen renamed, and, unless there are guarantees that provide this (e.g.,not previously referenced the file system in question (so there isread-only), problems for applications may occur. Therefore, use of such configurations should be limitednothing tosituations where the problems that this may causetransition). Referrals canbe tolerated. 7.7.4. Fsids and File System Transitions Since fsids are generallyonlyunique within a per-server basis, itcome into effect when an absent file system islikelyencountered at its root. The examples given in the sections below are somewhat artificial in thattheyan actual client willchange during a file system transition. Clients shouldnot typically do a multi-component look up, but will have cached information regarding the upper levels of the name hierarchy. However, these example are chosen to make thefsids received fromrequired behavior clear and easy to put within theserver visiblescope of a small number of requests, without getting unduly into details of how specific clients might choose toapplications since theycache things. 8.7.1. Referral Example (LOOKUP) Let us suppose that the following COMPOUND is sent in an environment in which /this/is/the/path is absent from the target server. This maynotbeglobally unique, and because they may change duringfor a number of reasons. It may be the case that the file systemtransition event. Applications are best served if they are isolated from such transitions tohas moved, or it may be theextent possible. 7.7.5. The Change Attribute and File System Transitions Sincecase that thechange attribute is defined as a server-specific one, change attributes fetched from onetarget serverare normally presumedis functioning mainly, or solely, tobe invalidrefer clients to the servers onanother server. Such a presumptionwhich various file systems are located. o PUTROOTFH o LOOKUP "this" o LOOKUP "is" o LOOKUP "the" o LOOKUP "path" o GETFH o GETATTR(fsid,fileid,size,time_modify) Under the given circumstances, the following will be the result. o PUTROOTFH --> NFS_OK. The current fh istroublesome since it would invalidate all cached change attributes, requiring refetching. Even more disruptive,now theabsenceroot ofany assured continuitythe pseudo-fs. o LOOKUP "this" --> NFS_OK. The current fh is for /this and is within thechange attribute means that even ifpseudo-fs. o LOOKUP "is" --> NFS_OK. The current fh is for /this/is and is within thesame valuepseudo-fs. o LOOKUP "the" --> NFS_OK. The current fh isretrieved on refetch, no conclusions can be drawn as to whetherfor /this/is/the and is within theobject in question has changed.pseudo-fs. o LOOKUP "path" --> NFS_OK. Theidentical change attribute could be merely an artifact ofcurrent fh is for /this/is/the/path and is within amodifiednew, absent filewith a different change attribute construction algorithm, withsystem, but ... the client will never see the value of thatnew algorithm just happening to resultfh. o GETFH --> NFS4ERR_MOVED. Fails because current fh is in anidentical change value. When the twoabsent filesystems have consistent change attribute formats,system at the start of the operation, andwe say that they are inthesame change class,specification makes no exception for GETFH. o GETATTR(fsid,fileid,size,time_modify) Not executed because the failure of the GETFH stops processing of the COMPOUND. Given the failure of the GETFH, the clientmay assume a continuityhas the job ofchange attribute construction and handle this situation just as it would be handled without anydetermining the root of the absent file systemtransition. 7.7.6. Lock StateandFile System Transitions In awhere to find that filesystem transition,system, i.e., theclient needsserver and path relative tohandle cases in which the two servers have cooperated in state management and in which they have not. Cooperation by two serversthat server's root fh. Note here that instate management requires coordination of client IDs. Beforethis example, the clientattempts to use a client ID associated with one server in a request todid not obtain filehandles and attribute information (e.g., fsid) for theserver ofintermediate directories, so that it would not be sure where theotherabsent filesystem, it must eliminatesystem starts. It could be thepossibilitycase, for example, thattwo non-cooperating servers have assigned the same client ID by accident. In/this/is/the is thecaseroot ofmigration, the servers involved inthemigration of amoved file systemSHOULD transfer all server state from the original toand that thenew server. When this is done, it must be done in a wayreason thatis transparent totheclient. With replication, such a degreelook up ofcommon state"path" succeeded istypically not the case. This state transfer will reduce disruption tothat theclient when afile systemtransition occurs. Ifwas not absent on that operation but was moved between theservers are successful in transferring all state, thenlast LOOKUP and theclient may useGETFH (since COMPOUND is not atomic). Even if we had theexisting stateids associated with that client IDfsids for all of theold file system instance in connection withintermediate directories, we could have no way of knowing thatsame client ID in connection with/this/is/the/path was thetransitionedroot of a new filesystem instance. File systems cooperating in state management may actually share state or simply divide the identifier space so assystem, since we don't yet have its fsid. In order torecognize (and reject as stale) each other's stateidsget the necessary information, let us re-send the chain of LOOKUPs with GETFHs andclient IDs. Servers that do share state may not do so under all conditions orGETATTRs to atall times. Ifleast get theserver cannotfsids so we can be surewhen accepting a client ID that it reflects the locks the client was given, the server must treat all associated state as stale and report it as such towhere theclient.appropriate file system boundaries are. The clientmust establish a new client ID oncould choose to get fs_locations at thedestination, if it does not have one already, and reclaim locks if allowed bysame time but in most cases theserver. In this case, old stateids andclientIDs should not be presented to the new server since there is no assurance that theywillnot conflict with IDs valid on that server. When actual locks are not known to be maintained, the destination server may establishhave agrace period specificgood guess as tothe given file system, with non-reclaim locks being rejected for thatwhere filesystem, even though normal lockssystem boundaries arebeing granted(because of where NFS4ERR_MOVED was, and was not, received) making fetching of fs_locations unnecessary. OP01: PUTROOTFH --> NFS_OK - Current fh is root of pseudo-fs. OP02: GETATTR(fsid) --> NFS_OK - Just forother file systems. Clients should not infercompleteness. Normally, clients will know theabsencefsid of the pseudo-fs as soon as they establish communication with agrace period for file systems being transitioned to a server from responsesserver. OP03: LOOKUP "this" --> NFS_OK OP04: GETATTR(fsid) --> NFS_OK - Get current fsid torequests for othersee where filesystems. Insystem boundaries are. The fsid will be that for thecase of lock reclamationpseudo-fs in this example, so no boundary. OP05: GETFH --> NFS_OK - Current fh is fora given/this and is within pseudo-fs. OP06: LOOKUP "is" --> NFS_OK - Current fh is for /this/is and is within pseudo-fs. OP07: GETATTR(fsid) --> NFS_OK - Get current fsid to see where file systemafter aboundaries are. The fsid will be that for the pseudo-fs in this example, so no boundary. OP08: GETFH --> NFS_OK - Current fh is for /this/is and is within pseudo-fs. OP09: LOOKUP "the" --> NFS_OK - Current fh is for /this/is/the and is within pseudo-fs. OP10: GETATTR(fsid) --> NFS_OK - Get current fsid to see where file systemtransition, edge conditions can arise similar to thoseboundaries are. The fsid will be that forreclaim after server restart (althoughthe pseudo-fs in this example, so no boundary. OP11: GETFH --> NFS_OK - Current fh is for /this/is/the and is within pseudo-fs. OP12: LOOKUP "path" --> NFS_OK - Current fh is for /this/is/the/path and is within a new, absent file system, but ... - The client will never see thecasevalue of that fh. OP13: GETATTR(fsid, fs_locations) --> NFS_OK - We are getting theplanned state transfer associated with migration, these canfsid to know where the file system boundaries are. In this operation, the fsid will beavoided by securely recording lock state as partdifferent than that ofstate migration). Unlessthedestination server can guaranteeparent directory (which in turn was retrieved in OP10). Note thatlocksthe fsid we are given will not necessarily beincorrectly granted,preserved at thedestination server should not allow lock reclaimsnew location. That fsid might be different, andshould avoid establishing a grace period. (See Section 9.14in fact the fsid we have forfurther details.) Servers are encouraged to provide facilities to allow locks tothis file system might bereclaimed on the new server aftera valid fsid of a different file systemtransition. Often such facilities may not be availableon that new server. - In this particular case, we are pretty sure anyway that what has moved is /this/is/the/path rather than /this/is/the since we have the fsid of the latter andclient should be prepared to re-obtain locks, even thoughit ispossiblethat of theclient maypseudo-fs, which presumably cannot move. However, in other examples, we might not haveits LOCK or OPEN request denied due to a conflicting lock. The consequencesthis kind ofhaving no facilities availableinformation toreclaim locks on the new server will dependrely onthe type of environment. In some environments, such as the transition between read-only(e.g., /this/is/the might be a non-pseudo filesystems, such denial of locks should not pose large difficulties in practice. When an attemptsystem separate from /this/is/the/path), so we need tore-establish a lockhave other reliable source information ona new server is denied,theclient should treatboundary of thesituation as if its original lock had been revoked. Notefile system thatwhen the lockisgranted,moved. If, for example, theclient cannot assume that no conflicting lock couldfile system /this/is had moved, we would havebeen granted in the interim. Where change attribute continuity is present,a case of migration rather than referral, and once theclient may checkboundaries of thechange attribute to check for unwantedmigrated filemodifications. Where evensystem was clear we could fetch fs_locations. - We are fetching fs_locations because the fact that we got an NFS4ERR_MOVED at this point means that it isnot available, and the file systemmost likely that this isnot read-only,aclient may reasonably treat all pending locks as having been revoked. 7.7.6.1. Transitionsreferral and we need theLease_time Attribute In order that the client may appropriately manage its lease indestination. Even if it is the caseofthat /this/is/the is a file systemtransition,that has migrated, we will still need thedestination server must establish proper valueslocation information forthe lease_time attribute. When state is transferred transparently,thatstate should includefile system. OP14: GETFH --> NFS4ERR_MOVED - Fails because current fh is in an absent file system at thecorrect valuestart of thelease_time attribute. The lease_time attribute onoperation, and the specification makes no exception for GETFH. Note that this means thedestinationservermustwill neverbe less than that onsend thesource, since this would result in premature expiration ofclient alease granted byfilehandle from within an absent file system. Given thesource server. Upon transitions in which state is transferred transparently,above, the client knows where the root of the absent file system isunder no obligation to refetch(/this/is/the/path) by noting where thelease_time attributechange of fsid occurred (between "the" andmay continue to use"path"). The fs_locations attribute also gives thevalue previously fetched (onclient thesource server). If state has not been transferred transparently becauseactual location of theclient ID is rejected when presented toabsent file system, so that thenew server,referral can proceed. The server gives the clientshould fetchthevaluebare minimum oflease_time oninformation about thenew (i.e., destination) server, and use itabsent file system so that there will be very little scope forsubsequent locking requests. However,problems of conflict between information sent by the referring servermust respect a grace periodand information ofat least as long asthelease_timefile system's home. No filehandles and very few attributes are present on thesourcereferring server,in order to ensure that clients have ample time to reclaim their lock before potentially conflicting non-reclaimed locks are granted. 7.7.7. Write VerifiersandFile System Transitions In a file system transition,thetwo file systemsclient can treat those it receives as transient information with the function of enabling the referral. 8.7.2. Referral Example (READDIR) Another context in which a client maybe clusteredencounter referrals is when it does a READDIR on a directory in which some of thehandlingsub-directories are the roots ofunstably written data. When thisabsent file systems. Suppose such a directory istheread as follows: o PUTROOTFH o LOOKUP "this" o LOOKUP "is" o LOOKUP "the" o READDIR (fsid, size, time_modify, mounted_on_fileid) In this case, because rdattr_error is not requested, fs_locations is not requested, and some of thetwo file systems belong toattributes cannot be provided, thesame write-verifier class, write verifiers returned from one system mayresult will becompared to those returned byan NFS4ERR_MOVED error on theother and superfluous writes avoided. When two file systems belong to different write-verifier classes, any verifier generated by one must not be compared to one provided byREADDIR, with theother. Instead, it should be treateddetailed results asnot equal even when the values are identical. 7.7.8. Readdir Cookies and Verifiers and File System Transitions In a file system transition,follows: o PUTROOTFH --> NFS_OK. The current fh is at thetwo file systems may be consistent in their handlingroot ofREADDIR cookiesthe pseudo-fs. o LOOKUP "this" --> NFS_OK. The current fh is for /this andverifiers. When thisis within thecase,pseudo-fs. o LOOKUP "is" --> NFS_OK. The current fh is for /this/is and is within thetwo file systems belong to the same readdir class, READDIR cookiespseudo-fs. o LOOKUP "the" --> NFS_OK. The current fh is for /this/is/the andverifiers from one system may be recognized byis within theother andpseudo-fs. o READDIRoperations started on one server may be validly continued on the other, simply by presenting(fsid, size, time_modify, mounted_on_fileid) --> NFS4ERR_MOVED. Note that thecookie and verifiersame error would have been returnedby a READDIR operation done onif /this/is/the had migrated, but it is returned because thefirst file system todirectory contains thesecond. When tworoot of an absent filesystems belong to different readdir classes, anysystem. So now suppose that we re-send with rdattr_error: o PUTROOTFH o LOOKUP "this" o LOOKUP "is" o LOOKUP "the" o READDIRcookie and verifier generated by one(rdattr_error, fsid, size, time_modify, mounted_on_fileid) The results will be: o PUTROOTFH --> NFS_OK. The current fh isnot valid onat thesecond, and must not be presented to that server byroot of theclient.pseudo-fs. o LOOKUP "this" --> NFS_OK. Theclient should act as if the verifier was rejected. 7.7.9. File System Data and File System Transitions When multiple replicas existcurrent fh is for /this andare used simultaneously or in succession by a client, applications using them will normally expect that they contain eitheris within thesame data or data thatpseudo-fs. o LOOKUP "is" --> NFS_OK. The current fh isconsistent withfor /this/is and is within thenormal sorts of changes that are made by other clients updatingpseudo-fs. o LOOKUP "the" --> NFS_OK. The current fh is for /this/is/the and is within thedata ofpseudo-fs. o READDIR (rdattr_error, fsid, size, time_modify, mounted_on_fileid) --> NFS_OK. The attributes for directory entry with thefile system (with metadata beingcomponent named "path" will only contain rdattr_error with thesamevalue NFS4ERR_MOVED, together with an fsid value and a value for mounted_on_fileid. So suppose we do another READDIR tothe degree inferred by theget fs_locationsattribute). However, when multiple file systems are presented(although we could have used a GETATTR directly, asreplicas of one another, the precise relationship betweenin Section 8.7.1). o PUTROOTFH o LOOKUP "this" o LOOKUP "is" o LOOKUP "the" o READDIR (rdattr_error, fs_locations, mounted_on_fileid, fsid, size, time_modify) The results would be: o PUTROOTFH --> NFS_OK. The current fh is at thedataroot ofone andthedata of anotherpseudo-fs. o LOOKUP "this" --> NFS_OK. The current fh isnot, as a general matter, specified by the NFSv4 protocol. Itfor /this and isquite possible to present as replicas file systems wherewithin thedata of those file systems is sufficiently different that some applications have problems dealing withpseudo-fs. o LOOKUP "is" --> NFS_OK. The current fh is for /this/is and is within thetransition between replicas.pseudo-fs. o LOOKUP "the" --> NFS_OK. Thenamespacecurrent fh is for /this/is/the and is within the pseudo-fs. o READDIR (rdattr_error, fs_locations, mounted_on_fileid, fsid, size, time_modify) --> NFS_OK. The attributes willtypicallybeconstructed so that applications can choose an appropriate level of support, so that in one position inas shown below. The attributes for thenamespace a varied set of replicasdirectory entry with the component named "path" willbe listed, while in anotheronlythose thatcontain: o rdattr_error (value: NFS_OK) o fs_locations o mounted_on_fileid (value: unique fileid within referring file system) o fsid (value: unique value within referring server) The attributes for entry "path" will not contain size or time_modify because these attributes areup-to-date may be considered replicas.not available within an absent file system. 8.8. Theprotocol does define four special cases ofAttribute fs_locations The fs_locations attribute is structured in therelationship among replicasfollowing way: struct fs_location4 { utf8str_cis server<>; pathname4 rootpath; }; struct fs_locations4 { pathname4 fs_root; fs_location4 locations<>; }; The fs_location4 data type is used tobe specified byrepresent theserver and relied uponlocation of a file system byclients: o When multipleproviding a serveraddresses correspond toname and thesame actual server,path to theclient may depend onroot of thefact that changes to data, metadata, or locks made on onefile systemare immediately reflected on others. owithin that server's namespace. Whenmultiple replicas exist and are used simultaneously byaclient, they must designate the same data. Whereset of servers have corresponding file systemsare writable, a change made on one instance must be visible on all instances, immediately uponat theearliersame path within their namespaces, an array of server names may be provided. An entry in thereturnserver array is a UTF-8 string and represents one ofthe modifying requestera traditional DNS host name, IPv4 address, IPv6 address, or an zero- length string. A zero-length string SHOULD be used to indicate thevisibility of that change on any ofcurrent address being used for theassociated replicas. This allowsRPC call. It is not aclient to use these replicas simultaneously without any special adaptation to the factrequirement thatthere are multiple replicas. In this case, locks (whether share reservations or byte-range locks), and delegations obtained on one replica are immediately reflected onallreplicas, even though these locks willservers that share the same rootpath bemanaged under a set of client IDs. o Whenlisted in onereplicafs_location4 instance. The array of server names isdesignated asprovided for convenience. Servers that share thesuccessor instance to another existing instance after return NFS4ERR_MOVED (i.e.,same rootpath may also be listed in separate fs_location4 entries in thecasefs_locations attribute. The fs_locations4 data type and fs_locations attribute contain an array ofmigration),such locations. Since theclientnamespace of each server maydepend onbe constructed differently, thefact that all changes written to stable storage on"fs_root" field is provided. The path represented by fs_root represents theoriginal instance are written to stable storagelocation of thesuccessor (uncommitted writes are dealt with in Section 7.7.7). o Where afile systemis not writable but represents a read-only copy (possibly periodically updated) of a writable file system, clients have similar requirements with regard toin thepropagation of updates. They may need a guaranteecurrent server's namespace, i.e., thatany change visible onof theoriginal file system instance must be immediately visible on any replica beforeserver from which theclient transitions access to that replica, in order to avoid any possibility that a client, in effecting a transitionfs_locations attribute was obtained. The fs_root path is meant toa replica, will see any reversion inaid the client by clearly referencing the root of the file systemstate. Since these file systemswhose locations arepresumed to be unsuitable for simultaneous use, there isbeing reported, nospecification of how locking is handled; in general, locks obtained on onematter what object within the current file systemwill be separate from thosethe current filehandle designates. The fs_root is simply the pathname the client used to reach the object onothers. Since these are goingthe current server (i.e., the object tobe read- only file systems, thiswhich the fs_locations attribute applies). When the fs_locations attribute isnot expected to pose an issue for clients or applications. 7.8. Effecting File System Referrals Referralsinterrogated and there areeffected when an absentno alternate file systemis encountered, and one or more alternate locations are made available bylocations, thefs_locations attribute. The client will typically getserver SHOULD return a zero- length array of fs_location4 structures, together with a valid fs_root. As anNFS4ERR_MOVED error, fetch the appropriate location information, and proceed to access theexample, suppose there is a replicated file systemon a different server, even though it retains its logical position within the original namespace. Referrals differ from migration events in that they happen only when the client has not previously referencedlocated at two servers (servA and servB). At servA, the file systemin question (so thereisnothing to transition). Referrals can only come into effect when an absentlocated at path /a/b/c. At, servB the file system isencounteredlocated atits root. The examples given inpath /x/y/z. If thesections below are somewhat artificial in that an actualclientwill not typically do a multi-component look up, but will have cached information regarding the upper levels of the name hierarchy. However, these example are chosenwere tomakeobtain therequired behavior clear and easy to put withinfs_locations value for thescope of a small number of requests, without getting unduly into details of how specific clientsdirectory at /a/b/c/d, it mightchoose to cache things. 7.8.1. Referral Example (LOOKUP) Let us supposenot necessarily know that thefollowing COMPOUNDfile system's root issentlocated in servA's namespace at /a/b/c. When the client switches to servB, it will need to determine that the directory it first referenced at servA is now represented by the path /x/y/z/d on servB. To facilitate this, the fs_locations attribute provided by servA would have anenvironmentfs_root value of /a/b/c and two entries inwhich /this/is/the/path is absent fromfs_locations. One entry in fs_locations will be for itself (servA) and thetarget server. This mayother will be for servB with anumberpath ofreasons. It may be/x/y/z. With this information, thecase thatclient is able to substitute /x/y/z for thefile system has moved, or it may be the case that/a/b/c at thetarget server is functioning mainly, or solely, to refer clientsbeginning of its access path and construct /x/y/z/d to use for theservers on which various file systems are located. o PUTROOTFH o LOOKUP "this" o LOOKUP "is" o LOOKUP "the" o LOOKUP "path" o GETFH o GETATTR(fsid,fileid,size,time_modify) Under the given circumstances,new server. Note that: there is no requirement that thefollowing willnumber of components in each rootpath be theresult. o PUTROOTFH --> NFS_OK. The current fhsame; there isnowno relation between therootnumber of components in rootpath or fs_root, and none of thepseudo-fs. o LOOKUP "this" --> NFS_OK. The current fh is for /thiscomponents in each rootpath andis withinfs_root have to be thepseudo-fs. o LOOKUP "is" --> NFS_OK.same. In the above example, we could have had a third element in the locations array, with server equal to "servC", and rootpath equal to "/I/II", and a fourth element in locations with server equal to "servD" and rootpath equal to "/aleph/beth/gimel/daleth/he". Thecurrent fhrelationship between fs_root to a rootpath is that the client replaces the pathname indicated in fs_root for/this/is and is withinthepseudo-fs. o LOOKUP "the" --> NFS_OK. Thecurrentfh isserver for/this/is/the and is withinthepseudo-fs. o LOOKUP "path" --> NFS_OK. The current fh issubstitute indicated in rootpath for/this/is/the/path and is withinthe new server. For an example of anew, absentreferred or migrated file system,but ... the client will never see the value of that fh. o GETFH --> NFS4ERR_MOVED. Fails because current fhsuppose there isin an absenta file system located at serv1. At serv1, thestartfile system is located at /az/buky/vedi/glagoli. The client finds that object at glagoli has migrated (or is a referral). The client gets the fs_locations attribute, which contains an fs_root of /az/buky/vedi/ glagoli, and one element in theoperation,locations array, with server equal to serv2, and rootpath equal to /izhitsa/fita. The client replaces /az/ buky/vedi/glagoli with /izhitsa/fita, and uses thespecification makes no exception for GETFH. o GETATTR(fsid,fileid,size,time_modify) Not executed becauselatter pathname on serv2. Thus, thefailure ofserver MUST return an fs_root that is equal to theGETFH stops processing ofpath theCOMPOUND. Givenclient used to reach thefailure ofobject to which theGETFH,fs_locations attribute applies. Otherwise, the clienthascannot determine thejob of determiningnew path to use on therootnew server. 8.8.1. Inferring Transition Modes When fs_locations is used, information about the specific locations should be assumed based on the following rules. The following rules are general and apply irrespective of theabsentcontext. o All listed file systemand where to find that file system, i.e.,instances should be considered as of theserversame handle class if andpath relative to that server's root fh. Note here that in this example,only if theclient did not obtain filehandles andcurrent fh_expire_type attributeinformation (e.g., fsid) fordoes not include theintermediate directories, soFH4_VOL_MIGRATION bit. Note thatit wouldin the case of referral, filehandle issues do not apply since there can besure whereno filehandles known within theabsentcurrent file systemstarts. It could be the case, for example, that /this/is/thenor is there any access to theroot of the moved file system and that the reason that the look up of "path" succeeded is thatfh_expire_type attribute on the referring (absent) file system. o All listed file systemwas not absent on that operation but was moved betweeninstances should be considered as of thelast LOOKUPsame fileid class if andthe GETFH (since COMPOUND is not atomic). Evenonly ifwe hadthefsids for all offh_expire_type attribute indicates persistent filehandles and does not include theintermediate directories, we could have no way of knowingFH4_VOL_MIGRATION bit. Note that/this/is/the/path wasin therootcase ofa new file system,referral, fileid issues do not apply sincewe don't yet have its fsid. In order to get the necessary information, let us re-send the chain of LOOKUPs with GETFHs and GETATTRs to at least get the fsids so wethere can besure whereno fileids known within theappropriatereferring (absent) file systemboundaries are. The client could choosenor is there any access toget fs_locations at the same time but in most casestheclient will have a good guess as to wherefh_expire_type attribute. o All file systemboundaries are (becauseinstances servers should be considered as ofwhere NFS4ERR_MOVED was, and was not, received) making fetchingdifferent change classes. o All file system instances servers should be considered as offs_locations unnecessary. OP01: PUTROOTFH --> NFS_OK - Current fh is rootdifferent readdir classes. For other class assignments, handling ofpseudo-fs. OP02: GETATTR(fsid) --> NFS_OK - Justfile system transitions depends on the reasons forcompleteness. Normally, clients will knowthefsid oftransition: o When thepseudo-fs as soon as they establish communication with a server. OP03: LOOKUP "this" --> NFS_OK OP04: GETATTR(fsid) --> NFS_OK - Get current fsidtransition is due tosee where file system boundaries are. The fsid will bemigration, thatforis, thepseudo-fs in this example, so no boundary. OP05: GETFH --> NFS_OK - Current fh is for /this and is within pseudo-fs. OP06: LOOKUP "is" --> NFS_OK - Current fh is for /this/is and is within pseudo-fs. OP07: GETATTR(fsid) --> NFS_OK - Get current fsidclient was directed tosee wherea new file systemboundaries are. The fsid willafter receiving an NFS4ERR_MOVED error, the target should bethat fortreated as being of thepseudo-fs in this example, so no boundary. OP08: GETFH --> NFS_OK - Current fhsame write- verifier class as the source. o When the transition isfor /this/isdue to failover to another replica, that is, the client selected another replica without receiving andis within pseudo-fs. OP09: LOOKUP "the" --> NFS_OK - Current fh isNFS4ERR_MOVED error, the target should be treated as being of a different write-verifier class from the source. The specific choices reflect typical implementation patterns for/this/is/thefailover andis within pseudo-fs. OP10: GETATTR(fsid) --> NFS_OK - Get current fsidcontrolled migration, respectively. See Section 17 for a discussion on the recommendations for the security flavor tosee where file system boundaries are. The fsid willbe used by any GETATTR operation thatforrequests thepseudo-fs in this example, so no boundary. OP11: GETFH --> NFS_OK - Current fh is for /this/is/the"fs_locations" attribute. 9. File Locking andis within pseudo-fs. OP12: LOOKUP "path" --> NFS_OK - Current fh is for /this/is/the/path and is within a new, absent file system, but ... - The client will never seeShare Reservations Integrating locking into thevalueNFS protocol necessarily causes it to be stateful. With the inclusion ofthat fh. OP13: GETATTR(fsid, fs_locations) --> NFS_OK - We are gettingshare reservations thefsid to know whereprotocol becomes substantially more dependent on state than thefile system boundaries are.traditional combination of NFS and NLM (Network Lock Manager) [xnfs]. There are three components to making this state manageable: o clear division between client and server o ability to reliably detect inconsistency in state between client and server o simple and robust recovery mechanisms In thisoperation,model, thefsid will be different than that ofserver owns theparent directory (which in turn was retrievedstate information. The client requests changes inOP10). Note thatlocks and thefsid weserver responds with the changes made. Non-client-initiated changes in locking state aregiven will not necessarily be preserved atinfrequent. The client receives prompt notification of such changes and can adjust its view of thenew location. That fsid might be different,locking state to reflect the server's changes. Individual pieces of state created by the server andin factpassed to thefsid we have for this file system might beclient at its request are represented by 128-bit stateids. These stateids may represent avalid fsidparticular open file, a set of byte-range locks held by a particular owner, or a recallable delegation of privileges to access adifferentfilesystem on that new server. - In thisin particularcase, we are pretty sure anyway that what has movedways or at a particular location. In all cases, there is/this/is/the/path rather than /this/is/the since we havea transition from thefsid ofmost general information that represents a client as a whole to thelattereventual lightweight stateid used for most client and server locking interactions. The details of this transition will vary with the type of object but it always starts with a client ID. To support Win32 share reservations it isthat ofnecessary to atomically OPEN or CREATE files and apply thepseudo-fs, which presumably cannot move. However,appropriate locks inother examples, we mightthe same operation. Having a separate share/unshare operation would nothave this kindallow correct implementation ofinformationthe Win32 OpenFile API. In order torely on (e.g., /this/is/the might becorrectly implement share semantics, the previous NFS protocol mechanisms used when anon-pseudofilesystem separate from /this/is/the/path), so weis opened or created (LOOKUP, CREATE, ACCESS) need tohave other reliable source information onbe replaced. The NFSv4 protocol has an OPEN operation that subsumes theboundaryNFSv3 methodology of LOOKUP, CREATE, and ACCESS. However, because many operations require a filehandle, thefile system thattraditional LOOKUP ismoved. If, for example, the file system /this/is had moved, we would havepreserved to map acase of migration rather than referral, and oncefile name to filehandle without establishing state on theboundariesserver. The policy of granting access or modifying files is managed by themigrated file system was clear we could fetch fs_locations. - We are fetching fs_locations becauseserver based on thefact that we got an NFS4ERR_MOVED at this point means that itclient's state. These mechanisms can implement policy ranging from advisory only locking to full mandatory locking. 9.1. Opens and Byte-Range Locks It ismost likelyassumed thatthis ismanipulating areferralbyte-range lock is rare when compared to READ andwe need the destination. Even if itWRITE operations. It isthe casealso assumed that/this/is/theserver restarts and network partitions are relatively rare. Therefore it isa file systemimportant thathas migrated, we will still needthelocationREAD and WRITE operations have a lightweight mechanism to indicate if they possess a held lock. A byte-range lock request contains the heavyweight informationfor that file system. OP14: GETFH --> NFS4ERR_MOVED - Fails because current fh is in an absent file system atrequired to establish a lock and uniquely define thestartowner of theoperation, andlock. The following sections describe thespecification makes no exception for GETFH. Note that this meanstransition from the heavy weight information to the eventual stateid used for most client and serverwill never sendlocking and lease interactions. 9.1.1. Client ID For each LOCK request, the client must identify itself to the server. This is done in such afilehandle from within an absent file system. Givenway as to allow for correct lock identification and crash recovery. A sequence of a SETCLIENTID operation followed by a SETCLIENTID_CONFIRM operation is required to establish theabove,identification onto the server. Establishment of identification by a new incarnation of the clientknows wherealso has therooteffect of immediately breaking any leased state that a previous incarnation of theabsent file system is (/this/is/the/path) by noting whereclient might have had on thechange of fsid occurred (between "the" and "path"). The fs_locations attribute also givesserver, as opposed to forcing the new client incarnation to wait for theactual location ofleases to expire. Breaking theabsent file system, so thatlease state amounts to thereferral can proceed. Theservergivesremoving all lock, share reservation, and, where the server is not supporting the CLAIM_DELEGATE_PREV claim type, all delegation state associated with same client with thebare minimumsame identity. For discussion ofinformation aboutdelegation state recovery, see Section 10.2.1. Owners of opens and owners of byte-range locks are separate entities and remain separate even if theabsent file system so that there will be very little scope for problemssame opaque arrays are used to designate owners ofconflicteach. The protocol distinguishes betweeninformation sentopen- owners (represented bythe referring serveropen_owner4 structures) andinformationlock-owners (represented by lock_owner4 structures). Both sorts ofthe file system's home. No filehandles and very few attributes are present on the referring server,owners consist of a clientid and an opaque owner string. For each client, theclient can treat those it receives as transient informationset of distinct owner values used with that client constitutes thefunctionset ofenablingowners of that type, for thereferral. 7.8.2. Referral Example (READDIR) Another context in which a client may encounter referralsgiven client. Each open iswhen it doesassociated with aREADDIR onspecific open-owner while each byte- range lock is associated with adirectory in which some oflock-owner and an open-owner, thesub-directories arelatter being theroots of absent file systems. Suppose such a directoryopen-owner associated with the open file under which the LOCK operation was done. Client identification isread as follows: o PUTROOTFH o LOOKUP "this" o LOOKUP "is" o LOOKUP "the" o READDIR (fsid, size, time_modify, mounted_on_fileid) In this case, because rdattr_errorencapsulated in the following structure: struct nfs_client_id4 { verifier4 verifier; opaque id<NFS4_OPAQUE_LIMIT>; }; The first field, verifier isnot requested, fs_locationsa client incarnation verifier that isnot requested, and some ofused to detect client reboots. Only if theattributes cannot be provided,verifier is different from that which theresult will be an NFS4ERR_MOVED error onserver has previously recorded for theREADDIR, withclient (as identified by thedetailed results as follows: o PUTROOTFH --> NFS_OK. The current fh is atsecond field of therootstructure, id) does the server start the process of canceling thepseudo-fs. o LOOKUP "this" --> NFS_OK.client's leased state. Thecurrent fh is for /this andsecond field, id iswithina variable length string that uniquely defines thepseudo-fs. o LOOKUP "is" --> NFS_OK. The current fh isclient. There are several considerations for/this/is and is withinhow thepseudo-fs. o LOOKUP "the" --> NFS_OK. The current fh is for /this/is/the and is withinclient generates thepseudo-fs.id string: oREADDIR (fsid, size, time_modify, mounted_on_fileid) --> NFS4ERR_MOVED. NoteThe string should be unique so that multiple clients do not present the sameerror would have been returned if /this/is/the had migrated, but it is returned because the directory contains the rootstring. The consequences of two clients presenting the same string range from one client getting anabsent file system. So now suppose that we re-send with rdattr_error: o PUTROOTFH o LOOKUP "this" o LOOKUP "is" o LOOKUP "the"error to one client having its leased state abruptly and unexpectedly canceled. oREADDIR (rdattr_error, fsid, size, time_modify, mounted_on_fileid)Theresults will be: o PUTROOTFH --> NFS_OK.string should be selected so the subsequent incarnations (e.g., reboots) of the same client cause the client to present the same string. Thecurrent fhimplementor isatcautioned against an approach that requires therootstring to be recorded in a local file because this precludes the use of thepseudo-fs. o LOOKUP "this" --> NFS_OK. The current fhimplementation in an environment where there isfor /thisno local disk and all file access iswithin the pseudo-fs.from an NFSv4 server. oLOOKUP "is" --> NFS_OK.Thecurrent fh isstring should be different for/this/is and is withineach server network address that thepseudo-fs. o LOOKUP "the" --> NFS_OK.client accesses, rather than common to all server network addresses. Thecurrent fhreason is that it may not be possible for/this/is/the andthe client to tell if the same server iswithinlistening on multiple network addresses. If thepseudo-fs. o READDIR (rdattr_error, fsid, size, time_modify, mounted_on_fileid) --> NFS_OK. The attributes for directory entryclient issues SETCLIENTID with thecomponent named "path"same id string to each network address of such a server, the server willonly contain rdattr_error withthink it is thevalue NFS4ERR_MOVED, together with an fsid valuesame client, anda value for mounted_on_fileid. So suppose we do another READDIReach successive SETCLIENTID will cause the server toget fs_locations (although we could have used a GETATTR directly, as in Section 7.8.1). o PUTROOTFH o LOOKUP "this" o LOOKUP "is" o LOOKUP "the" o READDIR (rdattr_error, fs_locations, mounted_on_fileid, fsid, size, time_modify) The results would be: o PUTROOTFH --> NFS_OK. The current fh is atbegin therootprocess of removing thepseudo-fs.client's previous leased state. oLOOKUP "this" --> NFS_OK.Thecurrent fh isalgorithm for/this and is withingenerating thepseudo-fs. o LOOKUP "is" --> NFS_OK. The current fh is for /this/isstring should not assume that the client's network address won't change. This includes changes between client incarnations andis withineven changes while thepseudo-fs. o LOOKUP "the" --> NFS_OK. The current fhclient isfor /this/is/thestilling running in its current incarnation. This means that if the client includes just the client's and server's network address in the id string, there iswithina real risk, after thepseudo-fs. o READDIR (rdattr_error, fs_locations, mounted_on_fileid, fsid, size, time_modify) --> NFS_OK. The attributes will be as shown below. The attributes forclient gives up thedirectory entry withnetwork address, that another client, using a similar algorithm for generating thecomponent named "path"id string, willonly contain:generate a conflicting id string. Given the above considerations, an example of a well generated id string is one that includes: ordattr_error (value: NFS_OK)The server's network address. ofs_locationsThe client's network address. omounted_on_fileid (value:For a user level NFSv4 client, it should contain additional information to distinguish the client from other user level clients running on the same host, such as an universally uniquefileid within referring file system)identifier (UUID). ofsid (value: unique value within referring server) The attributes for entry "path" will not contain sizeAdditional information that tends to be unique, such as one ortime_modify because these attributes are not available within an absent file system. 7.9. The Attribute fs_locationsmore of: * Thefs_locations attributeclient machine's serial number (for privacy reasons, it isstructured inbest to perform some one way function on thefollowing way: struct fs_location4 { utf8val_REQUIRED4 server<>; pathname4 rootpath; }; struct fs_locations4 { pathname4 fs_root; fs_location4 locations<>; };serial number). * A MAC address. * Thefs_location4 data typetimestamp of when the NFSv4 software was first installed on the client (though this isusedsubject torepresentthelocation of a file system by providingpreviously mentioned caution about using information that is stored in aserver name andfile, because thepathfile might only be accessible over NFSv4). * A true random number. However since this number ought to be theroot ofsame between client incarnations, this shares thefile system withinsame problem as thatserver's namespace. When a setofservers have corresponding file systems atthesame path within their namespaces, an arrayusing the timestamp ofserver names may be provided. An entry intheserver array issoftware installation. As aUTF-8 string and represents one ofsecurity measure, the server MUST NOT cancel atraditional DNS host name, IPv4 address, IPv6 address, or an zero- length string. A zero-length string SHOULD be used to indicateclient's leased state if thecurrent address being used forprincipal that established theRPC call. Itstate for a given id string is nota requirement that all servers that sharethe samerootpath be listed in one fs_location4 instance. The array of server names is provided for convenience. Servers that shareas thesame rootpath may also be listed in separate fs_location4 entries inprincipal issuing thefs_locations attribute. The fs_locations4 data typeSETCLIENTID. Note that SETCLIENTID andfs_locations attribute contain an arraySETCLIENTID_CONFIRM has a secondary purpose ofsuch locations. Sinceestablishing thenamespace of each server may be constructed differently,information the"fs_root" field is provided. The path represented by fs_root representsserver needs to make callbacks to thelocationclient for purpose of supporting delegations. It is permitted to change this information via SETCLIENTID and SETCLIENTID_CONFIRM within thefile system in the current server's namespace, i.e., thatsame incarnation of theserver from whichclient without removing thefs_locations attribute was obtained. The fs_root path is meant to aidclient's leased state. Once a SETCLIENTID and SETCLIENTID_CONFIRM sequence has successfully completed, the clientby clearly referencinguses therootshorthand client identifier, of type clientid4, instead of thefile system whose locations are being reported, no matter what object within the current file system the current filehandle designates. The fs_rootlonger and less compact nfs_client_id4 structure. This shorthand client identifier (a client ID) issimplyassigned by thepathnameserver and should be chosen so that it will not conflict with a client ID previously assigned by the server. This applies across server restarts or reboots. When a clientusedID is presented toreach the object ona server and that client ID is not recognized, as would happen after a server reboot, thecurrentserver(i.e.,will reject theobject to whichrequest with thefs_locations attribute applies).error NFS4ERR_STALE_CLIENTID. When this happens, thefs_locations attribute is interrogatedclient must obtain a new client ID by use of the SETCLIENTID operation andthere are no alternate file system locations,then proceed to any other necessary recovery for the serverSHOULD returnreboot case (See Section 9.6.2). The client must also employ the SETCLIENTID operation when it receives azero- length array of fs_location4 structures, together withNFS4ERR_STALE_STATEID error using avalid fs_root. As an example, suppose there isstateid derived from its current client ID, since this also indicates areplicated file system located at two servers (servA and servB). At servA,server reboot which has invalidated thefile system is located at path /a/b/c. At, servBexisting client ID (see Section 9.6.2 for details). See thefile system is located at path /x/y/z.detailed descriptions of SETCLIENTID and SETCLIENTID_CONFIRM for a complete specification of the operations. 9.1.2. Server Release of Client ID If the server determines that the clientwereholds no associated state for its client ID, the server may choose toobtainrelease thefs_locations valueclient ID. The server may make this choice forthe directory at /a/b/c/d, it might not necessarily knowan inactive client so that resources are not consumed by those intermittently active clients. If thefile system's root is located in servA's namespace at /a/b/c. Whenclient contacts the server after this release, the server must ensure the clientswitches to servB,receives the appropriate error so that it willneeduse the SETCLIENTID/SETCLIENTID_CONFIRM sequence todetermineestablish a new identity. It should be clear that thedirectory it first referenced at servA is now represented by the path /x/y/z/d on servB. To facilitate this,server must be very hesitant to release a client ID since thefs_locations attribute provided by servA would haveresulting work on the client to recover from such anfs_root value of /a/b/c and two entries in fs_locations. One entry in fs_locationsevent will befor itself (servA) andtheother will besame burden as if the server had failed and restarted. Typically a server would not release a client ID unless there had been no activity from that client forservB withmany minutes. Note that if the id string in apath of /x/y/z. With this information,SETCLIENTID request is properly constructed, and if the clientis abletakes care tosubstitute /x/y/zuse the same principal for each successive use of SETCLIENTID, then, barring an active denial of service attack, NFS4ERR_CLID_INUSE should never be returned. However, client bugs, server bugs, or perhaps a deliberate change of the/a/b/c atprincipal owner of thebeginningid string (such as the case ofits access patha client that changes security flavors, andconstruct /x/y/z/d to use forunder the newserver. Note that:flavor, there is norequirement thatmapping to thenumber of componentsprevious owner) will ineach rootpath berare cases result in NFS4ERR_CLID_INUSE. In that event, when thesame; there isserver gets a SETCLIENTID for a client ID that currently has norelation between the number of components in rootpathstate, orfs_root, and none ofit has state, but thecomponents in each rootpathlease has expired, rather than returning NFS4ERR_CLID_INUSE, the server MUST allow the SETCLIENTID, andfs_root have to beconfirm thesame. Innew client ID if followed by theabove example, we could have had a third element inappropriate SETCLIENTID_CONFIRM. 9.1.3. Stateid Definition When thelocations array, withserverequal to "servC", and rootpath equal to "/I/II", andgrants afourth element in locations with server equal to "servD"lock of any type (including opens, byte- range locks, androotpath equal to "/aleph/beth/gimel/daleth/he". The relationship between fs_root todelegations), it responds with arootpath isunique stateid thatthe client replaces the pathname indicated in fs_rootrepresents a set of locks (often a single lock) for thecurrent server forsame file, of thesubstitute indicated in rootpath forsame type, and sharing thenew server. Forsame ownership characteristics. Thus, opens of the same file by different open-owners each have anexampleidentifying stateid. Similarly, each set of byte-range locks on areferred or migratedfilesystem, suppose there isowned by afile system located at serv1. At serv1, the file system is located at /az/buky/vedi/glagoli. The client finds that object at glagolispecific lock-owner hasmigrated (orits own identifying stateid. Delegations also have associated stateids by which they may be referenced. The stateid is used as areferral). The client gets the fs_locations attribute, which contains an fs_rootshorthand reference to a lock or set of/az/buky/vedi/ glagoli,locks, andone element ingiven a stateid, thelocations array, withserverequal to serv2, and rootpath equal to /izhitsa/fita. The client replaces /az/ buky/vedi/glagoli with /izhitsa/fita, and usescan determine thelatter pathname on serv2. Thus,associated state-owner or state-owners (in theserver MUST returncase of anfs_root that is equal toopen-owner/ lock-owner pair) and thepathassociated filehandle. When stateids are used, theclient used to reach the object to which the fs_locations attribute applies. Otherwise,current filehandle must be the one associated with that stateid. All stateids associated with a given clientcannot determine the new path to use onID are associated with a common lease that represents thenew server. 7.9.1. Inferring Transition Modes When fs_locations is used, information aboutclaim of those stateids and thespecific locations shouldobjects they represent to beassumed based onmaintained by thefollowing rules. The following rules are general and apply irrespectiveserver. See Section 9.5 for a discussion of thecontext. o All listed file system instances shouldlease. Each stateid must beconsidered as of the same handle class if and only ifunique to thecurrent fh_expire_type attribute doesserver. Many operations take a stateid as an argument but notinclude the FH4_VOL_MIGRATION bit. Note that ina clientid, so thecase of referral, filehandle issues do not apply since there canserver must beno filehandles known within the current file system nor is there any accessable to infer thefh_expire_type attribute on the referring (absent) file system. o All listed file system instances should be considered as ofclient from thesame fileid class if and only ifstateid. 9.1.3.1. Stateid Types With thefh_expire_type attribute indicates persistent filehandles and does not includeexception of special stateids (see Section 9.1.3.3), each stateid represents locking objects of one of a set of types defined by theFH4_VOL_MIGRATION bit.NFSv4 protocol. Note that inthe caseall these cases, where we speak ofreferral, fileid issues do not apply since there can be no fileids known within the referring (absent) file system norguarantee, it is understood thereany access toare situations such as a client restart, or lock revocation, that allow thefh_expire_type attribute. o All file system instances servers shouldguarantee to beconsidered as of different change classes.voided. oAll file system instances servers should be considered as of different readdir classes. For other class assignments, handlingStateids may represent opens offile system transitions depends onfiles. Each stateid in this case represents thereasonsOPEN state for a given client ID/open-owner/filehandle triple. Such stateids are subject to change (with consequent incrementing of thetransition: o When the transition is duestateid's seqid) in response tomigration,OPENs thatis,result in upgrade and OPEN_DOWNGRADE operations. o Stateids may represent sets of byte-range locks. All locks held on a particular file by a particular owner and all gotten under theclient was directed toaegis of anewparticular open filesystem after receiving an NFS4ERR_MOVED error,are associated with a single stateid with thetarget should be treated asseqid being incremented whenever LOCK and LOCKU operations affect that set ofthe same write- verifier class as the source.locks. oWhenStateids may represent file delegations, which are recallable guarantees by thetransition is due to failoverserver toanother replica,the client, thatis,other clients will not reference, or will not modify a particular file, until the delegation is returned. A stateid represents a single delegation held by a clientselected another replica without receiving and NFS4ERR_MOVED error, the target should be treated as being offor adifferent write-verifier class from the source. The specific choices reflect typical implementation patterns for failoverparticular filehandle. 9.1.3.2. Stateid Structure Stateids are divided into two fields, a 96-bit "other" field identifying the specific set of locks andcontrolled migration, respectively. Seea 32-bit "seqid" sequence value. Except in the case of special stateids (see Section17 for9.1.3.3), adiscussion onparticular value of therecommendations"other" field denotes a set of locks of the same type (for example, byte-range locks, opens, or delegations), for a specific file or directory, and sharing thesecurity flavorsame ownership characteristics. The seqid designates a specific instance of such a set of locks, and is incremented tobe usedindicate changes in such a set of locks, either byany GETATTR operation that requeststhe"fs_locations" attribute. 8. NFS Server Name Space 8.1. Server Exports On a UNIX serveraddition or deletion of locks from thename space describes allset, a change in thefiles reachable by pathnames underbyte-range they apply to, or an upgrade or downgrade in theroot directorytype of one or"/". Onmore locks. When such aWindows NT server the name space constitutes allset of locks is first created, thefiles on disks named by mapped disk letters. NFSserveradministrators rarely make the entire server's filesystem name space available to NFS clients. More often portionsSHOULD return a stateid with seqid value of one. On subsequent operations that modify thename space are made available via an "export" feature. In previous versionsset of locks, theNFS protocol, the root filehandle for each exportserver isobtained through the MOUNT protocol;required to increment theclient sends"seqid" field by one whenever it returns astring that identifiesstateid for theexport of name spacesame state-owner/file/type combination and there is some change in the set of locks actually designated. In this case, the serverreturnswill return a stateid with an "other" field theroot filehandlesame as previously used forit. The MOUNT protocol supports an EXPORTS procedurethatwill enumeratestate-owner/file/type combination, with an incremented "seqid" field. This pattern continues until theserver's exports. 8.2. Browsing Exportsseqid is incremented past NFS4_UINT32_MAX, and one (not zero) SHOULD be the next seqid value. TheNFSv4 protocol provides a root filehandle that clients can use to obtain filehandles for these exports via a multi-component LOOKUP. A common user experiencepurpose of the incrementing of the seqid is touse a graphical user interface (perhaps a file "Open" dialog window) to find a file via progressive browsing through a directory tree. The client must be ableallow the server tomove from one exportcommunicate toanother export via single-component, progressive LOOKUP operations. This style of browsing is not well supported bytheNFSv2 and NFSv3 protocols. Theclientexpects all LOOKUPthe order in which operationsto remain withinthat modified locking state associated with asingle server filesystem. For example,stateid have been processed. In making comparisons between seqids, both by thedevice attribute will not change. This prevents aclientfrom taking name space paths that span exports. An automounter onin determining theclient can obtain a snapshotorder of operations and by theserver's name space usingserver in determining whether theEXPORTS procedure ofNFS4ERR_OLD_STATEID is to be returned, theMOUNT protocol. If it understandspossibility of theserver's pathname syntax, it can create an image of the server's name space on the client. The parts ofseqid being swapped around past thename space thatNFS4_UINT32_MAX value needs to be taken into account. 9.1.3.3. Special Stateids Stateid values whose "other" field is either all zeros or all ones are reserved. They may notexportedbe assigned by the serverare filled in with a "pseudo filesystem" that allows the user to browse from one mounted filesystem to another. There is a drawback to this representation ofbut have special meanings defined by theserver's name spaceprotocol. The particular meaning depends on whether theclient: it"other" field isstatic. If the server administrator adds a new export the client will be unaware of it. 8.3. Server Pseudo Filesystem NFSv4 servers avoid this name space inconsistency by presentingall zeros or all ones and theexports withinspecific value of theframework"seqid" field. The following combinations ofa single server name space. An NFSv4 client uses LOOKUP"other" andREADDIR operations to browse seamlessly from one export to another. Portions of the server name space that"seqid" arenot exporteddefined in NFSv4: o When "other" and "seqid" arebridged via a "pseudo filesystem" that provides a view of exported directories only. A pseudo filesystem hasboth zero, the stateid is treated as aunique fsidspecial anonymous stateid, which can be used in READ, WRITE, andbehaves like a normal, read only filesystem. Based onSETATTR requests to indicate theconstructionabsence of any open state associated with theserver's name space, itrequest. When an anonymous stateid value ispossible that multiple pseudo filesystems may exist. For example, /a pseudo filesystem /a/b real filesystem /a/b/c pseudo filesystem /a/b/c/d real filesystem Each of the pseudo filesystems are considered separate entitiesused, andthereforean existing open denies the form of access requested, then access willhave a unique fsid. 8.4. Multiple Roots The DOSbe denied to the request. o When "other" andWindows operating environments are sometimes described as having "multiple roots". Filesystems are commonly represented as disk letters. MacOS represents filesystems as top level names. NFSv4 servers for these platforms can construct a pseudo file system above these root names so that disk letters or volume names"seqid" aresimply directory names in the pseudo root. 8.5. Filehandle Volatility The nature ofboth all ones, theserver's pseudo filesystemstateid isthata special READ bypass stateid. When this value is used in WRITE or SETATTR, it isa logical representation of filesystem(s) available from the server. Therefore,treated like thepseudo filesystem is most likely constructed dynamically whenanonymous value. When used in READ, the server MAY grant access, even if access would normally be denied to READ requests. If a stateid value isfirst instantiated. It is expected thatused which has all zero or all ones in thepseudo filesystem may"other" field, but does nothave an on disk counterpart from which persistent filehandles could be constructed. Even though it is preferable thatmatch one of theserver provide persistent filehandles forcases above, thepseudo filesystem,server MUST return theNFSerror NFS4ERR_BAD_STATEID. Special stateids, unlike other stateids, are not associated with individual clientshould expect that pseudo file systemIDs or filehandlesare volatile. Thisand can beconfirmed by checking the associated "fh_expire_type" attribute for those filehandles in question. If the filehandles are volatile, the NFSused with all valid client IDs and filehandles. 9.1.3.4. Stateid Lifetime and Validation Stateids mustbe prepared to recoverremain valid until either afilehandle value (e.g., withclient restart or amulti-component LOOKUP) when receiving an error of NFS4ERR_FHEXPIRED. 8.6. Exported Root Ifserver restart or until theserver's root filesystem is exported, one might conclude that a pseudo-filesystem is not needed. This would be wrong. Assumeclient returns all of thefollowing filesystems on a server: / disk1 (exported) /a disk2 (not exported) /a/b disk3 (exported) Because disk2 is not exported, disk3 cannot be reachedlocks associated withsimple LOOKUPs. The server must bridgethegap with a pseudo-filesystem. 8.7. Mount Point Crossing The server filesystem environment may be constructed instateid by means of an operation sucha way that one filesystem contains a directory which is 'covered'as CLOSE ormounted upon by a second filesystem. For example: /a/b (filesystem 1) /a/b/c/d (filesystem 2) The pseudo filesystem for this server may be constructed to look like: / (place holder/not exported) /a/b (filesystem 1) /a/b/c/d (filesystem 2) It is the server's responsibility to presentDELEGRETURN. If thepseudo filesystem that is completelocks are lost due tothe client. Ifrevocation as long as the clientsends a lookup request for the path "/a/b/c/d", the server's responseID is valid, thefilehandle of the filesystem "/a/b/c/d". In previous versionsstateid remains a valid designation of that revoked state. Stateids associated with byte-range locks are an exception. They remain valid even if a LOCKU frees all remaining locks, so long as theNFS protocol, the server would respondopen file with which they are associated remains open. It should be noted that there are situations in which thefilehandle of directory "/a/b/c/d" withinclient's locks become invalid, without thefilesystem "/a/b". The NFSclientwillrequesting they beable to determine if it crosses a server mount point byreturned. These include lease expiration and achange in the valuenumber ofthe "fsid" attribute. 8.8. Security Policy and Name Space Presentation The applicationforms of lock revocation within theserver's security policy needs to be carefully considered by the implementor. One may chooselease period. It is important tolimit the viewability of portions of the pseudo filesystem based onnote that in these situations, theserver's perception ofstateid remains valid and theclient's abilityclient can use it toauthenticate itself properly. However, withdetermine thesupportdisposition ofmultiple security mechanisms and the ability to negotiatetheappropriate useassociated lost locks. An "other" value must never be reused for a different purpose (i.e. different filehandle, owner, or type ofthese mechanisms,locks) within theserver is unable to properly determine ifcontext of a single clientwill be able to authenticate itself. If, based on its policies, theID. A serverchooses to limitmay retain thecontents of"other" value for thepseudo filesystem,same purpose beyond theserverpoint where it mayeffectively hide filesystems from a clientotherwise be freed but if it does so, it must maintain "seqid" continuity with previous values. One mechanism that mayotherwise have legitimate access. As suggested practice,be used to satisfy theserver should applyrequirement that thesecurity policy of a shared resource inserver recognize invalid and out-of-date stateids is for theserver's namespaceserver to divide thecomponents"other" field of theresource's ancestors. For example: / /a/b /a/b/c The /a/b/c directory isstateid into two fields. o An index into areal filesystem and is the shared resource. The security policy for /a/b/c is Kerberos with integrity. The server should apply the same security policy to /, /a, and /a/b. This allows for the extension of the protection of the server's namespace to the ancestors of the real shared resource. For the casetable ofthe uselocking-state structures. o A generation number which is incremented on each allocation ofmultiple, disjoint security mechanisms in the server's resources, the securitya table entry for a particularobjectuse. And then store in each table entry, o The client ID with which theserver's namespace should be the union of all security mechanisms of all direct descendants. 9. File Locking and Share Reservations Integrating locking into the NFS protocol necessarily causes it to be stateful. Withstateid is associated. o The current generation number for theinclusion(at most one) valid stateid sharing this index value. o The filehandle ofshare reservationstheprotocol becomes substantially more dependentfile onstate thanwhich thetraditional combination of NFS and NLM (Network Lock Manager) [xnfs]. Therelocks arethree components to making this state manageable:taken. oclear division between client and serverAn indication of the type of stateid (open, byte-range lock, file delegation). oabilityThe last "seqid" value returned corresponding toreliably detect inconsistency in state between client and serverthe current "other" value. osimple and robust recovery mechanisms In this model,An indication of theserver ownscurrent status of thestate information. The client requests changes inlocksand the server respondsassociated withthe changes made. Non-client-initiated changes in locking state are infrequent. The client receives prompt notification of such changesthis stateid. In particular, whether these have been revoked and if so, for what reason. With this information, an incoming stateid canadjust its view of the locking state to reflect the server's changes. Individual pieces of state created by the serverbe validated andpassed totheclient at its request are represented by 128-bit stateids. Theseappropriate error returned when necessary. Special and non-special stateidsmay represent a particular open file,are handled separately. (See Section 9.1.3.3 for asetdiscussion ofbyte-range locks held byspecial stateids.) When aparticular owner,stateid is being tested, and the "other" field is all zeros or all ones, arecallable delegation of privileges to accesscheck that the "other" and "seqid" fields match afile in particular ways or atdefined combination for aparticular location. In all cases, therespecial stateid isa transition fromdone and themost general information that represents a clientresults determined asa whole tofollows: o If theeventual lightweight stateid used for most client"other" andserver locking interactions. The details of this transition will vary"seqid" fields do not match a defined combination associated with a special stateid, thetype of objecterror NFS4ERR_BAD_STATEID is returned. o If the combination is valid in general butit always starts with a client ID. To support Win32 share reservations itisnecessary to atomically OPEN or CREATE files. Having a separate share/unshare operation wouldnotallow correct implementation of the Win32 OpenFile API. In orderappropriate tocorrectly implement share semantics,theprevious NFS protocol mechanismscontext in which the stateid is used (e.g., an all-zero stateid is used when an open stateid is required in afileLOCK operation), the error NFS4ERR_BAD_STATEID isopened or created (LOOKUP, CREATE, ACCESS) need to be replaced. The NFSv4 protocol has an OPEN operation that subsumesalso returned. o Otherwise, theNFSv3 methodology of LOOKUP, CREATE,check is completed andACCESS. However, because many operations require a filehandle,thetraditional LOOKUPspecial stateid ispreserved to mapaccepted as valid. When afile name to filehandle without establishing state on the server. The policy of granting access or modifying filesstateid ismanaged bybeing tested, and theserver based on"other" field is neither all zeros or all ones, theclient's state. These mechanisms can implement policy ranging from advisory only lockingfollowing procedure could be used tofull mandatory locking. 9.1. Opensvalidate an incoming stateid andByte-Range Locks It is assumed that manipulating a byte-range lock is rarereturn an appropriate error, whencompared to READ and WRITE operations. It is also assumednecessary, assuming thatserver restartsthe "other" field would be divided into a table index andnetwork partitions are relatively rare. Therefore itan entry generation. o If the table index field isimportant thatoutside theREAD and WRITE operations have a lightweight mechanism to indicate if they possess a held lock. A byte-range lock request containsrange of theheavyweight information required to establish a lock and uniquely defineassociated table, return NFS4ERR_BAD_STATEID. o If theownerselected table entry is of a different generation than that specified in thelock. The following sections describeincoming stateid, return NFS4ERR_BAD_STATEID. o If thetransition fromselected table entry does not match theheavy weight information tocurrent filehandle, return NFS4ERR_BAD_STATEID. o If theeventualstateidused for most client and server locking andrepresents revoked state or state lost as a result of leaseinteractions. 9.1.1. Client ID For each LOCK request, the client must identify itself toexpiration, then return NFS4ERR_EXPIRED, NFS4ERR_BAD_STATEID, or NFS4ERR_ADMIN_REVOKED, as appropriate. o If theserver. Thisstateid type isdonenot valid for the context insuchwhich the stateid appears, return NFS4ERR_BAD_STATEID. Note that away as to allowstateid may be valid in general, but be invalid forcorrect lock identification and crash recovery. A sequence ofaSETCLIENTID operation followed byparticular operation, as, for example, when aSETCLIENTID_CONFIRM operationstateid which doesn't represent byte-range locks isrequiredpassed toestablish the identification onto the server. Establishment of identification by a new incarnation of the client also hastheeffect of immediately breaking any leased state that a previous incarnationnon-from_open case ofthe client might have had on the server, as opposed to forcing the new client incarnation to wait for the leasesLOCK or toexpire. Breaking the lease state amountsLOCKU, or when a stateid which does not represent an open is passed to CLOSE or OPEN_DOWNGRADE. In such cases, the serverremoving all lock, share reservation, and, whereMUST return NFS4ERR_BAD_STATEID. o If theserver"seqid" field is notsupportingzero, and it is greater than theCLAIM_DELEGATE_PREV claim type, all delegation state associated with same client withcurrent sequence value corresponding thesame identity. For discussion of delegation state recovery, see Section 10.2.1. Owners of opens and owners of byte-range locks are separate entities and remain separate even ifcurrent "other" field, return NFS4ERR_BAD_STATEID. o If thesame opaque arrays are used to designate owners of each. The protocol distinguishes between open- owners (represented by open_owner4 structures) and lock-owners (represented by lock_owner4 structures). Both sorts of owners consist of a clientid"seqid" field is less than the current sequence value corresponding the current "other" field, return NFS4ERR_OLD_STATEID. o Otherwise, the stateid is valid andan opaque owner string. For each client,thesettable entry should contain any additional information about the type ofdistinct owner values usedstateid and information associated with thatclient constitutes the set of ownersparticular type ofthat type, forstateid, such as thegiven client. Each open isassociatedwith a specificset of locks, such as open-ownerwhile each byte- range lock is associated with a lock-ownerandan open-owner, the latter being the open-owner associated withlock-owner information, as well as information on the specific locks, such as openfile under which the LOCK operation was done. Client identification is encapsulated in the following structure: struct nfs_client_id4 { verifier4 verifier; opaque id<NFS4_OPAQUE_LIMIT>; }; The first field, verifier is a client incarnation verifier that is usedmodes and byte ranges. 9.1.3.5. Stateid Use for I/O Operations Clients performing Input/Output (I/O) operations need todetect client reboots. Only if the verifier is different from that which the server has previously recordedselect an appropriate stateid based on theclient (as identifiedlocks (including opens and delegations) held by thesecond field of the structure, id) does the server startclient and theprocessvarious types ofcancelingstate-owners sending theclient's leased state. The second field, id is a variable length stringI/O requests. SETATTR operations thatuniquely defineschange theclient. Therefile size areseveral considerations for how the client generates the id string: otreated like I/O operations in this regard. Thestring should be unique so that multiple clients do not presentfollowing rules, applied in order of decreasing priority, govern thesame string. The consequencesselection oftwo clients presentingthesame string range from oneappropriate stateid. In following these rules, the clientgettingwill only consider locks of which it has actually received notification by anerror to one client having its leased state abruptly and unexpectedly canceled.appropriate operation response or callback. oThe string should be selected so the subsequent incarnations (e.g., reboots) ofIf thesameclientcauseholds a delegation for theclient to presentfile in question, thesame string. The implementor is cautioned against an approach that requiresdelegation stateid SHOULD be used. o Otherwise, if thestringentity corresponding tobe recorded inthe lock-owner (e.g., alocal file because this precludesprocess) sending theuse ofI/O has a byte-range lock stateid for theimplementation in an environment whereassociated open file, then the byte-range lock stateid for that lock-owner and open file SHOULD be used. o If there is nolocal diskbyte-range lock stateid, then the OPEN stateid for the current open-owner, andallthat OPEN stateid for the open fileaccess is from an NFSv4 server. o The string shouldin question SHOULD bedifferent for each server network address thatused. o Finally, if none of theclient accesses, rather than common to all server network addresses. The reason is that it may notabove apply, then a special stateid SHOULD bepossible forused. Ignoring these rules may result in situations in which theclientserver does not have information necessary totell ifproperly process thesame server is listening on multiple network addresses. Ifrequest. For example, when mandatory byte-range locks are in effect, if theclient issues SETCLIENTID withstateid does not indicate thesame id string to each network address of suchproper lock-owner, via aserver, thelock stateid, a request might be avoidably rejected. The serverwill think it is the same client,however should not try to enforce these ordering rules andeach successive SETCLIENTID will cause the servershould use whatever information is available tobegin theproperly process I/O requests. In particular, when a client has a delegation for a given file, it SHOULD take note ofremoving the client's previous leased state. o The algorithmthis fact in processing a request, even if it is sent with a special stateid. 9.1.3.6. Stateid Use forgeneratingSETATTR Operations In thestring should not assumecase of SETATTR operations, a stateid is present. In cases other than those that set theclient's network address won't change. This includes changes between client incarnations and even changes whilefile size, the client may send either a special stateid or, when a delegation isstilling running in its current incarnation. This means that if the client includes justheld for theclient's and server's network addressfile inthe id string, there isquestion, areal risk, afterdelegation stateid. While theclient gives upserver SHOULD validate thenetwork address, that another client, using a similar algorithm for generatingstateid and may use theid string, will generatestateid to optimize the determination as to whether aconflicting id string. Givendelegation is held, it SHOULD note theabove considerations, an examplepresence of awell generated id stringdelegation even when a special stateid isone that includes: o The server's network address. o The client's network address. o Forsent, and MUST accept auser level NFSv4 client, it should contain additional information to distinguishvalid delegation stateid when sent. 9.1.4. lock-owner When requesting a lock, the clientfrom other user level clients running onmust present to thesame host, such asserver the client ID and anuniversally uniqueidentifier(UUID). o Additional information that tends to be unique, such as one or more of: * The client machine's serial number (for privacy reasons, it is best to perform some one way function onfor theserial number). * A MAC address. * The timestampowner ofwhentheNFSv4 software was first installed on the client (though this is subjectrequested lock. These two fields are referred to as thepreviously mentioned caution about using information that is stored in a file, becauselock-owner and thefile might only be accessible over NFSv4). *definition of those fields are: o Atrue random number. However since this number ought to be the same betweenclientincarnations, this sharesID returned by thesame problemserver asthatpart of theusing the timestampclient's use of thesoftware installation. As a security measure, the server MUST NOT cancelSETCLIENTID operation. o A variable length opaque array used to uniquely define the owner of aclient's leased state iflock managed by theprincipal that establishedclient. This may be a thread id, process id, or other unique value. When thestate forserver grants the lock, it responds with agiven id stringunique stateid. The stateid isnot the sameused asthe principal issuing the SETCLIENTID. Note that SETCLIENTID and SETCLIENTID_CONFIRM hasasecondary purpose of establishingshorthand reference to theinformationlock-owner, since the serverneeds to make callbacks towill be maintaining theclient for purposecorrespondence between them. 9.1.5. Use ofsupporting delegations. It is permitted to change this information via SETCLIENTIDthe Stateid andSETCLIENTID_CONFIRM withinLocking All READ, WRITE and SETATTR operations contain a stateid. For thesame incarnationpurposes of this section, SETATTR operations which change theclient without removing the client's leased state. Oncesize attribute of aSETCLIENTIDfile are treated as if they are writing the area between the old andSETCLIENTID_CONFIRM sequence has successfully completed,new size (i.e., theclient usesrange truncated or added to theshorthand client identifier, of type clientid4, insteadfile by means of thelonger and less compact nfs_client_id4 structure. This shorthand client identifier (a client ID)SETATTR), even where SETATTR isassigned bynot explicitly mentioned in theserver and shouldtext. The stateid passed to one of these operations must bechosen soone that represents an OPEN (e.g., via the open- owner), a set of byte-range locks, or a delegation, or itwill not conflict withmay be aclient ID previously assigned by the server. This applies across server restartsspecial stateid representing anonymous access orreboots. Whenthe special bypass stateid. If the state-owner performs aclient ID is presented toREAD or WRITE in aserver and that client ID is not recognized, as would happen aftersituation in which it has established aserver reboot,lock or share reservation on the serverwill reject the request with the error NFS4ERR_STALE_CLIENTID. When this happens, the client must obtain(any OPEN constitutes anew client IDshare reservation) the stateid (previously returned byuse oftheSETCLIENTID operation and then proceedserver) must be used toany other necessary recovery forindicate what locks, including both byte-range locks and share reservations, are held by theserver reboot case (See Section 9.6.2). The client must also employstate-owner. If no state is established by theSETCLIENTID operation when it receives a NFS4ERR_STALE_STATEID error usingclient, either byte-range lock or share reservation, a stateidderived from its current client ID, since this also indicates a server reboot which has invalidated the existing client ID (see Section 9.6.2 for details). See the detailed descriptionsofSETCLIENTID and SETCLIENTID_CONFIRM forall bits 0 is used. Regardless whether acomplete specification of the operations. 9.1.2. Server Releasestateid ofClient ID Ifall bits 0, or a stateid returned by the serverdetermines thatis used, if there is a conflicting share reservation or mandatory byte-range lock held on theclient holds no associated state for its client ID,file, the servermay chooseMUST refuse toreleaseservice theclient ID. The server may make this choice for an inactive client so that resourcesREAD or WRITE operation. Share reservations arenot consumedestablished bythose intermittently active clients. If the client contacts the server after this release, the server must ensure the client receives the appropriate error soOPEN operations and by their nature are mandatory in thatit will usewhen theSETCLIENTID/SETCLIENTID_CONFIRM sequence to establish a new identity. It should be clearOPEN denies READ or WRITE operations, that denial results in such operations being rejected with error NFS4ERR_LOCKED. Byte-range locks may be implemented by the servermustas either mandatory or advisory, or the choice of mandatory or advisory behavior may bevery hesitant to release a client ID sincedetermined by theresulting workserver on theclient to recover from such an event will be the same burden as ifbasis of theserver had failed and restarted. Typically a server would not releasefile being accessed (for example, some UNIX-based servers support aclient ID unless there had been no activity from that client for many minutes. Note"mandatory lock bit" on the mode attribute such that if set, byte-range locks are required on theid string in a SETCLIENTID requestfile before I/O isproperly constructed,possible). When byte-range locks are advisory, they only prevent the granting of conflicting lock requests andifhave no effect on READs or WRITEs. Mandatory byte-range locks, however, prevent conflicting I/O operations. When they are attempted, they are rejected with NFS4ERR_LOCKED. When the clienttakes caregets NFS4ERR_LOCKED on a file it knows it has the proper share reservation for, it will need touseissue a LOCK request on thesame principal for each successive use of SETCLIENTID, then, barring an active denialregion ofservice attack, NFS4ERR_CLID_INUSE should neverthe file that includes the region the I/O was to bereturned. However, client bugs, server bugs, or perhapsperformed on, with an appropriate locktype (i.e., READ*_LT for adeliberate changeREAD operation, WRITE*_LT for a WRITE operation). With NFSv3, there was no notion of a stateid so there was no way to tell if theprincipal ownerapplication process of theid string (such as the case of aclientthat changes security flavors, and undersending thenew flavor,READ or WRITE operation had also acquired the appropriate byte-range lock on the file. Thus thereiswas nomappingway to implement mandatory locking. With theprevious owner) will in rare cases result in NFS4ERR_CLID_INUSE. Instateid construct, this barrier has been removed. Note thatevent, when the server gets a SETCLIENTIDfora client IDUNIX environments thatcurrently has no state, or it has state, butsupport mandatory file locking, thelease has expired, rather than returning NFS4ERR_CLID_INUSE,distinction between advisory and mandatory locking is subtle. In fact, advisory and mandatory byte-range locks are exactly theserver MUST allowsame in so far as theSETCLIENTID,APIs andconfirmrequirements on implementation. If thenew client IDmandatory lock attribute is set on the file, the server checks to see iffollowed bythe lock-owner has an appropriateSETCLIENTID_CONFIRM. 9.1.3. Stateid Definition Whenshared (read) or exclusive (write) byte-range lock on the region it wishes to read or write to. If there is no appropriate lock, the servergrantschecks if there is a conflicting lock (which can be done by attempting to acquire the conflicting lock on the behalf ofany type (including opens, byte- range locks,the lock-owner, anddelegations), it responds with a unique stateid that represents a set of locks (often a single lock) forif successful, release thesame file, oflock after thesame type,READ or WRITE is done), andsharingif there is, thesame ownership characteristics.server returns NFS4ERR_LOCKED. For Windows environments, there are no advisory byte-range locks, so the server always checks for byte-range locks during I/O requests. Thus,opensthe NFSv4 LOCK operation does not need to distinguish between advisory and mandatory byte-range locks. It is the NFS version 4 server's processing of thesame fileREAD and WRITE operations that introduces the distinction. Every stateid other than the special stateid values noted in this section, whether returned bydifferent open-owners each haveanidentifying stateid. Similarly, each set of byte-range locks on a file ownedOPEN-type operation (i.e., OPEN, OPEN_DOWNGRADE), or by aspecific lock-owner has its own identifying stateid. Delegations also have associated stateidsLOCK-type operation (i.e., LOCK or LOCKU), defines an access mode for the file (i.e., READ, WRITE, or READ- WRITE) as established by the original OPEN whichthey may be referenced. Thebegan the stateidis usedsequence, and as modified by subsequent OPENs and OPEN_DOWNGRADEs within that stateid sequence. When ashorthand reference to a lockREAD, WRITE, orset of locks, andSETATTR which specifies the size attribute, is done, the operation is subject to checking against the access mode to verify that the operation is appropriate givena stateid,theserver can determineOPEN with which theassociated state-owner or state-owners (inoperation is associated. In the case ofan open-owner/ lock-owner pair)WRITE-type operations (i.e., WRITEs and SETATTRs which set size), theassociated filehandle. When stateids are used, the current filehandleserver mustbe the one associated with that stateid. All stateids associated with a given client ID are associated with a common leaseverify thatrepresentstheclaim of those stateidsaccess mode allows writing and return an NFS4ERR_OPENMODE error if it does not. In theobjects they representcase, of READ, the server may perform the corresponding check on the access mode, or it may choose tobe maintained byallow READ on opens for WRITE only, to accommodate clients whose write implementation may unavoidably do reads (e.g., due to buffer cache constraints). However, even if READs are allowed in these circumstances, theserver. See Section 9.5server MUST still check fora discussionlocks that conflict with the READ (e.g., another open specifying denial of READs). Note that a server which does enforce thelease. Eachaccess mode check on READs need not explicitly check for conflicting share reservations since the existence of OPEN for read access guarantees that no conflicting share reservation can exist. A stateidmust be uniqueof all bits 1 (one) MAY allow READ operations to bypass locking checks at the server.ManyHowever, WRITE operationstakewith a stateid with bits all 1 (one) MUST NOT bypass locking checks and are treated exactly the same asan argument but notif aclientid, so the server muststateid of all bits 0 were used. A lock may not beable to infer the client from the stateid. 9.1.3.1. Stateid Types With the exceptiongranted while a READ or WRITE operation using one of the special stateids(see Section 9.1.3.3), each stateid represents locking objects of one of a set of types defined byis being performed and theNFSv4 protocol. Note that in all these cases, where we speakrange ofguarantee, it is understood there are situations such as a client restart, orthe lockrevocation, that allowrequest conflicts with theguarantee to be voided. o Stateids may represent opensrange offiles. Each stateid in this case representstheOPEN state for a given client ID/open-owner/filehandle triple. Such stateids are subject to change (with consequent incrementing ofREAD or WRITE operation. For thestateid's seqid) in response to OPENs that result in upgrade and OPEN_DOWNGRADE operations. o Stateids may represent setspurposes ofbyte-range locks. All locks held onthis paragraph, aparticular file byconflict occurs when aparticular ownershared lock is requested andall gotten under the aegis of a particular open file are associated withasingle stateid with the seqidWRITE operation is beingincremented whenever LOCKperformed, or an exclusive lock is requested andLOCKU operations affect that set of locks. o Stateids may represent file delegations, which are recallable guarantees by the server to the client, that other clients will not reference,either a READ orwill not modifyaparticular file, until the delegationWRITE operation isreturned.being performed. Astateid representsSETATTR that sets size is treated similarly to asingle delegation heldWRITE as discussed above. 9.1.6. Sequencing of Lock Requests Locking is different than most NFS operations as it requires "at- most-one" semantics that are not provided by ONC RPC. ONC RPC over aclient for a particular filehandle. 9.1.3.2. Stateid Structure Stateids are divided into two fields,reliable transport is not sufficient because a96-bit "other" field identifyingsequence of locking requests may span multiple TCP connections. In thespecific setface oflocksretransmission or reordering, lock or unlock requests must have a well defined and consistent behavior. To accomplish this, each lock request contains a32-bit "seqid"sequencevalue. Except in the case of special stateids (see Section 9.1.3.3),number that is aparticular value ofconsecutively increasing integer. Different state-owners have different sequences. The server maintains the"other" field denoteslast sequence number (L) received and the response that was returned. The server SHOULD assign aset of locksseqid value of one for thesame type (for example, byte-range locks, opens, or delegations),first request issued for any given state-owner. Note that for requests that contain aspecific file or directory, and sharing the same ownership characteristics. The seqid designatessequence number, for each state-owner, there should be no more than one outstanding request. If aspecific instance of suchrequest (r) with aset of locks, andprevious sequence number (r < L) isincremented to indicate changes in such a set of locks, either byreceived, it is rejected with theaddition or deletionreturn oflocks from the set,error NFS4ERR_BAD_SEQID. Given achange inproperly-functioning client, thebyte-range they apply to, or an upgrade or downgrade inresponse to (r) must have been received before thetype of one or more locks. When suchlast request (L) was sent. If asetduplicate oflockslast request (r == L) isfirst created,received, theserver SHOULD returnstored response is returned. If astateidrequest beyond the next sequence (r == L + 2) is received, it is rejected withseqid value of one. On subsequent operations that modifythesetreturn oflocks, the servererror NFS4ERR_BAD_SEQID. Sequence history isrequired to increment the "seqid" field by onereinitialized wheneverit returns a stateid forthesame state-owner/file/type combination and there is some change inSETCLIENTID/SETCLIENTID_CONFIRM sequence changes theset of locks actually designated. In this case,client verifier. Since theserver will return a stateidsequence number is represented with an"other" fieldunsigned 32-bit integer, thesame as previously used for that state-owner/file/type combination,arithmetic involved withan incremented "seqid" field. This pattern continues untiltheseqidsequence number isincremented past NFS4_UINT32_MAX,mod 2^32. Note that when the seqid wraps, it SHOULD bypass zero and use one(not zero) SHOULD beas the next seqid value.The purpose of the incrementingFor an example ofthe seqidmodulo arithmetic involving sequence numbers see [RFC0793]. It isto allowcritical the serverto communicatemaintain the last response sent to the client to provide a more reliable cache of duplicate non-idempotent requests than that of theordertraditional cache described inwhich operations that modified locking state associated with[Chet]. The traditional duplicate request cache uses astateid have been processed. In making comparisons between seqids, both byleast recently used algorithm for removing unneeded requests. However, the last lock request and response on a given state-owner must be cached as long as the lock state exists on the server. The clientin determiningMUST monotonically increment theorder of operations and bysequence number for theserverCLOSE, LOCK, LOCKU, OPEN, OPEN_CONFIRM, and OPEN_DOWNGRADE operations. This is true even indetermining whethertheNFS4ERR_OLD_STATEID isevent that the previous operation that used the sequence number received an error. The only exception tobe returned,this rule is if thepossibilityprevious operation received one of theseqid being swapped around pastfollowing errors: NFS4ERR_STALE_CLIENTID, NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID, NFS4ERR_BAD_SEQID, NFS4ERR_BADXDR, NFS4ERR_RESOURCE, NFS4ERR_NOFILEHANDLE, or NFS4ERR_MOVED. 9.1.7. Recovery from Replayed Requests As described above, theNFS4_UINT32_MAX value needs to be taken into account. 9.1.3.3. Special Stateids Stateid values whose "other" fieldsequence number iseither all zeros or all ones are reserved. They may not be assigned byper state-owner. As long as the serverbut have special meanings defined by the protocol. The particular meaning depends on whethermaintains the"other" field is all zeros or all oneslast sequence number received and follows thespecific valuemethods described above, there are no risks ofthe "seqid" field.a Byzantine router re-sending old requests. Thefollowing combinations of "other" and "seqid" are defined in NFSv4: o When "other" and "seqid" are both zero,server need only maintain thestateid is treated(state- owner, sequence number) state as long as there are open files or closed files with locks outstanding. LOCK, LOCKU, OPEN, OPEN_DOWNGRADE, and CLOSE each contain aspecial anonymous stateid, which can be used in READ, WRITE,sequence number andSETATTR requests to indicatetherefore theabsencerisk ofany open state associated with the request. When an anonymous stateid value is used, and an existing open deniestheformreplay ofaccess requested, then access will be denied tothese operations resulting in undesired effects is non-existent while therequest. o When "other" and "seqid" are both all ones,server maintains thestateid isstate-owner state. 9.1.8. Interactions of multiple sequence values Some Operations may have multiple sources of data for request sequence checking and retransmission determination. Some Operations have multiple sequence values associated with multiple types of state-owners. In addition, such Operations may also have aspecial READ bypass stateid.stateid with its own seqid value, that will be checked for validity. As noted above, there may be multiple sequence values to check. The following rules should be followed by the server in processing these multiple sequence values within a single operation. o Whenthisa sequence value associated with a state-owner isused in WRITE or SETATTR, itunavailable for checking because the state-owner istreated likeunknown to theanonymous value. When usedserver, it takes no part inREAD,theserver MAY grant access, even if access would normally be denied to READ requests. Ifcomparison. o When any of the state-owner sequence values are invalid, NFS4ERR_BAD_SEQID is returned. When a stateidvaluesequence isused which has all zerochecked, NFS4ERR_BAD_STATEID, orall ones in the "other" field,NFS4ERR_OLD_STATEID is returned as appropriate, butdoes not matchNFS4ERR_BAD_SEQID has priority. o When any one of thecases above, the server MUST return the error NFS4ERR_BAD_STATEID. Special stateids, unlike other stateids, are not associated with individual client IDs or filehandles and can be used with all valid client IDs and filehandles. 9.1.3.4. Stateid Lifetime and Validation Stateids must remain valid until eithersequence values matches aclient restart orprevious request, for aserver restart or untilstate-owner, it is treated as a retransmission and not re- executed. When theclient returns alltype of thelocks associated with the stateid by means of anoperationsuch as CLOSE or DELEGRETURN. Ifdoes not match that originally used, NFS4ERR_BAD_SEQID is returned. When thelocks are lost due to revocation as long asserver can determine that theclient ID is valid,request differs from thestateid remains a valid designationoriginal it may return NFS4ERR_BAD_SEQID. o When multiple ofthat revoked state. Stateids associated with byte-range locks are an exception. They remain valid even if a LOCKU frees all remaining locks, so long astheopen file with which they are associated remains open. It should be noted that there are situations in whichsequence values match previous operations, but theclient's locks become invalid, withoutoperations are not theclient requesting they besame, NFS4ERR_BAD_SEQID is returned.These include lease expirationo When there are no available sequence values available for comparison anda number of forms of lock revocation withinthelease period. Itoperation isimportant to note that in these situations,an OPEN, thestateid remains valid andserver indicates to the clientcan usethat an OPEN_CONFIRM is required, unless ittocan conclusively determinethe disposition of the associated lost locks. An "other" value must never be reusedthat confirmation is not required (e.g., by knowing that no open-owner state has ever been released for the current clientid). 9.1.9. Releasing state-owner State When adifferent purpose (i.e. different filehandle, owner,particular state-owner no longer holds open ortype of locks) withinfile locking state at the server, thecontext of a single client ID. Aserver mayretainchoose to release the"other" value forsequence number state associated with thesame purpose beyondstate-owner. The server may make this choice based on lease expiration, for thepoint where itreclamation of server memory, or other implementation specific details. Note that when this is done, a retransmitted request, normally identified by a matching state-owner sequence mayotherwisenot befreed but if it does so,correctly recognized, so that the client will not receive the original response that itmust maintain "seqid" continuity with previous values. One mechanismwould have if the state-owner state was not released. If the server were able to be sure thatmaya given state-owner would never again be usedto satisfyby a client, such an issue could not arise. Even when therequirement thatstate-owner state is released and theserver recognizeclient subsequently uses that state-owner, retransmitted requests will be detected as invalid andout-of-date stateids is for the server to dividethe"other" field ofrequest not executed, although thestateid into two fields. o An index intoclient may have atable of locking-state structures. o A generation number whichrecovery path that isincremented on each allocation of a table entry for a particular use. And then store in each table entry, o The client ID with whichmore complicated than simply getting thestateidoriginal response back transparently. In any event, the server isassociated. o The current generation number forable to safely release state-owner state (in the(at most one) valid stateid sharing this index value. o The filehandle ofsense that retransmitted requests will not be erroneously acted upon) when thefile on whichstate-owner no currently being utilized by thelocksclient (i.e., there aretaken. o An indication of the type of stateid (open, byte-range lock, file delegation). ono open files associated with an open-owner and no lock stateids associated with a lock-owner). Thelast "seqid" value returned correspondingserver may choose to hold thecurrent "other" value. o An indication ofstate-owner state in order to simplify thecurrent statusrecovery path, in the case in which retransmissions of currently active requests are received. However, thelocks associated withperiod it chooses to hold thisstateid.state is implementation specific. Inparticular, whether these have been revoked and if so, for what reason. With this information, an incoming stateid can be validated andtheappropriate error returned when necessary. Special and non-special stateids are handled separately. (See Section 9.1.3.3 for a discussion of special stateids.) Whencase that astateidLOCK, LOCKU, OPEN_DOWNGRADE, or CLOSE isbeing tested, andretransmitted after the"other" field is all zeros or all ones, a checkserver has previously released the state- owner state, the server will find that the"other" and "seqid" fields match a defined combination for a special stateid is donestate-owner has no files open and an error will be returned to theresults determined as follows: oclient. If the"other" and "seqid" fields do not match a defined combination associated withstate-owner does have aspecial stateid,file open, the stateid will not match and again an errorNFS4ERR_BAD_STATEID is returned. o If the combination is valid in general butisnot appropriatereturned to thecontext in whichclient. 9.1.10. Use of Open Confirmation In thestateid is used (e.g.,case that anall-zero stateidOPEN isused when an open stateid is required in a LOCK operation), the error NFS4ERR_BAD_STATEID is also returned. o Otherwise, the check is completedretransmitted and thespecial stateid is accepted as valid. When a stateidopen-owner is beingtested, andused for the"other" field is neither all zerosfirst time orall ones,thefollowing procedure could be used to validate an incoming stateid and return an appropriate error, when necessary, assuming thatopen-owner state has been previously released by the"other" field would be divided into a table index and an entry generation. o Ifserver, thetable index field is outsideuse of therangeOPEN_CONFIRM operation will prevent incorrect behavior. When the server observes the use of theassociated table, return NFS4ERR_BAD_STATEID. o Ifopen-owner for theselected table entry isfirst time, it will direct the client to perform the OPEN_CONFIRM for the corresponding OPEN. This sequence establishes the use of adifferent generation than that specified inopen-owner and associated sequence number. Since theincoming stateid, return NFS4ERR_BAD_STATEID. o IfOPEN_CONFIRM sequence connects a new open-owner on theselected table entry does not matchserver with an existing open-owner on a client, thecurrent filehandle, return NFS4ERR_BAD_STATEID. o Ifsequence number may have any value. The OPEN_CONFIRM step assures thestateid represents revoked state or state lost as a result of lease expiration, then return NFS4ERR_EXPIRED, NFS4ERR_BAD_STATEID, or NFS4ERR_ADMIN_REVOKED, as appropriate. o Ifserver that thestateid typevalue received isnot valid forthecontextcorrect one. (see Section 15.20 for further details.) There are a number of situations in which thestateid appears, return NFS4ERR_BAD_STATEID. Noterequirement to confirm an OPEN would pose difficulties for the client and server, in thata stateid maythey would bevalidprevented from acting ingeneral, buta timely fashion on information received, because that information would beinvalidprovisional, subject to deletion upon non-confirmation. Fortunately, these are situations in which the server can avoid the need for confirmation when responding to open requests. The two constraints are: o The server must not bestow aparticular operation, as,delegation forexample, whenany open which would require confirmation. o The server MUST NOT require confirmation on astateidreclaim-type open (i.e., one specifying claim type CLAIM_PREVIOUS or CLAIM_DELEGATE_PREV). These constraints are related in that reclaim-type opens are the only ones in whichdoesn't represent byte-range locks is passed tothenon-from_open case of LOCK orserver may be required toLOCKU, or whensend astateid which does not representdelegation. For CLAIM_NULL, sending the delegation is optional while for CLAIM_DELEGATE_CUR, no delegation is sent. Delegations being sent with an openis passedrequiring confirmation are troublesome because recovering from non-confirmation adds undue complexity toCLOSE or OPEN_DOWNGRADE. In such cases,theserver MUST return NFS4ERR_BAD_STATEID. o Ifprotocol while requiring confirmation on reclaim- type opens poses difficulties in that the"seqid" field is not zero, and it is greater thaninability to resolve thecurrent sequence value correspondingstatus of thecurrent "other" field, return NFS4ERR_BAD_STATEID. o Ifreclaim until lease expiration may make it difficult to have timely determination of the"seqid" fieldset of locks being reclaimed (since the grace period may expire). Requiring open confirmation on reclaim-type opens isless thanavoidable because of thecurrent sequence value correspondingnature of thecurrent "other" field, return NFS4ERR_OLD_STATEID. o Otherwise, the stateidenvironments in which such opens are done. For CLAIM_PREVIOUS opens, this isvalid and the table entryimmediately after server reboot, so there shouldcontain any additional information about the type of stateidbe no time for open-owners to be created, found to be unused, andinformation associatedrecycled. For CLAIM_DELEGATE_PREV opens, we are dealing withthat particular typeeither a client reboot situation or a network partition resulting in deletion ofstateid, such as the associated setlease state (and returning NFS4ERR_EXPIRED). A server which supports delegations can be sure that no open-owners for that client have been recycled since client initialization or deletion oflocks, such as open-owner and lock-owner information, as well as information on the specific locks, such as open modeslease state andbyte ranges. 9.1.3.5. Stateid Use for I/O Operations Clients performing I/O operations needthus can ensure that confirmation will not be required. 9.2. Lock Ranges The protocol allows a lock owner toselect an appropriate stateid based on the locks (including opens and delegations) held by the clientrequest a lock with a byte range andthe various typesthen either upgrade or unlock a sub-range ofstate-owners sendingtheI/O requests. SETATTR operationsinitial lock. It is expected thatchange the file size are treated like I/O operations inthisregard. The following rules, applied in order of decreasing priority, govern the selection of the appropriate stateid. In following these rules, the clientwillonly consider locks of which it has actually received notification bybe anappropriate operation responseuncommon type of request. In any case, servers orcallback. o If the client holds a delegation for theserver filein question, the delegation stateid SHOULDsystems may not beused. o Otherwise, if the entity correspondingable to support sub- range lock semantics. In thelock-owner (e.g.,event that aprocess) sending the I/O hasserver receives abyte-range lock stateidlocking request that represents a sub-range of current locking state for theassociated open file, then the byte-range lock stateid for that lock-owner and open file SHOULD be used. o If there is no byte-rangelockstateid, thenowner, theOPEN stateid forserver is allowed to return thecurrent open-owner, anderror NFS4ERR_LOCK_RANGE to signify thatOPEN stateid forit does not support sub-range lock operations. Therefore, theopen file in question SHOULDclient should beused. o Finally,prepared to receive this error and, ifnone ofappropriate, report theabove apply, then a special stateid SHOULDerror to the requesting application. The client is discouraged from combining multiple independent locking ranges that happen to beused. Ignoring these rules may result in situations in whichadjacent into a single request since the serverdoesmay nothave information necessarysupport sub-range requests and for reasons related toproperly processtherequest. For example, when mandatory byte-range locks arerecovery of file locking state ineffect, ifthestateid does not indicateevent of server failure. As discussed in the Section 9.6.2 below, theproper lock-owner, via a lock stateid, a request might be avoidably rejected. Theserverhowever should not trymay employ certain optimizations during recovery that work effectively only when the client's behavior during lock recovery is similar toenforce these ordering rules and should use whatever information is availablethe client's locking behavior prior toproperly process I/O requests. In particular, whenserver failure. 9.3. Upgrading and Downgrading Locks If a client has adelegation forwrite lock on agiven file,record, itSHOULD take notecan request an atomic downgrade ofthis fact in processingthe lock to a read lock via the LOCK request,even if it is sent with a special stateid. 9.1.3.6. Stateid Use for SETATTR Operations Inby setting thecase of SETATTR operations, a stateid is present. In cases other than those that settype to READ_LT. If thefile size,server supports atomic downgrade, the request will succeed. If not, it will return NFS4ERR_LOCK_NOTSUPP. The clientmay send eithershould be prepared to receive this error, and if appropriate, report the error to the requesting application. If aspecial stateid or, whenclient has adelegation is held forread lock on a record, it can request an atomic upgrade of thefile in question,lock to adelegation stateid. Whilewrite lock via the LOCK request by setting the type to WRITE_LT or WRITEW_LT. If the serverSHOULD validatedoes not support atomic upgrade, it will return NFS4ERR_LOCK_NOTSUPP. If thestateidupgrade can be achieved without an existing conflict, the request will succeed. Otherwise, the server will return either NFS4ERR_DENIED or NFS4ERR_DEADLOCK. The error NFS4ERR_DEADLOCK is returned if the client issued the LOCK request with the type set to WRITEW_LT andmay usethestateidserver has detected a deadlock. The client should be prepared tooptimizereceive such errors and if appropriate, report thedetermination aserror towhether a delegation is held, it SHOULD notethepresencerequesting application. 9.4. Blocking Locks Some clients require the support of blocking locks. The NFS version 4 protocol must not rely on adelegation even when a special stateid is sent,callback mechanism andMUST accepttherefore is unable to notify avalid delegation stateidclient whensent. 9.1.4. lock-owner When requestingalock, the client must presentpreviously denied lock has been granted. Clients have no choice but tothe server the client ID and an identifiercontinually poll for theowner of the requestedlock.These two fieldsThis presents a fairness problem. Two new lock types arereferredadded, READW and WRITEW, and are used to indicate toasthelock-owner andserver that thedefinition of those fields are: o AclientID returned by theis requesting a blocking lock. The serveras partshould maintain an ordered list of pending blocking locks. When theclient's use ofconflicting lock is released, theSETCLIENTID operation. o A variable length opaque array usedserver may wait the lease period for the first waiting client touniquely definere-request theowner of a lock managed bylock. After theclient. This may be a thread id, process id, or other unique value. Whenlease period expires theserver grantsnext waiting client request is allowed thelock,lock. Clients are required to poll at an interval sufficiently small that itresponds withis likely to acquire the lock in aunique stateid.timely manner. Thestateidserver isused asnot required to maintain ashorthand referencelist of pending blocked locks as it is not used to provide correct operation but only to increase fairness. Because of thelock-owner, since the server willunordered nature of crash recovery, storing of lock state to stable storage would bemaintaining the correspondence between them. 9.1.5. Userequired to guarantee ordered granting of blocking locks. Servers may also note theStateid and Locking All READ, WRITElock types andSETATTR operations containdelay returning denial of the request to allow extra time for astateid. Forconflicting lock to be released, allowing a successful return. In this way, clients can avoid thepurposesburden ofthis section, SETATTR operations which changeneedlessly frequent polling for blocking locks. The server should take care in thesize attributelength ofa file are treated as if they are writingdelay in thearea betweenevent theoldclient retransmits the request. If a server receives a blocking lock request, denies it, andnew size (i.e.,then later receives a nonblocking request for therange truncated or added tosame lock, which is also denied, then it should remove thefile by meanslock in question from its list of pending blocking locks. Clients should use such a nonblocking request to indicate to theSETATTR), even where SETATTRserver that this isnot explicitly mentioned inthetext. The stateid passedlast time they intend toone of these operations must be one that represents an OPEN (e.g., viapoll for theopen- owner), a set of byte-range locks, or a delegation, or itlock, as maybe a special stateid representing anonymous access orhappen when thespecial bypass stateid. Ifprocess requesting thestate-owner performs a READ or WRITE inlock is interrupted. This is asituation in whichcourtesy to the server, to prevent ithas establishedfrom unnecessarily waiting a lease period before granting other lockor share reservationrequests. However, clients are not required to perform this courtesy, and servers must not depend onthe server (any OPEN constitutes a share reservation) the stateid (previously returned by the server)them doing so. Also, clients must beusedprepared for the possibility that this final locking request will be accepted. 9.5. Lease Renewal The purpose of a lease is toindicate what locks, including both byte-rangeallow a server to remove stale locksand share reservations,that are held by a client that has crashed or is otherwise unreachable. It is not a mechanism for cache consistency and lease renewals may not be denied if thestate-owner. If no statelease interval has not expired. The client can implicitly provide a positive indication that it isestablished bystill active and that the associated state held at the server, for the client,either byte-range lockis still valid. Any operation made with a valid clientid (DELEGPURGE, LOCK, LOCKT, OPEN, RELEASE_LOCKOWNER, or RENEW) orshare reservation,a valid stateid (CLOSE, DELEGRETURN, LOCK, LOCKU, OPEN, OPEN_CONFIRM, OPEN_DOWNGRADE, READ, SETATTR, or WRITE) informs the server to renew all of the leases for that client (i.e., allbits 0 is used. Regardless whetherthose sharing a given client ID). In the latter case, the stateid must not be one of the special stateids consisting of all bits0,0 ora stateid returned by the server is used,all bits 1. Note that ifthere is a conflicting share reservation or mandatory byte-range lock held onthefile,client had restarted or rebooted, theserver MUST refuse to serviceclient would not be making these requests without issuing theREADSETCLIENTID/ SETCLIENTID_CONFIRM sequence. The use of the SETCLIENTID/ SETCLIENTID_CONFIRM sequence (one that changes the client verifier) notifies the server to drop the locking state associated with the client. SETCLIENTID/SETCLIENTID_CONFIRM never renews a lease. If the server has rebooted, the stateids (NFS4ERR_STALE_STATEID error) orWRITE operation. Share reservationsthe client ID (NFS4ERR_STALE_CLIENTID error) will not be valid hence preventing spurious renewals. This approach allows for low overhead lease renewal which scales well. In the typical case no extra RPC calls areestablished by OPEN operationsrequired for lease renewal and in the worst case one RPC is required every lease period (i.e., a RENEW operation). The number of locks held bytheir nature are mandatorythe client is not a factor since all state for the client is involved with the lease renewal action. Since all operations that create a new lease also renew existing leases, the server must maintain a common lease expiration time for all valid leases for a given client. This lease time can then be easily updated upon implicit lease renewal actions. 9.6. Crash Recovery The important requirement in crash recovery is that both the client and the server know when theOPEN denies READother has failed. Additionally, it is required that a client sees a consistent view of data across server restarts or reboots. All READ and WRITEoperations, that denial results in suchoperationsbeing rejected with error NFS4ERR_LOCKED. Byte-range locksthat maybe implemented byhave been queued within theserver as either mandatory or advisory,client or network buffers must wait until thechoice of mandatory or advisory behavior may be determined byclient has successfully recovered theserver onlocks protecting thebasis ofREAD and WRITE operations. 9.6.1. Client Failure and Recovery In thefile being accessed (for example, some UNIX-based servers supportevent that a"mandatory lock bit" onclient fails, themode attribute such that if set, byte-rangeserver may recover the client's locksare required onwhen thefile before I/O is possible). When byte-rangeassociated leases have expired. Conflicting locksare advisory, theyfrom another client may onlypreventbe granted after this lease expiration. If thegrantingclient is able to restart or reinitialize within the lease period the client may be forced to wait the remainder ofconflictingthe lease period before obtaining new locks. To minimize client delay upon restart, open and lock requestsand have no effect on READs or WRITEs. Mandatory byte-range locks, however, prevent conflicting I/O operations. When they are attempted, theyarerejectedassociated withNFS4ERR_LOCKED. Whenan instance of the clientgets NFS4ERR_LOCKED on a file it knows it has the proper share reservation for, it will need to issueby aLOCK request on the regionclient supplied verifier. This verifier is part of thefile that includes the regioninitial SETCLIENTID call made by theI/O was to be performed on, with an appropriate locktype (i.e., READ*_LT forclient. The server returns aREAD operation, WRITE*_LT forclient ID as aWRITE operation). With NFSv3, there was no notionresult ofa stateid so there was no way to tell iftheapplication processSETCLIENTID operation. The client then confirms the use of the clientsending the READ or WRITE operation had also acquired the appropriate byte-range lock onID with SETCLIENTID_CONFIRM. The client ID in combination with an opaque owner field is then used by thefile. Thus there was no wayclient toimplement mandatory locking. Withidentify thestateid construct, this barrier has been removed. Note thatopen owner forUNIX environmentsOPEN. This chain of associations is then used to identify all locks for a particular client. Since the verifier will be changed by the client upon each initialization, the server can compare a new verifier to the verifier associated with currently held locks and determine thatsupport mandatory file locking,they do not match. This signifies thedistinction between advisoryclient's new instantiation andmandatorysubsequent loss of locking state. As a result, the server issubtle. In fact, advisory and mandatory byte-rangefree to release all locks held which areexactlyassociated with the old client ID which was derived from the old verifier. Note that the verifier must have the samein so far asuniqueness properties of theAPIsverifier for the COMMIT operation. 9.6.2. Server Failure andrequirements on implementation.Recovery If themandatory lock attribute is set onserver loses locking state (usually as a result of a restart or reboot), it must allow clients time to discover this fact and re- establish thefile,lost locking state. The client must be able to re- establish the locking state without having the serverchecks to see ifdeny valid requests because thelock-ownerserver hasan appropriate shared (read) or exclusive (write) byte-range lock on the region it wishesgranted conflicting access toread or write to. Ifanother client. Likewise, if there isno appropriate lock,the possibility that clients have not yet re-established their locking state for a file, the serverchecks if theremust disallow READ and WRITE operations for that file. The duration of this recovery period isa conflicting lock (which can be done by attemptingequal toacquiretheconflicting lock onduration of thebehalflease period. A client can determine that server failure (and thus loss of locking state) has occurred, when it receives one of two errors. The NFS4ERR_STALE_STATEID error indicates a stateid invalidated by a reboot or restart. The NFS4ERR_STALE_CLIENTID error indicates a client ID invalidated by reboot or restart. When either of these are received, thelock-owner,client must establish a new client ID (see Section 9.1.1) andif successful, releasere-establish thelock afterlocking state as discussed below. The period of special handling of locking and READs and WRITEs, equal in duration to theREAD or WRITElease period, isdone), and if there is,referred to as theserver returns NFS4ERR_LOCKED. For Windows environments, there are no advisory byte-range locks, so"grace period". During theserver always checks for byte-rangegrace period, clients recover locksduring I/O requests. Thus,and theNFSv4associated state by reclaim-type locking requests (i.e., LOCKoperation does not needrequests with reclaim set todistinguish between advisorytrue andmandatory byte-range locks. It is the NFS version 4 server's processingOPEN operations with a claim type of either CLAIM_PREVIOUS or CLAIM_DELEGATE_PREV). During the grace period, the server must reject READ and WRITE operationsthat introduces the distinction. Every stateidand non-reclaim locking requests (i.e., otherthan the special stateid values noted in this section, whether returned by an OPEN-type operation (i.e., OPEN, OPEN_DOWNGRADE), or by a LOCK-type operation (i.e.,LOCKor LOCKU), defines an access mode for the file (i.e., READ, WRITE, or READ- WRITE) as established by the original OPEN which began the stateid sequence,andas modified by subsequent OPENs and OPEN_DOWNGRADEs within that stateid sequence. When a READ, WRITE, or SETATTR which specifies the size attribute, is done, the operation is subject to checking against the access mode to verify that the operation is appropriate given theOPEN operations) withwhich the operation is associated. In the casean error ofWRITE-type operations (i.e., WRITEs and SETATTRs which set size),NFS4ERR_GRACE. If the servermust verifycan reliably determine that granting a non-reclaim request will not conflict with reclamation of locks by other clients, theaccess mode allows writing and return an NFS4ERR_OPENMODENFS4ERR_GRACE errorif itdoesnot. Innot have to be returned and thecase, of READ,non- reclaim client request can be serviced. For the servermay perform the corresponding check on the access mode, or it may choosetoallowbe able to service READon opens forand WRITEonly, to accommodate clients whose write implementation may unavoidably do reads (e.g., due to buffer cache constraints). However, even if READs are allowed in these circumstances,operations during theserver MUST still check for locksgrace period, it must again be able to guarantee that no possible conflictwithcould arise between an impending reclaim locking request and the READ(e.g., another open specify denial of READs). Noteor WRITE operation. If the server is unable to offer that guarantee, the NFS4ERR_GRACE error must be returned to the client. For a serverwhich does enforceto provide simple, valid handling during theaccess mode check on READs need not explicitly check for conflicting share reservations sincegrace period, theexistence of OPEN for read access guarantees that no conflicting share reservation can exist. A stateid ofeasiest method is to simply reject allbits 1 (one) MAY allownon-reclaim locking requests and READ and WRITE operationsto bypass locking checks atby returning theserver.NFS4ERR_GRACE error. However,WRITE operations withastateid with bits all 1 (one) MUST NOT bypass locking checks and are treated exactlyserver may keep information about granted locks in stable storage. With this information, thesame asserver could determine if astateid of all bits 0 were used. Aregular lockmay not be granted while aor READ or WRITE operationusing onecan be safely processed. For example, if a count ofthe special stateidslocks on a given file isbeing performed andavailable in stable storage, therange ofserver can track reclaimed locks for thelock request conflicts withfile and when all reclaims have been processed, non-reclaim locking requests may be processed. This way therange ofserver can ensure that non-reclaim locking requests will not conflict with potential reclaim requests. With respect to I/O requests, if theREADserver is able to determine that there are no outstanding reclaim requests for a file by information from stable storage orWRITE operation. Foranother similar mechanism, thepurposesprocessing ofthis paragraph, a conflict occurs whenI/O requests could proceed normally for the file. To reiterate, for asharedserver that allows non-reclaim lockis requestedanda WRITEI/O requests to be processed during the grace period, it MUST determine that no lock subsequently reclaimed will be rejected and that no lock subsequently reclaimed would have prevented any I/O operationis being performed, or an exclusiveprocessed during the grace period. Clients should be prepared for the return of NFS4ERR_GRACE errors for non-reclaim lockis requestedandeither a READ orI/O requests. In this case the client should employ aWRITE operation is being performed.retry mechanism for the request. ASETATTR that sets size is treated similarlydelay (on the order of several seconds) between retries should be used toa WRITE as discussed above. 9.1.6. Sequencingavoid overwhelming the server. Further discussion ofLock Requests Lockingthe general issue isdifferent than most NFS operations as it requires "at- most-one" semanticsincluded in [Floyd]. The client must account for the server thatare not provided by ONCRPC. ONCRPC over a reliable transportisnot sufficient because a sequence ofable to perform I/O and non-reclaim locking requestsmay span multiple TCP connections. Inwithin theface of retransmission or reordering, lock or unlock requests must have agrace period as welldefined and consistent behavior. To accomplish this, each lock request contains a sequence numberas those thatis a consecutively increasing integer. Different state-owners have different sequences. The server maintainscannot do so. A reclaim-type locking request outside thelast sequence number (L) received andserver's grace period can only succeed if theresponseserver can guarantee thatwas returned. Theno conflicting lock or I/O request has been granted since reboot or restart. A serveris free to assign anymay, upon restart, establish a new value for thefirst request issuedlease period. Therefore, clients should, once a new client ID is established, refetch the lease_time attribute and use it as the basis forany given state-owner. Note thatlease renewal forrequeststhe lease associated with thatcontainserver. However, the server must establish, for this restart event, asequence number,grace period at least as long as the lease period foreach state-owner, there shouldthe previous server instantiation. This allows the client state obtained during the previous server instance to beno more than one outstanding request.reliably re-established. 9.6.3. Network Partitions and Recovery Ifa request (r) with a previous sequence number (r < L) is received, it is rejected withthereturnduration oferror NFS4ERR_BAD_SEQID. Givenaproperly-functioning client,network partition is greater than theresponse to (r) mustlease period provided by the server, the server will havebeennot receivedbefore the last request (L) was sent. Ifaduplicate of last request (r == L) is received,lease renewal from thestored response is returned.client. Ifa request beyondthis occurs, thenext sequence (r == L + 2) is received, it is rejected withserver may cancel thereturn of error NFS4ERR_BAD_SEQID. Sequence history is reinitialized wheneverlease and free all locks held for theSETCLIENTID/SETCLIENTID_CONFIRM sequence changesclient. As a result, all stateids held by the clientverifier. Sincewill become invalid or stale. Once thesequence numberclient isrepresentedable to reach the server after such a network partition, all I/O submitted by the client withan unsigned 32-bit integer,thearithmetic involvednow invalid stateids will fail with thesequence number is mod 2^32. For an example of modulo arithmetic involving sequence numbers see [RFC0793]. It is critical theservermaintainreturning thelast response sent toerror NFS4ERR_EXPIRED. Once this error is received, the clientto provide a more reliable cache of duplicate non-idempotent requests thanwill suitably notify the application thatofheld thetraditional cache described in [Chet]. The traditional duplicate request cache useslock. 9.6.3.1. Courtesy Locks As aleast recently used algorithm for removing unneeded requests. However,courtesy to thelast lock request and response on a given state-owner must be cached as longclient or as an optimization, thelock state existsserver may continue to hold locks, including delegations, onthe server. Thebehalf of a clientMUST monotonically increment the sequence numberfor which recent communication has extended beyond theCLOSE, LOCK, LOCKU, OPEN, OPEN_CONFIRM, and OPEN_DOWNGRADE operations. This is true even inlease period, delaying theevent thatcancellation of theprevious operation that usedlease. If thesequence number received an error. The only exception to this rule isserver receives a lock or I/O request that conflicts with one of these courtesy locks or if it runs out of resources, theprevious operation received oneserver MAY cause lease cancellation to occur at that time and henceforth return NFS4ERR_EXPIRED when any of thefollowing errors: NFS4ERR_STALE_CLIENTID, NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID, NFS4ERR_BAD_SEQID, NFS4ERR_BADXDR, NFS4ERR_RESOURCE, NFS4ERR_NOFILEHANDLE, or NFS4ERR_MOVED. 9.1.7. Recovery from Replayed Requests As described above,stateids associated with thesequence numberfreed locks isper state-owner. As long asused. If lease cancellation has not occurred and the servermaintainsreceives a lock or I/O request that conflicts with one of thelast sequence number received and followscourtesy locks, themethods described above, thererequirements areno risksas follows: o In the case of aByzantine router re-sending old requests. The server need only maintain the (state- owner, sequence number) state as long as there are open files or closed files with locks outstanding. LOCK, LOCKU, OPEN, OPEN_DOWNGRADE, and CLOSE each containcourtesy lock which is not asequence numberdelegation, it MUST free the courtesy lock andthereforegrant therisk ofnew request. o In thereplaycase ofthese operations resulting in undesired effectslock or IO request which conflicts with a delegation which isnon-existent whilebeing held as courtesy lock, the servermaintains the state-owner state. 9.1.8. Interactions of multiple sequence values Some Operations may have multiple sourcesMAY delay resolution ofdata forrequestsequence checkingbut MUST NOT reject the request andretransmission determination. Some Operations have multiple sequence values associated with multiple types of state-owners.MUST free the delegation and grant the new request eventually. o Inaddition, such Operations may also have a stateid with its own seqid value, that will be checked for validity. As noted above, there may be multiple sequence values to check. The following rules should be followed bytheserver in processing these multiple sequence values withincase of asingle operation. o Whenrequests for asequence value associateddelegation which conflicts with astate-ownerdelegation which isunavailable for checking becausebeing held as courtesy lock, thestate-owner is unknown toserver MAY grant theserver,new request or not as ittakes no part in the comparison. o When any ofchooses, but if it grants thestate-owner sequence values are invalid, NFS4ERR_BAD_SEQID is returned. When a stateid sequence is checked, NFS4ERR_BAD_STATEID, or NFS4ERR_OLD_STATEID is returned as appropriate, but NFS4ERR_BAD_SEQID has priority. o When any one of the sequence values matches a previousconflicting request,for a state-owner, it is treated as a retransmission and not re- executed. Whenthetype ofdelegation haled as courtesy lock MUST be freed. If theoperationserver does notmatch that originally used, NFS4ERR_BAD_SEQID is returned. When the server can determine that the request differs from the original it may return NFS4ERR_BAD_SEQID. o When multiple of the sequence values match previous operations, butreboot or cancel theoperations are notlease before thesame, NFS4ERR_BAD_SEQIDnetwork partition isreturned. o When there are no available sequence values available for comparison andhealed, when theoperation is an OPEN,original client tries to access a courtesy lock which was freed, the serverindicatesSHOULD send back a NFS4ERR_BAD_STATEID to theclient that an OPEN_CONFIRM is required, unless it can conclusively determine that confirmation is not required (e.g., by knowing that no open-owner state has ever been released forclient. If thecurrent clientid). 9.1.9. Releasing state-owner State Whenclient tries to access aparticular state-owner no longer holds open or file locking state at the server,courtesy lock which was not freed, then the servermay choose to release the sequence number state associated withSHOULD mark all of thestate-owner. The server may make this choice based oncourtesy locks as implicitly being renewed. 9.6.3.2. Lease Cancellation As a result of lease expiration,for the reclamation of server memory, or other implementation specific details. Note that when this is done, a retransmitted request, normally identified by a matching state-owner sequenceleases maynotbecorrectly recognized, so that the client will not receivecancelled, either immediately upon expiration or subsequently, depending on theoriginal response that it would have ifoccurrence of a conflicting lock or extension of thestate-owner state was not released. Ifperiod of partition beyond what the serverwere able to be sure that a given state-owner would never again be used bywill tolerate. When aclient, such an issue could not arise. Even when the state-ownerlease is cancelled, all locking state associated with it isreleasedfreed and use of any theclient subsequently uses that state-owner, retransmitted requestsassociated stateids willbe detected as invalid and the request not executed, althoughresult in NFS4ERR_EXPIRED being returned. Similarly, use of the associated clientid will result in NFS4ERR_EXPIRED being returned. The clientmay haveshould recover from this situation by using SETCLIENTID followed by SETCLIENTID_CONFIRM, in order to establish arecovery path that is more complicated than simply getting the original response back transparently. In any event, the servernew clientid. Once a lock isable to safely release state-owner state (in the sense that retransmitted requestsobtained using this clientid, a lease willnotbeerroneously acted upon) when the state-ownerestablished. 9.6.3.3. Client's Reaction to a Freed Lock There is nocurrently being utilized by theway for a client(i.e., there are no open files associated with an open-owner and no lock stateids associated withto predetermine how alock-owner). Thegiven servermay chooseis going toholdbehave during a network partition. When thestate-owner state in order to simplify the recovery path, inpartition heals, either thecase in which retransmissionsclient still has all ofcurrently active requests are received. However, the periodits locks, itchooses to hold this state is implementation specific. In the case that a LOCK, LOCKU, OPEN_DOWNGRADE, or CLOSE is retransmitted after the serverhaspreviously released the state- owner state, the server will find that the state-ownersome of its locks, or it hasno files open and an errornone of them. The client will bereturnedable to examine theclient. If the state-owner does have a file open, the stateid will not match and again anvarious erroris returnedreturn values tothe client. 9.1.10. Usedetermine its response. NFS4ERR_EXPIRED: All locks have been freed as a result ofOpen Confirmation In the case that an OPEN is retransmitted and the open-owner is being used fora lease cancellation which occurred during thefirst timepartition. The client should use a SETCLIENTID to recover. NFS4ERR_ADMIN_REVOKED: The current lock has been revoked before, during, or after theopen-owner statepartition. The client SHOULD handle this error as it normally would. NFS4ERR_BAD_STATEID: The current lock has beenpreviously released by the server, the use ofrevoked/released during theOPEN_CONFIRM operation will prevent incorrect behavior. Whenpartition and the serverobserves the use of the open-owner for the first time, it will direct thedid not reboot. Other locks MAY still be renewed. The clientto perform the OPEN_CONFIRM for the corresponding OPEN. This sequence establishes the use ofneed not do aopen-ownerSETCLIENTID andassociated sequence number. Since the OPEN_CONFIRM sequence connectsinstead SHOULD probe via anew open-owner onRENEW call. NFS4ERR_RECLAIM_BAD: The current lock has been revoked during the partition and the serverwith an existing open-ownerrebooted. The server might have no information ona client,thesequence numberother locks. They mayhave any value.still be renewable. NFS4ERR_NO_GRACE: TheOPEN_CONFIRM step assuresclient's locks have been revoked during the partition and the serverthatrebooted. None of thevalue receivedclient's locks will be renewable. NFS4ERR_OLD_STATEID: The server has not rebooted. The client SHOULD handle this error as it normally would. 9.6.3.4. Edge Conditions When a network partition isthe correct one. (see Section 15.20 for further details.) There arecombined with anumber of situations in whichserver reboot, then both therequirementserver and client have responsibilities toconfirm an OPEN would pose difficulties forensure that the clientand server, in that they would be prevented from acting indoes not reclaim atimely fashion on information received, because that information would be provisional, subject to deletion upon non-confirmation. Fortunately, these are situations inlock whichthe server can avoid the need for confirmation when respondingit should no longer be able toopen requests. The two constraintsaccess. Briefly those are: oThe server must not bestow a delegation forClient's responsibility: A client MUST NOT attempt to reclaim anyopenlocks whichwould require confirmation.it did not hold at the end of its most recent successfully established client lease. oTheServer's responsibility: A server MUST NOTrequire confirmation onallow areclaim-type open (i.e., one specifying claim type CLAIM_PREVIOUS or CLAIM_DELEGATE_PREV). These constraints are related inclient to reclaim a lock unless it knows thatreclaim-type opens are the only onesit could not have since granted a conflicting lock. However, inwhich thedeciding whether a conflicting lock could have been granted, it is permitted to assume its clients are responsible, as above. A server maybe required to sendconsider adelegation. For CLAIM_NULL, sending the delegation is optional while for CLAIM_DELEGATE_CUR, no delegation is sent. Delegations being sent withclient's lease "successfully established" once it has received an openrequiring confirmation are troublesome because recoveringoperation fromnon-confirmation adds undue complexity to the protocol while requiring confirmation on reclaim- type opens poses difficulties inthatthe inabilityclient. The above are directed toresolve the status of the reclaim until lease expiration may make it difficultCLAIM_PREVIOUS reclaims and not tohave timely determination of the set of locks being reclaimed (since the grace period may expire). Requiring open confirmation on reclaim-type opens is avoidable because of the nature of the environments inCLAIM_DELEGATE_PREV reclaims, whichsuch opens are done. For CLAIM_PREVIOUS opens, this is immediately aftergenerally do not involve a serverreboot, so there should be no time for open-owners to be created, foundreboot. However, when a server persistently stores delegation information tobe unused, and recycled. Forsupport CLAIM_DELEGATE_PREVopens, we are dealing with either a client reboot situation oracross anetwork partition resultingperiod indeletion of lease state (and returning NFS4ERR_EXPIRED). A serverwhichsupports delegations can be sure that no open-owners for that client have been recycled sinceboth clientinitialization or deletion of lease stateandthusserver are down at the same time, similar strictures apply. The next sections give examples showing what canensurego wrong if these responsibilities are neglected, and provides examples of server implementation strategies thatconfirmation will not be required. 9.2. Lock Rangescould meet a server's responsibilities. 9.6.3.4.1. First Server Edge Condition Theprotocol allowsfirst edge condition has the following scenario: 1. Client A acquires alock ownerlock. 2. Client A and server experience mutual network partition, such that client A is unable torequestrenew its lease. 3. Client A's lease expires, so server releases lock. 4. Client B acquires a lock that would have conflicted witha byte range and then either upgrade or unlock a sub-range of the initial lock. It is expectedthatthis will be an uncommon typeofrequest. In any case, servers or server filesystems may not be able to support sub- range lock semantics. InClient A. 5. Client B releases theevent that alock 6. Server reboots 7. Network partition between client A and serverreceivesheals. 8. Client A issues alocking request that representsRENEW operation, and gets back asub-range of current locking state for theNFS4ERR_STALE_CLIENTID. 9. Client A reclaims its lockowner,within theserver is allowed to returnserver's grace period. Thus, at theerror NFS4ERR_LOCK_RANGE to signify that it does not support sub-range lock operations. Therefore,final step, the server has erroneously granted clientshould be prepared to receive this error and, if appropriate, reportA's lock reclaim. If client B modified theerror toobject therequesting application. Thelock was protecting, clientis discouraged from combining multiple independent locking ranges that happen to be adjacent into a single request since the server may not support sub-range requestsA will experience object corruption. 9.6.3.4.2. Second Server Edge Condition The second known edge condition follows: 1. Client A acquires a lock. 2. Server reboots. 3. Client A andfor reasons related to the recovery of file locking state in the event of server failure. As discussed in the Section 9.6.2 below, theservermay employ certain optimizations during recoveryexperience mutual network partition, such thatwork effectively only when the client's behavior during lock recoveryclient A issimilarunable to reclaim its lock within theclient's locking behavior prior to server failure. 9.3. Upgrading and Downgrading Locks If a clientgrace period. 4. Server's reclaim grace period ends. Client A hasa write lockno locks recorded on server. 5. Client B acquires arecord, it can request an atomic downgradelock that would have conflicted with that of Client A. 6. Client B releases thelock tolock. 7. Server reboots areadsecond time. 8. Network partition between client A and server heals. 9. Client A issues a RENEW operation, and gets back a NFS4ERR_STALE_CLIENTID. 10. Client A reclaims its lockviawithin theLOCK request, by settingserver's grace period. As with thetype to READ_LT. Iffirst edge condition, theserver supports atomic downgrade,final step of therequest will succeed. If not, it will return NFS4ERR_LOCK_NOTSUPP. The client should be prepared to receive this error, and if appropriate, reportscenario of theerror tosecond edge condition has therequesting application. If aserver erroneously granting clienthas a readA's lockon a record, it can request an atomic upgradereclaim. 9.6.3.4.3. Handling Server Edge Conditions In both of thelock toabove examples, the client attempts reclaim of awritelockviathat it held at theLOCK requestend of its most recent successfully established lease; thus, it has fulfilled its responsibility. The server, however, has failed, bysettinggranting a reclaim, despite having granted a conflicting lock since thetype to WRITE_LT or WRITEW_LT. Ifreclaimed lock was last held. Solving these edge conditions requires that the serverdoes not support atomic upgrade,either assume after itwillreboots that edge condition occurs, and thus returnNFS4ERR_LOCK_NOTSUPP. IfNFS4ERR_NO_GRACE for all reclaim attempts, or that theupgrade can be achieved without an existing conflict,server record some information in stable storage. The amount of information therequest will succeed. Otherwise,server records in stable storage is in inverse proportion to how harsh the serverwill return either NFS4ERR_DENIED or NFS4ERR_DEADLOCK.wants to be whenever the edge conditions occur. Theerror NFS4ERR_DEADLOCKserver that isreturned if the client issuedcompletely tolerant of all edge conditions will record in stable storage every lock that is acquired, removing theLOCK request withlock record from stable storage only when thetype set to WRITEW_LT andlock is unlocked by theserver has detected a deadlock. Theclientshould be prepared to receive such errorsandif appropriate, reporttheerror tolock's owner advances therequesting application. 9.4. Blocking Locks Some clients requiresequence number such that thesupport of blocking locks. The NFS version 4 protocol mustlock release is notrely onthe last stateful event for the owner's sequence. For the two aforementioned edge conditions, the harshest acallback mechanism and therefore is unable to notifyserver can be, and still support aclient whengrace period for reclaims, requires that the server record in stable storage information some minimal information. For example, apreviously denied lock has been granted. Clients have no choice but to continually pollserver implementation could, for each client, save in stable storage a record containing: o thelock. This presentsclient's id string o afairness problem. Two new lock types are added, READW and WRITEW, and are used to indicateboolean that indicates if the client's lease expired or if there was administrative intervention (see Section 9.8) to revoke a byte-range lock, share reservation, or delegation o a timestamp that is updated the first time after a serverthatboot or reboot the clientis requesting a blocking lock.acquires byte-range locking, share reservation, or delegation state on the server. The timestamp need not be updated on subsequent lock requests until the server reboots. The servershould maintain an ordered list of pending blocking locks. Whenimplementation would also record in theconflicting lock is released,stable storage the timestamps from the two most recent servermay waitreboots. Assuming thelease periodabove record keeping, for the firstwaiting client to re-requestedge condition, after thelock. Afterserver reboots, the record that client A's leaseperiod expiresexpired means that another client could have acquired a conflicting record lock, share reservation, or delegation. Hence thenext waitingserver must reject a reclaim from clientrequest is allowedA with thelock. Clients are required to poll aterror NFS4ERR_NO_GRACE or NFS4ERR_RECLAIM_BAD. For the second edge condition, after the server reboots for a second time, the record that the client had aninterval sufficiently smallunexpired record lock, share reservation, or delegation established before the server's previous incarnation means thatit is likely to acquirethelock in a timely manner. Theserveris not required to maintainmust reject alistreclaim from client A with the error NFS4ERR_NO_GRACE or NFS4ERR_RECLAIM_BAD. Regardless ofpending blocked locks as it is used to increase fairnessthe level andnot correct operation. Because ofapproach to record keeping, theunordered nature of crash recovery, storingserver MUST implement one oflock state to stable storage would be requiredthe following strategies (which apply toguarantee ordered grantingreclaims ofblocking locks. Servers may also note the lock typesshare reservations, byte-range locks, anddelay returning denial ofdelegations): 1. Reject all reclaims with NFS4ERR_NO_GRACE. This is super harsh, but necessary if therequestserver does not want toallow extra time for a conflictingrecord lock state in stable storage. 2. Record sufficient state in stable storage tobe released, allowing a successful return.meet its responsibilities. Inthis way, clients can avoiddoubt, theburden of needlessly frequent polling for blocking locks. Theserver shouldtake care inerr on thelengthside ofdelay inbeing harsh. In the eventthe client retransmits the request. Ifthat, after a serverreceives a blocking lock request, denies it, and then later receives a nonblocking request for the same lock, which is also denied, then it should remove the lock in question from its list of pending blocking locks. Clients should use such a nonblocking request to indicate toreboot, the server determines thatthisthere is unrecoverable damage or corruption to thelast time they intend to poll for the lock, as may happen whentheprocess requestingstable storage, then for all clients and/or locks affected, thelock is interrupted. This is a courtesy toserver MUST return NFS4ERR_NO_GRACE. 9.6.3.4.4. Client Edge Condition A third edge condition effects theserver, to prevent it from unnecessarily waiting a lease period before granting other lock requests. However, clients are not required to perform this courtesy,client andservers mustnotdepend on them doing so. Also, clients must be prepared forthepossibility that this final locking request will be accepted. 9.5. Lease Renewal The purpose of a lease is to allow aserver. If the serverto remove stalereboots in the middle of the client reclaiming some locksthat are held byand then aclient that has crashed or is otherwise unreachable. Itnetwork partition isnot a mechanism for cache consistency and lease renewals may notestablished, the client might bedenied ifin thelease interval hassituation of having reclaimed some, but notexpired. The client can implicitly provide a positive indicationall locks. In thatit is still active andcase, a conservative client would assume that theassociated state held at the server, for the client, is still valid. Any operation made withnon-reclaimed locks were revoked. The third known edge condition follows: 1. Client A acquires avalid clientid (DELEGPURGE, LOCK, LOCKT, OPEN, RELEASE_LOCKOWNER, or RENEW) orlock 1. 2. Client A acquires avalid stateid (CLOSE, DELEGRETURN, LOCK, LOCKU, OPEN, OPEN_CONFIRM, OPEN_DOWNGRADE, READ, SETATTR, or WRITE) informslock 2. 3. Server reboots. 4. Client A issues a RENEW operation, and gets back a NFS4ERR_STALE_CLIENTID. 5. Client A reclaims its lock 1 within the server's grace period. 6. Client A and server experience mutual network partition, such that client A is unable torenew all ofreclaim its remaining locks within theleases forgrace period. 7. Server's reclaim grace period ends. 8. Client B acquires a lock thatclient (i.e., all those sharingwould have conflicted with Client A's lock 2. 9. Client B releases the lock. 10. Server reboots agivensecond time. 11. Network partition between clientID). In the latter case,A and server heals. 12. Client A issues a RENEW operation, and gets back a NFS4ERR_STALE_CLIENTID. 13. Client A reclaims both lock 1 and lock 2 within thestateid must not be one ofserver's grace period. At thespecial stateids consisting of all bits 0 or all bits 1. Note that iflast step, the client reclaims lock 2 as if it hadrestarted or rebooted,held that lock continuously, when in fact a conflicting lock was granted to client B. This occurs because the clientwouldfailed its responsibility, by attempting to reclaim lock 2 even though it had notbe making these requests without issuingheld that lock at theSETCLIENTID/ SETCLIENTID_CONFIRM sequence. The useend of theSETCLIENTID/ SETCLIENTID_CONFIRM sequence (onelease thatchangeswas established by theclient verifier) notifiesSETCLIENTID after the first serverto drop the locking state associated with the client. SETCLIENTID/SETCLIENTID_CONFIRM never renewsreboot. (The client did hold lock 2 on a previous lease.IfBut it is only the most recent lease that matters.) A serverhas rebooted,could avoid this situation by rejecting thestateids (NFS4ERR_STALE_STATEID error) or the client ID (NFS4ERR_STALE_CLIENTID error) will not be valid hence preventing spurious renewals. This approach allows for low overhead lease renewal which scales well. In the typical case no extra RPC calls are required for lease renewal and in the worst case one RPC is required every lease period (i.e., a RENEW operation). The numberreclaim of lock 2. However, to do so accurately it would have to ensure that additional information about individual locks heldby the client issurvives reboot. Server implementations are nota factor since all state forrequired to do that, so the clientis involved with the lease renewal action. Since all operationsmust not assume thatcreate a new lease also renew existing leases,the servermust maintain a common lease expiration time for all valid leases forwill. Instead, agiven client. This lease time can then be easily updated upon implicit lease renewal actions. 9.6. Crash Recovery The important requirement in crash recovery is that both theclientandMUST reclaim only those locks which it successfully acquired from the previous serverknow when the other has failed. Additionally, it is requiredinstance, omitting any that it failed to reclaim before aclient sees a consistent view of data across server restarts or reboots. All READ and WRITE operations that may have been queued within the client or network buffers must wait untilnew reboot. Thus, in the last step above, clienthas successfully recoveredA should reclaim only lock 1. 9.6.3.4.5. Client's Handling of Reclaim Errors A mandate for thelocks protectingclient's handling of theREAD and WRITE operations. 9.6.1. Client FailureNFS4ERR_NO_GRACE andRecovery InNFS4ERR_RECLAIM_BAD errors is outside theevent that a client fails,scope of this specification, since theserver may recoverstrategies for such handling are very dependent on the client'slocks whenoperating environment. However, one potential approach is described below. When theassociated leases have expired. Conflicting locks from another client may only be granted after this lease expiration. Ifclient's reclaim fails, it could examine the change attribute of the objects the client isabletrying torestartreclaim state for, and use that to determine whether to re-establish the state via normal OPEN orreinitialize withinLOCK requests. This is acceptable provided thelease periodclient's operating environment allows it. In other words, the clientmay be forcedimplementor is advised towait the remainder ofdocument for his users thelease period before obtaining new locks. To minimizebehavior. The clientdelay upon restart, open andcould also inform the application that its byte-range lockrequests are associated with an instanceor share reservations (whether they were delegated or not) have been lost, such as via a UNIX signal, a GUI pop-up window, etc. See Section 10.5, for a discussion of what the clientby ashould do for dealing with unreclaimed delegations on clientsupplied verifier. This verifier is partstate. For further discussion of revocation of locks see Section 9.8. 9.7. Recovery from a Lock Request Timeout or Abort In theinitial SETCLIENTID call made by the client. The server returnsevent aclient ID aslock request times out, aresult ofclient may decide to not retry theSETCLIENTID operation.request. The clientthen confirmsmay also abort theuse ofrequest when theclient ID with SETCLIENTID_CONFIRM. The client ID in combination with an opaque owner field is then used by the client to identify the open ownerprocess forOPEN. This chain of associationswhich it was issued isthen usedterminated (e.g., in UNIX due toidentify all locks foraparticular client. Sincesignal). It is possible though that theverifier will be changed byserver received theclientrequest and acted uponeach initialization,it. This would change the state on the servercan compare a new verifier towithout theverifier associated with currently held locks and determineclient being aware of the change. It is paramount thatthey do not match. This signifiestheclient's new instantiation and subsequent loss of locking state. Asclient re-synchronize state with server before it attempts any other operation that takes aresult,seqid and/or a stateid with theserversame state- owner. This isfreestraightforward torelease all locks held which are associated withdo without a special re- synchronize operation. Since the server maintains the last lock request and response received on the state-owner, for each state-owner, theoldclientID which was derived fromshould cache theold verifier. Notelast lock request it sent such that theverifier must havelock request did not receive a response. From this, thesame uniqueness properties ofnext time theverifierclient does a lock operation for theCOMMIT operation. 9.6.2. Server Failurestate-owner, it can send the cached request, if there is one, andRecovery Ifif theserver loses lockingrequest was one that established state(usually as(e.g., a LOCK or OPEN operation), the server will return the cached resultof a restartorreboot), it must allow clients time to discover this fact and re- establishif never saw thelost locking state.request, perform it. The clientmust be ablecan follow up with a request tore- establishremove thelockingstatewithout having(e.g., a LOCKU or CLOSE operation). With this approach, theserver deny valid requests becausesequencing and stateid information on the client and serverhas granted conflicting access to another client. Likewise, if there isfor thepossibility that clients have not yet re-established their lockinggiven state-owner will re-synchronize and in turn the lock statefor a file,will re-synchronize. 9.8. Server Revocation of Locks At any point, the servermust disallow READcan revoke locks held by a client andWRITE operationsthe client must be prepared forthat file. The duration ofthisrecovery periodevent. When the client detects that its locks have been or may have been revoked, the client isequal toresponsible for validating theduration ofstate information between itself and the server. Validating locking state for thelease period. Aclientcan determinemeans thatserver failure (and thus loss of locking state) has occurred, whenitreceives one of two errors. The NFS4ERR_STALE_STATEID error indicates a stateid invalidated by a rebootmust verify orrestart.reclaim state for each lock currently held. TheNFS4ERR_STALE_CLIENTID error indicates a client ID invalidated byfirst instance of lock revocation is upon server reboot orrestart. When either of these are received,re- initialization. In this instance the clientmust establish a new client ID (see Section 9.1.1)will receive an error (NFS4ERR_STALE_STATEID or NFS4ERR_STALE_CLIENTID) andre-establishthelocking stateclient will proceed with normal crash recovery asdiscussed below. The period of special handling of locking and READs and WRITEs, equaldescribed indurationthe previous section. The second lock revocation event is the inability to renew the leaseperiod,before expiration. While this isreferred to asconsidered a rare or unusual event, the"grace period". Duringclient must be prepared to recover. Both thegrace period, clients recover locksserver and client will be able to detect theassociated state by reclaim-type locking requests (i.e., LOCK requests with reclaim setfailure totruerenew the lease andOPEN operations with a claim typeare capable ofeither CLAIM_PREVIOUS or CLAIM_DELEGATE_PREV). Duringrecovering without data corruption. For thegrace period,server, it tracks theserver must reject READ and WRITE operations and non-reclaim locking requests (i.e., other LOCKlast renewal event serviced for the client andOPEN operations) with an error of NFS4ERR_GRACE. Ifknows when theserver can reliably determine that granting a non-reclaim requestlease willnot conflict with reclamation of locks by other clients, the NFS4ERR_GRACE error does not have to be returned andexpire. Similarly, thenon- reclaimclientrequest can be serviced. For the server to be able to service READ and WRITEmust track operationsduringwhich will renew thegrace period, it must again be able to guaranteelease period. Using the time thatno possible conflict could arise between an impending reclaim lockingeach such request was sent and theREAD or WRITE operation. If the server is unable to offertime thatguarantee, the NFS4ERR_GRACE error must be returned totheclient. For a server to provide simple, valid handling duringcorresponding reply was received, thegrace period,client should bound theeasiest method is to simply reject all non-reclaim locking requests and READ and WRITE operations by returningtime that theNFS4ERR_GRACE error. However, a server may keep information about granted locks in stable storage. With this information,corresponding renewal could have occurred on the servercouldand thus determine if it is possible that aregularlease period expiration could have occurred. The third lockor READ or WRITE operationrevocation event canbe safely processed. For example, ifoccur as acountresult oflocks onadministrative intervention within the lease period. While this is considered agiven filerare event, it isavailable in stable storage, the server can track reclaimed locks for the file and when all reclaims have been processed, non-reclaim locking requests may be processed. This way the server can ensurepossible thatnon-reclaim locking requests will not conflict with potential reclaim requests. With respect to I/O requests, iftheserver is ableserver's administrator has decided todetermine that there are no outstanding reclaim requests forrelease or revoke afileparticular lock held byinformation from stable storage or another similar mechanism, the processing of I/O requests could proceed normally forthefile. To reiterate, forclient. As aserver that allows non-reclaim lock and I/O requests to be processed duringresult of revocation, thegrace period, it MUST determine that no lock subsequently reclaimedclient willbe rejected and that no lock subsequently reclaimed would have prevented any I/O operation processed during the grace period. Clients should be prepared for the returnreceive an error ofNFS4ERR_GRACE errors for non-reclaim lock and I/O requests.NFS4ERR_ADMIN_REVOKED. In thiscaseinstance the clientshould employ a retry mechanism for the request. A delay (on the order of several seconds) between retries should be used to avoid overwhelming the server. Further discussion ofmay assume that only thegeneral issue is included in [Floyd].state-owner's locks have been lost. The clientmust account for the server that is able to perform I/O and non-reclaim locking requests withinnotifies thegrace period as well as those that cannot do so. A reclaim-type locking request outsidelock holder appropriately. The client MUST NOT assume theserver's gracelease periodcan only succeed if the server can guarantee that no conflicting lock or I/O requesthas beengranted since reboot or restart. A server may, upon restart, establishrenewed as anew value for the lease period. Therefore, clients should, onceresult of anew client ID is established, refetch the lease_time attribute and use it asfailed operation. When thebasis for lease renewal forclient determines the leaseassociated with that server. However,period may have expired, theserverclient mustestablish,mark all locks held forthis restart event, a grace period at least as long asthe associated leaseperiod for the previous server instantiation.as "unvalidated". Thisallowsmeans the client has been unable to re-establish or confirm the appropriate lock stateobtained duringwith the server. As described in Section 9.6, there are scenarios in which thepreviousserverinstance to be reliably re-established. 9.6.3. Network Partitions and Recovery Ifmay grant conflicting locks after theduration oflease period has expired for anetwork partitionclient. When it isgreater thanpossible that the lease periodprovided by the server,has expired, theserver will haveclient must validate each lock currently held to ensure that a conflicting lock has notreceivedbeen granted. The client may accomplish this task by issuing an I/O request, either alease renewal frompending I/O or a zero-length read, specifying theclient.stateid associated with the lock in question. Ifthis occurs,theserver may cancelresponse to thelease and free all locks held forrequest is success, theclient. As a result,client has validated allstateids heldof the locks governed by that stateid and re-established theclient will become invalid or stale. Onceappropriate state between itself and theclient is able to reachserver. If theserver after such a network partition, allI/Osubmitted byrequest is not successful, then one or more of theclientlocks associated with thenow invalid stateids will fail withstateid was revoked by the serverreturning the error NFS4ERR_EXPIRED. Once this error is received,and the clientwill suitablymust notify theapplication that held the lock. 9.6.3.1. Courtesy Locks Asowner. 9.9. Share Reservations A share reservation is acourtesymechanism tothe client or as an optimization, the server may continuecontrol access tohold locks, including delegations, on behalf ofa file. It is a separate and independent mechanism from byte-range locking. When a clientfor which recent communication has extended beyondopens a file, it issues an OPEN operation to thelease period, delayingserver specifying thecancellationtype ofthe lease. If the server receives a lockaccess required (READ, WRITE, orI/O request that conflicts with oneBOTH) and the type ofthese courtesy locksaccess to deny others (OPEN4_SHARE_DENY_NONE, OPEN4_SHARE_DENY_READ, OPEN4_SHARE_DENY_WRITE, orif it runs out of resources,OPEN4_SHARE_DENY_BOTH). If theserver MAY cause lease cancellation to occur at that time and henceforth return NFS4ERR_EXPIRED when any ofOPEN fails thestateids associated withclient will fail thefreed locks is used. If lease cancellation has not occurred andapplication's open request. Pseudo-code definition of theserver receives a lock or I/O request that conflicts with onesemantics: if (request.access == 0) return (NFS4ERR_INVAL) else if ((request.access & file_state.deny)) || (request.deny & file_state.access)) return (NFS4ERR_DENIED) This checking of share reservations on OPEN is done with no exception for an existing OPEN for thecourtesy locks,same open-owner. The constants used for therequirementsOPEN and OPEN_DOWNGRADE operations for the access and deny fields are as follows:o In the case of a courtesy lock which is notconst OPEN4_SHARE_ACCESS_READ = 0x00000001; const OPEN4_SHARE_ACCESS_WRITE = 0x00000002; const OPEN4_SHARE_ACCESS_BOTH = 0x00000003; const OPEN4_SHARE_DENY_NONE = 0x00000000; const OPEN4_SHARE_DENY_READ = 0x00000001; const OPEN4_SHARE_DENY_WRITE = 0x00000002; const OPEN4_SHARE_DENY_BOTH = 0x00000003; 9.10. OPEN/CLOSE Operations To provide correct share semantics, adelegation, itclient MUSTfreeuse thecourtesy lockOPEN operation to obtain the initial filehandle andgrantindicate thenew request. o Indesired access and what access, if any, to deny. Even if thecase of lock or IO request which conflicts withclient intends to use adelegation which is being held as courtesy lock, the server MAY delay resolutionstateid ofrequest but MUST NOT rejectall 0's or all 1's, it must still obtain therequest and MUST freefilehandle for thedelegation and grantregular file with thenew request eventually. o InOPEN operation so thecase ofappropriate share semantics can be applied. Clients that do not have arequestsdeny mode built into their programming interfaces for opening adelegation which conflicts with a delegation which is being held as courtesy lock, the server MAY grant the newfile should requestor not as it chooses, but if it grantsa deny mode of OPEN4_SHARE_DENY_NONE. The OPEN operation with theconflicting request,CREATE flag, also subsumes thedelegation haledCREATE operation for regular files ascourtesy lock MUST be freed. If the server does not reboot or cancel the lease before the network partition is healed, whenused in previous versions of theoriginal client tries to accessNFS protocol. This allows acourtesy lock which was freed, the server SHOULD send backcreate with aNFS4ERR_BAD_STATEIDshare to be done atomically. The CLOSE operation removes all share reservations held by theclient.open- owner on that file. If byte-range locks are held, the clienttries to access a courtesy lock which was not freed, then the serverSHOULDmarkrelease allof the courtesylocksas implicitly being renewed. 9.6.3.2. Lease Cancellation Asbefore issuing aresult of lease expiration, leases may be cancelled, either immediately upon expiration or subsequently, dependingCLOSE. The server MAY free all outstanding locks on CLOSE but some servers may not support theoccurrenceCLOSE of aconflictingfile that still has byte-range locks held. The server MUST return failure, NFS4ERR_LOCKS_HELD, if any locks would exist after the CLOSE. The LOOKUP operation will return a filehandle without establishing any lockor extension ofstate on theperiod of partition beyond whatserver. Without a valid stateid, the server willtolerate. Whenassume the client has the least access. For example, if one client opened alease is cancelled, all locking state associatedfile with OPEN4_SHARE_DENY_BOTH and another client accesses the file via a filehandle obtained through LOOKUP, the second client could only read the file using the special read bypass stateid. The second client could not WRITE the file at all because itis freedwould not have a valid stateid from OPEN andusethe special anonymous stateid would not be allowed access. 9.10.1. Close and Retention of State Information Since a CLOSE operation requests deallocation of a stateid, dealing with retransmission ofanytheassociated stateids will result in NFS4ERR_EXPIRED being returned. Similarly, useCLOSE, may pose special difficulties, since the state information, which normally would be used to determine the state of theassociated clientid will result in NFS4ERR_EXPIREDopen file beingreturned. The client should recover fromdesignated, might be deallocated, resulting in an NFS4ERR_BAD_STATEID error. Servers may deal with thissituation by using SETCLIENTID followed by SETCLIENTID_CONFIRM,problem inorder to establish a new clientid. Oncealocknumber of ways. To provide the greatest degree assurance that the protocol isobtained usingbeing used properly, a server should, rather than deallocate the stateid, mark it as close-pending, and retain the stateid with thisclientid,status, until later deallocation. In this way, alease willretransmitted CLOSE can beestablished. 9.6.3.3. Client's Reaction to a Freed Lock There is no way for a clientrecognized since the stateid points topredetermine howstate information with this distinctive status, so that it can be handled without error. When adopting this strategy, agivenserveris going to behave during a network partition. Whenshould retain thepartition heals, eitherstate information until theclient still has all of its locks, it has some of its locks, or it has none of them.earliest of: o Another validly sequenced request for the same open-owner, that is not a retransmission. o Theclient will be able to examinetime that an open-owner is freed by thevarious error return valuesserver due todetermine its response. NFS4ERR_EXPIRED:period with no activity. o All lockshave beenfor the client are freed as a result of alease cancellation which occurred duringSETCLIENTID. Servers may avoid this complexity, at thepartition. The client should usecost of less complete protocol error checking, by simply responding NFS4_OK in the event of aSETCLIENTID to recover. NFS4ERR_ADMIN_REVOKED: The current lock has been revoked before, during, or afterCLOSE for a deallocated stateid, on thepartition. The client SHOULD handleassumption that thiserror ascase must be caused by a retransmitted close. When adopting this approach, itnormally would. NFS4ERR_BAD_STATEID: The current lock has been revoked/released during the partition andis desirable to at least log an error when returning a no-error indication in this situation. If the serverdid not reboot. Other locks MAY still be renewed. The client need not domaintains aSETCLIENTIDreply-cache mechanism, it can verify the CLOSE is indeed a retransmission andinstead SHOULD probe viaavoid error logging in most cases. 9.11. Open Upgrade and Downgrade When an OPEN is done for aRENEW call. NFS4ERR_RECLAIM_BAD: The current lock has been revoked during the partitionfile and theserver rebooted. The server might have no information onopen-owner for which theother locks. They may still be renewable. NFS4ERR_NO_GRACE: The client's locks have been revoked duringopen is being done already has thepartition andfile open, theserver rebooted. None ofresult is to upgrade the open file status maintained on theclient's locks will be renewable. NFS4ERR_OLD_STATEID: Theserverhas not rebooted.to include the access and deny bits specified by the new OPEN as well as those for the existing OPEN. Theclient SHOULD handle this errorresult is that there is one open file, asit normally would. 9.6.3.4. Edge Conditions When a network partitionfar as the protocol iscombined with a server reboot, then bothconcerned, and it includes theserverunion of the access andclient have responsibilities to ensure thatdeny bits for all of theclient does not reclaimOPEN requests completed. Only alock which it should no longersingle CLOSE will beable to access. Briefly those are: o Client's responsibility: A client MUST NOT attemptdone toreclaim any locks which it did not hold atreset theendeffects ofits most recent successfully established client lease. o Server's responsibility: A server MUST NOT allow a client to reclaim a lock unless it knowsboth OPENs. Note thatit could not have since granted a conflicting lock. However, in deciding whether a conflicting lock could have been granted, it is permitted to assume its clients are responsible, as above. A serverthe client, when issuing the OPEN, mayconsider a client's lease "successfully established" once it has received an open operation fromnot know thatclient.the same file is in fact being opened. The aboveare directed to CLAIM_PREVIOUS reclaims and not to CLAIM_DELEGATE_PREV reclaims, which generally do not involve a server reboot. However, when a server persistently stores delegation information to support CLAIM_DELEGATE_PREV across a period in whichonly applies if bothclient andOPENs result in the OPENed object being designated by the same filehandle. When the serverare down atchooses to export multiple filehandles corresponding to the sametime, similar strictures apply. The next sections give examples showing what can go wrong if these responsibilities are neglected,file object andprovides examplesreturns different filehandles on two different OPENs of the same file object, the serverimplementation strategies that could meet a server's responsibilities. 9.6.3.4.1. First Server Edge Condition The first edge condition hasMUST NOT "OR" together thefollowing scenario: 1. Client A acquires a lock. 2. Client Aaccess and deny bits and coalesce the two open files. Instead the serverexperience mutual network partition, such that client A is unable to renew its lease. 3. Client A's lease expires, so server releases lock. 4. Client B acquires a lock that would have conflictedmust maintain separate OPENs withthat of Client A. 5. Client B releasesseparate stateids and will require separate CLOSEs to free them. When multiple open files on thelock 6. Server reboots 7. Network partition betweenclientA and server heals. 8. Client A issues a RENEW operation, and gets backare merged into aNFS4ERR_STALE_CLIENTID. 9. Client A reclaims its lock withinsingle open file object on theserver's grace period. Thus, atserver, thefinal step,close of one of theserver has erroneously granted client A's lock reclaim. If client B modified the object the lock was protecting, client A will experience object corruption. 9.6.3.4.2. Second Server Edge Condition The second known edge condition follows: 1. Client A acquires a lock. 2. Server reboots. 3. Client A and server experience mutual network partition, such that client A is unable to reclaim its lock withinopen files (on thegrace period. 4. Server's reclaim grace period ends. Client A has no locks recorded on server. 5. Client B acquires a lock that would have conflicted with thatclient) may necessitate change ofClient A. 6. Client B releasesthelock. 7. Server reboots a second time. 8. Network partition between client A and server heals. 9. Client A issues a RENEW operation,access andgets back a NFS4ERR_STALE_CLIENTID. 10. Client A reclaims its lock within the server's grace period. As with the first edge condition, the final stepdeny status of thescenario ofopen file on thesecond edge condition hasserver. This is because theserver erroneously granting client A's lock reclaim. 9.6.3.4.3. Handling Server Edge Conditions In bothunion of theabove examples,access and deny bits for theclient attempts reclaim ofremaining opens may be smaller (i.e., alock that it held at the end of its most recent successfully established lease; thus, it has fulfilled its responsibility.proper subset) than previously. Theserver, however, has failed, by granting a reclaim, despite having granted a conflicting lock sinceOPEN_DOWNGRADE operation is used to make thereclaimed lock was last held. Solving these edge conditions requires thatnecessary change and theserver either assume afterclient should use itreboots that edge condition occurs, and thus return NFS4ERR_NO_GRACE for all reclaim attempts, or thatto update the serverrecord some information in stable storage.so that share reservation requests by other clients are handled properly. Theamount of information the server records in stable storage is in inverse proportion to how harshstateid returned has theserver wantssame "other" field as that passed tobe whenevertheedge conditions occur.server. Theserver that is completely tolerant of all edge conditions will record"seqid" value instable storage every lock that is acquired, removing the lock record from stable storage only whenthelockreturned stateid MUST be incremented, even in situations in which there isunlocked byno change to theclientaccess and deny bits for thelock's owner advances the sequence number such that the lock release is notfile. 9.12. Short and Long Leases When determining thelast stateful eventtime period for theowner's sequence. For the two aforementioned edge conditions,server lease, theharshest ausual lease tradeoffs apply. Short leases are good for fast servercan be, and still supportrecovery at agrace period for reclaims, requires thatcost of increased RENEW or READ (with zero length) requests. Longer leases are certainly kinder and gentler to servers trying to handle very large numbers of clients. The number of RENEW requests drop in proportion to the lease time. The disadvantages of long leases are slower recovery after serverrecord in stable storage information some minimal information. For example, afailure (the serverimplementation could,must wait foreach client, save in stable storage a record containing: otheclient's id string o a boolean that indicates ifleases to expire and theclient'sgrace period to elapse before granting new lock requests) and increased file contention (if client fails to transmit an unlock request then server must wait for leaseexpired orexpiration before granting new locks). Long leases are usable ifthere was administrative intervention (see Section 9.8) to revoke a byte-range lock, share reservation, or delegation o a timestamp thatthe server isupdatedable to store lease state in non-volatile memory. Upon recovery, thefirst time after aserverboot or rebootcan reconstruct theclient acquires byte-range locking, share reservation, or delegationlease stateon the server. The timestamp needfrom its non-volatile memory and continue operation with its clients and therefore long leases would not beupdated on subsequent lock requests until the server reboots. The server implementation would also record inan issue. 9.13. Clocks, Propagation Delay, and Calculating Lease Expiration To avoid thestable storageneed for synchronized clocks, lease times are granted by thetimestamps fromserver as a time delta. However, there is a requirement that thetwo most recentclient and serverreboots. Assumingclocks do not drift excessively over theabove record keeping, forduration of thefirst edge condition, afterlock. There is also theserver reboots,issue of propagation delay across therecordnetwork which could easily be several hundred milliseconds as well as the possibility that requests will be lost and need to be retransmitted. To take propagation delay into account, the clientA'sshould subtract it from leaseexpired meanstimes (e.g., if the client estimates the one-way propagation delay as 200 msec, then it can assume that the lease is already 200 msec old when it gets it). In addition, it will take another 200 msec to get a response back to the server. So the clientcould have acquiredmust send aconflicting record lock, share reservation,lock renewal ordelegation. Hencewrite data back to the servermust reject a reclaim from client A with400 msec before theerror NFS4ERR_NO_GRACE or NFS4ERR_RECLAIM_BAD. Forlease would expire. The server's lease period configuration should take into account thesecond edge condition, afternetwork distance of theserver reboots for a second time,clients that will be accessing therecordserver's resources. It is expected that the lease period will take into account the network propagation delays and other network delay factors for the clienthadpopulation. Since the protocol does not allow for anunexpired record lock, share reservation, or delegation established beforeautomatic method to determine an appropriate lease period, the server'sprevious incarnation means thatadministrator may have to tune theserver must rejectlease period. 9.14. Migration, Replication and State When responsibility for handling areclaim from client A with the error NFS4ERR_NO_GRACEgiven file system is transferred to a new server (migration) orNFS4ERR_RECLAIM_BAD. Regardless ofthelevel and approachclient chooses torecord keeping, theuse an alternate serverMUST implement one(e.g., in response to server unresponsiveness) in the context of file system replication, thefollowing strategies (which apply to reclaimsappropriate handling ofshare reservations, byte-rangestate shared between the client and server (i.e., locks, leases, stateids, anddelegations): 1. Reject all reclaims with NFS4ERR_NO_GRACE. Thisclient IDs) issuper harsh, but necessary if the server does not want to record lock state in stable storage. 2. Record sufficient state in stable storage to meet its responsibilities. In doubt, theas described below. The handling differs between migration and replication. For related discussion of file servershould err on the sidestate and recover ofbeing harsh. Insuch see theevent that, aftersections under Section 9.6. If a serverreboot, the server determines that there is unrecoverable damagereplica orcorruption to the the stable storage, then for all clients and/or locks affected, thea serverMUST return NFS4ERR_NO_GRACE. 9.6.3.4.4. Client Edge Condition A third edge condition effectsimmigrating a file system agrees to, or is expected to, accept opaque values from the clientand not the server. Ifthat originated from another server, then servers SHOULD encode theserver reboots"opaque" values in network byte order. This way, servers acting as replicas or immigrating file systems will be able to parse values like stateids, directory cookies, filehandles, etc. even if their native byte order is different from other servers cooperating in themiddlereplication and migration of theclient reclaiming some locksfile system. 9.14.1. Migration andthen a network partition is established,State In theclient might becase of migration, the servers involved in thesituationmigration ofhaving reclaimed some, but not all locks. In that case,aconservative client would assume thatfile system SHOULD transfer all server state from thenon-reclaimed locks were revoked. The third known edge condition follows: 1. Client A acquires a lock 1. 2. Client A acquires a lock 2. 3. Server reboots. 4. Client A issues a RENEW operation, and gets back a NFS4ERR_STALE_CLIENTID. 5. Client A reclaims its lock 1 withinoriginal to theserver's grace period. 6. Client A and server experience mutual network partition, suchnew server. This must be done in a way thatclient Aisunabletransparent toreclaim its remaining locks withinthegrace period. 7. Server's reclaim grace period ends. 8. Client B acquires a lock that would have conflicted with Client A's lock 2. 9. Client B releasesclient. This state transfer will ease thelock. 10. Server reboots a second time. 11. Network partition between client A and server heals. 12. Client A issues a RENEW operation, and gets backclient's transition when aNFS4ERR_STALE_CLIENTID. 13. Client A reclaims both lock 1 and lock 2 within the server's grace period. At the last step,file system migration occurs. If theclient reclaims lock 2 as if it had held that lock continuously, whenservers are successful infact a conflicting lock was granted to client B. This occurs becausetransferring all state, the clientfailed its responsibility, by attemptingwill continue toreclaim lock 2 even though it had not held that lock at the end of the lease that was establisheduse stateids assigned by theSETCLIENTID afteroriginal server. Therefore thefirstnew serverreboot. (Themust recognize these stateids as valid. This holds true for the clientdid hold lock 2 onID as well. Since responsibility for an entire file system is transferred with aprevious lease. But itmigration event, there isonly the most recent leaseno possibility thatmatters.) Aconflicts will arise on the new servercould avoid this situation by rejectingas a result of thereclaimtransfer of locks. As part of the transfer oflock 2. However, to do so accurately it would have to ensure that additionalinformationabout individual locks held survives reboot. Server implementations are not requiredbetween servers, leases would be transferred as well. The leases being transferred todo that, so the client must not assume thatthe new serverwill. Instead,will typically have aclient MUST reclaim only those locks which it successfully acquireddifferent expiration time fromthe previous server instance, omitting any that it failed to reclaim before a new reboot. Thus, in the last step above, client A should reclaim only lock 1. 9.6.3.4.5. Client's Handling of Reclaim Errors A mandatethose for theclient's handling of the NFS4ERR_NO_GRACE and NFS4ERR_RECLAIM_BAD errors is outsidesame client, previously on thescope of this specification, sinceold server. To maintain thestrategies for such handling are very dependentproperty that all leases on a given server for a given client expire at theclient's operating environment. However, one potential approach is described below. Whensame time, theclient's reclaim fails, it could examineserver should advance thechange attributeexpiration time to the later of theobjectsleases being transferred or the leases already present. This allows the clientis trying to reclaim state for, and use thattodetermine whethermaintain lease renewal of both classes without special effort. The servers may choose not tore-establishtransfer the statevia normal OPEN or LOCK requests. Thisinformation upon migration. However, this choice isacceptable provided the client's operating environment allows it.discouraged. Inother words, the client implementor is advised to document for his usersthis case, when thebehavior. Theclientcould also informpresents state information from theapplication that its byte-range lock or share reservations (whether they were delegated or not) have been lost, such as via a UNIX signal,original server (e.g., in aGUI pop-up window, etc. See Section 10.5, forRENEW op or adiscussion of what the client should do for dealing with unreclaimed delegations on client state. For further discussion of revocationREAD op oflocks see Section 9.8. 9.7. Recovery from a Lock Request Timeout or Abort Inzero length), theevent a lock request times out, aclientmay decidemust be prepared tonot retryreceive either NFS4ERR_STALE_CLIENTID or NFS4ERR_STALE_STATEID from therequest.new server. The clientmay also abort the request when the process for whichshould then recover its state information as itwas issued is terminated (e.g.,normally would inUNIX dueresponse to asignal). It is possible though that theserverreceivedfailure. The new server must take care to allow for therequest and acted upon it. Thisrecovery of state information as it wouldchangein thestate onevent of server restart. A client SHOULD re-establish new callback information with the new serverwithoutas soon as possible, according to sequences described in Section 15.35 and Section 15.36. This ensures that server operations are not blocked by the inability to recall delegations. 9.14.2. Replication and State Since clientbeing aware ofswitch-over in thechange. Itcase of replication isparamount thatnot under server control, theclient re-synchronizehandling of statewith server before it attempts any other operation that takes a seqid and/or a stateid with the same state- owner. Thisisstraightforward todifferent. In this case, leases, stateids and client IDs dowithoutnot have validity across aspecial re- synchronize operation. Since thetransition from one servermaintains the last lock request and response received on the state-owner, for each state-owner, theto another. The clientshould cachemust re-establish its locks on thelast lock request it sent such thatnew server. This can be compared to thelock request did not receivere- establishment of locks by means of reclaim-type requests after aresponse. From this,server reboot. The difference is that thenext timeserver has no provision to distinguish requests reclaiming locks from those obtaining new locks or to defer the latter. Thus, a clientdoesre-establishing a lockoperation for the state-owner, it can send the cached request, if there is one, and ifon therequest was one that established state (e.g.,new server (by means of a LOCK or OPENoperation), the server will return the cached result or if never sawrequest), may have therequest, perform it. The client can follow up withrequests denied due to arequestconflicting lock. Since replication is intended for read-only use of file systems, such denial of locks should not pose large difficulties in practice. When an attempt toremove the state (e.g.,re-establish aLOCKU or CLOSE operation). With this approach, the sequencing and stateid informationlock onthe client anda new serverforis denied, thegiven state-owner will re-synchronize and in turnclient should treat the situation as if his original lockstate will re-synchronize. 9.8. Server Revocationhad been revoked. 9.14.3. Notification ofLocks At any point,Migrated Lease In theserver can revoke locks held by a client andcase of lease renewal, the clientmustmay not bepreparedsubmitting requests forthis event. When the client detectsa file system thatits locks have been or may havehas beenrevoked,migrated to another server. This can occur because of the implicit lease renewal mechanism. The clientis responsiblerenews leases forvalidating the state information between itself andall file systems when submitting a request to any one file system at the server.Validating locking stateIn order for the clientmeansto schedule renewal of leases thatitmay have been relocated to the new server, the client mustverify or reclaim statefind out about lease relocation before those leases expire. To accomplish this, all operations which implicitly renew leases foreach lock currently held. The first instance of lock revocation is upon server reboot or re- initialization. In this instance thea clientwill receive an error (NFS4ERR_STALE_STATEID or NFS4ERR_STALE_CLIENTID)(such as OPEN, CLOSE, READ, WRITE, RENEW, LOCK, andthe clientothers), willproceed with normal crash recovery as described inreturn theprevious section. The second lock revocation event iserror NFS4ERR_LEASE_MOVED if responsibility for any of theinabilityleases to be renewed has been transferred torenew the lease before expiration. While this is consideredarare or unusual event,new server. This condition will continue until the clientmust be prepared to recover. Bothreceives an NFS4ERR_MOVED error and the serverand client will be able to detectreceives thefailuresubsequent GETATTR(fs_locations) for an access torenew theeach file system for which a leaseand are capable of recovering without data corruption. For the server, it trackshas been moved to a new server. By convention, thelast renewal event serviced forcompound including theclient and knows whenGETATTR(fs_locations) SHOULD append a RENEW operation to permit thelease will expire. Similarly,server to identify the clientmust track operations which will renewdoing thelease period. Usingaccess. Upon receiving thetimeNFS4ERR_LEASE_MOVED error, a client thateach such request was sent and the timesupports file system migration MUST probe all file systems from thatthe corresponding reply was received,server on which it holds open state. Once the clientshould boundhas successfully probed all those file systems which are migrated, thetimeserver MUST resume normal handling of stateful requests from that client. In order to support legacy clients that do not handle thecorresponding renewal could have occurred onNFS4ERR_LEASE_MOVED error correctly, the serverand thus determine if it is possible that a lease period expiration could have occurred. The third lock revocation event can occur asSHOULD time out after aresultwait ofadministrative intervention within theat least two leaseperiod. While this is considered a rare event,periods, at which time itis possible that the server's administrator has decided to release or revokewill resume normal handling of stateful requests from all clients. If aparticular lock held byclient attempts to access theclient. As a result of revocation,migrated files, the server MUST reply NFS4ERR_MOVED. When the clientwill receivereceives anerror of NFS4ERR_ADMIN_REVOKED. In this instanceNFS4ERR_MOVED error, the clientmay assume that onlycan follow thestate-owner's locks have been lost. The client notifiesnormal process to obtain thelock holder appropriately. The client may not assumenew server information (through thelease period has been renewed as a resultfs_locations attribute) and perform renewal ofa failed operation. Whenthose leases on theclient determinesnew server. If thelease period may have expired,server has not had state transferred to it transparently, the clientmust mark all locks held forwill receive either NFS4ERR_STALE_CLIENTID or NFS4ERR_STALE_STATEID from theassociated leasenew server, as"unvalidated". This means thedescribed above. The clienthas been unable to re-establish or confirm the appropriate lockcan then recover statewith the server. As described in Section 9.6, there are scenariosinformation as it does inwhichthe event of server failure. 9.14.4. Migration and the Lease_time Attribute In order that the client maygrant conflicting locks afterappropriately manage its leases in thelease period has expiredcase of migration, the destination server must establish proper values fora client.the lease_time attribute. Whenitstate ispossibletransferred transparently, that state should include thelease period has expired,correct value of theclientlease_time attribute. The lease_time attribute on the destination server mustvalidate each lock currently held to ensurenever be less than thata conflicting lock has not been granted. The client may accomplishon the source since thistaskwould result in premature expiration of leases granted byissuing an I/O request, either a pending I/O or a zero-length read, specifying the stateid associated withthelocksource server. Upon migration inquestion. If the response to the requestwhich state issuccess,transferred transparently, the clienthas validated all ofis under no obligation to re- fetch thelocks governed by that stateidlease_time attribute andre-establishedmay continue to use theappropriate state between itself andvalue previously fetched (on theserver.source server). Ifthe I/O request isstate has notsuccessful, then onebeen transferred transparently (i.e., the client sees a real ormore ofsimulated server reboot), thelocks associated withclient should fetch thestateid was revoked byvalue of lease_time on theservernew (i.e., destination) server, and use it for subsequent locking requests. However theclientserver mustnotify the owner. 9.9. Share Reservations A share reservation isrespect amechanism to control accessgrace period at least as long as the lease_time on the source server, in order toa file. It is a separate and independent mechanism from byte-range locking. When a client opens a file, it issues an OPEN operationensure that clients have ample time to reclaim their locks before potentially conflicting non-reclaimed locks are granted. The means by which the new serverspecifyingobtains thetypevalue ofaccess required (READ, WRITE, or BOTH) andlease_time on thetype of accessold server is left todeny others (OPEN4_SHARE_DENY_NONE, OPEN4_SHARE_DENY_READ, OPEN4_SHARE_DENY_WRITE, or OPEN4_SHARE_DENY_BOTH). If the OPEN failstheclient will failserver implementations. It is not specified by theapplication's open request. Pseudo-code definitionNFS version 4 protocol. 10. Client-Side Caching Client-side caching ofthe semantics: if (request.access == 0) return (NFS4ERR_INVAL) else if ((request.access & file_state.deny)) || (request.deny & file_state.access)) return (NFS4ERR_DENIED) This checkingdata, ofshare reservations on OPENfile attributes, and of file names isdoneessential to providing good performance withno exception for an existing OPEN for the same open-owner. The constants used fortheOPENNFS protocol. Providing distributed cache coherence is a difficult problem andOPEN_DOWNGRADE operations forprevious versions of theaccess and deny fields are as follows: const OPEN4_SHARE_ACCESS_READ = 0x00000001; const OPEN4_SHARE_ACCESS_WRITE = 0x00000002; const OPEN4_SHARE_ACCESS_BOTH = 0x00000003; const OPEN4_SHARE_DENY_NONE = 0x00000000; const OPEN4_SHARE_DENY_READ = 0x00000001; const OPEN4_SHARE_DENY_WRITE = 0x00000002; const OPEN4_SHARE_DENY_BOTH = 0x00000003; 9.10. OPEN/CLOSE Operations To provide correct share semantics, aNFS protocol have not attempted it. Instead, several NFS clientMUST use the OPEN operationimplementation techniques have been used toobtain the initial filehandle and indicatereduce thedesired accessproblems that a lack of coherence poses for users. These techniques have not been clearly defined by earlier protocol specifications and it is often unclear whataccess, if any, to deny. Even if theis valid or invalid clientintendsbehavior. The NFSv4 protocol uses many techniques similar touse a stateid of all 0's or all 1's, it must still obtain the filehandle for the regular file with the OPEN operation so the appropriate share semantics can be applied. Clientsthose thatdo nothavea deny mode built into their programming interfaces for opening a file should request a deny mode of OPEN4_SHARE_DENY_NONE. The OPEN operation with the CREATE flag, also subsumes the CREATE operation for regular files asbeen used in previousversions of the NFS protocol. This allows a create withprotocol versions. The NFSv4 protocol does not provide distributed cache coherence. However, it defines asharemore limited set of caching guarantees tobe done atomically. The CLOSE operation removes allallow locks and share reservationsheld by the open- owner on that file. If byte-range locks are held, theto be used without destructive interference from clientSHOULD release all locks before issuingside caching. In addition, the NFSv4 protocol introduces aCLOSE. Thedelegation mechanism which allows many decisions normally made by the serverMAY free all outstanding locks on CLOSE but some servers may notto be made locally by clients. This mechanism provides efficient support of theCLOSEcommon cases where sharing is infrequent or where sharing is read- only. 10.1. Performance Challenges for Client-Side Caching Caching techniques used in previous versions ofa file that still has byte-range locks held. The server MUST return failure, NFS4ERR_LOCKS_HELD, if any locks would exist aftertheCLOSE. The LOOKUP operation will return a filehandle without establishing any lock state onNFS protocol have been successful in providing good performance. However, several scalability challenges can arise when those techniques are used with very large numbers of clients. This is particularly true when clients are geographically distributed which classically increases theserver. Without a valid stateid,latency for cache re-validation requests. The previous versions of theserver will assumeNFS protocol repeat their file data cache validation requests at theclient hastime theleast access. For example, iffile is opened. This behavior can have serious performance drawbacks. A common case is oneclient openedin which a filewith OPEN4_SHARE_DENY_BOTH and another client accesses the file viais only accessed by afilehandle obtained through LOOKUP,single client. Therefore, sharing is infrequent. In this case, repeated reference to thesecondserver to find that no conflicts exist is expensive. A better option with regards to performance is to allow a clientcould only read thethat repeatedly opens a fileusingto do so without reference to thespecial read bypass stateid. The secondserver. This is done until potentially conflicting operations from another clientcould not WRITE theactually occur. A similar situation arises in connection with fileat all because it would not have a valid stateid from OPENlocking. Sending file lock and unlock requests to thespecial anonymous stateid would not be allowed access. 9.10.1. Closeserver as well as the read andRetention of State Information Since a CLOSE operationwrite requestsdeallocation of a stateid, dealingnecessary to make data caching consistent withretransmission of the CLOSE, may pose special difficulties, sincethestate information, which normally would belocking semantics (see Section 10.3.2) can severely limit performance. When locking is used todetermineprovide protection against infrequent conflicts, a large penalty is incurred. This penalty may discourage thestateuse ofthe openfilebeing designated, might be deallocated, resulting in an NFS4ERR_BAD_STATEID error. Servers may deallocking by applications. The NFSv4 protocol provides more aggressive caching strategies withthis problem in a number of ways. To provide the greatest degree assurance thattheprotocol is being used properly,following design goals: o Compatibility with a large range of servershould, rather than deallocatesemantics. o Provide thestateid, mark itsame caching benefits asclose-pending, and retainprevious versions of thestateid with this status, until later deallocation. In this way,NFS protocol when unable to provide the more aggressive model. o Requirements for aggressive caching are organized so that aretransmitted CLOSElarge portion of the benefit can berecognized since the stateid points to state information with this distinctive status, so that itobtained even when not all of the requirements can behandled without error. When adopting this strategy, a server should retain the state information until the earliest of: o Another validly sequenced request for the same open-owner, that is not a retransmission. omet. Thetime that an open-owner is freed by the server due to period with no activity. o All locksappropriate requirements for theclientserver arefreed as a resultdiscussed in later sections in which specific forms ofa SETCLIENTID. Servers may avoid this complexity, at the costcaching are covered (see Section 10.4). 10.2. Delegation and Callbacks Recallable delegation ofless complete protocol error checking,server responsibilities for a file to a client improves performance bysimply responding NFS4_OKavoiding repeated requests to the server in theeventabsence ofa CLOSE for a deallocated stateid, oninter-client conflict. With theassumption that this case must be caused byuse of aretransmitted close. When adopting this approach, it is desirable"callback" RPC from server toat least log an error when returningclient, ano-error indication in this situation. If theservermaintains a reply-cache mechanism, it can verify the CLOSE is indeed a retransmission and avoid error loggingrecalls delegated responsibilities when another client engages inmost cases. 9.11. Open Upgrade and Downgrade When an OPEN is done forsharing of afile and the open-owner for which the open is being done already has the file open, the resultdelegated file. A delegation isto upgrade the open file status maintained onpassed from the server toincludetheaccess and deny bits specified by the new OPEN as well as those forclient, specifying theexisting OPEN. The result is that there is one open file, as far asobject of theprotocol is concerned,delegation andit includestheuniontype ofthe access and deny bits for alldelegation. There are different types ofthe OPEN requests completed. Onlydelegations but each type contains asingle CLOSE willstateid to bedoneused toreset the effects of both OPENs. Note thatrepresent theclient,delegation whenissuing the OPEN, may not knowperforming operations that depend on thesame filedelegation. This stateid isin fact being opened. The above only applies if both OPENs result in the OPENed object being designated by the same filehandle. When the server chooses to export multiple filehandles correspondingsimilar to those associated with locks and share reservations but differs in that thesame file objectstateid for a delegation is associated with a client ID andreturns different filehandlesmay be used ontwo different OPENsbehalf of all thesame file object, the server MUST NOT "OR" together the access and deny bits and coalesce the two open files. Insteadopen-owners for theserver must maintain separate OPENs with separate stateids and will require separate CLOSEsgiven client. A delegation is made tofree them. When multiple open files onthe clientare merged intoas asingle open file object on the server, the close of one of the open files (on the client) may necessitate change of the accesswhole anddeny statusnot to any specific process or thread of control within it. Because callback RPCs may not work in all environments (due to firewalls, for example), correct protocol operation does not depend on them. Preliminary testing of callback functionality by means of a CB_NULL procedure determines whether callbacks can be supported. The CB_NULL procedure checks theopen file on the server. This is because the unioncontinuity of theaccesscallback path. A server makes a preliminary assessment of callback availability to a given client anddeny bits foravoids delegating responsibilities until it has determined that callbacks are supported. Because theremaining opens may be smaller (i.e.,granting of aproper subset) than previously. The OPEN_DOWNGRADE operationdelegation isused to makealways conditional upon thenecessary changeabsence of conflicting access, clients must not assume that a delegation will be granted and they must always be prepared for OPENs to be processed without any delegations being granted. Once granted, a delegation behaves in most ways like a lock. There is an associated lease that is subject to renewal together with all of the other leases held by that client. Unlike locks, an operation by a second clientshould use ittoupdatea delegated file will cause the serverso that share reservation requests by other clients are handled properly. The stateid returned hasto recall a delegation through a callback. On recall, thesame "other" fieldclient holding the delegation must flush modified state (such asthat passedmodified data) to theserver. The "seqid" value inserver and return thereturned stateid MUSTdelegation. The conflicting request will not beincremented, even in situations in which thereacted on until the recall isno change tocomplete. The recall is considered complete when theaccess and deny bits forclient returns thefile. 9.12. Short and Long Leases When determiningdelegation or thetime periodserver times out its wait for theserver lease,delegation to be returned and revokes theusual lease tradeoffs apply. Short leases are good for fast server recovery atdelegation as acostresult ofincreased RENEW or READ (with zero length) requests. Longer leases are certainly kinder and gentler to servers tryingthe timeout. In the interim, the server will either delay responding tohandle very large numbers of clients. The number of RENEWconflicting requestsdrop in proportionor respond to them with NFS4ERR_DELAY. Following thelease time. The disadvantagesresolution oflong leases are slower recovery after server failure (thethe recall, the servermust wait forhas theleasesinformation necessary toexpire andgrant or deny the second client's request. At the time thegrace period to elapse before granting new lock requests) and increased file contention (ifclientfailsreceives a delegation recall, it may have substantial state that needs totransmit an unlock request thenbe flushed to the server. Therefore, the servermust waitshould allow sufficient time forlease expiration before granting new locks). Long leases are usable ifthe delegation to be returned since it may involve numerous RPCs to the server. If the server is able tostore leasedetermine that the client is diligently flushing statein non-volatile memory. Upon recovery,to the servercan reconstructas a result of thelease state from its non-volatile memory and continue operation with its clients and therefore long leases would not be an issue. 9.13. Clocks, Propagation Delay, and Calculating Lease Expiration To avoid the need for synchronized clocks, lease times are granted byrecall, the serveras aMAY extend the usual timedelta. However, there isallowed for arequirement that the client and server clocks do not drift excessively over the duration of the lock. There is also the issue of propagation delay across the network which could easily be several hundred milliseconds as well asrecall. However, thepossibility that requests will be lost and need totime allowed for recall completion SHOULD NOT beretransmitted. To take propagation delay into account, the client should subtract it from lease times (e.g., if the client estimates the one-way propagation delay as 200 msec, then it can assume that the leaseunbounded. An example of this isalready 200 msec oldwhenit gets it). In addition, it will take another 200 msecresponsibility togetmediate opens on aresponse backgiven file is delegated tothe server. So the client must sendalock renewal or write data back to the server 400 msec before the lease would expire.client (see Section 10.4). Theserver's lease period configuration should take into account the network distance of the clients thatserver willbe accessingnot know what opens are in effect on theserver's resources. It is expected thatclient. Without this knowledge thelease periodserver willtake into accountbe unable to determine if thenetwork propagation delaysaccess andother network delay factorsdeny state for theclient population. Sincefile allows any particular open until theprotocol does not allowdelegation foran automatic method to determine an appropriate lease period, the server's administrator may have to tunethelease period. 9.14. Migration, Replication and State When responsibility for handling a givenfilesystem is transferredhas been returned. A client failure or a network partition can result in failure to respond to anew server (migration) orrecall callback. In this case, theclient chooses to use an alternateserver(e.g.,will revoke the delegation which inresponseturn will render useless any modified state still on the client. Clients need to be aware that serverunresponsiveness) in the context of file system replication,implementors may enforce practical limitations on theappropriate handlingnumber ofstate shared betweendelegations issued. Further, as there is no way to determine which delegations to revoke, theclient andserver(i.e., locks, leases, stateids, and client IDs)isas described below. The handling differs between migration and replication. For related discussion of file server state and recover of such see the sections under Section 9.6.allowed to revoke any. Ifa server replica or athe serverimmigrating a filesystem agrees to, orisexpected to, accept opaque values from the client that originated fromimplemented to revoke anotherserver,delegation held by that client, thenit is a wise implementation practice for the servers to encodethe"opaque" values in network byte order. This way, servers acting as replicas or immigrating filesystems willclient may be able toparse values like stateids, directory cookies, filehandles, etc. even if their native byte order is different from other servers cooperatingdetermine that a limit has been reached because each new delegation request results inthe replicationa revoke. The client could then determine which delegations it may not need andmigration of the filesystem. 9.14.1. Migration and Statepreemptively release them. 10.2.1. Delegation Recovery There are three situations that delegation recovery must deal with: o Client reboot or restart o Server reboot or restart (see Section 9.6.3.1) o Network partition (full or callback-only) In thecase of migration,event theservers involved inclient reboots or restarts, themigrationconfirmation of afilesystem SHOULD transfer all server state from the original to the new server. This must beSETCLIENTID doneinwith an nfs_client_id4 with away that is transparent to the client. This state transfernew verifier4 value willeaseresult in theclient's transition whenrelease of byte-range locks and share reservations. Delegations, however, may be treated afilesystem migration occurs. If the servers are successfulbit differently. There will be situations intransferring all state,which delegations will need to be reestablished after a client reboots or restarts. The reason for this is the client may have file data stored locally and this data was associated with the previously held delegations. The client willcontinueneed touse stateids assigned byreestablish the appropriate file state on theoriginalserver.ThereforeTo allow for this type of client recovery, thenewservermust recognize these stateids as valid.MAY allow delegations to be retained after other sort of locks are released. Thisholds trueimplies that requests from other clients that conflict with these delegations will need to wait. Because the normal recall process may require significant time for the clientID as well. Since responsibilityto flush changed state to the server, other clients need to be prepared foran entire filesystem is transferred with a migration event, there is no possibilitydelays thatconflicts will arise on the new server as a result of the transfer of locks. As partoccur because of a conflicting delegation. In order to give clients a chance to get through thetransfer of information between servers,reboot process during which leaseswouldwill not betransferred as well. The leases being transferred torenewed, thenewserverwill typically have a different expiration time from those for the same client, previously onMAY extend theold server. To maintainperiod for delegation recovery beyond thepropertytypical lease expiration period. For open delegations, such delegations thatall leases onare not released are reclaimed using OPEN with agiven serverclaim type of CLAIM_DELEGATE_PREV. (See Section 10.5 and Section 15.18 for discussion of open delegation and the details of OPEN respectively). A server MAY support agivenclaim type of CLAIM_DELEGATE_PREV, but if it does, it MUST NOT remove delegations upon SETCLIENTID_CONFIRM and instead MUST make them available for clientexpire atreclaim using CLAIM_DELEGATE_PREV. The server MUST NOT remove thesame time,delegations until either theserver should advanceclient does a DELEGPURGE, or one lease period has elapsed from theexpirationtimetothe later of theleases being transferredSETCLIENTID_CONFIRM or theleases already present. This allowslast successful CLAIM_DELEGATE_PREV reclaim. Note that theclient to maintain lease renewal of both classes without special effort. The servers may chooserequirement stated above is not meant totransfer the state information upon migration. However, this choice is discouraged. In this case,imply that when the clientpresents state information from the original server (e.g., in a RENEW op or a READ op of zero length), the client must be prepared to receive either NFS4ERR_STALE_CLIENTID or NFS4ERR_STALE_STATEID from the new server. The client should then recover its state informationis no longer obliged, asit normally would in response to a server failure. The new server must take carerequired above, toallow for the recovery of state information asretain delegation information, that itwould in the eventshould necessarily dispose ofserver restart. A client SHOULD re-establish new callback information withit. Some specific cases are: o When thenew server as soon as possible, according to sequences described in Section 15.35 and Section 15.36. This ensures that server operations are not blockedperiod is terminated by theinability to recall delegations. 9.14.2. Replication and State Since client switch-over in the caseoccurrence ofreplication is not under server control, the handlingDELEGPURGE, deletion ofstateunreclaimed delegations isdifferent. In this case, leases, stateidsappropriate andclient IDs do not have validity acrossdesirable. o When the period is terminated by atransition from one serverlease period elapsing without a successful CLAIM_DELEGATE_PREV reclaim, and that situation appears toanother. The client must re-establish its locks on the new server. This canbecompared tothere- establishment of locks by meansresult ofreclaim-type requests afteraserver reboot. The difference is that the servernetwork partition (i.e., lease expiration hasno provision to distinguish requests reclaiming locks from those obtaining newoccurred), a server's lease expiration approach, possibly including the use of courtesy locksor to deferwould normally provide for thelatter. Thus, a client re-establishing a lock onretention of unreclaimed delegations. Even in thenew server (by meansevent that lease cancellation occurs, such delegation should be reclaimed using CLAIM_DELEGATE_PREV as part ofa LOCK or OPEN request), may havenetwork partition recovery. o When therequests denied due to a conflicting lock. Since replicationperiod of non-communicating isintended for read-onlyfollowed by a client reboot, unreclaimed delegations, should also be reclaimable by use offilesystems, such denialCLAIM_DELEGATE_PREV as part oflocks should not pose large difficulties in practice.client reboot recovery. o Whenan attempt to re-establishthe period is terminated by alock onlease period elapsing without anew serversuccessful CLAIM_DELEGATE_PREV reclaim, and lease renewal isdenied,occurring, theclient should treatserver may well conclude that unreclaimed delegations have been abandoned, and consider the situation asif his original lock had been revoked. 9.14.3. Notification of Migrated Lease In the caseone in which an implied DELEGPURGE should be assumed. A server that supports a claim type oflease renewal,CLAIM_DELEGATE_PREV MUST support theclient may not be submitting requests forDELEGPURGE operation, and similarly afilesystemserver thathas been migrated to another server. This can occur because ofsupports DELEGPURGE MUST support CLAIM_DELEGATE_PREV. A server which does not support CLAIM_DELEGATE_PREV MUST return NFS4ERR_NOTSUPP if theimplicit lease renewal mechanism. Theclientrenews leasesattempts to use that feature or performs a DELEGPURGE operation. Support forall filesystems when submittingarequestclaim type of CLAIM_DELEGATE_PREV, is often referred toany one filesystem at the server. In orderas providing for "client-persistent delegations" in that they allow use of client persistent storage on the client toschedule renewal of leases that may have been relocated to the new server,store data written by the client, even across a clientmust find out about lease relocation before those leases expire. To accomplish this, all operations which implicitly renew leases for arestart. It should be noted that, with the optional exception noted below, this feature requires persistent storage to be used on the client(such as OPEN, CLOSE, READ, WRITE, RENEW, LOCK,andothers), will returndoes not add to persistent storage requirements on theerror NFS4ERR_LEASE_MOVED if responsibilityserver. One good way to think about client-persistent delegations is that forany oftheleasesmost part, they function like "courtesy locks", with special semantic adjustments to allow them to berenewed has been transferredretained across a client restart, which cause all other sorts of locks to be freed. Such locks are generally not retained across anew server. This condition will continue untilserver restart. The one exception is the case of simultaneous failure of the clientreceives an NFS4ERR_MOVED errorandtheserverreceivesand is discussed below. When thesubsequent GETATTR(fs_locations) for an access to each filesystem for which a lease has been movedserver indicates support of CLAIM_DELEGATE_PREV (implicitly) by returning NFS_OK to DELEGPURGE, anew server. By convention, the compound including the GETATTR(fs_locations) SHOULD appendclient with aRENEW operationwrite delegation, can use write-back caching for data topermit the serverbe written toidentify the client doingtheaccess. Upon receivingserver, deferring theNFS4ERR_LEASE_MOVED error, a client that supports filesystem migration MUST probe all filesystems from that server on which it holds open state. Oncewrite-back, until such time as the delegation is recalled, possibly after intervening clienthas successfully probed all those filesystems which are migrated,restarts. Similarly, when the serverMUST resume normal handlingindicates support ofstateful requests from that client. In orderCLAIM_DELEGATE_PREV, a client with a read delegation and an open-for-write subordinate tosupport legacy clientsthatdo not handle the NFS4ERR_LEASE_MOVED error correctly,delegation, may be sure of theserver SHOULD time out after a waitintegrity ofat least two lease periods, at which time it will resume normal handlingits persistently cached copy ofstateful requests from all clients. Ifthe file after a clientattempts to access the migrated files,restart without specific verification of theserver MUST reply NFS4ERR_MOVED.change attribute. When theclient receives an NFS4ERR_MOVED error, the client can follow the normal process to obtain the newserverinformation (throughreboots or restarts, delegations are reclaimed (using thefs_locations attribute)OPEN operation with CLAIM_PREVIOUS) in a similar fashion to byte- range locks andperform renewal of those leases onshare reservations. However, there is a slight semantic difference. In thenew server. Ifnormal case, if the serverhasdecides that a delegation should nothad state transferred tobe granted, ittransparently, the client will receive either NFS4ERR_STALE_CLIENTID or NFS4ERR_STALE_STATEID fromperforms thenew server, as described above. The client can then recover state information as it does inrequested action (e.g., OPEN) without granting any delegation. For reclaim, theevent ofserverfailure. 9.14.4. Migration andgrants theLease_time Attribute In orderdelegation but a special designation is applied so that the clientmay appropriately manage its leases intreats thecasedelegation as having been granted but recalled by the server. Because ofmigration,this, thedestination server must establish proper values forclient has thelease_time attribute. Whenduty to write all modified stateis transferred transparently, that state should includeto thecorrect value ofserver and then return thelease_time attribute. The lease_time attribute ondelegation. This process of handling delegation reclaim reconciles three principles of thedestinationNFSv4 protocol: o Upon reclaim, a client claiming resources assigned to it by an earlier server instance mustneverbeless than that ongranted those resources. o The server has unquestionable authority to determine whether delegations are to be granted and, once granted, whether they are to be continued. o The use of callbacks is not to be depended upon until thesource since this would result in premature expirationclient has proven its ability to receive them. When a client has more than a single open associated with a delegation, state for those additional opens can be established using OPEN operations ofleases granted bytype CLAIM_DELEGATE_CUR. When these are used to establish opens associated with reclaimed delegations, thesource server. Upon migrationserver MUST allow them when made within the grace period. Situations in whichstatethere istransferred transparently, thea series of client and server restarts where there isundernoobligation to re- fetchrestart of both at thelease_time attributesame time, are dealt with via a combination of CLAIM_DELEGATE_PREV andmay continue to use the value previously fetched (on the source server). If state has not been transferred transparently (i.e.,CLAIM_PREVIOUS reclaim cycles. Persistent storage is needed only on the client. For each server failure, a CLAIM_PREVIOUS reclaim cycle is done, while for each clientseesrestart, areal or simulated server reboot),CLAIM_DELEGATE_PREV reclaim cycle is done. To deal with the possibility of simultaneous failure of clientshould fetchand server (e.g., a data center power outage), thevalue of lease_time onserver MAY persistently store delegation information so that it can respond to a CLAIM_DELEGATE_PREV reclaim request which it receives from a restarting client. This is thenew (i.e., destination) server, and useone case in which persistent delegation state can be retained across a server restart. A server is not required to store this information, but if it does do so, it should do so forsubsequent locking requests. Howeverwrite delegations and for read delegations, during the pendency of which (across multiple client and/or servermust respect a grace period at least as longinstances), some open-for-write was done as part of delegation. When thelease_time onspace to persistently record such information is limited, thesource server,server should recall delegations inorder to ensure that clients have ample timethis class in preference toreclaim their locks before potentially conflicting non-reclaimed lockskeeping them active without persistent storage recording. When a network partition occurs, delegations aregranted. The meanssubject to freeing bywhichthenewserverobtains the value of lease_time onwhen theold serverlease renewal period expires. This isleftsimilar to theserver implementations. It is not specifiedbehavior for locks and share reservations, and, as for locks and share reservations it may be modified by support for "courtesy locks" in which locks are not freed in theNFS version 4 protocol. 10. Client-Side Caching Client-side caching of data,absence offile attributes,a conflicting lock request. Whereas, for locks and share reservations, freeing offile names is essential to providing good performance with the NFS protocol. Providing distributed cache coherence is a difficult problem and previous versionslocks will occur immediately upon the appearance of a conflicting request, for delegations, theNFS protocol have not attempted it. Instead, several NFS client implementation techniques have been used to reduceserver may institute period during which conflicting requests are held off. Eventually theproblems thatoccurrence of alackconflicting request from another client will cause revocation ofcoherence poses for users. These techniques have not been clearly definedthe delegation. A loss of the callback path (e.g., byearlier protocol specifications and it is often unclear what is valid or invalid client behavior. The NFSv4 protocol uses many techniques similar to those thatlater network configuration change) will havebeen useda similar effect inprevious protocol versions. The NFSv4 protocol does not provide distributed cache coherence. However,that itdefines a more limited setcan also result in revocation ofcaching guarantees to allow locksa delegation A recall request will fail andshare reservations to be used without destructive interference from client side caching. In addition,revocation of theNFSv4 protocol introduces adelegationmechanism which allows many decisionswill result. A client normallymade by the server to be made locally by clients. This mechanism provides efficient supportfinds out about revocation of a delegation when it uses a stateid associated with a delegation and receives one of thecommon cases where sharing is infrequenterrors NFS4ERR_EXPIRED, NFS4ERR_BAD_STATEID, orwhere sharing is read- only. 10.1. Performance Challenges for Client-Side Caching Caching techniques used in previous versions ofNFS4ERR_ADMIN_REVOKED (NFS4ERR_EXPIRED indicates that all lock state associated with theNFS protocol haveclient has beensuccessful in providing good performance. However, several scalability challenges can ariselost). It also may find out about delegation revocation after a client reboot whenthose techniques are used with very large numbersit attempts to reclaim a delegation and receives NFS4ERR_EXPIRED. Note that in the case ofclients. This is particularly true when clientsa revoked OPEN_DELEGATE_WRITE delegation, there aregeographically distributed which classically increasesissues because data may have been modified by thelatencyclient whose delegation is revoked and separately by other clients. See Section 10.5.1 forcache re-validation requests. The previous versionsa discussion of such issues. Note also that when delegations are revoked, information about theNFS protocol repeat their file data cache validation requests at the timerevoked delegation will be written by thefile is opened.server to stable storage (as described in Section 9.6). Thisbehavior can have serious performance drawbacks. A common caseisonedone to deal with the case in which afile is only accessed byserver reboots after revoking asingle client. Therefore, sharingdelegation but before the client holding the revoked delegation isinfrequent. In this case, repeated reference tonotified about theserver to findrevocation. Note thatno conflicts exist is expensive. A better option with regards to performancewhen there isto allowaclient that repeatedly opensloss of afile to do so without referencedelegation, due tothe server. This is done until potentially conflicting operations from another client actually occur. A similar situation arisesa network partition inconnectionwhich all locks associated withfile locking. Sending file lock and unlock requests totheserver as well aslease are lost, theread and write requests necessary to make data caching consistent withclient will also receive thelocking semantics (see Section 10.3.2)error NFS4ERR_EXPIRED. This case canseverely limit performance. When lockingbe distinguished from other situations in which delegations are revoked by seeing that the associated clientid becomes invalid so that NFS4ERR_STALE_CLIENTID isused to provide protection against infrequent conflicts, a large penaltyreturned when it isincurred. This penalty may discourage the use of file locking by applications. The NFSv4 protocol provides more aggressive caching strategies withused. When NFS4ERR_EXPIRED is returned, thefollowing design goals: o Compatibility with a large range ofserversemantics. o Provide the same caching benefits as previous versions ofMAY retain information about theNFS protocol when unable to providedelegations held by themore aggressive model. o Requirements for aggressive caching are organized soclient, deleting those that are invalidated by alarge portion ofconflicting request. Retaining such information will allow thebenefit can be obtained even when notclient to recover allofnon-invalidated delegations using therequirements can be met. The appropriate requirements forclaim type CLAIM_DELEGATE_PREV, once theserver are discussed in later sections in which specific forms of caching are covered (see Section 10.4). 10.2. Delegation and Callbacks Recallable delegation of server responsibilities for a fileSETCLIENTID_CONFIRM is done to recover. Attempted recovery of a delegation that the clientimproves performancehas no record of, typically because they were invalidated byavoiding repeated requests to the server inconflicting requests, will get theabsence of inter-client conflict. Witherror NFS4ERR_BAD_RECLAIM. Once a reclaim is attempted for all delegations that theuse ofclient held, it SHOULD do a"callback" RPC from serverDELEGPURGE toclient, aallow any remaining serverrecalls delegated responsibilities when another client engages in sharing of a delegated file. Adelegationis passed from the serverinformation to be freed. 10.3. Data Caching When applications share access tothe client, specifying the object of the delegation and the type of delegation. There are different types of delegations but each type containsastateidset of files, they need to beusedimplemented so as torepresent the delegation when performing operations that depend ontake account of thedelegation.possibility of conflicting access by another application. Thisstateidissimilar to those associated with locks and share reservations but differstrue whether the applications inthatquestion execute on different clients or reside on thestateid for a delegation is associated with a client IDsame client. Share reservations andmay be used on behalf of allbyte-range locks are theopen-owners forfacilities thegiven client. A delegation is madeNFS version 4 protocol provides to allow applications to coordinate access by providing mutual exclusion facilities. The NFSv4 protocol's data caching must be implemented such that it does not invalidate theclient as a wholeassumptions that those using these facilities depend upon. 10.3.1. Data Caching and OPENs In order to avoid invalidating the sharing assumptions that applications rely on, NFSv4 clients should not provide cached data toany specific processapplications orthreadmodify it on behalf ofcontrol within it. Because callback RPCs mayan application when it would notwork in all environments (duebe valid tofirewalls, for example), correct protocol operation does not depend on them. Preliminary testing of callback functionality by means of a CB_NULL procedure determines whether callbacks can be supported. The CB_NULL procedure checks the continuity of the callback path. A server makes a preliminary assessment of callback availability to a given client and avoids delegating responsibilities until it has determinedobtain or modify thatcallbacks are supported. Because the granting ofsame data via adelegation is always conditional uponREAD or WRITE operation. Furthermore, in the absence ofconflicting access, clients must not assume that aopen delegationwill be granted(see Section 10.4) two additional rules apply. Note that these rules are obeyed in practice by many NFSv2 andtheyNFSv3 clients. o First, cached data present on a client mustalways be prepared for OPENs tobeprocessed without any delegations being granted. Once granted, a delegation behaves in most ways like a lock. There isrevalidated after doing anassociated leaseOPEN. Revalidating means thatis subject to renewal together with all oftheother leases held by that client. Unlike locks, an operation by a secondclientto a delegated file will cause the server to recall a delegation through a callback. On recall,fetches theclient holdingchange attribute from thedelegation must flush modified state (such as modified data) toserver, compares it with theservercached change attribute, andreturnif different, declares thedelegation. The conflicting request will not be acted on untilcached data (as well as therecallcached attributes) as invalid. This iscomplete. The recallto ensure that the data for the OPENed file isconsidered complete whenstill correctly reflected in theclient returnsclient's cache. This validation must be done at least when thedelegationclient's OPEN operation includes DENY=WRITE or BOTH thus terminating a period in which other clients may have had theserver times its wait foropportunity to open thedelegationfile with WRITE access. Clients may choose tobe returned and revokesdo thedelegation as a resultrevalidation more often (i.e., at OPENs specifying DENY=NONE) to parallel the NFSv3 protocol's practice for the benefit of users assuming this degree of cache revalidation. Since thetimeout. Inchange attribute is updated for data and metadata modifications, some client implementors may be tempted to use theinterim,time_modify attribute and not theserver will either delay respondingchange attribute toconflicting requests or respondvalidate cached data, so that metadata changes do not spuriously invalidate clean data. The implementor is cautioned in this approach. The change attribute is guaranteed to change for each update tothem with NFS4ERR_DELAY. Following the resolution oftherecall,file, whereas time_modify is guaranteed to change only at theserver hasgranularity of theinformation necessary to grant or denytime_delta attribute. Use by thesecondclient'srequest. Atdata cache validation logic of time_modify and not thetimechange attribute runs the risk of the clientreceives a delegation recall, it may have substantial state that needs toincorrectly marking stale data as valid. o Second, modified data must be flushed to theserver. Therefore, theservershould allow sufficient timebefore closing a file OPENed forthe delegation to be returned since it may involve numerous RPCswrite. This is complementary to theserver.first rule. If theserverdata isable to determine thatnot flushed at CLOSE, the revalidation done after the client OPENs a file isdiligentlyunable to achieve its purpose. The other aspect to flushingstatethe data before close is that the data must be committed to stable storage, at theserver as a result ofserver, before therecall,CLOSE operation is requested by theserver may extendclient. In theusual time allowed forcase of arecall. However, the time allowed for recall completion shouldserver reboot or restart and a CLOSEd file, it may not beunbounded. An example ofpossible to retransmit the data to be written to the file. Hence, thisis when responsibilityrequirement. 10.3.2. Data Caching and File Locking For those applications that choose tomediate opens on a givenuse file locking instead of share reservations to exclude inconsistent file access, there isdelegatedan analogous set of constraints that apply toaclient(see Section 10.4). The server will not know what opensside data caching. These rules arein effect oneffective only if theclient. Without this knowledgefile locking is used in a way that matches in an equivalent way theserver will be unableactual READ and WRITE operations executed. This is as opposed todetermine iffile locking that is based on pure convention. For example, it is possible to manipulate a two-megabyte file by dividing the file into two one-megabyte regions and protecting access to the two regions by file locks on bytes zero anddeny stateone. A lock for write on byte zero of the fileallows any particular open untilwould represent thedelegationright to do READ and WRITE operations on the first region. A lock for write on byte one of the filehas been returned. A client failure or a network partition can result in failure to respondwould represent the right toa recall callback. In this case,do READ and WRITE operations on theserver will revokesecond region. As long as all applications manipulating thedelegation which in turnfile obey this convention, they willrender useless any modified state stillwork onthe client. Clients need to be aware that server implementorsa local file system. However, they mayenforce practical limitations onnot work with thenumber of delegations issued. Further, as there is no way to determine which delegations to revoke,NFSv4 protocol unless clients refrain from data caching. The rules for data caching in theserver is allowedfile locking environment are: o First, when a client obtains a file lock for a particular region, the data cache corresponding torevoke any.that region (if any cached data exists) must be revalidated. If theserver is implemented to revoke another delegation held bychange attribute indicates thatclient, thentheclientfile maybe able to determine that a limit hashave beenreached because each new delegation request results in a revoke. Theupdated since the cached data was obtained, the clientcould then determine which delegations it may not need and preemptively release them. 10.2.1. Delegation Recovery There are three situations that delegation recoverymustdeal with: o Client reboot or restart o Server reboot or restart o Network partition (fullflush orcallback-only) Ininvalidate theeventcached data for the newly locked region. A clientreboots or restarts, the confirmation of a SETCLIENTID done with an nfs_client_id4 with a new verifier4 value will result inmight choose to invalidate all of non-modified cached data that it has for thereleasefile but the only requirement for correct operation is to invalidate all ofbyte-range locks and share reservations. Delegations, however, may be treated a bit differently. There will be situationsthe data inwhich delegations will need to be reestablished afterthe newly locked region. o Second, before releasing aclient reboots or restarts. The reasonwrite lock forthis isa region, all modified data for that region must be flushed to theclient may have fileserver. The modified datastored locallymust also be written to stable storage. Note that flushing data to the server andthisthe invalidation of cached datawas associated withmust reflect thepreviously held delegations. Theactual byte ranges locked or unlocked. Rounding these up or down to reflect client cache block boundaries willneedcause problems if not carefully done. For example, writing a modified block when only half of that block is within an area being unlocked may cause invalid modification toreestablishtheappropriate file state onregion outside theserver. To allow forunlocked area. This, in turn, may be part of a region locked by another client. Clients can avoid thistypesituation by synchronously performing portions ofclient recovery,write operations that overlap that portion (initial or final) that is not a full block. Similarly, invalidating a locked area which is not an integral number of full buffer blocks would require theserver MAY allow delegationsclient tobe retained after other sort of locks are released. This implies that requestsread one or two partial blocks fromother clientsthe server if the revalidation procedure shows thatconflict with these delegations will need to wait. Becausethenormal recall process may require significant time fordata which the client possesses may not be valid. The data that is written toflush changed statethe server as a prerequisite to the unlocking of a region must be written, at the server,other clients needtobe prepared for delays that occurstable storage. The client may accomplish this either with synchronous writes or by following asynchronous writes with a COMMIT operation. This is required because retransmission of the modified data after aconflicting delegation. In order to give clientsserver reboot might conflict with achancelock held by another client. A client implementation may choose toget through the reboot process duringaccommodate applications whichleases will not be renewed,use byte-range locking in non-standard ways (e.g., using a byte-range lock as a global semaphore) by flushing to the serverMAY extendmore data upon a LOCKU than is covered by theperiodlocked range. This may include modified data within files other than the one fordelegation recovery beyondwhich thetypical lease expiration period. For open delegations, such delegations thatunlocks are being done. In such cases, the client must notreleased are reclaimed using OPENinterfere witha claim type of CLAIM_DELEGATE_PREV. (See Section 10.5applications whose READs andSection 15.18 for discussionWRITEs are being done only within the bounds ofopen delegation andrecord locks which thedetailsapplication holds. For example, an application locks a single byte ofOPEN respectively). A server MAY supportaclaim type of CLAIM_DELEGATE_PREV, but if it does, it MUST NOT remove delegations upon SETCLIENTID_CONFIRMfile andinstead MUST make them available for client reclaim using CLAIM_DELEGATE_PREV. The server MUST NOT remove the delegations until either theproceeds to write that single byte. A clientdoesthat chose to handle aDELEGPURGE, or one lease period has elapsed from the time the later of the SETCLIENTID_CONFIRM orLOCKU by flushing all modified data to thelast successful CLAIM_DELEGATE_PREV reclaim. Noteserver could validly write thatthe requirement stated above issingle byte in response to an unrelated unlock. However, it would notmeantbe valid toimply that whenwrite theclient is no longer obliged, as required above, to retain delegation information,entire block in which that single written byte was located since itshould necessarily dispose of it. Some specific cases are: o When the periodincludes an area that isterminatednot locked and might be locked bythe occurrence of DELEGPURGE, deletion of unreclaimed delegations isanother client. Client implementations can avoid this problem by dividing files with modified data into those for which all modifications are done to areas covered by an appropriate byte-range lock anddesirable. o When the period is terminatedthose for which there are modifications not covered by alease period elapsing without a successful CLAIM_DELEGATE_PREV reclaim,byte-range lock. Any writes done for the former class of files must not include areas not locked andthat situation appears to bethus not modified on theresultclient. 10.3.3. Data Caching and Mandatory File Locking Client side data caching needs to respect mandatory file locking when it is in effect. The presence of mandatory file locking for anetwork partition (i.e., lease expirationgiven file is indicated when the client gets back NFS4ERR_LOCKED from a READ or WRITE on a file it hasoccurred),an appropriate share reservation for. When mandatory locking is in effect for aserver's lease expiration approach, possibly includingfile, theuse of courtesy locks would normally provideclient must check for an appropriate file lock for data being read or written. If a lock exists for theretention of unreclaimed delegations. Even inrange being read or written, theevent that lease cancellation occurs, such delegation should be reclaimedclient may satisfy the request usingCLAIM_DELEGATE_PREV as part of network partition recovery. o Whentheperiod of non-communicatingclient's validated cache. If an appropriate file lock isfollowed by a client reboot, unreclaimed delegations, should also be reclaimable by use of CLAIM_DELEGATE_PREV as partnot held for the range ofclient reboot recovery. o Whentheperiod is terminatedread or write, the read or write request must not be satisfied bya lease period elapsing without a successful CLAIM_DELEGATE_PREV reclaim, and lease renewal is occurring,theserver may well conclude that unreclaimed delegations have been abandoned,client's cache andconsiderthesituation as one in which an implied DELEGPURGE shouldrequest must beassumed. Asent to the serverthat supportsfor processing. When aclaim type of CLAIM_DELEGATE_PREV MUST supportread or write request partially overlaps a locked region, theDELEGPURGE operation,request should be subdivided into multiple pieces with each region (locked or not) treated appropriately. 10.3.4. Data Caching andsimilarly a server that supports DELEGPURGE MUST support CLAIM_DELEGATE_PREV. A serverFile Identity When clients cache data, the file data needs to be organized according to the file system object to whichdoes not support CLAIM_DELEGATE_PREV MUST return NFS4ERR_NOTSUPP iftheclient attemptsdata belongs. For NFSv3 clients, the typical practice has been touse that feature or performs a DELEGPURGE operation. Supportassume fora claim typethe purpose ofCLAIM_DELEGATE_PREV, is often referred to as providing for "client-persistent delegations" incaching thatthey allow use ofdistinct filehandles represent distinct file system objects. The clientpersistent storage onthen has theclientchoice tostoreorganize and maintain the datawritten bycache on this basis. In theclient, even across a client restart. It should be noted that, withNFSv4 protocol, there is now theoptional exception noted below, this feature requires persistent storagepossibility to have significant deviations from a "one filehandle per object" model because a filehandle may beusedconstructed on theclient and does not add to persistent storage requirements onbasis of theserver. One good wayobject's pathname. Therefore, clients need a reliable method tothink about client-persistent delegations is that fordetermine if two filehandles designate themost part, they function like "courtesy locks", with a special semantic adjustmentssame file system object. If clients were simply toallow themassume that all distinct filehandles denote distinct objects and proceed tobe retained across ado data caching on this basis, caching inconsistencies would arise between the distinct clientrestart,side objects whichcause all other sorts of locksmapped tobe freed. Such locks are generally not retained across athe same serverrestart. The one exception isside object. By providing a method to differentiate filehandles, thecase of simultaneous failure ofNFSv4 protocol alleviates a potential functional regression in comparison with the NFSv3 protocol. Without this method, caching inconsistencies within the same client could occur andserver and is discussed below. When the server indicates supportthis has not been present in previous versions ofCLAIM_DELEGATE_PREV (implicitly) by returning NFS_OKthe NFS protocol. Note that it is possible toDELEGPURGE, a clienthave such inconsistencies witha write delegation, can use write-back caching for data to be written toapplications executing on multiple clients but that is not theserver, deferringissue being addressed here. For thewrite-back, until such time aspurposes of data caching, thedelegation is recalled, possibly after interveningfollowing steps allow an NFSv4 clientrestarts. Similarly, whento determine whether two distinct filehandles denote the same serverindicates supportside object: o If GETATTR directed to two filehandles returns different values ofCLAIM_DELEGATE_PREV, a clientthe fsid attribute, then the filehandles represent distinct objects. o If GETATTR for any file witha read delegation andanopen-for-write subordinate tofsid thatdelegation, may be sure ofmatches theintegrity of its persistently cached copyfsid of thefile aftertwo filehandles in question returns aclient restart without specific verificationunique_handles attribute with a value of TRUE, then thechange attribute. When the server reboots or restarts, delegationstwo objects arereclaimed (using the OPEN operation with CLAIM_PREVIOUS) in a similar fashiondistinct. o If GETATTR directed tobyte- range locks and share reservations. However, there is a slight semantic difference. Inthenormal case, iftwo filehandles does not return theserver decidesfileid attribute for both of the handles, then it cannot be determined whether the two objects are the same. Therefore, operations which depend on thata delegation should notknowledge (e.g., client side data caching) cannot begranted,done reliably. Note that if GETATTR does not return the fileid attribute for both filehandles, itperformswill return it for neither of therequested action (e.g., OPEN) without granting any delegation. For reclaim,filehandles, since the fsid for both filehandles is the same. o If GETATTR directed to the two filehandles returns different values for the fileid attribute, then they are distinct objects. o Otherwise they are the same object. 10.4. Open Delegation When a file is being OPENed, the servergrantsmay delegate further handling of opens and closes for that file to the opening client. Any such delegationbut a special designationisapplied sorecallable, since the circumstances that allowed for theclient treatsdelegation are subject to change. In particular, the server may receive a conflicting OPEN from another client, the server must recall the delegationas having been granted but recalled bybefore deciding whether theserver. Because of this,OPEN from the other clienthas the duty to write all modified statemay be granted. Making a delegation is up to the server andthen return theclients should not assume that any particular OPEN either will or will not result in an open delegation.This process of handling delegation reclaim reconciles three principlesThe following is a typical set ofthe NFSv4 protocol:conditions that servers might use in deciding whether OPEN should be delegated: oUpon reclaim, aThe clientreporting resources assigned to it by an earlier server instancemust begranted those resources. o The server has unquestionable authority to determine whether delegations areable tobe granted and, once granted, whether they arerespond tobe continued. othe server's callback requests. The server will useof callbacks is not to be depended upon untiltheclient has proven its ability to receive them. WhenCB_NULL procedure for a test of callback ability. o The clienthas more than a singlemust have responded properly to previous recalls. o There must be no current openassociatedconflicting witha delegation, state for those additional opens canthe requested delegation. o There should beestablished using OPEN operations of type CLAIM_DELEGATE_CUR. When these are used to establish opens associatedno current delegation that conflicts withreclaimed delegations,theserver MUST allow them when made withindelegation being requested. o The probability of future conflicting open requests should be low based on thegrace period. Situations in which there us a seriesrecent history ofclient and server restarts where there is no restartthe file. o The existence ofboth atany server-specific semantics of OPEN/CLOSE that would make thesame time, are dealtrequired handling incompatible withvia a combinationthe prescribed handling that the delegated client would apply (see below). There are two types ofCLAIM_DELEGATE_PREVopen delegations, OPEN_DELEGATE_READ andCLAIM_PREVIOUS reclaim cycles. Persistent storage is needed only on the client. For each server failure,OPEN_DELEGATE_WRITE. A OPEN_DELEGATE_READ delegation allows aCLAIM_PREVIOUS reclaim cycle is done, while for eachclientrestart,to handle, on its own, requests to open aCLAIM_DELEGATE_PREV reclaim cyclefile for reading that do not deny read access to others. It MUST, however, continue to send all requests to open a file for writing to the server. Multiple OPEN_DELEGATE_READ delegations may be outstanding simultaneously and do not conflict. A OPEN_DELEGATE_WRITE delegation allows the client to handle, on its own, all opens. Only one OPEN_DELEGATE_WRITE delegation may exist for a given file at a given time and it isdone. To dealinconsistent with any OPEN_DELEGATE_READ delegations. When a single client holds a OPEN_DELEGATE_READ delegation, it is assured that no other client may modify thepossibility of simultaneous failurecontents or attributes of the file. If more than one clientand server (e.g., a data center power outage),holds an OPEN_DELEGATE_READ delegation, then theserver MAY persistently store delegation information socontents and attributes of thatit can respondfile are not allowed to change. When aCLAIM_DELEGATE_PREV reclaim request whichclient has an OPEN_DELEGATE_WRITE delegation, itreceives from a restarting client. This ismay modify theone case in which persistent delegation state canfile data since no other client will beretained acrossaccessing the file's data. The client holding aserver restart. A server isOPEN_DELEGATE_WRITE delegation may only affect file attributes which are intimately connected with the file data: size, time_modify, change. When a client has an open delegation, it does notrequiredsend OPENs or CLOSEs tostore this information,the server butif it does do so, it should do soupdates the appropriate status internally. For a OPEN_DELEGATE_READ delegation, opens that cannot be handled locally (opens for writedelegations and foror that deny readdelegations, duringaccess) must be sent to thependency of which (across multiple client and/or server instances), some open-for-write was done as part of delegation.server. Whenthe space to persistently record such informationan open delegation islimited,made, theserver should recall delegations in this class in preference to keeping them active without persistent storage recording. When a network partition occurs, delegations are subjectresponse tofreeing bytheserver whenOPEN contains an open delegation structure which specifies thelease renewal period expires. This is similarfollowing: o the type of delegation (read or write) o space limitation information to control flushing of data on close (OPEN_DELEGATE_WRITE delegation only, see Section 10.4.1) o an nfsace4 specifying read and write permissions o a stateid to represent thebehaviordelegation forlocksREAD andshare reservations, and, as for locksWRITE The delegation stateid is separate andshare reservations it may be modified by supportdistinct from the stateid for"courtesy locks" in which locks are not freed intheabsence ofOPEN proper. The standard stateid, unlike the delegation stateid, is associated with aconflicting lock request. Whereas, for locksparticular open-owner andshare reservations, freeing of lockswilloccur immediately upon the appearance of a conflicting request, for delegations,continue to be valid after theserver may institute period during which conflicting requests are held off. Eventuallydelegation is recalled and theoccurrence offile remains open. When aconflictingrequestfrom anotherinternal to the client is made to open a file and open delegation is in effect, it willcause revocation ofbe accepted or rejected solely on thedelegation. A lossbasis of thecallback path (e.g., by later network configuration change) will have a similar effect in that it can alsofollowing conditions. Any requirement for other checks to be made by the delegate should result inrevocation of aopen delegationA recallbeing denied so that the checks can be made by the server itself. o The access and deny bits for the requestwill failandrevocation ofthedelegation will result. A client normally finds out about revocation of a delegation when it uses a stateid associatedfile as described in Section 9.9. o The read and write permissions as determined below. The nfsace4 passed withadelegationand receives one ofcan be used to avoid frequent ACCESS calls. The permission check should be as follows: o If theerrors NFS4ERR_EXPIRED, NFS4ERR_BAD_STATEID, or NFS4ERR_ADMIN_REVOKED (NFS4ERR_EXPIREDnfsace4 indicates thatall lock state associated withtheclient has been lost). It alsoopen mayfind out about delegation revocation after a client reboot whenbe done, then itattemptsshould be granted without reference toreclaim a delegation and receives NFS4ERR_EXPIRED. Notethe server. o If the nfsace4 indicates thatinthecase of a revoked OPEN_DELEGATE_WRITE delegation, there are issues because dataopen mayhave been modified bynot be done, then an ACCESS request must be sent to theclient whose delegationserver to obtain the definitive answer. The server may return an nfsace4 that isrevoked and separately by other clients. See Section 10.5.1 for a discussionmore restrictive than the actual ACL ofsuch issues.the file. This includes an nfsace4 that specifies denial of all access. Notealsothatwhen delegations are revoked, information about the revoked delegation will be written bysome common practices such as mapping theservertraditional user "root" tostable storage (as described in Section 9.6). This is donethe user "nobody" may make it incorrect todeal withreturn thecase in which a server reboots after revoking a delegation but beforeactual ACL of theclient holdingfile in therevokeddelegationis notified aboutresponse. The use of delegation together with various other forms of caching creates therevocation. Notepossibility thatwhen there is a loss of a delegation, due tono server authentication will ever be performed for anetwork partition in whichgiven user since alllocks associated withof thelease are lost,user's requests might be satisfied locally. Where the clientwill also receiveis depending on theerror NFS4ERR_EXPIRED.server for authentication, the client should be sure authentication occurs for each user by use of the ACCESS operation. This should be the casecaneven if an ACCESS operation would not bedistinguished from other situations in which delegations are revokedrequired otherwise. As mentioned before, the server may enforce frequent authentication byseeing thatreturning an nfsace4 denying all access with every open delegation. 10.4.1. Open Delegation and Data Caching OPEN delegation allows much of the message overhead associatedclientid becomes invalid so that NFS4ERR_STALE_CLIENTID is returnedwith the opening and closing files to be eliminated. An open whenitan open delegation isused. When NFS4ERR_EXPIRED Is returned,in effect does not require that a validation message be sent to the serverMAY retain information aboutunless there exists a potential for conflict with thedelegations held byrequested share mode. The continued endurance of theclient, deleting those"OPEN_DELEGATE_READ delegation" provides a guarantee thatare invalidated byno OPEN for write and thus no write has occurred that did not originate from this client. Similarly, when closing aconflicting request. Retaining such information will allowfile opened for write and if OPEN_DELEGATE_WRITE delegation is in effect, theclientdata written does not have to be flushed torecover all non-invalidated delegations usingtheclaim type CLAIM_DELEGATE_PREV, onceserver until theSETCLIENTID_CONFIRMopen delegation isdone to recover. Attempted recoveryrecalled. The continued endurance ofathe open delegation provides a guarantee thatthe client hasnorecord of, typically because they were invalidatedopen and thus no read or write has been done byconflicting requests, will getanother client. For theerror NFS4ERR_BAD_RECLAIM. Oncepurposes of open delegation, READs and WRITEs done without an OPEN are treated as the functional equivalents of areclaim is attempted for all delegationscorresponding type of OPEN. This refers to the READs and WRITEs that use theclient held, it SHOULD dospecial stateids consisting of all zero bits or all one bits. Therefore, READs or WRITEs with aDELEGPURGE to allow any remainingspecial stateid done by another client will force the serverdelegation information to be freed. 10.3. Data Caching When applications share accessto recall asetOPEN_DELEGATE_WRITE delegation. A WRITE with a special stateid done by another client will force a recall offiles, they needOPEN_DELEGATE_READ delegations. With delegations, a client is able tobe implemented so asavoid writing data totake account ofthepossibilityserver when the CLOSE ofconflicting access by another application. Thisa file is serviced. The file close system call istrue whether the applications in question execute on different clients or reside onthesame client. Share reservations and byte-range locks areusual point at which thefacilitiesclient is notified of a lack of stable storage for theNFS version 4 protocol provides to allow applications to coordinate accessmodified file data generated byproviding mutual exclusion facilities. The NFSv4 protocol'sthe application. At the close, file datacaching must be implemented such that it does not invalidateis written to theassumptions that those using these facilities depend upon. 10.3.1. Data Cachingserver andOPENs In orderthrough normal accounting the server is able toavoid invalidatingdetermine if the available file system space for thesharing assumptions that applications rely on, NFSv4 clients should not provide cacheddatato applicationshas been exceeded (i.e., server returns NFS4ERR_NOSPC ormodify it on behalfNFS4ERR_DQUOT). This accounting includes quotas. The introduction ofan application when it would not be valid to obtain or modifydelegations requires thatsame data viaaREAD or WRITE operation. Furthermore,alternative method be in place for theabsencesame type ofopen delegation (see Section 10.4) two additional rules apply. Note that these rules are obeyed in practice by many NFSv2 and NFSv3 clients. o First, cached data present on acommunication to occur between clientmust be revalidated after doing an OPEN. Revalidating means thatand server. In theclient fetchesdelegation response, thechange attribute fromserver provides either theserver, compares it withlimit of thecached change attribute, and if different, declaressize of thecached data (as well asfile or thecached attributes) as invalid. This is tonumber of modified blocks and associated block size. The server must ensure that the client will be able to flush dataforto theOPENed file is still correctly reflectedserver of a size equal to that provided in theclient's cache. This validationoriginal delegation. The server mustbe done at least whenmake this assurance for all outstanding delegations. Therefore, theclient's OPEN operation includes DENY=WRITEserver must be careful in its management of available space for new orBOTH thus terminatingmodified data taking into account available file system space and any applicable quotas. The server can recall delegations as aperiod in which other clients may have had the opportunity to openresult of managing the available filewith WRITE access. Clients may choose to dosystem space. The client should abide by therevalidation more often (i.e., at OPENs specifying DENY=NONE) to parallelserver's state space limits for delegations. If theNFSv3 protocol's practiceclient exceeds the stated limits for thebenefit of users assuming this degree of cache revalidation. Sincedelegation, thechange attributeserver's behavior isupdated for data and metadata modifications, some client implementors may be tempted to useundefined. Based on server conditions, quotas or available file system space, thetime_modify attribute and not change to validate cached data, so that metadata changes do not spuriously invalidate clean data.server may grant OPEN_DELEGATE_WRITE delegations with very restrictive space limitations. Theimplementor is cautionedlimitations may be defined inthis approach. The change attribute is guaranteeda way that will always force modified data tochange for each updatebe flushed to thefile, whereas time_modify is guaranteedserver on close. With respect tochange only at the granularity of the time_delta attribute. Use by the client's data cache validation logic of time_modify and not change runs the risk of the client incorrectly marking stale data as valid. o Second,authentication, flushing modified datamust be flushedto the serverbefore closingafter afile OPENed for write. This is complementary toCLOSE has occurred may be problematic. For example, thefirst rule. Ifuser of thedata isapplication may have logged off the client and unexpired authentication credentials may notflushed at CLOSE,be present. In this case, therevalidation done afterclientOPENs as file is unablemay need toachieve its purpose. The other aspecttake special care toflushing the data before close isensure thatthe data mustlocal unexpired credentials will in fact becommitted to stable storage, at the server, before the CLOSE operation is requestedavailable. This may be accomplished by tracking theclient. In the caseexpiration time ofa server rebootcredentials and flushing data well in advance of their expiration orrestartby making private copies of credentials to assure their availability when needed. 10.4.2. Open Delegation and File Locks When aCLOSEd file, itclient holds a OPEN_DELEGATE_WRITE delegation, lock operations maynotbepossible to retransmit the data toperformed locally. This includes those required for mandatory file locking. This can bewritten todone since thefile. Hence, this requirement. 10.3.2. Data Caching and File Locking For those applicationsdelegation implies thatchoose to use file locking instead of share reservations to exclude inconsistent file access,thereis an analogous setcan be no conflicting locks. Similarly, all ofconstraintsthe revalidations thatapply to client sidewould normally be associated with obtaining locks and the flushing of datacaching. These rulesassociated with the releasing of locks need not be done. When a client holds a OPEN_DELEGATE_READ delegation, lock operations areeffective only ifnot performed locally. All lock operations, including those requesting non-exclusive locks, are sent to thefile lockingserver for resolution. 10.4.3. Handling of CB_GETATTR The server needs to employ special handling for a GETATTR where the target isused inawayfile thatmatcheshas a OPEN_DELEGATE_WRITE delegation inan equivalent wayeffect. The reason for this is that theactual READclient holding the OPEN_DELEGATE_WRITE delegation may have modified the data andWRITE operations executed. This is as opposedthe server needs tofile lockingreflect this change to the second client thatis based on pure convention. For example, it is possiblesubmitted the GETATTR. Therefore, the client holding the OPEN_DELEGATE_WRITE delegation needs tomanipulate a two-megabyte file by dividingbe interrogated. The server will use thefile into two one-megabyte regionsCB_GETATTR operation. The only attributes that the server can reliably query via CB_GETATTR are size andprotecting accesschange. Since CB_GETATTR is being used to satisfy another client's GETATTR request, the server only needs to know if thetwo regions by file locks on bytes zero and one. A lock for write on byte zero ofclient holding thefile would representdelegation has a modified version of theright to do READ and WRITE operations onfile. If thefirst region. A lock for write on byte oneclient's copy of the delegated filewould representis not modified (data or size), theright to do READ and WRITE operations onserver can satisfy the secondregion. As long as all applications manipulatingclient's GETATTR request from thefile obey this convention, they will work on a local filesystem. However, they may not work withattributes stored locally at theNFSv4 protocol unless clients refrain from data caching. The rules for data caching inserver. If the filelocking environment are: o First, when a client obtains a file lock for a particular region,is modified, thedata cache correspondingserver only needs tothat region (if any cached data exists) must be revalidated.know about this modified state. If thechange attribute indicatesserver determines that the filemay have been updated sinceis currently modified, it will respond to thecached data was obtained,second client's GETATTR as if theclient must flush or invalidatefile had been modified locally at thecached data forserver. Since thenewly locked region. A client might choose to invalidate allform ofnon-modified cached data that it has forthefile butchange attribute is determined by theonly requirement for correct operationserver and is opaque toinvalidate all ofthedata inclient, thenewly locked region. o Second, before releasing a write lock for a region, all modified data for that region must be flushedclient and server need to agree on a method of communicating theserver. Themodifieddata must also be written to stable storage. Note that flushing data tostate of theserver andfile. For theinvalidationsize attribute, the client will report its current view ofcached data must reflecttheactual byte ranges locked or unlocked. Rounding these up or down to reflect client cache block boundaries will cause problems if not carefully done.file size. Forexample, writing a modified block when only half of that blockthe change attribute, the handling iswithin an area being unlocked may cause invalid modification tomore involved. For theregion outsideclient, theunlocked area. This, in turn, mayfollowing steps will bepart oftaken when receiving aregion locked by another client. Clients can avoidOPEN_DELEGATE_WRITE delegation: o The value of the change attribute will be obtained from the server and cached. Let thissituationvalue be represented bysynchronously performing portions of write operations that overlap that portion (initial or final) that is not a full block. Similarly, invalidatingc. o The client will create alocked area whichvalue greater than c that will be used for communicating modified data isnot an integral number of full buffer blocks would requireheld at the client. Let this value be represented by d. o When the clientto read one or two partial blocks fromis queried via CB_GETATTR for theserverchange attribute, it checks to see if it holds modified data. If therevalidation procedure shows thatfile is modified, thedata whichvalue d is returned for theclient possesses may not be valid. The data thatchange attribute value. If this file iswritten tonot currently modified, theserver as a prerequisite toclient returns theunlockingvalue c for the change attribute. For simplicity ofa region must be written, atimplementation, theserver, to stable storage. Theclientmay accomplish this either with synchronous writes or by following asynchronous writes with a COMMIT operation.MAY for each CB_GETATTR return the same value d. This isrequired because retransmission oftrue even if, between successive CB_GETATTR operations, themodifiedclient again modifies in the file's dataafter a server reboot might conflict with a lock held by another client. Aor metadata in its cache. The clientimplementation may choosecan return the same value because the only requirement is that the client be able toaccommodate applications which use byte-range locking in non-standard ways (e.g., using a byte-range lock as a global semaphore) by flushingindicate to the servermore data upon a LOCKU than is covered bythat thelocked range. This may includeclient holds modifieddata within files other thandata. Therefore, theone for whichvalue of d may always be c + 1. While theunlocks are being done. In such cases,change attribute is opaque to the clientmust not interfere with applications whose READs and WRITEs are being done only withinin theboundssense that it has no idea what units ofrecord locks whichtime, if any, theapplication holds. For example, an application locks a single byte of a file and proceeds to writeserver is counting change with, it is not opaque in thatsingle byte. Athe clientthat chose to handle a LOCKU by flushing all modified datahas to treat it as an unsigned integer, and the servercould validly write that single byte in responsehas toan unrelated unlock. However, it would notbevalidable towritesee theentire block in whichresults of the client's changes to thatsingle written byte was located sinceinteger. Therefore, the server MUST encode the change attribute in network order when sending itincludes an area that is not locked and might be locked by another client. Client implementations can avoid this problem by dividing files with modified data into those for which all modifications are donetoareas covered by an appropriate byte-range lock and those for which there are modifications not covered by a byte-range lock. Any writes done for the former class of files must not include areas not locked and thus not modified onthe client.10.3.3. Data Caching and Mandatory File Locking Client side data caching needsThe client MUST decode it from network order torespect mandatory file lockingits native order when receiving it and the client MUST encode it network order when sending it to the server. For this reason, the change attribute isin effect. The presencedefined as an unsigned integer rather than an opaque array ofmandatory file locking for a given file is indicated whenbytes. For theclient gets back NFS4ERR_LOCKED fromserver, the following steps will be taken when providing aREAD or WRITE onOPEN_DELEGATE_WRITE delegation: o Upon providing afileOPEN_DELEGATE_WRITE delegation, the server will cache a copy of the change attribute in the data structure ithas an appropriate share reservation for.uses to record the delegation. Let this value be represented by sc. o Whenmandatory locking is in effect forafile, thesecond clientmust check for an appropriate file lock for data being read or written. Ifsends alock exists forGETATTR operation on therange being read or written,same file to theclient may satisfyserver, therequest usingserver obtains theclient's validated cache. If an appropriate file lock is not held forchange attribute from therange offirst client. Let this value be cc. o If theread or write,value cc is equal to sc, theread or write request mustfile is notbe satisfied by the client's cachemodified and therequest must be sent to theserverfor processing. When a read or write request partially overlaps a locked region,returns therequest should be subdivided into multiple pieces with each region (locked or not) treated appropriately. 10.3.4. Data Cachingcurrent values for change, time_metadata, andFile Identity When clients cache data, the file data needs to be organized accordingtime_modify (for example) to thefilesystem objectsecond client. o If the value cc is NOT equal towhichsc, thedata belongs. For NFSv3 clients,file is currently modified at thetypical practice has beenfirst client and most likely will be modified at the server at a future time. The server then uses its current time toassumeconstruct attribute values forthe purposetime_metadata and time_modify. A new value ofcachingsc, which we will call nsc, is computed by the server, such thatdistinct filehandles represent distinct filesystem objects.nsc >= sc + 1. Theclientserver thenhasreturns thechoice to organizeconstructed time_metadata, time_modify, andmaintainnsc values to thedata cache on this basis. Inrequester. The server replaces sc in theNFSv4 protocol, there is nowdelegation record with nsc. To prevent the possibilityto have significant deviationsof time_modify, time_metadata, and change froma "one filehandle per object" model because a filehandle may be constructed on the basis of the object's pathname. Therefore, clients need a reliable methodappearing todeterminego backward (which would happen iftwo filehandles designatethesame filesystem object. If clients were simply to assume that all distinct filehandles denote distinct objects and proceedclient holding the delegation fails todowrite its modified datacaching on this basis, caching inconsistencies would arise between the distinct client side objects which mappedto thesameserverside object. By providing a method to differentiate filehandles, the NFSv4 protocol alleviates a potential functional regression in comparison with the NFSv3 protocol. Without this method, caching inconsistencies within the same client could occur and this has not been present in previous versions ofbefore theNFS protocol. Note that it is possible to have such inconsistencies with applications executing on multiple clients but thatdelegation isnot the issue being addressed here. For the purposes of data caching, the following steps allow an NFSv4 client to determine whether two distinct filehandles denoterevoked or returned), thesameserverside object: o If GETATTR directed to two filehandles returns different values of the fsid attribute, thenSHOULD update thefilehandles represent distinct objects. o If GETATTR for any filefile's metadata record withan fsid that matches the fsid ofthetwo filehandles in question returns a unique_handlesconstructed attributewith a valuevalues. For reasons ofTRUE, thenreasonable performance, committing thetwo objects are distinct. o If GETATTR directedconstructed attribute values to stable storage is OPTIONAL. As discussed earlier in this section, thetwo filehandles does notclient MAY return thefileid attribute for both of the handles, then it cannot be determined whether the two objects are the same. Therefore, operations which dependsame cc value onthat knowledge (e.g., client side data caching) cannot be done reliably. Note thatsubsequent CB_GETATTR calls, even ifGETATTR does not returnthefileid attribute for both filehandles, it will return it for neither offile was modified in thefilehandles, sinceclient's cache yet again between successive CB_GETATTR calls. Therefore, thefsid for both filehandles isserver must assume that thesame. o If GETATTR directedfile has been modified yet again, and MUST take care to ensure that thetwo filehandlesnew nsc it constructs and returnsdifferent values for the fileid attribute, then they are distinct objects. o Otherwise they are the same object. 10.4. Open Delegation When a fileisbeing OPENed,greater than theserver may delegate further handling of opens and closes forprevious nsc it returned. An example implementation's delegation record would satisfy this mandate by including a boolean field (let us call it "modified") thatfileis set to FALSE when theopening client. Any suchdelegation isrecallable, since the circumstances that allowed forgranted, and an sc value set at thedelegation are subjecttime of grant tochange. In particular, the server may receive a conflicting OPEN from another client, the server must recall the delegation before deciding whether the OPEN fromtheother client maychange attribute value. The modified field would begranted. Making a delegation is upset to TRUE theserverfirst time cc != sc, andclients should not assume that any particular OPEN either will or will not result in an open delegation. The followingwould stay TRUE until the delegation isa typical set of conditions that servers might use in deciding whether OPEN should be delegated: oreturned or revoked. Theclient must be able to respondprocessing for constructing nsc, time_modify, and time_metadata would use this pseudo code: if (!modified) { do CB_GETATTR for change and size; if (cc != sc) modified = TRUE; } else { do CB_GETATTR for size; } if (modified) { sc = sc + 1; time_modify = time_metadata = current_time; update sc, time_modify, time_metadata into file's metadata; } This would return to theserver's callback requests.client (that sent GETATTR) the attributes it requested, but make sure size comes from what CB_GETATTR returned. The serverwill usewould not update theCB_NULL procedure forfile's metadata with the client's modified size. In the case that the file attribute size is different than the server's current value, the server treats this as atestmodification regardless ofcallback ability. o The client must have responded properlythe value of the change attribute retrieved via CB_GETATTR and responds toprevious recalls. o There must be no current open conflicting withtherequested delegation. o Theresecond client as in the last step. This methodology resolves issues of clock differences between client and server and other scenarios where the use of CB_GETATTR break down. It should beno current delegationnoted thatconflicts withthe server is under no obligation to use CB_GETATTR and therefore the server MAY simply recall the delegationbeing requested. oto avoid its use. 10.4.4. Recall of Open Delegation Theprobabilityfollowing events necessitate recall offuture conflictingan openrequests should be low based on the recent history ofdelegation: o Potentially conflicting OPEN request (or READ/WRITE done with "special" stateid) o SETATTR issued by another client o REMOVE request for thefile.file oThe existence of any server-specific semanticsRENAME request for the file as either source or target ofOPEN/CLOSE that would maketherequired handling incompatible withRENAME Whether a RENAME of a directory in theprescribed handling thatpath leading to thedelegated client would apply (see below). There are two typesfile results in recall of an opendelegations, OPEN_DELEGATE_READ and OPEN_DELEGATE_WRITE. A OPEN_DELEGATE_READdelegationallows a client to handle,depends onits own, requests to open athe semantics of the server filefor readingsystem. If thatdo not deny read access to others. It MUST, however, continue to send all requests to openfile system denies such RENAMEs when a filefor writing tois open, theserver. Multiple OPEN_DELEGATE_READ delegations mayrecall must beoutstanding simultaneously and do not conflict. A OPEN_DELEGATE_WRITE delegation allowsperformed to determine whether theclientfile in question is, in fact, open. In addition tohandle, on its own, all opens. Only one OPEN_DELEGATE_WRITE delegationthe situations above, the server mayexist for a given filechoose to recall open delegations ata givenany timeandif resource constraints make itis inconsistent with any OPEN_DELEGATE_READ delegations.advisable to do so. Clients should always be prepared for the possibility of recall. When asingleclientholdsreceives aOPEN_DELEGATE_READrecall for an open delegation, itis assured that no other client may modifyneeds to update state on thecontents or attributes ofserver before returning thefile. If more than onedelegation. These same updates must be done whenever a clientholds an OPEN_DELEGATE_READ delegation, then the contents and attributes of that file are not allowedchooses tochange. Whenreturn aclient has an OPEN_DELEGATE_WRITE delegation, it may modify the file data since no other client willdelegation voluntarily. The following items of state need to beaccessingdealt with: o If thefile's data. The client holding a OPEN_DELEGATE_WRITE delegation may only affectfileattributes which are intimately connectedassociated with thefile data: size, time_modify, change. When a client has andelegation is no longer opendelegation, it does not send OPENs or CLOSEsand no previous CLOSE operation has been sent to theserver but updates the appropriate status internally. Forserver, aOPEN_DELEGATE_READ delegation, opens that cannot be handled locally (opens for write or that deny read access)CLOSE operation must be sent to the server.When ano If a file has other opendelegation is made, the response toreferences at the client, then OPENcontains an open delegation structure which specifies the following: o the type of delegation (read or write) o space limitation information to control flushing of data on close (OPEN_DELEGATE_WRITE delegation only, see Section 10.4.1) o an nfsace4 specifying read and write permissions o a stateidoperations must be sent torepresent the delegation for READ and WRITE The delegation stateid is separate and distinct from the stateid fortheOPEN proper.server. Thestandard stateid, unlike the delegation stateid, is associated with a particular lock-owner andappropriate stateids willcontinue tobevalid after the delegation is recalled andprovided by thefile remains open. When a request internal toserver for subsequent use by the clientis made to open a file and opensince the delegationis in effect, itstateid will not longer beaccepted or rejected solely onvalid. These OPEN requests are done with thebasisclaim type of CLAIM_DELEGATE_CUR. This will allow thefollowing conditions. Any requirement for other checks to be made bypresentation of thedelegate should result in opendelegationbeing deniedstateid so that thechecksclient canbe made by the server itself. o The access and deny bits forestablish therequest andappropriate rights to perform thefile as described inOPEN. (see Section9.9.15.18 for details.) oThe read and write permissions as determined below. The nfsace4 passed with delegation can be usedIf there are granted file locks, the corresponding LOCK operations need toavoid frequent ACCESS calls. The permission check shouldbeas follows:performed. This applies to the OPEN_DELEGATE_WRITE delegation case only. oIfFor a OPEN_DELEGATE_WRITE delegation, if at thenfsace4 indicates thattime of recall the file is not openmay be done, then it shouldfor write, all modified data for the file must begranted without referenceflushed to the server.oIf thenfsace4 indicates that the open maydelegation had notbe done, then an ACCESS request must be sent toexisted, theserver to obtainclient would have done this data flush before thedefinitive answer. The server may return an nfsace4 thatCLOSE operation. o For a OPEN_DELEGATE_WRITE delegation when a file ismore restrictive thanstill open at theactual ACLtime of recall, any modified data for thefile. This includes an nfsace4 that specifies denial of all access. Note that some common practices such as mapping the traditional user "root"file needs to be flushed to theuser "nobody" may makeserver. o With the OPEN_DELEGATE_WRITE delegation in place, itincorrect to returnis possible that theactual ACLfile was truncated during the duration of thefile indelegation. For example, thedelegation response. The usetruncation could have occurred as a result ofdelegation togetheran OPEN UNCHECKED4 withvarious other formsa size attribute value ofcaching creates the possibility that no server authentication will ever be performed forzero. Therefore, if agiven user since alltruncation of theuser's requests might be satisfied locally. Where the client is depending onfile has occurred and this operation has not been propagated to theserver for authentication,server, theclient should be sure authentication occurs for each user by use oftruncation must occur before any modified data is written to theACCESS operation. This should beserver. In the caseeven if an ACCESS operation would not be required otherwise. As mentioned before, the server may enforce frequent authentication by returning an nfsace4 denying all access with every open delegation. 10.4.1. Open Delegation and Data Caching OPEN delegation allows muchof OPEN_DELEGATE_WRITE delegation, file locking imposes some additional requirements. To precisely maintain themessage overheadassociatedwith the opening and closing files to be eliminated. An open when an open delegationinvariant, it isin effect does not require that a validation message be sentrequired tothe server unless there exists a potentialflush any modified data in any region forconflict with the requested share mode. The continued endurance of the "OPEN_DELEGATE_READ delegation" provideswhich aguarantee that no OPEN forwriteand thuslock was released while the OPEN_DELEGATE_WRITE delegation was in effect. However, because the OPEN_DELEGATE_WRITE delegation implies nowrite has occurred that did not originate from this client. Similarly, when closingother locking by other clients, afile openedsimpler implementation is to flush all modified data forwrite andthe file (as described just above) if any write lock has been released while the OPEN_DELEGATE_WRITE delegationiswas ineffect, the data written doeseffect. An implementation need nothavewait until delegation recall (or deciding tobe flushedvoluntarily return a delegation) to perform any of theserver untilabove actions, if implementation considerations (e.g., resource availability constraints) make that desirable. Generally, however, the fact that the actual opendelegation is recalled. The continued endurancestate of theopen delegation provides a guarantee that no openfile may continue to change makes it not worthwhile to send information about opens andthus no read or write has been done by another client. Forcloses to thepurposes of open delegation, READs and WRITEs done without an OPEN are treatedserver, except asthe functional equivalentspart ofa corresponding typedelegation return. Only in the case ofOPEN. This refers toclosing theREADs and WRITEsopen thatuseresulted in obtaining thespecial stateids consisting of all zero bits or all one bits. Therefore, READs or WRITEs with a special stateiddelegation would clients be likely to do this early, since, in that case, the close once doneby another clientwillforcenot be undone. Regardless of theserver to recall a OPEN_DELEGATE_WRITE delegation. A WRITE with a special stateid done by another client will force a recall of OPEN_DELEGATE_READ delegations. With delegations, a clientclient's choices on scheduling these actions, all must be performed before the delegation isable to avoid writing datareturned, including (when applicable) the close that corresponds to the open that resulted in the delegation. These actions can be performed either in previous requests or in previous operations in the same COMPOUND request. 10.4.5. OPEN Delegation Race with CB_RECALL The serverwheninforms theCLOSEclient of recall via afileCB_RECALL. A race case which may develop isserviced. The file close system callwhen the delegation is immediately recalled before theusual point atCOMPOUND which established theclientdelegation isnotified ofreturned to the client. As the CB_RECALL provides both alack of stable storagestateid and a filehandle for which themodified file data generated byclient has no mapping, it cannot honor theapplication.recall attempt. At this point, theclose, file data is written toclient has two choices, either do not respond or respond with NFS4ERR_BADHANDLE. If it does not respond, then it runs theserver and through normal accountingrisk of the serveris abledeciding todetermine ifnot grant it further delegations. If instead it does reply with NFS4ERR_BADHANDLE, then both theavailable filesystem space forclient and thedata has been exceeded (i.e.,serverreturns NFS4ERR_NOSPC or NFS4ERR_DQUOT). This accounting includes quotas.might be able to detect that a race condition is occurring. Theintroductionclient can keep a list ofdelegations requires thatpending delegations. When it receives aalternative method be in placeCB_RECALL for an unknown delegation, it can cache thesame type of communication to occur between clientstateid andserver. In the delegation response, the server provides either the limitfilehandle on a list of pending recalls. When it is provided with a delegation, it would only use it if it was not on thesize ofpending recall list. Upon thefile ornext CB_RECALL, it could immediately return thenumberdelegation. In turn, the server can keep track ofmodified blockswhen it issues a delegation andassociated block size. The server must ensureassume thattheif a clientwill be able to flush dataresponds to theserver ofCB_RECALL with asize equalNFS4ERR_BADHANDLE, then the client has yet tothat provided inreceive theoriginaldelegation. The servermust make this assurance for all outstanding delegations. Therefore,SHOULD give theserver must be careful in its management of available space for new or modified data taking into account available filesystem spaceclient a reasonable time both to get this delegation andany applicable quotas. The server can recall delegations asto return it before revoking the delegation. Unlike aresult of managingfailed callback path, theavailable filesystem space. The clientserver shouldabide by the server's state space limits for delegations. Ifperiodically probe the clientexceeds the stated limits for the delegation, the server's behavior is undefined. Based on server conditions, quotas or available filesystem space, the server may grant OPEN_DELEGATE_WRITE delegationswithvery restrictive space limitations. The limitations may be defined in a way that will always force modified data to be flushedCB_RECALL to see if it has received theserver on close. With respect to authentication, flushing modified datadelegation and is ready to return it. When the serverafter a CLOSEfinally determines that enough time hasoccurred may be problematic. For example,lapsed, it SHOULD revoke theuser ofdelegation and it SHOULD NOT revoke theapplication may have logged offlease. During this extended recall process, theclient and unexpired authentication credentials may notserver SHOULD bepresent. In this case,renewing the clientmay need to take special care to ensurelease. The intent here is thatlocal unexpired credentials will in fact be available. This may be accomplished by trackingtheexpiration time of credentials and flushing data well in advance of their expiration orclient not pay too onerous a burden for a condition caused bymaking private copies of credentialsthe server. 10.4.6. Clients that Fail toassure their availability when needed. 10.4.2. OpenHonor Delegationand File Locks When aRecalls A clientholds a OPEN_DELEGATE_WRITE delegation, lock operationsmaybe performed locally. This includes those requiredfail to respond to a recall formandatory file locking. This can be done sincevarious reasons, such as a failure of thedelegation implies that there cancallback path from server to the client. The client may beno conflicting locks. Similarly, allunaware of a failure in therevalidationscallback path. This lack of awareness could result in the client finding out long after the failure thatwould normally be associated with obtaining locksits delegation has been revoked, and another client has modified theflushing ofdataassociated withfor which thereleasing of locks need not be done. Whenclient had a delegation. This is especially a problem for the clientholdsthat held aOPEN_DELEGATE_READ delegation, lock operations are not performed locally. All lock operations,OPEN_DELEGATE_WRITE delegation. The server also has a dilemma in that the client that fails to respond to the recall might also be sending other NFS requests, including thoserequesting non-exclusive locks, are sent tothat renew theserverlease before the lease expires. Without returning an error forresolution. 10.4.3. Handling of CB_GETATTR Thethose lease renewing operations, the serverneeds to employ special handling for a GETATTR whereleads thetarget is a fileclient to believe thathas a OPEN_DELEGATE_WRITEthe delegation it has is ineffect. The reason for thisforce. This difficulty isthatsolved by theclient holdingfollowing rules: o When the callback path is down, the server MUST NOT revoke theOPEN_DELEGATE_WRITEdelegationmay have modifiedif one of thedatafollowing occurs: * The client has issued a RENEW operation and the serverneeds to reflect this change tohas returned an NFS4ERR_CB_PATH_DOWN error. The server MUST renew the lease for any byte-range locks and share reservations thesecondclient has thatsubmittedtheGETATTR. Therefore,server has known about (as opposed to those locks and share reservations the clientholdinghas established but not yet sent to theOPEN_DELEGATE_WRITE delegation needsserver, due tobe interrogated. The server will usetheCB_GETATTR operation.delegation). Theonly attributes that theservercan reliably query via CB_GETATTR are size and change. Since CB_GETATTR is being usedSHOULD give the client a reasonable time to return its delegations tosatisfy another client's GETATTR request,the serveronly needs to know ifbefore revoking the client's delegations. * The clientholding the delegationhas not issued amodified versionRENEW operation for some period of time after thefile. Ifserver attempted to recall theclient's copydelegation. This period of time MUST NOT be less than thedelegated file is not modified (data or size), the server can satisfy the second client's GETATTR request from the attributes stored locally at the server. Ifvalue of thefile is modified,lease_time attribute. o When theserver only needsclient holds a delegation, it cannot rely on operations, except for RENEW, that take a stateid, toknow about this modified state. If the server determinesrenew delegation leases across callback path failures. The client thatthe file is currently modified, it will respondwants to keep delegations in force across callback path failures must use RENEW to do so. 10.4.7. Delegation Revocation At thesecond client's GETATTR as if the file had been modified locally at the server. Since the form of the change attribute is determined by the server andpoint a delegation isopaque torevoked, if there are associated opens on the client, theclient and serverapplications holding these opens need toagree onbe notified. This notification usually occurs by returning errors for READ/WRITE operations or when amethod of communicating the modified state ofclose is attempted for the open file.For the size attribute, the client will report its current view ofIf no opens exist for the filesize. Forat thechange attribute,point thehandlingdelegation ismore involved. For the client, the following steps will be taken when receiving a OPEN_DELEGATE_WRITE delegation: o The valuerevoked, then notification of thechange attribute will be obtained from the server and cached. Let this value be represented by c. o The client will create a value greater than c that will be used for communicatingrevocation is unnecessary. However, if there is modified datais heldpresent at theclient. Let this value be represented by d. o When theclientis queried via CB_GETATTRfor thechange attribute, it checks to see if it holds modified data. If the file is modified,file, thevalue d is returned foruser of thechange attribute value. If this file isapplication should be notified. Unfortunately, it may notcurrently modified,be possible to notify theclient returnsuser since active applications may not be present at thevalue cclient. See Section 10.5.1 for additional details. 10.5. Data Caching and Revocation When locks and delegations are revoked, thechange attribute.assumptions upon which successful caching depend are no longer guaranteed. Forsimplicity of implementation, the client MAY for each CB_GETATTR returnany locks or share reservations that have been revoked, thesame value d.corresponding owner needs to be notified. Thisis true even if, between successive CB_GETATTR operations,notification includes applications with a file open that has a corresponding delegation which has been revoked. Cached data associated with theclient again modifies inrevocation must be removed from thefile'sclient. In the case of modified dataor metadataexisting inits cache. The client can return the same value becausetheonly requirement isclient's cache, that data must be removed from the clientbe able to indicatewithout it being written to theserver thatserver. As mentioned, the assumptions made by the clientholds modified data. Therefore,are no longer valid at thevalue of dpoint when a lock or delegation has been revoked. For example, another client mayalways be c + 1. Whilehave been granted a conflicting lock after thechange attribute is opaque torevocation of theclient inlock at thesense that it has no idea what units of time, if any,first client. Therefore, theserver is counting change with, it is not opaque in thatdata within the lock range may have been modified by the other client. Obviously, the first clienthasis unable to guarantee totreat it as an unsigned integer, andtheserverapplication what has occurred tobe able to seetheresultsfile in the case of revocation. Notification to a lock owner will in many cases consist of simply returning an error on theclient's changesnext and all subsequent READs/WRITEs tothat integer. Therefore,theserver MUST encodeopen file or on thechange attribute in network order when sending it toclose. Where theclient. The client MUST decode it from network ordermethods available toits native order when receiving it and thea clientMUST encode it network order when sending it to the server. Formake such notification impossible because errors for certain operations may not be returned, more drastic action such as signals or process termination may be appropriate. The justification for thisreason, changeisdefined asthat anunsigned integer rather thaninvariant for which anopaque array of bytes. For the server,application depends on may be violated. Depending on how errors are typically treated for thefollowing steps willclient operating environment, further levels of notification including logging, console messages, and GUI pop-ups may betaken when providing a OPEN_DELEGATE_WRITE delegation: o Upon providingappropriate. 10.5.1. Revocation Recovery for Write Open Delegation Revocation recovery for a OPEN_DELEGATE_WRITEdelegation,delegation poses theserver will cache a copyspecial issue ofthe change attribute in themodified datastructure it uses to recordin thedelegation. Let this value be represented by sc. o When a secondclientsends a GETATTR operation oncache while thesamefile is not open. In this situation, any client which does not flush modified data to theserver, theserverobtainson each close must ensure that thechange attribute fromuser receives appropriate notification of thefirst client. Let this value be cc. o Iffailure as a result of thevalue cc is equalrevocation. Since such situations may require human action tosc,correct problems, notification schemes in which thefileappropriate user or administrator isnot modifiednotified may be necessary. Logging and console messages are typical examples. If there is modified data on theserver returnsclient, it must not be flushed normally to thecurrent values for change, time_metadata, and time_modify (for example)server. A client may attempt to provide a copy of thesecond client. o Iffile data as modified during thevalue cc is NOT equaldelegation under a different name in the file system name space tosc,ease recovery. Note that when the client can determine that the fileis currentlyhas not been modifiedatby any other client, or when thefirstclientand most likely will be modified athas a complete cached copy of theserver atfile in question, such afuture time. The server then uses its current time to construct attribute values for time_metadata and time_modify. A new valuesaved copy ofsc, which we will call nsc, is computed by the server, such that nsc >= sc + 1. The server then returnstheconstructed time_metadata, time_modify, and nsc values toclient's view of therequester. The server replaces sc infile may be of particular value for recovery. In other cases, recovery using a copy of thedelegation record with nsc. To preventfile based partially on thepossibility of time_modify, time_metadata,client's cached data andchange from appearing to go backward (which would happen ifpartially on theclient holdingserver copy as modified by other clients, will be anything but straightforward, so clients may avoid saving file contents in these situations or mark thedelegation failsresults specially towrite itswarn users of possible problems. Saving of such modified datato the server before thein delegationis revokedrevocation situations may be limited to files of a certain size orreturned), the server SHOULD update the file's metadata record withmight be used only when sufficient disk space is available within theconstructed attribute values. For reasons of reasonable performance, committingtarget file system. Such saving may also be restricted to situations when theconstructed attribute valuesclient has sufficient buffering resources tostable storagekeep the cached copy available until it isOPTIONAL. Asproperly stored to the target file system. 10.6. Attribute Caching The attributes discussedearlierin thissection, the client MAY returnsection do not include named attributes. Individual named attributes are analogous to files and caching of thesame cc valuedata for these needs to be handled just as data caching is for regular files. Similarly, LOOKUP results from an OPENATTR directory are to be cached onsubsequent CB_GETATTR calls, even if the file was modified intheclient'ssame basis as any other pathnames and similarly for directory contents. Clients may cacheyet again between successive CB_GETATTR calls. Therefore,file attributes obtained from the servermust assumeand use them to avoid subsequent GETATTR requests. Such caching is write through in thatthemodification to filehas been modified yet again,attributes is always done by means of requests to the server andMUST take careshould not be done locally and cached. The exception toensurethis are modifications to attributes that are intimately connected with data caching. Therefore, extending a file by writing data to thenew nsc it constructs and returnslocal data cache isgreater thanreflected immediately in theprevious nsc it returned. An example implementation's delegation record would satisfysize as seen on the client without thismandate by including a boolean field (let us call it "modified") that is setchange being immediately reflected on the server. Normally such changes are not propagated directly toFALSEthe server but when thedelegationmodified data isgranted, and an sc value set at the time of grantflushed to thechangeserver, analogous attributevalue. Thechanges are made on the server. When open delegation is in effect, the modifiedfield wouldattributes may besetreturned toTRUEthefirst time cc != sc, and would stay TRUE untilserver in thedelegation is returned or revoked. The processing for constructing nsc, time_modify, and time_metadata would use this pseudo code: if (!modified) { doresponse to a CB_GETATTRfor change and size; if (cc != sc) modified = TRUE; } else { do CB_GETATTR for size; } if (modified) { sc = sc + 1; time_modify = time_metadata = current_time; update sc, time_modify, time_metadata into file's metadata; } This would return to the client (that sent GETATTR) the attributes it requested, but make sure size comes from what CB_GETATTR returned.call. Theserver would not update the file's metadata with the client's modified size. In the caseresult of local caching of attributes is that thefileattributesize is different than the server's current value,caches maintained on individual clients will not be coherent. Changes made in one order on the servertreats this asmay be seen in amodification regardless of the value of the change attribute retrieved via CB_GETATTR and responds to the seconddifferent order on one clientasand in a third order on a different client. The typical file system application programming interfaces do not provide means to atomically modify or interrogate attributes for multiple files at thelast step. This methodology resolves issues of clock differences between client and server and other scenariossame time. The following rules provide an environment where theuse of CB_GETATTR break down. It shouldpotential incoherency mentioned above can benoted thatreasonably managed. These rules are derived from theserver is under no obligation to use CB_GETATTR and thereforepractice of previous NFS protocols. o All attributes for a given file (per-fsid attributes excepted) are cached as a unit at theserver MAY simply recallclient so that no non-serializability can arise within thedelegation to avoid its use. 10.4.4. Recall of Open Delegation The following events necessitate recallcontext ofan open delegation: o Potentially conflicting OPEN request (or READ/WRITE done with "special" stateid)a single file. oSETATTR issued by anotherAn upper time boundary is maintained on how long a cliento REMOVE request forcache entry can be kept without being refreshed from thefileserver. oRENAME request forWhen operations are performed that modify attributes at thefileserver, the updated attribute set is requested aseither source or targetpart of theRENAME Whether a RENAME of acontaining RPC. This includes directoryinoperations that update attributes indirectly. This is accomplished by following thepath leading tomodifying operation with a GETATTR operation and then using thefileresultsin recallofan open delegation depends onthesemantics ofGETATTR to update theserver filesystem. Ifclient's cached attributes. Note thatfilesystem denies such RENAMEs when a file is open, the recall must be performed to determine whetherif thefile in question is, in fact, open. In additionfull set of attributes to be cached is requested by READDIR, thesituations above, the server may choose to recall open delegations at any time if resource constraints make it advisable to do so. Clients should alwaysresults can beprepared forcached by thepossibility of recall. When aclientreceives a recall for an open delegation, it needs to update stateon theserver before returning the delegation. Thesesameupdates must be done whenever abasis as attributes obtained via GETATTR. A clientchooses to return a delegation voluntarily. The following itemsmay validate its cached version ofstate need to be dealt with: o If theattributes for a fileassociated withby fetching just both thedelegation is no longer openchange andno previous CLOSE operation has been sent to the server, a CLOSE operation must be sent totime_access attributes and assuming that if theserver. o If a filechange attribute hasother open references attheclient, then OPEN operations must be sent tosame value as it did when theserver.attributes were cached, then no attributes other than time_access have changed. Theappropriate stateids will be provided byreason why time_access is also fetched is because many servers operate in environments where theserver for subsequent useoperation that updates change does not update time_access. For example, POSIX file semantics do not update access time when a file is modified by theclient sincewrite system call. Therefore, thedelegation stateid will not longer be valid. These OPEN requests are doneclient that wants a current time_access value should fetch it with change during theclaim typeattribute cache validation processing and update its cached time_access. The client may maintain a cache ofCLAIM_DELEGATE_CUR. This will allow the presentationmodified attributes for those attributes intimately connected with data ofthe delegation stateid so thatmodified regular files (size, time_modify, and change). Other than those three attributes, the clientcan establish the appropriate rightsMUST NOT maintain a cache of modified attributes. Instead, attribute changes are immediately sent toperformtheOPEN. (see Section 15.18 for details.) o If there are granted file locks,server. In some operating environments, thecorresponding LOCK operations needequivalent tobe performed. This appliestime_access is expected to be implicitly updated by each read of theOPEN_DELEGATE_WRITE delegation case only. o For a OPEN_DELEGATE_WRITE delegation, if at the timecontent ofrecallthe file object. If an NFS client isnot open for write, all modified data forcaching the content of a filemust be flushed to the server. If the delegation had not existed,object, whether it is a regular file, directory, or symbolic link, the clientwould have done this data flush beforeSHOULD NOT update theCLOSE operation. o For a OPEN_DELEGATE_WRITE delegation whentime_access attribute (via SETATTR or afilesmall READ or READDIR request) on the server with each read that isstill open atsatisfied from cache. The reason is that this can defeat thetimeperformance benefits ofrecall, any modified data forcaching content, especially since an explicit SETATTR of time_access may alter thefile needs to be flushed tochange attribute on the server.o WithIf theOPEN_DELEGATE_WRITE delegation in place, it is possiblechange attribute changes, clients that are caching thefile was truncated duringcontent will think theduration ofcontent has changed, and will re-read unmodified data from thedelegation. For example,server. Nor is thetruncation could have occurred as a result of an OPEN UNCHECKED4 with a size attribute value of zero. Therefore, ifclient encouraged to maintain atruncationmodified version ofthe file has occurred andtime_access in its cache, since thisoperation has not been propagated towould mean that theserver,client will either eventually have to write thetruncation must occur before any modified data is writtenaccess time to theserver. Inserver with bad performance effects, or it would never update thecaseserver's time_access, thereby resulting in a situation where an application that caches access time between a close and open ofOPEN_DELEGATE_WRITE delegation,the same filelocking imposes some additional requirements. To precisely maintainobserves theassociated invariant, it is requiredaccess time oscillating between the past and present. The time_access attribute always means the time of last access toflush any modified data in any region for whichawrite lockfile by a read that wasreleased whilesatisfied by theOPEN_DELEGATE_WRITE delegation wasserver. This way clients will tend to see only time_access changes that go forward ineffect. However, becausetime. 10.7. Data and Metadata Caching and Memory Mapped Files Some operating environments include theOPEN_DELEGATE_WRITE delegation implies no other locking by other clients, a simpler implementation is to flush all modified datacapability for an application to map a file's content into thefile (as described just above) if any write lockapplication's address space. Each time the application accesses a memory location that corresponds to a block that has not beenreleased whileloaded into theOPEN_DELEGATE_WRITE delegation was in effect. An implementation need not wait until delegation recall (or deciding to voluntarily returnaddress space, adelegation) to perform any ofpage fault occurs and theabove actions,file is read (or ifimplementation considerations (e.g., resource availability constraints) make that desirable. Generally, however,thefact thatblock does not exist in theactual open state offile, thefile may continue to change makes it not worthwhile to send information about opensblock is allocated andcloses tothen instantiated in theserver, exceptapplication's address space). As long aspart of delegation return. Only ineach memory mapped access to thecasefile requires a page fault, the relevant attributes ofclosingtheopenfile thatresulted in obtaining the delegation would clients be likelyare used todo this early, since,detect access and modification (time_access, time_metadata, time_modify, and change) will be updated. However, inthat case, the close once donemany operating environments, when page faults are not required these attributes will not beundone. Regardless of the client's choicesupdated onscheduling these actions, all must be performed before the delegation is returned, including (when applicable) the close that correspondsreads or updates to theopen that resulted infile via memory access (regardless of whether thedelegation. These actions can be performed either in previous requestsfile is a local file orin previous operations in the same COMPOUND request. 10.4.5. OPEN Delegation Race with CB_RECALL The server informs theis being access remotely). A client or server MAY fail to update attributes ofrecall viaaCB_RECALL. A race case which may develop is when the delegationfile that isimmediately recalled before the COMPOUND which established the delegationbeing accessed via memory mapped I/O. This has several implications: o If there isreturned to the client. Asan application on theCB_RECALL provides bothserver that has memory mapped astateid andfile that afilehandle for which theclienthas no mapping, it cannot honor the recall attempt. At this point,is also accessing, the clienthas two choices, either do not respond or respond with NFS4ERR_BADHANDLE. If it doesmay notrespond, then it runs the riskbe able to get a consistent value of theserver decidingchange attribute tonot grant it further delegations. If instead it does reply with NFS4ERR_BADHANDLE, then both the client and thedetermine whether its cache is stale or not. A servermight be able to detectthata race conditionknows that the file isoccurring. The client can keep a list of pending delegations. When it receives a CB_RECALLmemory mapped could always pessimistically return updated values foran unknown delegation, it can cachechange so as to force thestateidapplication to always get the most up to date data andfilehandle on a listmetadata for the file. However, due to the negative performance implications ofpending recalls. When itthis, such behavior is OPTIONAL. o If the memory mapped file isprovided with a delegation, it would only use it if it wasnot being modified on thepending recall list. Uponserver, and instead is just being read by an application via thenext CB_RECALL, it could immediately returnmemory mapped interface, thedelegation. In turn,client will not see an updated time_access attribute. However, in many operating environments, neither will any process running on theserver can keep track of when it issues a delegation and assumeserver. Thus NFS clients are at no disadvantage with respect to local processes. o If there is another client that is memory mapping the file, and ifathat clientresponds to the CB_RECALL withis holding aNFS4ERR_BADHANDLE, thenOPEN_DELEGATE_WRITE delegation, theclient has yet to receivesame set of issues as discussed in thedelegation. Theprevious two bullet items apply. So, when a serverSHOULD give the clientdoes areasonable time both to get this delegation andCB_GETATTR toreturn it before revoking the delegation. Unlikeafailed callback path, the server should periodically probefile that the clientwith CB_RECALL to see if ithasreceivedmodified in its cache, thedelegation andresponse from CB_GETATTR will not necessarily be accurate. As discussed earlier, the client's obligation isreadytoreturn it. When the server finally determinesreport thatenough timethe file haslapsed, it SHOULD revokebeen modified since the delegationandwas granted, not whether itSHOULD NOT revoke the lease. During this extended recall process,has been modified again between successive CB_GETATTR calls, and the serverSHOULD be renewing the client lease. The intent here isMUST assume that any file the clientnot pay too onerous a burden for a condition caused byhas modified in cache has been modified again between successive CB_GETATTR calls. Depending on theserver. 10.4.6. Clients that Fail to Honor Delegation Recalls A client may fail to respond to a recall for various reasons, such as a failurenature of thecallback path from server to the client. The clientclient's memory management system, this weak obligation may not beunaware of a failurepossible. A client MAY return stale information in CB_GETATTR whenever thecallback path. This lackfile is memory mapped. o The mixture ofawareness could result in the client finding out long after the failure that its delegation has been revoked,memory mapping andanother client has modified the data for whichfile locking on theclient had a delegation. Thissame file isespecially a problem forproblematic. Consider the following scenario, where the page size on each clientthat held a OPEN_DELEGATE_WRITE delegation. The server also hasis 8192 bytes. * Client A memory maps first page (8192 bytes) of file X * Client B memory maps first page (8192 bytes) of file X * Client A write locks first 4096 bytes * Client B write locks second 4096 bytes * Client A, via adilemma in that the client that fails to respondSTORE instruction modifies part of its locked region. * Simultaneous tothe recall might also be sending other NFS requests, including those that renew the lease before the lease expires. Without returning an error for those lease renewing operations, the server leads theclientto believe that the delegation it has is in force. This difficulty is solved by the following rules: o When the callback path is down, the server MUST NOT revoke the delegation if oneA, client B issues a STORE on part of its locked region. Here thefollowing occurs: * Thechallenge is for each clienthas issuedto resynchronize to get aRENEW operation and the server has returned an NFS4ERR_CB_PATH_DOWN error. The server MUST renewcorrect view of thelease for any byte-range locks and share reservationsfirst page. In many operating environments, the virtual memory management systems on each clienthasonly know a page is modified, not that a subset of theserver has known about (as opposedpage corresponding tothose locks and share reservationstheclientrespective lock regions hasestablished butbeen modified. So it is notyet sent to the server, duepossible for each client to do thedelegation). The server SHOULD give the client a reasonable timeright thing, which is toreturn its delegationsonly write to the serverbefore revoking the client's delegations. * The client has not issued a RENEW operation for some periodthat portion oftime aftertheserver attempted to recallpage that is locked. For example, if client A simply writes out thedelegation. This period of time MUST NOT be less thanpage, and then client B writes out thevalue ofpage, client A's data is lost. Moreover, if mandatory locking is enabled on thelease_time attribute. ofile, then we have a different problem. When clients A and B issue theclient holdsSTORE instructions, the resulting page faults require adelegation, it cannot relybyte-range lock onoperations, except for RENEW, that take a stateid, to renew delegation leases across callback path failures. Thethe entire page. Each clientthat wantsthen tries tokeep delegations in force across callback path failures must use RENEWextend their locked range todo so. 10.4.7. Delegation Revocation Atthepointentire page, which results in adelegation is revoked, if there are associated opens on the client,deadlock. Communicating theapplications holding these opens needNFS4ERR_DEADLOCK error tobe notified. This notification usually occurs by returning errors for READ/WRITE operations or whenacloseSTORE instruction isattempted for the open file. If no opens exist for the filedifficult atthe point the delegationbest. If a client isrevoked, then notification oflocking therevocation is unnecessary. However, ifentire memory mapped file, there ismodified data presentno problem with advisory or mandatory byte-range locking, at least until the clientfor the file,unlocks a region in theusermiddle of theapplication should be notified. Unfortunately, it may not be possible to notifyfile. Given theuser since active applications may not be present atabove issues theclient. See Section 10.5.1 for additional details. 10.5. Data Caching and Revocation When locks and delegationsfollowing arerevoked, the assumptions upon which successful caching dependpermitted: o Clients and servers MAY deny memory mapping a file they know there areno longer guaranteed. For anybyte-range locksor share reservations that have been revoked, the corresponding owner needs to be notified. This notification includes applications withfor. o Clients and servers MAY deny a byte-range lock on a fileopen that hasthey know is memory mapped. o A client MAY deny memory mapping acorresponding delegation which has been revoked. Cached data associated withfile that it knows requires mandatory locking for I/O. If mandatory locking is enabled after therevocation mustfile is opened and mapped, the client MAY deny the application further access to its mapped file. 10.8. Name Caching The results of LOOKUP and READDIR operations may beremoved fromcached to avoid theclient. Incost of subsequent LOOKUP operations. Just as in the case ofmodified data existing inattribute caching, inconsistencies may arise among theclient's cache, that data must be removed fromvarious client caches. To mitigate the effects of these inconsistencies and given the context of typical file system APIs, an upper time boundary is maintained on how long a client name cache entry can be kept withoutit being written to the server. As mentioned,verifying that theassumptionsentry has not been made invalid by a directory change operation performed by another client. When a client is not making changes to a directory for which there exist name cache entries, the clientareneeds to periodically fetch attributes for that directory to ensure that it is not being modified. After determining that nolonger valid atmodification has occurred, thepoint whenexpiration time for the associated name cache entries may be updated to be the current time plus the name cache staleness bound. When alock or delegation has been revoked. For example, anotherclientmayis making changes to a given directory, it needs to determine whether there have beengranted a conflicting lockchanges made to the directory by other clients. It does this by using the change attribute as reported before and after therevocation ofdirectory operation in thelock atassociated change_info4 value returned for thefirst client. Therefore,operation. The server is able to communicate to the client whether the change_info4 datawithinis provided atomically with respect to thelock range may have been modified bydirectory operation. If theother client. Obviously,change values are provided atomically, thefirstclient isunable to guaranteethen able to compare theapplication what has occurred topre-operation change value with thefilechange value in thecase of revocation. Notification to a lock owner will in many cases consist of simply returning an error onclient's name cache. If thenext and all subsequent READs/WRITEs tocomparison indicates that theopen file or ondirectory was updated by another client, theclose. Wherename cache associated with themethods available to a client make such notification impossible because errors for certain operations may not be returned, more drastic action such as signals or process termination may be appropriate. The justification for thismodified directory isthat an invariant for which an application depends on maypurged from the client. If the comparison indicates no modification, the name cache can beviolated. Dependingupdated onhow errors are typically treated forthe clientoperating environment, further levels of notification including logging, console messages,to reflect the directory operation andGUI pop-ups maythe associated timeout extended. The post-operation change value needs to beappropriate. 10.5.1. Revocation Recovery for Write Open Delegation Revocation recoverysaved as the basis fora OPEN_DELEGATE_WRITE delegation posesfuture change_info4 comparisons. As demonstrated by thespecial issue of modified data inscenario above, name caching requires that the client revalidate name cachewhiledata by inspecting thefilechange attribute of a directory at the point when the name cache item was cached. This requires that the server update the change attribute for directories when the contents of the corresponding directory isnot open. In this situation, anymodified. For a clientwhich does not flush modified datato use the change_info4 information appropriately and correctly, the serveron each closemustensure thatreport theuser receives appropriate notification ofpre and post operation change attribute values atomically. When thefailure as a result ofserver is unable to report therevocation. Since such situations may require human actionbefore and after values atomically with respect tocorrect problems, notification schemesthe directory operation, the server must indicate that fact inwhichtheappropriate user or administrator is notified may be necessary. Logging and console messages are typical examples. If therechange_info4 return value. When the information ismodified data onnot atomically reported, theclient, it mustclient should not assume that other clients have not changed the directory. 10.9. Directory Caching The results of READDIR operations may beflushed normallyused to avoid subsequent READDIR operations. Just as in theserver. A clientcases of attribute and name caching, inconsistencies mayattempt to provide a copyarise among the various client caches. To mitigate the effects of these inconsistencies, and given the context of typical filedata as modified duringsystem APIs, thedelegation underfollowing rules should be followed: o Cached READDIR information for adifferent namedirectory which is not obtained in a single READDIR operation must always be a consistent snapshot of directory contents. This is determined by using a GETATTR before thefilesystem name space to ease recovery. Note that whenfirst READDIR and after theclient can determinelast of READDIR that contributes to thefile has not been modified by any other client, or whencache. o An upper time boundary is maintained to indicate theclient haslength of time acompletedirectory cache entry is considered valid before the client must revalidate the cachedcopyinformation. The revalidation technique parallels that discussed in the case offilename caching. When the client is not changing the directory in question,such a saved copychecking the change attribute of theclient's viewdirectory with GETATTR is adequate. The lifetime of thefile maycache entry can beof particular value for recovery. In other case, recovery usingextended at these checkpoints. When acopy of the file based partially onclient is modifying theclient's cached data and partially on the server copy as modified by other clients, will be anything but straightforward, so clients may avoid saving file contents in these situations or mark the results specially to warn users of possible problems. Saving of such modified data in delegation revocation situations may be limited to files of a certain size or might be used only when sufficient disk space is available within the target filesystem. Such saving may also be restricted to situations whendirectory, the clienthas sufficient buffering resourcesneeds tokeepuse thecached copy available until it is properly storedchange_info4 data tothe target filesystem. 10.6. Attribute Caching The attributes discussed in this section do not include named attributes. Individual named attributesdetermine whether there areanalogous to files and caching ofother clients modifying thedata for these needs to be handled just as data cachingdirectory. If it isfor regular files. Similarly, LOOKUP results from an OPENATTR directorydetermined that no other client modifications areto be cached onoccurring, thesame basis as any other pathnames and similarly for directory contents. Clientsclient may update its directory cachefile attributes obtained from the server and use themtoavoid subsequent GETATTR requests. Suchreflect its own changes. As demonstrated previously, directory cachingis write through inrequires thatmodification to file attributes is always done by means of requests totheserver and should not be done locally and cached. The exception to this are modifications to attributes that are intimately connected withclient revalidate directory cache datacaching. Therefore, extending a filebywriting data to the local data cache is reflected immediately in the size as seen oninspecting theclient without thischangebeing immediately reflected onattribute of a directory at theserver. Normally such changes are not propagated directly topoint when the directory was cached. This requires that the serverbutupdate the change attribute for directories when themodified datacontents of the corresponding directory isflushedmodified. For a client to use theserver, analogous attribute changes are made onchange_info4 information appropriately and correctly, theserver.server must report the pre and post operation change attribute values atomically. Whenopen delegationthe server isin effect,unable to report themodified attributes may be returnedbefore and after values atomically with respect to the directory operation, the server must indicate that fact in theresponse to a CB_GETATTR call. The result of local caching of attributes is thatchange_info4 return value. When theattribute caches maintained on individual clients willinformation is notbe coherent. Changes made in one order onatomically reported, theserver may be seen in a different order on oneclientand in a third order on a different client. The typical filesystem application programming interfaces doshould notprovide means to atomically modify or interrogate attributes for multiple files at the same time. The following rules provide an environment whereassume that other clients have not changed thepotential incoherency mentioned above can be reasonably managed. These rules are derived fromdirectory. 11. Minor Versioning To address thepracticerequirement ofpreviousan NFSprotocols. o All attributes for a given file (per-fsid attributes excepted) are cached as a unit at the client soprotocol thatno non-serializabilitycanarise withinevolve as thecontext of a single file. o An upper time boundary is maintained on how long a client cache entry can be kept without being refreshed from the server. o When operations are performed that change attributes atneed arises, theserver,NFSv4 protocol contains theupdated attribute setrules and framework to allow for future minor changes or versioning. The base assumption with respect to minor versioning isrequested as partthat any future accepted minor version must follow the IETF process and be documented in a standards track RFC. Therefore, each minor version number will correspond to an RFC. Minor version 0 of thecontaining RPC. This includes directory operations that update attributes indirectly. ThisNFS version 4 protocol isaccomplishedrepresented byfollowing the modifying operation with a GETATTR operationthis RFC. The COMPOUND andthen usingCB_COMPOUND procedures support theresultsencoding of theGETATTR to update the client's cached attributes. Note that if the full set of attributes to be cached isminor version being requested byREADDIR,theresults can be cached byclient. The following items represent theclient onbasic rules for thesame basis as attributes obtained via GETATTR. A client may validate its cached versiondevelopment ofattributes forminor versions. Note that afile by fetching just bothfuture minor version may decide to modify or add to thechange and time_access attributes and assuming that iffollowing rules as part of thechange attribute hasminor version definition. 1. Procedures are not added or deleted To maintain thesame value as it did whengeneral RPC model, NFSv4 minor versions will not add to or delete procedures from theattributes were cached, then no attributes other than time_access have changed.NFS program. 2. Minor versions may add operations to the COMPOUND and CB_COMPOUND procedures. Thereason why time_access is also fetched is because many servers operate in environments whereaddition of operations to theoperation that updates changeCOMPOUND and CB_COMPOUND procedures does notupdate time_access. For example, POSIX file semantics do not update access time when a file is modified byaffect thewrite system call. Therefore,RPC model. 1. Minor versions may append attributes to theclientbitmap4 thatwants a current time_access value should fetch it with change during the attribute cache validation processing and update its cached time_access. The client may maintain a cacherepresents sets ofmodified attributes for thoseattributesintimately connected with data of modified regular files (size, time_modify,andchange). Other than those three attributes,to theclient MUST NOT maintain a cachefattr4 that represents sets ofmodified attributes. Instead,attributechanges are immediately sent tovalues. This allows for theserver. In some operating environments,expansion of theequivalent to time_access is expectedattribute model tobe implicitly updated by each readallow for future growth or adaptation. 2. Minor version X must append any new attributes after the last documented attribute. Since attribute results are specified as an opaque array of per-attribute XDR encoded results, thecontentcomplexity of adding new attributes in thefile object. Ifmidst of the current definitions would be too burdensome. 3. Minor versions must not modify the structure of anNFS client is cachingexisting operation's arguments or results. Again, thecontentcomplexity of handling multiple structure definitions for afile object, whether itsingle operation isa regular file, directory, or symbolic link, the client SHOULD NOT update the time_access attribute (via SETATTR or a small READ or READDIR request) on the server with each read that is satisfied from cache. The reason is that this can defeat the performance benefits of caching content, especially since an explicit SETATTR of time_access may alter the change attribute on the server. If the change attribute changes, clients that are caching the content will think the content has changed, and will re-read unmodified data from the server. Nor is the client encouraged to maintain a modified version of time_access in its cache, since this would mean that the client will either eventually have to write the access time to the server with bad performance effects, or it would never update the server's time_access, thereby resulting in a situation where an application that caches access time between a close and open of the same file observes the access time oscillating between the past and present. The time_access attribute always means the time of last access to a file by a read that was satisfied by the server. This way clients will tend to see only time_access changes that go forward in time. 10.7. Data and Metadata Caching and Memory Mapped Files Some operating environments include the capability for an application to map a file's content into the application's address space. Each time the application accesses a memory location that corresponds to a block that has not been loaded into the address space, a page fault occurs and the file is read (or if the block does not exist in the file, the block is allocated and then instantiated in the application's address space). As long as each memory mapped access to the file requires a page fault, the relevant attributes of the file that are used to detect access and modification (time_access, time_metadata, time_modify, and change) will be updated. However, in many operating environments, when page faults are not required these attributes will not be updated on reads or updates to the file via memory access (regardless whether the file is local file or is being access remotely). A client or server MAY fail to update attributes of a file that is being accessed via memory mapped I/O. This has several implications: o If there is an application on the server that has memory mapped a file that a client is also accessing, the client may not be able to get a consistent value of the change attribute to determine whether its cache is stale or not. A server that knows that the file is memory mapped could always pessimistically return updated values for change so as to force the application to always get the most up to date data and metadata for the file. However, due to the negative performance implications of this, such behavior is OPTIONAL. o If the memory mapped file is not being modified on the server, and instead is just being read by an application via the memory mapped interface, the client will not see an updated time_access attribute. However, in many operating environments, neither will any process running on the server. Thus NFS clients are at no disadvantage with respect to local processes. o If there is another client that is memory mapping the file, and if that client is holding a OPEN_DELEGATE_WRITE delegation, the same set of issues as discussed in the previous two bullet items apply. So, when a server does a CB_GETATTR to a file that the client has modified in its cache, the response from CB_GETATTR will not necessarily be accurate. As discussed earlier, the client's obligation is to report that the file has been modified since the delegation was granted, not whether it has been modified again between successive CB_GETATTR calls, and the server MUST assume that any file the client has modified in cache has been modified again between successive CB_GETATTR calls. Depending on the nature of the client's memory management system, this weak obligation may not be possible. A client MAY return stale information in CB_GETATTR whenever the file is memory mapped. o The mixture of memory mapping and file locking on the same file is problematic. Consider the following scenario, where the page size on each client is 8192 bytes. * Client A memory maps first page (8192 bytes) of file X * Client B memory maps first page (8192 bytes) of file X * Client A write locks first 4096 bytes * Client B write locks second 4096 bytes * Client A, via a STORE instruction modifies part of its locked region. * Simultaneous to client A, client B issues a STORE on part of its locked region. Here the challenge is for each client to resynchronize to get a correct view of the first page. In many operating environments, the virtual memory management systems on each client only know a page is modified, not that a subset of the page corresponding to the respective lock regions has been modified. So it is not possible for each client to do the right thing, which is to only write to the server that portion of the page that is locked. For example, if client A simply writes out the page, and then client B writes out the page, client A's data is lost. Moreover, if mandatory locking is enabled on the file, then we have a different problem. When clients A and B issue the STORE instructions, the resulting page faults require a byte-range lock on the entire page. Each client then tries to extend their locked range to the entire page, which results in a deadlock. Communicating the NFS4ERR_DEADLOCK error to a STORE instruction is difficult at best. If a client is locking the entire memory mapped file, there is no problem with advisory or mandatory byte-range locking, at least until the client unlocks a region in the middle of the file. Given the above issues the following are permitted: o Clients and servers MAY deny memory mapping a file they know there are byte-range locks for. o Clients and servers MAY deny a byte-range lock on a file they know is memory mapped. o A client MAY deny memory mapping a file that it knows requires mandatory locking for I/O. If mandatory locking is enabled after the file is opened and mapped, the client MAY deny the application further access to its mapped file. 10.8. Name Caching The results of LOOKUP and READDIR operations may be cached to avoid the cost of subsequent LOOKUP operations. Just as in the case of attribute caching, inconsistencies may arise among the various client caches. To mitigate the effects of these inconsistencies and given the context of typical filesystem APIs, an upper time boundary is maintained on how long a client name cache entry can be kept without verifying that the entry has not been made invalid by a directory change operation performed by another client. When a client is not making changes to a directory for which there exist name cache entries, the client needs to periodically fetch attributes for that directory to ensure that it is not being modified. After determining that no modification has occurred, the expiration time for the associated name cache entries may be updated to be the current time plus the name cache staleness bound. When a client is making changes to a given directory, it needs to determine whether there have been changes made to the directory by other clients. It does this by using the change attribute as reported before and after the directory operation in the associated change_info4 value returned for the operation. The server is able to communicate to the client whether the change_info4 data is provided atomically with respect to the directory operation. If the change values are provided atomically, the client is then able to compare the pre-operation change value with the change value in the client's name cache. If the comparison indicates that the directory was updated by another client, the name cache associated with the modified directory is purged from the client. If the comparison indicates no modification, the name cache can be updated on the client