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