idnits 2.17.1 draft-ietf-nfsv4-scsi-layout-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (December 03, 2015) is 3067 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Possible downref: Non-RFC (?) normative reference: ref. 'LEGAL' ** Obsolete normative reference: RFC 5661 (Obsoleted by RFC 8881) -- Possible downref: Non-RFC (?) normative reference: ref. 'SAM-4' -- Possible downref: Non-RFC (?) normative reference: ref. 'SAS3' -- Possible downref: Non-RFC (?) normative reference: ref. 'SBC3' -- Possible downref: Non-RFC (?) normative reference: ref. 'SPC4' Summary: 1 error (**), 0 flaws (~~), 1 warning (==), 7 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 NFSv4 C. Hellwig 3 Internet-Draft December 03, 2015 4 Intended status: Standards Track 5 Expires: June 5, 2016 7 Parallel NFS (pNFS) SCSI Layout 8 draft-ietf-nfsv4-scsi-layout-05.txt 10 Abstract 12 The Parallel Network File System (pNFS) allows a separation between 13 the metadata (onto a metadata server) and data (onto a storage 14 device) for a file. The SCSI Layout Type is defined in this document 15 as an extension to pNFS to allow the use SCSI based block storage 16 devices. 18 Status of this Memo 20 This Internet-Draft is submitted in full conformance with the 21 provisions of BCP 78 and BCP 79. 23 Internet-Drafts are working documents of the Internet Engineering 24 Task Force (IETF). Note that other groups may also distribute 25 working documents as Internet-Drafts. The list of current Internet- 26 Drafts is at http://datatracker.ietf.org/drafts/current/. 28 Internet-Drafts are draft documents valid for a maximum of six months 29 and may be updated, replaced, or obsoleted by other documents at any 30 time. It is inappropriate to use Internet-Drafts as reference 31 material or to cite them other than as "work in progress." 33 This Internet-Draft will expire on June 5, 2016. 35 Copyright Notice 37 Copyright (c) 2015 IETF Trust and the persons identified as the 38 document authors. All rights reserved. 40 This document is subject to BCP 78 and the IETF Trust's Legal 41 Provisions Relating to IETF Documents 42 (http://trustee.ietf.org/license-info) in effect on the date of 43 publication of this document. Please review these documents 44 carefully, as they describe your rights and restrictions with respect 45 to this document. Code Components extracted from this document must 46 include Simplified BSD License text as described in Section 4.e of 47 the Trust Legal Provisions and are provided without warranty as 48 described in the Simplified BSD License. 50 Table of Contents 52 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 53 1.1. Conventions Used in This Document . . . . . . . . . . . . 4 54 1.2. General Definitions . . . . . . . . . . . . . . . . . . . 4 55 1.3. Code Components Licensing Notice . . . . . . . . . . . . . 4 56 1.4. XDR Description . . . . . . . . . . . . . . . . . . . . . 4 57 2. SCSI Layout Description . . . . . . . . . . . . . . . . . . . 6 58 2.1. Background and Architecture . . . . . . . . . . . . . . . 6 59 2.2. layouttype4 . . . . . . . . . . . . . . . . . . . . . . . 7 60 2.3. GETDEVICEINFO . . . . . . . . . . . . . . . . . . . . . . 8 61 2.3.1. Volume Identification . . . . . . . . . . . . . . . . 8 62 2.3.2. Volume Topology . . . . . . . . . . . . . . . . . . . 9 63 2.4. Data Structures: Extents and Extent Lists . . . . . . . . 12 64 2.4.1. Layout Requests and Extent Lists . . . . . . . . . . . 14 65 2.4.2. Layout Commits . . . . . . . . . . . . . . . . . . . . 15 66 2.4.3. Layout Returns . . . . . . . . . . . . . . . . . . . . 16 67 2.4.4. Layout Revocation . . . . . . . . . . . . . . . . . . 16 68 2.4.5. Client Copy-on-Write Processing . . . . . . . . . . . 17 69 2.4.6. Extents are Permissions . . . . . . . . . . . . . . . 18 70 2.4.7. Partial-Bock Updates . . . . . . . . . . . . . . . . . 19 71 2.4.8. End-of-file Processing . . . . . . . . . . . . . . . . 19 72 2.4.9. Layout Hints . . . . . . . . . . . . . . . . . . . . . 20 73 2.4.10. Client Fencing . . . . . . . . . . . . . . . . . . . . 20 74 2.5. Crash Recovery Issues . . . . . . . . . . . . . . . . . . 22 75 2.6. Recalling Resources: CB_RECALL_ANY . . . . . . . . . . . . 22 76 2.7. Transient and Permanent Errors . . . . . . . . . . . . . . 23 77 2.8. Volatile write caches . . . . . . . . . . . . . . . . . . 23 78 3. Enforcing NFSv4 Semantics . . . . . . . . . . . . . . . . . . 24 79 3.1. Use of Open Stateids . . . . . . . . . . . . . . . . . . . 24 80 3.2. Enforcing Security Restrictions . . . . . . . . . . . . . 25 81 3.3. Enforcing Locking Restrictions . . . . . . . . . . . . . . 25 82 4. Security Considerations . . . . . . . . . . . . . . . . . . . 26 83 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 27 84 6. Normative References . . . . . . . . . . . . . . . . . . . . . 27 85 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 28 86 Appendix B. RFC Editor Notes . . . . . . . . . . . . . . . . . . 28 87 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 28 89 1. Introduction 91 Figure 1 shows the overall architecture of a Parallel NFS (pNFS) 92 system: 94 +-----------+ 95 |+-----------+ +-----------+ 96 ||+-----------+ | | 97 ||| | NFSv4.1 + pNFS | | 98 +|| Clients |<------------------------------>| Server | 99 +| | | | 100 +-----------+ | | 101 ||| +-----------+ 102 ||| | 103 ||| | 104 ||| Storage +-----------+ | 105 ||| Protocol |+-----------+ | 106 ||+----------------||+-----------+ Control | 107 |+-----------------||| | Protocol| 108 +------------------+|| Storage |------------+ 109 +| Systems | 110 +-----------+ 112 Figure 1 114 The overall approach is that pNFS-enhanced clients obtain sufficient 115 information from the server to enable them to access the underlying 116 storage (on the storage systems) directly. See the Section 12 of 117 [RFC5661] for more details. This document is concerned with access 118 from pNFS clients to storage devices over block storage protocols 119 based on the the SCSI Architecture Model ([SAM-4]), e.g., Fibre 120 Channel Protocol (FCP) for Fibre Channel, Internet SCSI (iSCSI) or 121 Serial Attached SCSI (SAS). pNFS SCSI layout requires block based 122 SCSI command sets, for example SCSI Block Commands ([SBC3]). While 123 SCSI command set for non-block based access exist these are not 124 supported by the SCSI layout type, and all future references to SCSI 125 storage devices will imply a block based SCSI command set. 127 The Server to Storage System protocol, called the "Control Protocol", 128 is not of concern for interoperability, although it will typically be 129 the same SCSI based storage protocol. 131 This document is based on [RFC5663] and makes changes to the block 132 layout type to provide a better pNFS layout protocol for SCSI based 133 storage devices. Despite these changes, [RFC5663] remains the 134 defining document for the existing block layout type. [RFC6688] is 135 unnecessary in the context of the SCSI layout type because the new 136 layout type provides mandatory disk access protection as part of the 137 layout type definition. In contrast to [RFC5663], this document uses 138 SCSI protocol features to provide reliable fencing by using SCSI 139 Persistent Reservations, and it can provide reliable and efficient 140 device discovery by using SCSI device identifiers instead of having 141 to rely on probing all devices potentially attached to a client for a 142 signature. This new layout type also optimizes the I/O path by 143 reducing the size of the LAYOUTCOMMIT payload 145 1.1. Conventions Used in This Document 147 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 148 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 149 document are to be interpreted as described in [RFC2119]. 151 1.2. General Definitions 153 The following definitions are provided for the purpose of providing 154 an appropriate context for the reader. 156 Byte This document defines a byte as an octet, i.e., a datum exactly 157 8 bits in length. 159 Client The "client" is the entity that accesses the NFS server's 160 resources. The client may be an application that contains the 161 logic to access the NFS server directly. The client may also be 162 the traditional operating system client that provides remote file 163 system services for a set of applications. 165 Server The "server" is the entity responsible for coordinating 166 client access to a set of file systems and is identified by a 167 server owner. 169 1.3. Code Components Licensing Notice 171 The external data representation (XDR) description and scripts for 172 extracting the XDR description are Code Components as described in 173 Section 4 of "Legal Provisions Relating to IETF Documents" [LEGAL]. 174 These Code Components are licensed according to the terms of Section 175 4 of "Legal Provisions Relating to IETF Documents". 177 1.4. XDR Description 179 This document contains the XDR [RFC4506] description of the NFSv4.1 180 SCSI layout protocol. The XDR description is embedded in this 181 document in a way that makes it simple for the reader to extract into 182 a ready-to-compile form. The reader can feed this document into the 183 following shell script to produce the machine readable XDR 184 description of the NFSv4.1 SCSI layout: 186 #!/bin/sh 187 grep '^ *///' $* | sed 's?^ */// ??' | sed 's?^ *///$??' 189 That is, if the above script is stored in a file called "extract.sh", 190 and this document is in a file called "spec.txt", then the reader can 191 do: 193 sh extract.sh < spec.txt > scsi_prot.x 195 The effect of the script is to remove leading white space from each 196 line, plus a sentinel sequence of "///". 198 The embedded XDR file header follows. Subsequent XDR descriptions, 199 with the sentinel sequence are embedded throughout the document. 201 Note that the XDR code contained in this document depends on types 202 from the NFSv4.1 nfs4_prot.x file [RFC5662]. This includes both nfs 203 types that end with a 4, such as offset4, length4, etc., as well as 204 more generic types such as uint32_t and uint64_t. 206 /// /* 207 /// * This code was derived from RFCTBD10 208 /// * Please reproduce this note if possible. 209 /// */ 210 /// /* 211 /// * Copyright (c) 2010,2015 IETF Trust and the persons 212 /// * identified as the document authors. All rights reserved. 213 /// * 214 /// * Redistribution and use in source and binary forms, with 215 /// * or without modification, are permitted provided that the 216 /// * following conditions are met: 217 /// * 218 /// * - Redistributions of source code must retain the above 219 /// * copyright notice, this list of conditions and the 220 /// * following disclaimer. 221 /// * 222 /// * - Redistributions in binary form must reproduce the above 223 /// * copyright notice, this list of conditions and the 224 /// * following disclaimer in the documentation and/or other 225 /// * materials provided with the distribution. 226 /// * 227 /// * - Neither the name of Internet Society, IETF or IETF 228 /// * Trust, nor the names of specific contributors, may be 229 /// * used to endorse or promote products derived from this 230 /// * software without specific prior written permission. 231 /// * 232 /// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 233 /// * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 234 /// * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 235 /// * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 236 /// * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 237 /// * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 238 /// * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 239 /// * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 240 /// * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 241 /// * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 242 /// * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 243 /// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 244 /// * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 245 /// * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 246 /// * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 247 /// */ 248 /// 249 /// /* 250 /// * nfs4_scsi_layout_prot.x 251 /// */ 252 /// 253 /// %#include "nfsv41.h" 254 /// 256 2. SCSI Layout Description 258 2.1. Background and Architecture 260 The fundamental storage model supported by SCSI storage devices is a 261 Logical Unit (LU) consisting of a sequential series of fixed-size 262 blocks. Logical units used as devices for NFS scsi layouts, and the 263 SCSI initiators used for the pNFS Metadata Server and clients MUST 264 support SCSI persistent reservations. 266 A pNFS layout for this SCSI class of storage is responsible for 267 mapping from an NFS file (or portion of a file) to the blocks of 268 storage volumes that contain the file. The blocks are expressed as 269 extents with 64-bit offsets and lengths using the existing NFSv4 270 offset4 and length4 types. Clients MUST be able to perform I/O to 271 the block extents without affecting additional areas of storage 272 (especially important for writes); therefore, extents MUST be aligned 273 to 512-byte boundaries. 275 The pNFS operation for requesting a layout (LAYOUTGET) includes the 276 "layoutiomode4 loga_iomode" argument, which indicates whether the 277 requested layout is for read-only use or read-write use. A read-only 278 layout may contain holes that are read as zero, whereas a read-write 279 layout will contain allocated, but un-initialized storage in those 280 holes (read as zero, can be written by client). This document also 281 supports client participation in copy-on-write (e.g., for file 282 systems with snapshots) by providing both read-only and un- 283 initialized storage for the same range in a layout. Reads are 284 initially performed on the read-only storage, with writes going to 285 the un-initialized storage. After the first write that initializes 286 the un-initialized storage, all reads are performed to that now- 287 initialized writable storage, and the corresponding read-only storage 288 is no longer used. 290 The SCSI layout solution expands the security responsibilities of the 291 pNFS clients, and there are a number of environments where the 292 mandatory to implement security properties for NFS cannot be 293 satisfied. The additional security responsibilities of the client 294 follow, and a full discussion is present in Section 4, "Security 295 Considerations". 297 o Typically, SCSI storage devices provide access control mechanisms 298 (e.g., Logical Unit Number (LUN) mapping and/or masking), which 299 operate at the granularity of individual hosts, not individual 300 blocks. For this reason, block-based protection must be provided 301 by the client software. 303 o Similarly, SCSI storage devices typically are not able to validate 304 NFS locks that apply to file regions. For instance, if a file is 305 covered by a mandatory read-only lock, the server can ensure that 306 only readable layouts for the file are granted to pNFS clients. 307 However, it is up to each pNFS client to ensure that the readable 308 layout is used only to service read requests, and not to allow 309 writes to the existing parts of the file. 311 Since SCSI storage devices are generally not capable of enforcing 312 such file-based security, in environments where pNFS clients cannot 313 be trusted to enforce such policies, pNFS SCSI layouts SHOULD NOT be 314 used. 316 2.2. layouttype4 318 The layout4 type defined in [RFC5662] is extended with a new value as 319 follows: 321 enum layouttype4 { 322 LAYOUT4_NFSV4_1_FILES = 1, 323 LAYOUT4_OSD2_OBJECTS = 2, 324 LAYOUT4_BLOCK_VOLUME = 3, 325 LAYOUT4_SCSI = 0x80000005 326 [[RFC Editor: please modify the LAYOUT4_SCSI 327 to be the layouttype assigned by IANA]] 328 }; 330 This document defines structure associated with the layouttype4 value 331 LAYOUT4_SCSI. [RFC5661] specifies the loc_body structure as an XDR 332 type "opaque". The opaque layout is uninterpreted by the generic 333 pNFS client layers, but obviously must be interpreted by the Layout 334 Type implementation. 336 2.3. GETDEVICEINFO 338 2.3.1. Volume Identification 340 SCSI targets implementing [SPC4] export unique LU names for each LU 341 through the Device Identification VPD page (page code 0x83), which 342 can be obtained using the INQUIRY command with the EVPD bit set to 343 one. This document uses a subset of this information to identify LUs 344 backing pNFS SCSI layouts. It is similar to the "Identification 345 Descriptor Target Descriptor" specified in [SPC4], but limits the 346 allowed values to those that uniquely identify a LU. Device 347 Identification VPD page descriptors used to identify LUs for use with 348 pNFS SCSI layouts must adhere to the following restrictions: 350 1. The "ASSOCIATION" MUST be set to 0 (The DESIGNATOR field is 351 associated with the addressed logical unit). 353 2. The "DESIGNATOR TYPE" MUST be set to one of four values that are 354 required for the mandatory logical unit name in [SPC4], as 355 explicitly listed in the "pnfs_scsi_designator_type" enumeration: 357 PS_DESIGNATOR_T10 T10 vendor ID based 359 PS_DESIGNATOR_EUI64 EUI-64-based 361 PS_DESIGNATOR_NAA NAA 363 PS_DESIGNATOR_NAME SCSI name string 365 Any other association or designator type MUST NOT be used. Use 366 of T10 vendor IDs is discouraged when one of the other types can 367 be used. 369 The "CODE SET" VPD page field is stored in the "sbv_code_set" field 370 of the "pnfs_scsi_base_volume_info4" structure, the "DESIGNATOR TYPE" 371 is stored in "sbv_designator_type", and the DESIGNATOR is stored in 372 "sbv_designator". Due to the use of a XDR array the "DESIGNATOR 373 LENGTH" field does not need to be set separately. Only certain 374 combinations of "sbv_code_set" and "sbv_designator_type" are valid, 375 please refer to [SPC4] for details, and note that ASCII may be used 376 as the code set for UTF-8 text that contains only printable ASCII 377 characters. Note that a Device Identification VPD page MAY contain 378 multiple descriptors with the same association, code set and 379 designator type. NFS clients thus MUST check all the descriptors for 380 a possible match to "sbv_code_set", "sbv_designator_type" and 381 "sbv_designator". 383 Storage devices such as storage arrays can have multiple physical 384 network ports that need not be connected to a common network, 385 resulting in a pNFS client having simultaneous multipath access to 386 the same storage volumes via different ports on different networks. 387 Selection of one or multiple ports to access the storage device is 388 left up to the client. 390 Additionally the server returns a Persistent Reservation key in the 391 "sbv_pr_key" field. See Section 2.4.10 for more details on the use 392 of Persistent Reservations. 394 2.3.2. Volume Topology 396 The pNFS SCSI layout volume topology is expressed as an arbitrary 397 combination of base volume types enumerated in the following data 398 structures. The individual components of the topology are contained 399 in an array and components may refer to other components by using 400 array indices. 402 /// enum pnfs_scsi_volume_type4 { 403 /// PNFS_SCSI_VOLUME_SLICE = 1, /* volume is a slice of 404 /// another volume */ 405 /// PNFS_SCSI_VOLUME_CONCAT = 2, /* volume is a 406 /// concatenation of 407 /// multiple volumes */ 408 /// PNFS_SCSI_VOLUME_STRIPE = 3 /* volume is striped across 409 /// multiple volumes */ 410 /// PNFS_SCSI_VOLUME_BASE = 4, /* volume maps to a single 411 /// LU */ 412 /// }; 413 /// 414 /// /* 415 /// * Code sets from SPC-3. 416 /// */ 417 /// enum pnfs_scsi_code_set { 418 /// PS_CODE_SET_BINARY = 1, 419 /// PS_CODE_SET_ASCII = 2, 420 /// PS_CODE_SET_UTF8 = 3 421 /// }; 422 /// 423 /// /* 424 /// * Designator types from taken from SPC-3. 425 /// * 426 /// * Other values are allocated in SPC-3, but not mandatory to 427 /// * implement or aren't Logical Unit names. 428 /// */ 429 /// enum pnfs_scsi_designator_type { 430 /// PS_DESIGNATOR_T10 = 1, 431 /// PS_DESIGNATOR_EUI64 = 2, 432 /// PS_DESIGNATOR_NAA = 3, 433 /// PS_DESIGNATOR_NAME = 8 434 /// }; 435 /// 436 /// /* 437 /// * Logical Unit name + reservation key. 438 /// */ 439 /// struct pnfs_scsi_base_volume_info4 { 440 /// pnfs_scsi_code_set sbv_code_set; 441 /// pnfs_scsi_designator_type sbv_designator_type; 442 /// opaque sbv_designator<>; 443 /// uint64_t sbv_pr_key; 444 /// }; 445 /// 447 /// struct pnfs_scsi_slice_volume_info4 { 448 /// offset4 ssv_start; /* offset of the start of 449 /// the slice in bytes */ 450 /// length4 ssv_length; /* length of slice in 451 /// bytes */ 452 /// uint32_t ssv_volume; /* array index of sliced 453 /// volume */ 454 /// }; 455 /// 456 /// 457 /// struct pnfs_scsi_concat_volume_info4 { 458 /// uint32_t scv_volumes<>; /* array indices of volumes 459 /// which are concatenated */ 460 /// }; 462 /// 463 /// struct pnfs_scsi_stripe_volume_info4 { 464 /// length4 ssv_stripe_unit; /* size of stripe in bytes */ 465 /// uint32_t ssv_volumes<>; /* array indices of 466 /// volumes which are striped 467 /// across -- MUST be same 468 /// size */ 469 /// }; 471 /// 472 /// union pnfs_scsi_volume4 switch (pnfs_scsi_volume_type4 type) { 473 /// case PNFS_SCSI_VOLUME_BASE: 474 /// pnfs_scsi_base_volume_info4 sv_simple_info; 475 /// case PNFS_SCSI_VOLUME_SLICE: 476 /// pnfs_scsi_slice_volume_info4 sv_slice_info; 477 /// case PNFS_SCSI_VOLUME_CONCAT: 478 /// pnfs_scsi_concat_volume_info4 sv_concat_info; 479 /// case PNFS_SCSI_VOLUME_STRIPE: 480 /// pnfs_scsi_stripe_volume_info4 sv_stripe_info; 481 /// }; 482 /// 484 /// /* SCSI layout-specific type for da_addr_body */ 485 /// struct pnfs_scsi_deviceaddr4 { 486 /// pnfs_scsi_volume4 sda_volumes<>; /* array of volumes */ 487 /// }; 488 /// 490 The "pnfs_scsi_deviceaddr4" data structure is a structure that allows 491 arbitrarily complex nested volume structures to be encoded. The 492 types of aggregations that are allowed are stripes, concatenations, 493 and slices. Note that the volume topology expressed in the 494 pnfs_scsi_deviceaddr4 data structure will always resolve to a set of 495 pnfs_scsi_volume_type4 PNFS_SCSI_VOLUME_BASE. The array of volumes 496 is ordered such that the root of the volume hierarchy is the last 497 element of the array. Concat, slice, and stripe volumes MUST refer 498 to volumes defined by lower indexed elements of the array. 500 The "pnfs_scsi_device_addr4" data structure is returned by the server 501 as the storage-protocol-specific opaque field da_addr_body in the 502 "device_addr4" structure by a successful GETDEVICEINFO operation 503 [RFC5661]. 505 As noted above, all device_addr4 structures eventually resolve to a 506 set of volumes of type PNFS_SCSI_VOLUME_BASE. Complicated volume 507 hierarchies may be composed of dozens of volumes each with several 508 signature components; thus, the device address may require several 509 kilobytes. The client SHOULD be prepared to allocate a large buffer 510 to contain the result. In the case of the server returning 511 NFS4ERR_TOOSMALL, the client SHOULD allocate a buffer of at least 512 gdir_mincount_bytes to contain the expected result and retry the 513 GETDEVICEINFO request. 515 2.4. Data Structures: Extents and Extent Lists 517 A pNFS SCSI layout is a list of extents within a flat array of data 518 blocks in a volume. The details of the volume topology can be 519 determined by using the GETDEVICEINFO operation. The SCSI layout 520 describes the individual block extents on the volume that make up the 521 file. The offsets and length contained in an extent are specified in 522 units of bytes. 524 /// enum pnfs_scsi_extent_state4 { 525 /// PNFS_SCSI_READ_WRITE_DATA = 0, /* the data located by 526 /// this extent is valid 527 /// for reading and 528 /// writing. */ 529 /// PNFS_SCSI_READ_DATA = 1, /* the data located by this 530 /// extent is valid for 531 /// reading only; it may not 532 /// be written. */ 533 /// PNFS_SCSI_INVALID_DATA = 2, /* the location is valid; the 534 /// data is invalid. It is a 535 /// newly (pre-) allocated 536 /// extent. The client MUST 537 /// not read from this 538 /// space */ 539 /// PNFS_SCSI_NONE_DATA = 3 /* the location is invalid. 540 /// It is a hole in the file. 541 /// The client MUST NOT read 542 /// from or write to this 543 /// space */ 544 /// }; 545 /// 546 /// struct pnfs_scsi_extent4 { 547 /// deviceid4 se_vol_id; /* id of the volume on 548 /// which extent of file is 549 /// stored. */ 550 /// offset4 se_file_offset; /* starting byte offset 551 /// in the file */ 552 /// length4 se_length; /* size in bytes of the 553 /// extent */ 554 /// offset4 se_storage_offset; /* starting byte offset 555 /// in the volume */ 556 /// pnfs_scsi_extent_state4 se_state; 557 /// /* state of this extent */ 558 /// }; 559 /// 561 /// /* SCSI layout-specific type for loc_body */ 562 /// struct pnfs_scsi_layout4 { 563 /// pnfs_scsi_extent4 sl_extents<>; 564 /// /* extents which make up this 565 /// layout. */ 566 /// }; 567 /// 569 The SCSI layout consists of a list of extents that map the regions of 570 the file to locations on a volume. The "se_storage_offset" field 571 within each extent identifies a location on the volume specified by 572 the "se_vol_id" field in the extent. The se_vol_id itself is 573 shorthand for the whole topology of the volume on which the file is 574 stored. The client is responsible for translating this volume- 575 relative offset into an offset on the appropriate underlying SCSI LU. 577 Each extent maps a region of the file onto a portion of the specified 578 LU. The se_file_offset, se_length, and se_state fields for an extent 579 returned from the server are valid for all extents. In contrast, the 580 interpretation of the se_storage_offset field depends on the value of 581 se_state as follows (in increasing order): 583 PNFS_SCSI_READ_WRITE_DATA means that se_storage_offset is valid, and 584 points to valid/initialized data that can be read and written. 586 PNFS_SCSI_READ_DATA means that se_storage_offset is valid and points 587 to valid/initialized data that can only be read. Write operations 588 are prohibited; the client may need to request a read-write 589 layout. 591 PNFS_SCSI_INVALID_DATA means that se_storage_offset is valid, but 592 points to invalid un-initialized data. This data must not be read 593 from the disk until it has been initialized. A read request for a 594 PNFS_SCSI_INVALID_DATA extent must fill the user buffer with 595 zeros, unless the extent is covered by a PNFS_SCSI_READ_DATA 596 extent of a copy-on-write file system. Write requests must write 597 whole server-sized blocks to the disk; bytes not initialized by 598 the user must be set to zero. Any write to storage in a 599 PNFS_SCSI_INVALID_DATA extent changes the written portion of the 600 extent to PNFS_SCSI_READ_WRITE_DATA; the pNFS client is 601 responsible for reporting this change via LAYOUTCOMMIT. 603 PNFS_SCSI_NONE_DATA means that se_storage_offset is not valid, and 604 this extent may not be used to satisfy write requests. Read 605 requests may be satisfied by zero-filling as for 606 PNFS_SCSI_INVALID_DATA. PNFS_SCSI_NONE_DATA extents may be 607 returned by requests for readable extents; they are never returned 608 if the request was for a writable extent. 610 An extent list contains all relevant extents in increasing order of 611 the se_file_offset of each extent; any ties are broken by increasing 612 order of the extent state (se_state). 614 2.4.1. Layout Requests and Extent Lists 616 Each request for a layout specifies at least three parameters: file 617 offset, desired size, and minimum size. If the status of a request 618 indicates success, the extent list returned must meet the following 619 criteria: 621 o A request for a readable (but not writable) layout returns only 622 PNFS_SCSI_READ_DATA or PNFS_SCSI_NONE_DATA extents (but not 623 PNFS_SCSI_INVALID_DATA or PNFS_SCSI_READ_WRITE_DATA extents). 625 o A request for a writable layout returns PNFS_SCSI_READ_WRITE_DATA 626 or PNFS_SCSI_INVALID_DATA extents (but not PNFS_SCSI_NONE_DATA 627 extents). It may also return PNFS_SCSI_READ_DATA extents only 628 when the offset ranges in those extents are also covered by 629 PNFS_SCSI_INVALID_DATA extents to permit writes. 631 o The first extent in the list MUST contain the requested starting 632 offset. 634 o The total size of extents within the requested range MUST cover at 635 least the minimum size. One exception is allowed: the total size 636 MAY be smaller if only readable extents were requested and EOF is 637 encountered. 639 o Extents in the extent list MUST be logically contiguous for a 640 read-only layout. For a read-write layout, the set of writable 641 extents (i.e., excluding PNFS_SCSI_READ_DATA extents) MUST be 642 logically contiguous. Every PNFS_SCSI_READ_DATA extent in a read- 643 write layout MUST be covered by one or more PNFS_SCSI_INVALID_DATA 644 extents. This overlap of PNFS_SCSI_READ_DATA and 645 PNFS_SCSI_INVALID_DATA extents is the only permitted extent 646 overlap. 648 o Extents MUST be ordered in the list by starting offset, with 649 PNFS_SCSI_READ_DATA extents preceding PNFS_SCSI_INVALID_DATA 650 extents in the case of equal se_file_offsets. 652 According to [RFC5661], if the minimum requested size, 653 loga_minlength, is zero, this is an indication to the metadata server 654 that the client desires any layout at offset loga_offset or less that 655 the metadata server has "readily available". Given the lack of a 656 clear definition of this phrase, in the context of the SCSI layout 657 type, when loga_minlength is zero, the metadata server SHOULD: 659 o when processing requests for readable layouts, return all such, 660 even if some extents are in the PNFS_SCSI_NONE_DATA state. 662 o when processing requests for writable layouts, return extents 663 which can be returned in the PNFS_SCSI_READ_WRITE_DATA state. 665 2.4.2. Layout Commits 667 /// 668 /// /* SCSI layout-specific type for lou_body */ 669 /// 670 /// struct pnfs_scsi_range4 { 671 /// offset4 sr_file_offset; /* starting byte offset 672 /// in the file */ 673 /// length4 sr_length; /* size in bytes */ 674 /// }; 675 /// 676 /// struct pnfs_scsi_layoutupdate4 { 677 /// pnfs_scsi_range4 slu_commit_list<>; 678 /// /* list of extents which 679 /// * now contain valid data. 680 /// */ 681 /// }; 683 The "pnfs_scsi_layoutupdate4" structure is used by the client as the 684 SCSI layout-specific argument in a LAYOUTCOMMIT operation. The 685 "slu_commit_list" field is a list covering regions of the file layout 686 that were previously in the PNFS_SCSI_INVALID_DATA state, but have 687 been written by the client and should now be considered in the 688 PNFS_SCSI_READ_WRITE_DATA state. The extents in the commit list MUST 689 be disjoint and MUST be sorted by sr_file_offset. Implementors 690 should be aware that a server may be unable to commit regions at a 691 granularity smaller than a file-system block (typically 4 KB or 8 692 KB). As noted above, the block-size that the server uses is 693 available as an NFSv4 attribute, and any extents included in the 694 "slu_commit_list" MUST be aligned to this granularity and have a size 695 that is a multiple of this granularity. Since the block in question 696 is in state PNFS_SCSI_INVALID_DATA, byte ranges not written should be 697 filled with zeros. This applies even if it appears that the area 698 being written is beyond what the client believes to be the end of 699 file. 701 2.4.3. Layout Returns 703 A LAYOUTRETURN operation represents an explicit release of resources 704 by the client. This may be done in response to a CB_LAYOUTRECALL or 705 before any recall, in order to avoid a future CB_LAYOUTRECALL. When 706 the LAYOUTRETURN operation specifies a LAYOUTRETURN4_FILE return 707 type, then the layoutreturn_file4 data structure specifies the region 708 of the file layout that is no longer needed by the client. 710 The LAYOUTRETURN operation is done without any SCSI layout specific 711 data. The opaque "lrf_body" field of the "layoutreturn_file4" data 712 structure MUST have length zero. 714 2.4.4. Layout Revocation 716 Layouts may be unilaterally revoked by the server, due to the 717 client's lease time expiring, or the client failing to return a 718 layout which has been recalled in a timely manner. For the SCSI 719 layout type this is accomplished by fencing off the client from 720 access to storage as described in Section 2.4.10. When this is done, 721 it is necessary that all I/Os issued by the fenced-off client be 722 rejected by the storage This includes any in-flight I/Os that the 723 client issued before the layout was revoked. 725 Note, that the granularity of this operation can only be at the 726 host/LU level. Thus, if one of a client's layouts is unilaterally 727 revoked by the server, it will effectively render useless *all* of 728 the client's layouts for files located on the storage units 729 comprising the volume. This may render useless the client's layouts 730 for files in other file systems. See Section 2.4.10.5 for a 731 discussion of recovery from from fencing. 733 2.4.5. Client Copy-on-Write Processing 735 Copy-on-write is a mechanism used to support file and/or file system 736 snapshots. When writing to unaligned regions, or to regions smaller 737 than a file system block, the writer must copy the portions of the 738 original file data to a new location on disk. This behavior can 739 either be implemented on the client or the server. The paragraphs 740 below describe how a pNFS SCSI layout client implements access to a 741 file that requires copy-on-write semantics. 743 Distinguishing the PNFS_SCSI_READ_WRITE_DATA and PNFS_SCSI_READ_DATA 744 extent types in combination with the allowed overlap of 745 PNFS_SCSI_READ_DATA extents with PNFS_SCSI_INVALID_DATA extents 746 allows copy-on-write processing to be done by pNFS clients. In 747 classic NFS, this operation would be done by the server. Since pNFS 748 enables clients to do direct block access, it is useful for clients 749 to participate in copy-on-write operations. All SCSI pNFS clients 750 MUST support this copy-on-write processing. 752 When a client wishes to write data covered by a PNFS_SCSI_READ_DATA 753 extent, it MUST have requested a writable layout from the server; 754 that layout will contain PNFS_SCSI_INVALID_DATA extents to cover all 755 the data ranges of that layout's PNFS_SCSI_READ_DATA extents. More 756 precisely, for any se_file_offset range covered by one or more 757 PNFS_SCSI_READ_DATA extents in a writable layout, the server MUST 758 include one or more PNFS_SCSI_INVALID_DATA extents in the layout that 759 cover the same se_file_offset range. When performing a write to such 760 an area of a layout, the client MUST effectively copy the data from 761 the PNFS_SCSI_READ_DATA extent for any partial blocks of 762 se_file_offset and range, merge in the changes to be written, and 763 write the result to the PNFS_SCSI_INVALID_DATA extent for the blocks 764 for that se_file_offset and range. That is, if entire blocks of data 765 are to be overwritten by an operation, the corresponding 766 PNFS_SCSI_READ_DATA blocks need not be fetched, but any partial- 767 block writes must be merged with data fetched via PNFS_SCSI_READ_DATA 768 extents before storing the result via PNFS_SCSI_INVALID_DATA extents. 769 For the purposes of this discussion, "entire blocks" and "partial 770 blocks" refer to the server's file-system block size. Storing of 771 data in a PNFS_SCSI_INVALID_DATA extent converts the written portion 772 of the PNFS_SCSI_INVALID_DATA extent to a PNFS_SCSI_READ_WRITE_DATA 773 extent; all subsequent reads MUST be performed from this extent; the 774 corresponding portion of the PNFS_SCSI_READ_DATA extent MUST NOT be 775 used after storing data in a PNFS_SCSI_INVALID_DATA extent. If a 776 client writes only a portion of an extent, the extent may be split at 777 block aligned boundaries. 779 When a client wishes to write data to a PNFS_SCSI_INVALID_DATA extent 780 that is not covered by a PNFS_SCSI_READ_DATA extent, it MUST treat 781 this write identically to a write to a file not involved with copy- 782 on-write semantics. Thus, data must be written in at least block- 783 sized increments, aligned to multiples of block-sized offsets, and 784 unwritten portions of blocks must be zero filled. 786 2.4.6. Extents are Permissions 788 Layout extents returned to pNFS clients grant permission to read or 789 write; PNFS_SCSI_READ_DATA and PNFS_SCSI_NONE_DATA are read-only 790 (PNFS_SCSI_NONE_DATA reads as zeroes), PNFS_SCSI_READ_WRITE_DATA and 791 PNFS_SCSI_INVALID_DATA are read/write, (PNFS_SCSI_INVALID_DATA reads 792 as zeros, any write converts it to PNFS_SCSI_READ_WRITE_DATA). This 793 is the only means a client has of obtaining permission to perform 794 direct I/O to storage devices; a pNFS client MUST NOT perform direct 795 I/O operations that are not permitted by an extent held by the 796 client. Client adherence to this rule places the pNFS server in 797 control of potentially conflicting storage device operations, 798 enabling the server to determine what does conflict and how to avoid 799 conflicts by granting and recalling extents to/from clients. 801 If a client makes a layout request that conflicts with an existing 802 layout delegation, the request will be rejected with the error 803 NFS4ERR_LAYOUTTRYLATER. This client is then expected to retry the 804 request after a short interval. During this interval, the server 805 SHOULD recall the conflicting portion of the layout delegation from 806 the client that currently holds it. This reject-and-retry approach 807 does not prevent client starvation when there is contention for the 808 layout of a particular file. For this reason, a pNFS server SHOULD 809 implement a mechanism to prevent starvation. One possibility is that 810 the server can maintain a queue of rejected layout requests. Each 811 new layout request can be checked to see if it conflicts with a 812 previous rejected request, and if so, the newer request can be 813 rejected. Once the original requesting client retries its request, 814 its entry in the rejected request queue can be cleared, or the entry 815 in the rejected request queue can be removed when it reaches a 816 certain age. 818 NFSv4 supports mandatory locks and share reservations. These are 819 mechanisms that clients can use to restrict the set of I/O operations 820 that are permissible to other clients. Since all I/O operations 821 ultimately arrive at the NFSv4 server for processing, the server is 822 in a position to enforce these restrictions. However, with pNFS 823 layouts, I/Os will be issued from the clients that hold the layouts 824 directly to the storage devices that host the data. These devices 825 have no knowledge of files, mandatory locks, or share reservations, 826 and are not in a position to enforce such restrictions. For this 827 reason the NFSv4 server MUST NOT grant layouts that conflict with 828 mandatory locks or share reservations. Further, if a conflicting 829 mandatory lock request or a conflicting open request arrives at the 830 server, the server MUST recall the part of the layout in conflict 831 with the request before granting the request. 833 2.4.7. Partial-Bock Updates 835 SCSI storage devices do not provide byte granularity access and can 836 only perform read and write operations atomically on a block 837 granularity. WRITES to SCSI storage devices thus require read- 838 modify-write cycles to write data smaller than the block size or 839 which is otherwise not block-aligned. Write operations from multiple 840 clients to the same block can thus lead to data corruption even if 841 the byte range written by the applications does not overlap. When 842 there are multiple clients who wish to access the same block, a pNFS 843 server MUST avoid these conflicts by implementing a concurrency 844 control policy of single writer XOR multiple readers for a given data 845 block. 847 2.4.8. End-of-file Processing 849 The end-of-file location can be changed in two ways: implicitly as 850 the result of a WRITE or LAYOUTCOMMIT beyond the current end-of-file, 851 or explicitly as the result of a SETATTR request. Typically, when a 852 file is truncated by an NFSv4 client via the SETATTR call, the server 853 frees any disk blocks belonging to the file that are beyond the new 854 end-of-file byte, and MUST write zeros to the portion of the new end- 855 of-file block beyond the new end-of-file byte. These actions render 856 any pNFS layouts that refer to the blocks that are freed or written 857 semantically invalid. Therefore, the server MUST recall from clients 858 the portions of any pNFS layouts that refer to blocks that will be 859 freed or written by the server before effecting the file truncation. 860 These recalls may take time to complete; as explained in [RFC5661], 861 if the server cannot respond to the client SETATTR request in a 862 reasonable amount of time, it SHOULD reply to the client with the 863 error NFS4ERR_DELAY. 865 Blocks in the PNFS_SCSI_INVALID_DATA state that lie beyond the new 866 end-of-file block present a special case. The server has reserved 867 these blocks for use by a pNFS client with a writable layout for the 868 file, but the client has yet to commit the blocks, and they are not 869 yet a part of the file mapping on disk. The server MAY free these 870 blocks while processing the SETATTR request. If so, the server MUST 871 recall any layouts from pNFS clients that refer to the blocks before 872 processing the truncate. If the server does not free the 873 PNFS_SCSI_INVALID_DATA blocks while processing the SETATTR request, 874 it need not recall layouts that refer only to the 875 PNFS_SCSI_INVALID_DATA blocks. 877 When a file is extended implicitly by a WRITE or LAYOUTCOMMIT beyond 878 the current end-of-file, or extended explicitly by a SETATTR request, 879 the server need not recall any portions of any pNFS layouts. 881 2.4.9. Layout Hints 883 The layout hint attribute specified in [RFC5661] is not supported by 884 the SCSI layout, and the pNFS server MUST reject setting a layout 885 hint attribute with a loh_type value of LAYOUT4_SCSI_VOLUME during 886 OPEN or SETATTR operations. On a file system only supporting the 887 SCSI layout a server MUST NOT report the layout_hint attribute in the 888 supported_attrs attribute. 890 2.4.10. Client Fencing 892 The pNFS SCSI protocol must handle situations in which a system 893 failure, typically a network connectivity issue, requires the server 894 to unilaterally revoke extents from a client after the client fails 895 to respond to a CB_LAYOUTRECALL request. This is implemented by 896 fencing off a non-responding client from access to the storage 897 device. 899 The pNFS SCSI protocol implements fencing using Persistent 900 Reservations (PRs), similar to the fencing method used by existing 901 shared disk file systems. By placing a PR of type "Exclusive Access 902 - All Registrants" on each SCSI LU exported to pNFS clients the MDS 903 prevents access from any client that does not have an outstanding 904 device device ID that gives the client a reservation key to access 905 the LU, and allows the MDS to revoke access to the logic unit at any 906 time. 908 2.4.10.1. PRs - Key Generation 910 To allow fencing individual systems, each system must use a unique 911 Persistent Reservation key. [SPC4] does not specify a way to 912 generate keys. This document assigns the burden to generate unique 913 keys to the MDS, which must generate a key for itself before 914 exporting a volume, and a key for each client that accesses a scsi 915 layout volumes. Individuals keys for each volume that a client can 916 access are permitted but not required. 918 2.4.10.2. PRs - MDS Registration and Reservation 920 Before returning a PNFS_SCSI_VOLUME_BASE volume to the client, the 921 MDS needs to prepare the volume for fencing using PRs. This is done 922 by registering the reservation generated for the MDS with the device 923 using the "PERSISTENT RESERVE OUT" command with a service action of 924 "REGISTER", followed by a "PERSISTENT RESERVE OUT" command, with a 925 service action of "RESERVE" and the type field set to 8h (Exclusive 926 Access - All Registrants). To make sure all I_T nexuses are 927 registered, the MDS SHOULD set the "All Target Ports" (ALL_TG_PT) bit 928 when registering the key, or otherwise ensure the registration is 929 performed for each initiator port. 931 2.4.10.3. PRs - Client Registration 933 Before performing the first IO to a device returned from a 934 GETDEVICEINFO operation the client will register the registration key 935 returned in sbv_pr_key with the storage device by issuing a 936 "PERSISTENT RESERVE OUT" command with a service action of REGISTER 937 with the "SERVICE ACTION RESERVATION KEY" set to the reservation key 938 returned in sbv_pr_key. To make sure all I_T nexus are registered, 939 the client SHOULD set the "All Target Ports" (ALL_TG_PT) bit when 940 registering the key, or otherwise ensure the registration is 941 performed for each initiator port. 943 When a client stops using a device earlier returned by GETDEVICEINFO 944 it MUST unregister the earlier registered key by issuing a 945 "PERSISTENT RESERVE OUT" command with a service action of "REGISTER" 946 with the "RESERVATION KEY" set to the earlier registered reservation 947 key. 949 2.4.10.4. PRs - Fencing Action 951 In case of a non-responding client the MDS fences the client by 952 issuing a "PERSISTENT RESERVE OUT" command with the service action 953 set to "PREEMPT" or "PREEMPT AND ABORT", the reservation key field 954 set to the server's reservation key, the service action reservation 955 key field set to the reservation key associated with the non- 956 responding client, and the type field set to 8h (Exclusive Access - 957 All Registrants). 959 After the MDS preempts a client, all client I/O to the LU fails. The 960 client should at this point return any layout that refers to the 961 device ID that points to the LU. Note that the client can 962 distinguish I/O errors due to fencing from other errors based on the 963 "RESERVATION CONFLICT" SCSI status. Refer to [SPC4] for details. 965 2.4.10.5. Client Recovery After a Fence Action 967 A client that detects a "RESERVATION CONFLICT" SCSI status (I/O 968 error) on the storage devices MUST commit all layouts that use the 969 storage device through the MDS, return all outstanding layouts for 970 the device, forget the device ID and unregister the reservation key. 971 Future GETDEVICEINFO calls may refer to the storage device again, in 972 which case the client will perform a new registration based on the 973 key provided (via sbv_pr_key) at that time. 975 2.5. Crash Recovery Issues 977 A critical requirement in crash recovery is that both the client and 978 the server know when the other has failed. Additionally, it is 979 required that a client sees a consistent view of data across server 980 restarts. These requirements and a full discussion of crash recovery 981 issues are covered in the "Crash Recovery" section of the NFSv41 982 specification [RFC5661]. This document contains additional crash 983 recovery material specific only to the SCSI layout. 985 When the server crashes while the client holds a writable layout, and 986 the client has written data to blocks covered by the layout, and the 987 blocks are still in the PNFS_SCSI_INVALID_DATA state, the client has 988 two options for recovery. If the data that has been written to these 989 blocks is still cached by the client, the client can simply re-write 990 the data via NFSv4, once the server has come back online. However, 991 if the data is no longer in the client's cache, the client MUST NOT 992 attempt to source the data from the data servers. Instead, it should 993 attempt to commit the blocks in question to the server during the 994 server's recovery grace period, by sending a LAYOUTCOMMIT with the 995 "loca_reclaim" flag set to true. This process is described in detail 996 in Section 18.42.4 of [RFC5661]. 998 2.6. Recalling Resources: CB_RECALL_ANY 1000 The server may decide that it cannot hold all of the state for 1001 layouts without running out of resources. In such a case, it is free 1002 to recall individual layouts using CB_LAYOUTRECALL to reduce the 1003 load, or it may choose to request that the client return any layout. 1005 The NFSv4.1 spec [RFC5661] defines the following types: 1007 const RCA4_TYPE_MASK_BLK_LAYOUT = 4; 1009 struct CB_RECALL_ANY4args { 1010 uint32_t craa_objects_to_keep; 1011 bitmap4 craa_type_mask; 1012 }; 1014 When the server sends a CB_RECALL_ANY request to a client specifying 1015 the RCA4_TYPE_MASK_BLK_LAYOUT bit in craa_type_mask, the client 1016 should immediately respond with NFS4_OK, and then asynchronously 1017 return complete file layouts until the number of files with layouts 1018 cached on the client is less than craa_object_to_keep. 1020 2.7. Transient and Permanent Errors 1022 The server may respond to LAYOUTGET with a variety of error statuses. 1023 These errors can convey transient conditions or more permanent 1024 conditions that are unlikely to be resolved soon. 1026 The error NFS4ERR_RECALLCONFLICT indicates that the server has 1027 recently issued a CB_LAYOUTRECALL to the requesting client, making it 1028 necessary for the client to respond to the recall before processing 1029 the layout request. A client can wait for that recall to be receive 1030 and processe or it can retry as for NFS4ERR_TRYLATER, as described 1031 below. 1033 The error NFS4ERR_TRYLATER is used to indicate that the server cannot 1034 immediately grant the layout to the client. This may be due to 1035 constraints on writable sharing of blocks by multiple clients or to a 1036 conflict with a recallable lock (e.g. a delegation). In either case, 1037 a reasonable approach for the client is to wait several milliseconds 1038 and retry the request. The client SHOULD track the number of 1039 retries, and if forward progress is not made, the client should 1040 abandon the attempt to get a layout and perform READ and WRITE 1041 operations by sending them to the server 1043 The error NFS4ERR_LAYOUTUNAVAILABLE may be returned by the server if 1044 layouts are not supported for the requested file or its containing 1045 file system. The server may also return this error code if the 1046 server is the progress of migrating the file from secondary storage, 1047 there is a conflicting lock that would prevent the layout from being 1048 granted, or for any other reason that causes the server to be unable 1049 to supply the layout. As a result of receiving 1050 NFS4ERR_LAYOUTUNAVAILABLE, the client should abandon the attempt to 1051 get a layout and perform READ and WRITE operations by sending them to 1052 the MDS. It is expected that a client will not cache the file's 1053 layoutunavailable state forever. In particular, when the file is 1054 closed or opened by the client, issuing a new LAYOUTGET is 1055 appropriate. 1057 2.8. Volatile write caches 1059 Many storage devices implement volatile write caches that require an 1060 explicit flush to persist the data from write operations to stable 1061 storage. Storage devices implementing [SBC3] should indicate a 1062 volatile write cache by setting the WCE bit to 1 in the Caching mode 1063 page. When a volatile write cache is used, the pNFS server must 1064 ensure the volatile write cache has been committed to stable storage 1065 before the LAYOUTCOMMIT operation returns by using one of the 1066 SYNCHRONIZE CACHE commands. 1068 3. Enforcing NFSv4 Semantics 1070 The functionality provided by SCSI Persistent Reservations makes it 1071 possible for the MDS to control access by individual client machines 1072 to specific LUs. Individual client machines may be allowed to or 1073 prevented from reading or writing to certain block devices. Finer- 1074 grained access control methods are not generally available. 1076 For this reason, certain responsibilities for enforcing NFSv4 1077 semantics, including security and locking, are delegated to pNFS 1078 clients when SCSI layouts are being used. The metadata server's role 1079 is to only grant layouts appropriately and the pNFS clients have to 1080 be trusted to only perform accesses allowed by the layout extents 1081 they currently hold (e.g., and not access storage for files on which 1082 a layout extent is not held). In general, the server will not be 1083 able to prevent a client that holds a layout for a file from 1084 accessing parts of the physical disk not covered by the layout. 1085 Similarly, the server will not be able to prevent a client from 1086 accessing blocks covered by a layout that it has already returned. 1087 The pNFS client must respect the layout model for this mapping type 1088 to appropriately respect NFSv4 semantics. 1090 Furthermore, there is no way for the storage to determine the 1091 specific NFSv4 entity (principal, openowner, lockowner) on whose 1092 behalf the IO operation is being done. This fact may limit the 1093 functionality to be supported and require the pNFS client to 1094 implement server policies other than those describable by layouts. 1095 In cases in which layouts previously granted become invalid, the 1096 server has the option of recalling them. In situations in which 1097 communication difficulties prevent this from happening, layouts may 1098 be revoked by the server. This revocation is accompanied by changes 1099 in persistent reservation which have the effect of preventing SCSI 1100 access to the LUs in question by the client. 1102 3.1. Use of Open Stateids 1104 The effective implementation of these NFSv4 semantic constraints is 1105 complicated by the different granularities of the actors for the 1106 different types of the functionality to be enforced: 1108 o To enforce security constraints for particular principals. 1110 o To enforce locking constraints for particular owners (openowners 1111 and lockowners) 1113 Fundamental to enforcing both of these sorts of constraints is the 1114 principle that a pNFS client must not issue a SCSI IO operation 1115 unless it possesses both: 1117 o A valid open stateid for the file in question, performing the IO 1118 that allows IO of the type in question, which is associated with 1119 the openowner and principal on whose behalf the IO is to be done. 1121 o A valid layout stateid for the file in question that covers the 1122 byte range on which the IO is to be done and that allows IO of 1123 that type to be done. 1125 As a result, if the equivalent of IO with an anonymous or write- 1126 bypass stateid is to be done, it MUST NOT by done using the pNFS SCSI 1127 layout type. The client MAY attempt such IO using READs and WRITEs 1128 that do not use pNFS and are directed to the MDS. 1130 When open stateids are revoked, due to lease expiration or any form 1131 of administrative revocation, the server MUST recall all layouts that 1132 allow IO to be done on any of the files for which open revocation 1133 happens. When there is a failure to successfully return those 1134 layouts, the client MUST be fenced. 1136 3.2. Enforcing Security Restrictions 1138 The restriction noted above provides adequate enforcement of 1139 appropriate security restriction when the principal issuing the IO is 1140 the same as that opening the file. The server is responsible for 1141 checking that the IO mode requested by the open is allowed for the 1142 principal doing the OPEN. If the correct sort of IO is done on 1143 behalf of the same principal, then the security restriction is 1144 thereby enforced. 1146 If IO is done by a principal different from the one that opened the 1147 file, the client SHOULD send the IO to be performed by the metadata 1148 server rather than doing it directly to the storage device. 1150 3.3. Enforcing Locking Restrictions 1152 Mandatory enforcement of whole-file locking by means of share 1153 reservations is provided when the pNFS client obeys the requirement 1154 set forth in Section 2.1 above. Since performing IO requires a valid 1155 open stateid an IO that violates an existing share reservation would 1156 only be possible when the server allows conflicting open stateids to 1157 exist. 1159 The nature of the SCSI layout type is such implementation/enforcement 1160 of mandatory byte-range locks is very difficult. Given that layouts 1161 are granted to clients rather than owners, the pNFS client is in no 1162 position to successfully arbitrate among multiple lockowners on the 1163 same client. Suppose lockowner A is doing a write and, while the IO 1164 is pending, lockowner B requests a mandatory byte-range for a byte 1165 range potentially overlapping the pending IO. In such a situation, 1166 the lock request cannot be granted while the IO is pending. In a 1167 non-pNFS environment, the server would have to wait for pending IO 1168 before granting the mandatory byte-range lock. In the pNFS 1169 environment the server does not issue the IO and is thus in no 1170 position to wait for its completion. The server may recall such 1171 layouts but in doing so, it has no way of distinguishing those being 1172 used by lockowners A and B, making it difficult to allow B to perform 1173 IO while forbidding A from doing so. Given this fact, the MDS need 1174 to successfully recall all layouts that overlap the range being 1175 locked before returning a successful response to the LOCK request. 1176 While the lock is in effect, the server SHOULD respond to requests 1177 for layouts which overlap a currently locked area with 1178 NFS4ERR_LAYOUTUNAVAILABLE. To simplify the required logic a server 1179 MAY do this for all layout requests on the file in question as long 1180 as there are any byte-range locks in effect. 1182 Given these difficulties it may be difficult for servers supporting 1183 mandatory byte-range locks to also support SCSI layouts. Servers can 1184 support advisory byte-range locks instead. The NFSv4 protocol 1185 currently has no way of determining whether byte-range lock support 1186 on a particular file system will be mandatory or advisory, except by 1187 trying operation which would conflict if mandatory locking is in 1188 effect. Therefore, to avoid confusion, servers SHOULD NOT switch 1189 between mandatory and advisory byte-range locking based on whether 1190 any SCSI layouts have been obtained or whether a client that has 1191 obtained a SCSI layout has requested a byte-range lock. 1193 4. Security Considerations 1195 Access to SCSI storage devices is logically at a lower layer of the 1196 I/O stack than NFSv4, and hence NFSv4 security is not directly 1197 applicable to protocols that access such storage directly. Depending 1198 on the protocol, some of the security mechanisms provided by NFSv4 1199 (e.g., encryption, cryptographic integrity) may not be available or 1200 may be provided via different means. At one extreme, pNFS with SCSI 1201 layouts can be used with storage access protocols (e.g., serial 1202 attached SCSI ([SAS3]) that provide essentially no security 1203 functionality. At the other extreme, pNFS may be used with storage 1204 protocols such as iSCSI ([RFC7143]) that can provide significant 1205 security functionality. It is the responsibility of those 1206 administering and deploying pNFS with a SCSI storage access protocol 1207 to ensure that appropriate protection is provided to that protocol 1208 (physical security is a common means for protocols not based on IP). 1209 In environments where the security requirements for the storage 1210 protocol cannot be met, pNFS SCSI layouts SHOULD NOT be used. 1212 When security is available for a storage protocol, it is generally at 1213 a different granularity and with a different notion of identity than 1214 NFSv4 (e.g., NFSv4 controls user access to files, iSCSI controls 1215 initiator access to volumes). The responsibility for enforcing 1216 appropriate correspondences between these security layers is placed 1217 upon the pNFS client. As with the issues in the first paragraph of 1218 this section, in environments where the security requirements are 1219 such that client-side protection from access to storage outside of 1220 the layout is not sufficient, pNFS SCSI layouts SHOULD NOT be used. 1222 5. IANA Considerations 1224 IANA is requested to assign a new pNFS layout type in the pNFS Layout 1225 Types Registry as follows (the value 5 is suggested): Layout Type 1226 Name: LAYOUT4_SCSI Value: 0x00000005 RFC: RFCTBD10 How: L (new layout 1227 type) Minor Versions: 1 1229 6. Normative References 1231 [LEGAL] IETF Trust, "Legal Provisions Relating to IETF Documents", 1232 November 2008, . 1235 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1236 Requirement Levels", March 1997. 1238 [RFC4506] Eisler, M., "XDR: External Data Representation Standard", 1239 STD 67, RFC 4506, May 2006. 1241 [RFC5661] Shepler, S., Ed., Eisler, M., Ed., and D. Noveck, Ed., 1242 "Network File System (NFS) Version 4 Minor Version 1 1243 Protocol", RFC 5661, January 2010. 1245 [RFC5662] Shepler, S., Ed., Eisler, M., Ed., and D. Noveck, Ed., 1246 "Network File System (NFS) Version 4 Minor Version 1 1247 External Data Representation Standard (XDR) Description", 1248 RFC 5662, January 2010. 1250 [RFC5663] Black, D., Ed., Fridella, S., Ed., and J. Glasgow, Ed., 1251 "Parallel NFS (pNFS) Block/Volume Layout", RFC 5663, 1252 January 2010. 1254 [RFC6688] Black, D., Ed., Glasgow, J., and S. Faibish, "Parallel NFS 1255 (pNFS) Block Disk Protection", RFC 6688, July 2012. 1257 [RFC7143] Chadalapaka, M., Meth, K., and D. Black, "Internet Small 1258 Computer System Interface (iSCSI) Protocol 1259 (Consolidated)", RFC RFC7143, April 2014. 1261 [SAM-4] INCITS Technical Committee T10, "SCSI Architecture Model - 1262 4 (SAM-4)", ANSI INCITS 447-2008, ISO/IEC 14776-414, 2008. 1264 [SAS3] INCITS Technical Committee T10, "Serial Attached Scsi-3", 1265 ANSI INCITS ANSI INCITS 519-2014, ISO/IEC 14776-154, 2014. 1267 [SBC3] INCITS Technical Committee T10, "SCSI Block Commands-3", 1268 ANSI INCITS INCITS 514-2014, ISO/IEC 14776-323, 2014. 1270 [SPC4] INCITS Technical Committee T10, "SCSI Primary Commands-4", 1271 ANSI INCITS 513-2015, 2015. 1273 Appendix A. Acknowledgments 1275 Large parts of this document were copied verbatim, and others were 1276 inspired by [RFC5663]. Thank to David Black, Stephen Fridella and 1277 Jason Glasgow for their work on the pNFS block/volume layout 1278 protocol. 1280 David Black, Robert Elliott and Tom Haynes provided a throughout 1281 review of early drafts of this document, and their input lead to the 1282 current form of the document. 1284 David Noveck provided ample feedback to various drafts of this 1285 document, wrote the section on enforcing NFSv4 semantics and rewrote 1286 various sections to better catch the intent. 1288 Appendix B. RFC Editor Notes 1290 [RFC Editor: please remove this section prior to publishing this 1291 document as an RFC] 1293 [RFC Editor: prior to publishing this document as an RFC, please 1294 replace all occurrences of RFCTBD10 with RFCxxxx where xxxx is the 1295 RFC number of this document] 1297 Author's Address 1299 Christoph Hellwig 1301 Email: hch@lst.de