idnits 2.17.1 draft-ietf-nfsv4-scsi-layout-03.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 (November 03, 2015) is 3097 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. 'SPC3' 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 November 03, 2015 4 Intended status: Standards Track 5 Expires: May 6, 2016 7 Parallel NFS (pNFS) SCSI Layout 8 draft-ietf-nfsv4-scsi-layout-03.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 May 6, 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 . . . . . . . . . . . . . . . . . . . . 16 66 2.4.3. Layout Returns . . . . . . . . . . . . . . . . . . . . 16 67 2.4.4. Client Copy-on-Write Processing . . . . . . . . . . . 17 68 2.4.5. Extents are Permissions . . . . . . . . . . . . . . . 18 69 2.4.6. End-of-file Processing . . . . . . . . . . . . . . . . 19 70 2.4.7. Layout Hints . . . . . . . . . . . . . . . . . . . . . 20 71 2.4.8. Client Fencing . . . . . . . . . . . . . . . . . . . . 20 72 2.5. Crash Recovery Issues . . . . . . . . . . . . . . . . . . 22 73 2.6. Recalling Resources: CB_RECALL_ANY . . . . . . . . . . . . 22 74 2.7. Transient and Permanent Errors . . . . . . . . . . . . . . 23 75 2.8. Volatile write caches . . . . . . . . . . . . . . . . . . 23 76 3. Enforcing NFSv4 Semantics . . . . . . . . . . . . . . . . . . 24 77 3.1. Use of Open Stateids . . . . . . . . . . . . . . . . . . . 24 78 3.2. Enforcing Security Restrictions . . . . . . . . . . . . . 25 79 3.3. Enforcing Locking Restrictions . . . . . . . . . . . . . . 25 80 4. Security Considerations . . . . . . . . . . . . . . . . . . . 26 81 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 27 82 6. Normative References . . . . . . . . . . . . . . . . . . . . . 27 83 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . . 28 84 Appendix B. RFC Editor Notes . . . . . . . . . . . . . . . . . . 28 85 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 29 87 1. Introduction 89 Figure 1 shows the overall architecture of a Parallel NFS (pNFS) 90 system: 92 +-----------+ 93 |+-----------+ +-----------+ 94 ||+-----------+ | | 95 ||| | NFSv4.1 + pNFS | | 96 +|| Clients |<------------------------------>| Server | 97 +| | | | 98 +-----------+ | | 99 ||| +-----------+ 100 ||| | 101 ||| | 102 ||| Storage +-----------+ | 103 ||| Protocol |+-----------+ | 104 ||+----------------||+-----------+ Control | 105 |+-----------------||| | Protocol| 106 +------------------+|| Storage |------------+ 107 +| Systems | 108 +-----------+ 110 Figure 1 112 The overall approach is that pNFS-enhanced clients obtain sufficient 113 information from the server to enable them to access the underlying 114 storage (on the storage systems) directly. See the Section 12 of 115 [RFC5661] for more details. This document is concerned with access 116 from pNFS clients to storage devices over block storage protocols 117 based on the the SCSI Architecture Model ([SAM-4]), e.g., Fibre 118 Channel Protocol (FCP) for Fibre Channel, Internet SCSI (iSCSI) or 119 Serial Attached SCSI (SAS). pNFS SCSI layout requires block based 120 SCSI command sets, for example SCSI Block Commands ([SBC3]). While 121 SCSI command set for non-block based access exist these are not 122 supported by the SCSI layout type, and all future references to SCSI 123 storage devices will imply a block based SCSI command set. 125 The Server to Storage System protocol, called the "Control Protocol", 126 is not of concern for interoperability, although it will typically be 127 the same SCSI based storage protocol. 129 This document is based on and updates [RFC5663] to provide a better 130 pNFS layout protocol for SCSI based storage devices, and functionally 131 obsoletes [RFC6688] by providing mandatory disk access protection as 132 part of the protocol. Unlike [RFC5663] this document can make use of 133 SCSI protocol features and thus can provide reliable fencing by using 134 SCSI Persistent Reservations, and it can provide reliable and 135 efficient device discovery by using SCSI device identifiers instead 136 of having to rely on probing all devices potentially attached to a 137 client for a signature. The document also optimizes the I/O path by 138 reducing the size of the LAYOUTCOMMIT payload. 140 1.1. Conventions Used in This Document 142 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 143 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 144 document are to be interpreted as described in [RFC2119]. 146 1.2. General Definitions 148 The following definitions are provided for the purpose of providing 149 an appropriate context for the reader. 151 Byte This document defines a byte as an octet, i.e., a datum exactly 152 8 bits in length. 154 Client The "client" is the entity that accesses the NFS server's 155 resources. The client may be an application that contains the 156 logic to access the NFS server directly. The client may also be 157 the traditional operating system client that provides remote file 158 system services for a set of applications. 160 Server The "server" is the entity responsible for coordinating 161 client access to a set of file systems and is identified by a 162 server owner. 164 1.3. Code Components Licensing Notice 166 The external data representation (XDR) description and scripts for 167 extracting the XDR description are Code Components as described in 168 Section 4 of "Legal Provisions Relating to IETF Documents" [LEGAL]. 169 These Code Components are licensed according to the terms of Section 170 4 of "Legal Provisions Relating to IETF Documents". 172 1.4. XDR Description 174 This document contains the XDR [RFC4506] description of the NFSv4.1 175 SCSI layout protocol. The XDR description is embedded in this 176 document in a way that makes it simple for the reader to extract into 177 a ready-to-compile form. The reader can feed this document into the 178 following shell script to produce the machine readable XDR 179 description of the NFSv4.1 SCSI layout: 181 #!/bin/sh 182 grep '^ *///' $* | sed 's?^ */// ??' | sed 's?^ *///$??' 184 That is, if the above script is stored in a file called "extract.sh", 185 and this document is in a file called "spec.txt", then the reader can 186 do: 188 sh extract.sh < spec.txt > scsi_prot.x 190 The effect of the script is to remove leading white space from each 191 line, plus a sentinel sequence of "///". 193 The embedded XDR file header follows. Subsequent XDR descriptions, 194 with the sentinel sequence are embedded throughout the document. 196 Note that the XDR code contained in this document depends on types 197 from the NFSv4.1 nfs4_prot.x file [RFC5662]. This includes both nfs 198 types that end with a 4, such as offset4, length4, etc., as well as 199 more generic types such as uint32_t and uint64_t. 201 /// /* 202 /// * This code was derived from RFCTBD10 203 /// * Please reproduce this note if possible. 204 /// */ 205 /// /* 206 /// * Copyright (c) 2010,2015 IETF Trust and the persons identified 207 /// * as the document authors. All rights reserved. 208 /// * 209 /// * Redistribution and use in source and binary forms, with 210 /// * or without modification, are permitted provided that the 211 /// * following conditions are met: 212 /// * 213 /// * - Redistributions of source code must retain the above 214 /// * copyright notice, this list of conditions and the 215 /// * following disclaimer. 216 /// * 217 /// * - Redistributions in binary form must reproduce the above 218 /// * copyright notice, this list of conditions and the 219 /// * following disclaimer in the documentation and/or other 220 /// * materials provided with the distribution. 221 /// * 222 /// * - Neither the name of Internet Society, IETF or IETF 223 /// * Trust, nor the names of specific contributors, may be 224 /// * used to endorse or promote products derived from this 225 /// * software without specific prior written permission. 226 /// * 227 /// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 228 /// * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 229 /// * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 230 /// * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 231 /// * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 232 /// * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 233 /// * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 234 /// * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 235 /// * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 236 /// * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 237 /// * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 238 /// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 239 /// * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 240 /// * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 241 /// * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 242 /// */ 243 /// 244 /// /* 245 /// * nfs4_scsi_layout_prot.x 246 /// */ 247 /// 248 /// %#include "nfsv41.h" 249 /// 251 2. SCSI Layout Description 253 2.1. Background and Architecture 255 The fundamental storage abstraction supported by SCSI storage devices 256 is a Logical Unit (LU) consisting of a sequential series of fixed- 257 size blocks. This can be thought of as a logical disk; it may be 258 realized by the storage system as a physical disk, a portion of a 259 physical disk, or something more complex (e.g., concatenation, 260 striping, RAID, and combinations thereof) involving multiple physical 261 disks or portions thereof. Logical units used as devices for NFS 262 scsi layouts, and the SCSI initiators used for the pNFS Metadata 263 Served and clients MUST support SCSI persistent reservations. 265 A pNFS layout for this SCSI class of storage is responsible for 266 mapping from an NFS file (or portion of a file) to the blocks of 267 storage volumes that contain the file. The blocks are expressed as 268 extents with 64-bit offsets and lengths using the existing NFSv4 269 offset4 and length4 types. Clients MUST be able to perform I/O to 270 the block extents without affecting additional areas of storage 271 (especially important for writes); therefore, extents MUST be aligned 272 to 512-byte boundaries, and writable extents MUST be aligned to the 273 block size used by the NFSv4 server in managing the actual file 274 system (4 kilobytes and 8 kilobytes are common block sizes). This 275 block size is available as the NFSv4.1 layout_blksize attribute. 276 [RFC5661]. Readable extents SHOULD be aligned to the block size used 277 by the NFSv4 server, but in order to support legacy file systems with 278 fragments, alignment to 512-byte boundaries is acceptable. 280 The pNFS operation for requesting a layout (LAYOUTGET) includes the 281 "layoutiomode4 loga_iomode" argument, which indicates whether the 282 requested layout is for read-only use or read-write use. A read-only 283 layout may contain holes that are read as zero, whereas a read-write 284 layout will contain allocated, but un-initialized storage in those 285 holes (read as zero, can be written by client). This document also 286 supports client participation in copy-on-write (e.g., for file 287 systems with snapshots) by providing both read-only and un- 288 initialized storage for the same range in a layout. Reads are 289 initially performed on the read-only storage, with writes going to 290 the un-initialized storage. After the first write that initializes 291 the un-initialized storage, all reads are performed to that now- 292 initialized writable storage, and the corresponding read-only storage 293 is no longer used. 295 The SCSI layout solution expands the security responsibilities of the 296 pNFS clients, and there are a number of environments where the 297 mandatory to implement security properties for NFS cannot be 298 satisfied. The additional security responsibilities of the client 299 follow, and a full discussion is present im Section 4, "Security 300 Considerations". 302 o Typically, SCSI storage devices provide access control mechanisms 303 (e.g., Logical Unit Number (LUN) mapping and/or masking), which 304 operate at the granularity of individual hosts, not individual 305 blocks. For this reason, block-based protection must be provided 306 by the client software. 308 o Similarly, SCSI storage devices typically are not able to validate 309 NFS locks that apply to file regions. For instance, if a file is 310 covered by a mandatory read-only lock, the server can ensure that 311 only readable layouts for the file are granted to pNFS clients. 312 However, it is up to each pNFS client to ensure that the readable 313 layout is used only to service read requests, and not to allow 314 writes to the existing parts of the file. 316 Since SCSI storage devices are generally not capable of enforcing 317 such file-based security, in environments where pNFS clients cannot 318 be trusted to enforce such policies, pNFS SCSI layouts SHOULD NOT be 319 used. 321 2.2. layouttype4 323 The layout4 type defined in [RFC5662] is extended with a new value as 324 follows: 326 enum layouttype4 { 327 LAYOUT4_NFSV4_1_FILES = 1, 328 LAYOUT4_OSD2_OBJECTS = 2, 329 LAYOUT4_BLOCK_VOLUME = 3, 330 LAYOUT4_SCSI = 0x80000005 331 [[RFC Editor: please modify the LAYOUT4_SCSI 332 to be the layouttype assigned by IANA]] 333 }; 335 This document defines structure associated with the layouttype4 value 336 LAYOUT4_SCSI. [RFC5661] specifies the loc_body structure as an XDR 337 type "opaque". The opaque layout is uninterpreted by the generic 338 pNFS client layers, but obviously must be interpreted by the Layout 339 Type implementation. 341 2.3. GETDEVICEINFO 343 2.3.1. Volume Identification 345 SCSI targets implementing [SPC3] export unique LU names for each LU 346 through the Device Identification VPD page (page code 0x83), which 347 can be obtained using the INQUIRY command with the EVPD bit set to 348 one. This document uses a subset of this information to identify LUs 349 backing pNFS SCSI layouts. It is similar to the "Identification 350 Descriptor Target Descriptor" specified in [SPC3], but limits the 351 allowed values to those that uniquely identify a LU. Device 352 Identification VPD page descriptors used to identify LUs for use with 353 pNFS SCSI layouts must adhere to the following restrictions: 355 1. The "ASSOCIATION" MUST be set to 0 (The DESIGNATOR field is 356 associated with the addressed logical unit). 358 2. The "DESIGNATOR TYPE" MUST be set to one of four values that are 359 required for the mandatory logical unit name in [SPC3], as 360 explicitly listed in the "pnfs_scsi_designator_type" enumeration: 362 PS_DESIGNATOR_T10 T10 vendor ID based 364 PS_DESIGNATOR_EUI64 EUI-64-based 366 PS_DESIGNATOR_NAA NAA 368 PS_DESIGNATOR_NAME SCSI name string 370 Any other associate or designator type MUST NOT be used. 372 The "CODE SET" VPD page field is stored in the "sbv_code_set" field 373 of the "pnfs_scsi_base_volume_info4" structure, the "DESIGNATOR TYPE" 374 is stored in "sbv_designator_type", and the DESIGNATOR is stored in 375 "sbv_designator". Due to the use of a XDR array the "DESIGNATOR 376 LENGTH" field does not need to be set separately. Only certain 377 combinations of "sbv_code_set" and "sbv_designator_type" are valid, 378 please refer to [SPC3] for details, and note that ASCII may be used 379 as the code set for UTF-8 text that contains only printable ASCII 380 characters. Note that a Device Identification VPD page MAY contain 381 multiple descriptors with the same association, code set and 382 designator type. NFS clients thus MUST check all the descriptors for 383 a possible match to "sbv_code_set", "sbv_designator_type" and 384 "sbv_designator". 386 Storage devices such as storage arrays can have multiple physical 387 network ports that need not be connected to a common network, 388 resulting in a pNFS client having simultaneous multipath access to 389 the same storage volumes via different ports on different networks. 390 Selection of one or multiple ports to access the storage device is 391 left up to the client. 393 Additionally the server returns a Persistent Reservation key in the 394 "sbv_pr_key" field. See Section 2.4.8 for more details on the use of 395 Persistent Reservations. 397 2.3.2. Volume Topology 399 The pNFS SCSI layout volume topology is expressed as an arbitrary 400 combination of base volume types enumerated in the following data 401 structures. The individual components of the topology are contained 402 in an array and components may refer to other components by using 403 array indices. 405 /// enum pnfs_scsi_volume_type4 { 406 /// PNFS_SCSI_VOLUME_SLICE = 1, /* volume is a slice of 407 /// another volume */ 408 /// PNFS_SCSI_VOLUME_CONCAT = 2, /* volume is a 409 /// concatenation of 410 /// multiple volumes */ 411 /// PNFS_SCSI_VOLUME_STRIPE = 3 /* volume is striped across 412 /// multiple volumes */ 413 /// PNFS_SCSI_VOLUME_BASE = 4, /* volume maps to a single 414 /// LU */ 415 /// }; 416 /// 418 /// /* 419 /// * Code sets from SPC-3. 420 /// */ 421 /// enum pnfs_scsi_code_set { 422 /// PS_CODE_SET_BINARY = 1, 423 /// PS_CODE_SET_ASCII = 2, 424 /// PS_CODE_SET_UTF8 = 3 425 /// }; 426 /// 427 /// /* 428 /// * Designator types from taken from SPC-3. 429 /// * 430 /// * Other values are allocated in SPC-3, but not mandatory to 431 /// * implement or aren't Logical Unit names. 432 /// */ 433 /// enum pnfs_scsi_designator_type { 434 /// PS_DESIGNATOR_T10 = 1, 435 /// PS_DESIGNATOR_EUI64 = 2, 436 /// PS_DESIGNATOR_NAA = 3, 437 /// PS_DESIGNATOR_NAME = 8 438 /// }; 439 /// 440 /// /* 441 /// * Logical Unit name + reservation key. 442 /// */ 443 /// struct pnfs_scsi_base_volume_info4 { 444 /// pnfs_scsi_code_set sbv_code_set; 445 /// pnfs_scsi_designator_type sbv_designator_type; 446 /// opaque sbv_designator<>; 447 /// uint64_t sbv_pr_key; 448 /// }; 449 /// 451 /// 452 /// struct pnfs_scsi_slice_volume_info4 { 453 /// offset4 ssv_start; /* offset of the start of the 454 /// slice in bytes */ 455 /// length4 ssv_length; /* length of slice in bytes */ 456 /// uint32_t ssv_volume; /* array index of sliced 457 /// volume */ 458 /// }; 460 /// 461 /// struct pnfs_scsi_concat_volume_info4 { 462 /// uint32_t scv_volumes<>; /* array indices of volumes 463 /// which are concatenated */ 464 /// }; 466 /// 467 /// struct pnfs_scsi_stripe_volume_info4 { 468 /// length4 ssv_stripe_unit; /* size of stripe in bytes */ 469 /// uint32_t ssv_volumes<>; /* array indices of volumes 470 /// which are striped across -- 471 /// MUST be same size */ 472 /// }; 474 /// 475 /// union pnfs_scsi_volume4 switch (pnfs_scsi_volume_type4 type) { 476 /// case PNFS_SCSI_VOLUME_BASE: 477 /// pnfs_scsi_base_volume_info4 sv_simple_info; 478 /// case PNFS_SCSI_VOLUME_SLICE: 479 /// pnfs_scsi_slice_volume_info4 sv_slice_info; 480 /// case PNFS_SCSI_VOLUME_CONCAT: 481 /// pnfs_scsi_concat_volume_info4 sv_concat_info; 482 /// case PNFS_SCSI_VOLUME_STRIPE: 483 /// pnfs_scsi_stripe_volume_info4 sv_stripe_info; 484 /// }; 485 /// 487 /// /* SCSI layout specific type for da_addr_body */ 488 /// struct pnfs_scsi_deviceaddr4 { 489 /// pnfs_scsi_volume4 sda_volumes<>; /* array of volumes */ 490 /// }; 491 /// 493 The "pnfs_scsi_deviceaddr4" data structure is a structure that allows 494 arbitrarily complex nested volume structures to be encoded. The 495 types of aggregations that are allowed are stripes, concatenations, 496 and slices. Note that the volume topology expressed in the 497 pnfs_scsi_deviceaddr4 data structure will always resolve to a set of 498 pnfs_scsi_volume_type4 PNFS_SCSI_VOLUME_BASE. The array of volumes 499 is ordered such that the root of the volume hierarchy is the last 500 element of the array. Concat, slice, and stripe volumes MUST refer 501 to volumes defined by lower indexed elements of the array. 503 The "pnfs_scsi_device_addr4" data structure is returned by the server 504 as the storage-protocol-specific opaque field da_addr_body in the 505 "device_addr4" structure by a successful GETDEVICEINFO operation 506 [RFC5661]. 508 As noted above, all device_addr4 structures eventually resolve to a 509 set of volumes of type PNFS_SCSI_VOLUME_BASE. Complicated volume 510 hierarchies may be composed of dozens of volumes each with several 511 signature components; thus, the device address may require several 512 kilobytes. The client SHOULD be prepared to allocate a large buffer 513 to contain the result. In the case of the server returning 514 NFS4ERR_TOOSMALL, the client SHOULD allocate a buffer of at least 515 gdir_mincount_bytes to contain the expected result and retry the 516 GETDEVICEINFO request. 518 2.4. Data Structures: Extents and Extent Lists 520 A pNFS SCSI layout is a list of extents within a flat array of data 521 blocks in a logical volume. The details of the volume topology can 522 be determined by using the GETDEVICEINFO operation. The SCSI layout 523 describes the individual block extents on the volume that make up the 524 file. The offsets and length contained in an extent are specified in 525 units of bytes. 527 /// enum pnfs_scsi_extent_state4 { 528 /// PNFS_SCSI_READ_WRITE_DATA = 0, /* the data located by this 529 /// extent is valid 530 /// for reading and writing. */ 531 /// PNFS_SCSI_READ_DATA = 1, /* the data located by this 532 /// extent is valid for reading 533 /// only; it may not be 534 /// written. */ 535 /// PNFS_SCSI_INVALID_DATA = 2, /* the location is valid; the 536 /// data is invalid. It is a 537 /// newly (pre-) allocated 538 /// extent. There is physical 539 /// space on the volume. */ 540 /// PNFS_SCSI_NONE_DATA = 3 /* the location is invalid. 541 /// It is a hole in the file. 542 /// There is no physical space 543 /// on the volume. */ 544 /// }; 545 /// 546 /// struct pnfs_scsi_extent4 { 547 /// deviceid4 se_vol_id; /* id of logical 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 /// }; 560 /// 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 logical 570 regions of the file to physical locations on a volume. The 571 "se_storage_offset" field within each extent identifies a location on 572 the logical volume specified by the "se_vol_id" field in the extent. 573 The se_vol_id itself is shorthand for the whole topology of the 574 logical volume on which the file is stored. The client is 575 responsible for translating this logical offset into an offset on the 576 appropriate underlying SCSI LU. In most cases, all extents in a 577 layout will reside on the same volume and thus have the same 578 se_vol_id. In the case of copy-on-write file systems, the 579 PNFS_SCSI_READ_DATA extents may have a different se_vol_id from the 580 writable extents. 582 Each extent maps a logical region of the file onto a portion of the 583 specified LU. The se_file_offset, se_length, and se_state fields for 584 an extent returned from the server are valid for all extents. In 585 contrast, the interpretation of the se_storage_offset field depends 586 on the value of se_state as follows (in increasing order): 588 PNFS_SCSI_READ_WRITE_DATA means that se_storage_offset is valid, and 589 points to valid/initialized data that can be read and written. 591 PNFS_SCSI_READ_DATA means that se_storage_offset is valid andpoints 592 to valid/initialized data that can only be read. Write operations 593 are prohibited; the client may need to request a read-write 594 layout. 596 PNFS_SCSI_INVALID_DATA means that se_storage_offset is valid, but 597 points to invalid un-initialized data. This data must not be 598 physically read from the disk until it has been initialized. A 599 read request for a PNFS_SCSI_INVALID_DATA extent must fill the 600 user buffer with zeros, unless the extent is covered by a 601 PNFS_SCSI_READ_DATA extent of a copy-on-write file system. Write 602 requests must write whole server-sized blocks to the disk; bytes 603 not initialized by the user must be set to zero. Any write to 604 storage in a PNFS_SCSI_INVALID_DATA extent changes the written 605 portion of the extent to PNFS_SCSI_READ_WRITE_DATA; the pNFS 606 client is responsible for reporting this change via LAYOUTCOMMIT. 608 PNFS_SCSI_NONE_DATA means that se_storage_offset is not valid, and 609 this extent may not be used to satisfy write requests. Read 610 requests may be satisfied by zero-filling as for 611 PNFS_SCSI_INVALID_DATA. PNFS_SCSI_NONE_DATA extents may be 612 returned by requests for readable extents; they are never returned 613 if the request was for a writable extent. 615 An extent list contains all relevant extents in increasing order of 616 the se_file_offset of each extent; any ties are broken by increasing 617 order of the extent state (se_state). 619 2.4.1. Layout Requests and Extent Lists 621 Each request for a layout specifies at least three parameters: file 622 offset, desired size, and minimum size. If the status of a request 623 indicates success, the extent list returned must meet the following 624 criteria: 626 o A request for a readable (but not writable) layout returns only 627 PNFS_SCSI_READ_DATA or PNFS_SCSI_NONE_DATA extents (but not 628 PNFS_SCSI_INVALID_DATA or PNFS_SCSI_READ_WRITE_DATA extents). 630 o A request for a writable layout returns PNFS_SCSI_READ_WRITE_DATA 631 or PNFS_SCSI_INVALID_DATA extents (but not PNFS_SCSI_NONE_DATA 632 extents). It may also return PNFS_SCSI_READ_DATA extents only 633 when the offset ranges in those extents are also covered by 634 PNFS_SCSI_INVALID_DATA extents to permit writes. 636 o The first extent in the list MUST contain the requested starting 637 offset. 639 o The total size of extents within the requested range MUST cover at 640 least the minimum size. One exception is allowed: the total size 641 MAY be smaller if only readable extents were requested and EOF is 642 encountered. 644 o Extents in the extent list MUST be logically contiguous for a 645 read-only layout. For a read-write layout, the set of writable 646 extents (i.e., excluding PNFS_SCSI_READ_DATA extents) MUST be 647 logically contiguous. Every PNFS_SCSI_READ_DATA extent in a read- 648 write layout MUST be covered by one or more PNFS_SCSI_INVALID_DATA 649 extents. This overlap of PNFS_SCSI_READ_DATA and 650 PNFS_SCSI_INVALID_DATA extents is the only permitted extent 651 overlap. 653 o Extents MUST be ordered in the list by starting offset, with 654 PNFS_SCSI_READ_DATA extents preceding PNFS_SCSI_INVALID_DATA 655 extents in the case of equal se_file_offsets. 657 If the minimum requested size, loga_minlength, is zero, this is an 658 indication to the metadata server that the client desires any layout 659 at offset loga_offset or less that the metadata server has "readily 660 available". Readily is subjective, and depends on the layout type 661 and the pNFS server implementation. For SCSI layout servers, readily 662 available SHOULD be interpreted such that readable layouts are always 663 available, even if some extents are in the PNFS_SCSI_NONE_DATA state. 664 When processing requests for writable layouts, a layout is readily 665 available if extents can be returned in the PNFS_SCSI_READ_WRITE_DATA 666 state. 668 2.4.2. Layout Commits 670 /// 671 /// /* SCSI layout specific type for lou_body */ 672 /// 673 /// struct pnfs_scsi_range4 { 674 /// offset4 sr_file_offset; /* starting byte offset 675 /// in the file */ 676 /// length4 sr_length; /* size in bytes */ 677 /// }; 678 /// 679 /// struct pnfs_scsi_layoutupdate4 { 680 /// pnfs_scsi_range4 slu_commit_list<>; 681 /// /* list of extents which 682 /// * now contain valid data. 683 /// */ 684 /// }; 686 The "pnfs_scsi_layoutupdate4" structure is used by the client as the 687 SCSI layout specific argument in a LAYOUTCOMMIT operation. The 688 "slu_commit_list" field is a list covering regions of the file layout 689 that were previously in the PNFS_SCSI_INVALID_DATA state, but have 690 been written by the client and should now be considered in the 691 PNFS_SCSI_READ_WRITE_DATA state. The extents in the commit list MUST 692 be disjoint and MUST be sorted by sr_file_offset. Implementors 693 should be aware that a server may be unable to commit regions at a 694 granularity smaller than a file-system block (typically 4 KB or 8 695 KB). As noted above, the block-size that the server uses is 696 available as an NFSv4 attribute, and any extents included in the 697 "slu_commit_list" MUST be aligned to this granularity and have a size 698 that is a multiple of this granularity. If the client believes that 699 its actions have moved the end-of-file into the middle of a block 700 being committed, the client MUST write zeroes from the end-of-file to 701 the end of that block before committing the block. Failure to do so 702 may result in junk (un-initialized data) appearing in that area if 703 the file is subsequently extended by moving the end-of-file. 705 2.4.3. Layout Returns 707 The LAYOUTRETURN operation is done without any SCSI layout specific 708 data. When the LAYOUTRETURN operation specifies a 709 LAYOUTRETURN4_FILE_return type, then the layoutreturn_file4 data 710 structure specifies the region of the file layout that is no longer 711 needed by the client. The opaque "lrf_body" field of the 712 "layoutreturn_file4" data structure MUST have length zero. A 713 LAYOUTRETURN operation represents an explicit release of resources by 714 the client, usually done for the purpose of avoiding unnecessary 715 CB_LAYOUTRECALL operations in the future. The client may return 716 disjoint regions of the file by using multiple LAYOUTRETURN 717 operations within a single COMPOUND operation. 719 Note that the SCSI layout supports unilateral layout revocation. 720 When a layout is unilaterally revoked by the server, usually due to 721 the client's lease time expiring, or a delegation being recalled, or 722 the client failing to return a layout in a timely manner, it is 723 important for the sake of correctness that any in-flight I/Os that 724 the client issued before the layout was revoked are rejected at the 725 storage. For the SCSI protocol, this is possible by fencing a client 726 with an expired layout timer from the physical storage. Note, 727 however, that the granularity of this operation can only be at the 728 host/LU level. Thus, if one of a client's layouts is unilaterally 729 revoked by the server, it will effectively render useless *all* of 730 the client's layouts for files located on the storage units 731 comprising the logical volume. This may render useless the client's 732 layouts for files in other file systems. 734 2.4.4. Client Copy-on-Write Processing 736 Copy-on-write is a mechanism used to support file and/or file system 737 snapshots. When writing to unaligned regions, or to regions smaller 738 than a file system block, the writer must copy the portions of the 739 original file data to a new location on disk. This behavior can 740 either be implemented on the client or the server. The paragraphs 741 below describe how a pNFS SCSI layout client implements access to a 742 file that requires copy-on-write semantics. 744 Distinguishing the PNFS_SCSI_READ_WRITE_DATA and PNFS_SCSI_READ_DATA 745 extent types in combination with the allowed overlap of 746 PNFS_SCSI_READ_DATA extents with PNFS_SCSI_INVALID_DATA extents 747 allows copy-on-write processing to be done by pNFS clients. In 748 classic NFS, this operation would be done by the server. Since pNFS 749 enables clients to do direct block access, it is useful for clients 750 to participate in copy-on-write operations. All SCSI pNFS clients 751 MUST support this copy-on-write processing. 753 When a client wishes to write data covered by a PNFS_SCSI_READ_DATA 754 extent, it MUST have requested a writable layout from the server; 755 that layout will contain PNFS_SCSI_INVALID_DATA extents to cover all 756 the data ranges of that layout's PNFS_SCSI_READ_DATA extents. More 757 precisely, for any se_file_offset range covered by one or more 758 PNFS_SCSI_READ_DATA extents in a writable layout, the server MUST 759 include one or more PNFS_SCSI_INVALID_DATA extents in the layout that 760 cover the same se_file_offset range. When performing a write to such 761 an area of a layout, the client MUST effectively copy the data from 762 the PNFS_SCSI_READ_DATA extent for any partial blocks of 763 se_file_offset and range, merge in the changes to be written, and 764 write the result to the PNFS_SCSI_INVALID_DATA extent for the blocks 765 for that se_file_offset and range. That is, if entire blocks of data 766 are to be overwritten by an operation, the corresponding 767 PNFS_SCSI_READ_DATA blocks need not be fetched, but any partial- 768 block writes must be merged with data fetched via PNFS_SCSI_READ_DATA 769 extents before storing the result via PNFS_SCSI_INVALID_DATA extents. 770 For the purposes of this discussion, "entire blocks" and "partial 771 blocks" refer to the server's file-system block size. Storing of 772 data in a PNFS_SCSI_INVALID_DATA extent converts the written portion 773 of the PNFS_SCSI_INVALID_DATA extent to a PNFS_SCSI_READ_WRITE_DATA 774 extent; all subsequent reads MUST be performed from this extent; the 775 corresponding portion of the PNFS_SCSI_READ_DATA extent MUST NOT be 776 used after storing data in a PNFS_SCSI_INVALID_DATA extent. If a 777 client writes only a portion of an extent, the extent may be split at 778 block aligned boundaries. 780 When a client wishes to write data to a PNFS_SCSI_INVALID_DATA extent 781 that is not covered by a PNFS_SCSI_READ_DATA extent, it MUST treat 782 this write identically to a write to a file not involved with copy- 783 on-write semantics. Thus, data must be written in at least block- 784 sized increments, aligned to multiples of block-sized offsets, and 785 unwritten portions of blocks must be zero filled. 787 2.4.5. Extents are Permissions 789 Layout extents returned to pNFS clients grant permission to read or 790 write; PNFS_SCSI_READ_DATA and PNFS_SCSI_NONE_DATA are read-only 791 (PNFS_SCSI_NONE_DATA reads as zeroes), PNFS_SCSI_READ_WRITE_DATA and 792 PNFS_SCSI_INVALID_DATA are read/write, (PNFS_SCSI_INVALID_DATA reads 793 as zeros, any write converts it to PNFS_SCSI_READ_WRITE_DATA). This 794 is the only means a client has of obtaining permission to perform 795 direct I/O to storage devices; a pNFS client MUST NOT perform direct 796 I/O operations that are not permitted by an extent held by the 797 client. Client adherence to this rule places the pNFS server in 798 control of potentially conflicting storage device operations, 799 enabling the server to determine what does conflict and how to avoid 800 conflicts by granting and recalling extents to/from clients. 802 SCSI storage devices do not provide byte granularity access and can 803 only perform read and write operations atomically on a block 804 granularity, and thus require read-modify-write cycles to write data 805 smaller than the block size. Overlapping concurrent read and write 806 operations to the same data thus will cause the read to return a 807 mixture of before-write and after-write data. Additionally, data 808 corruption can occur if the underlying storage is striped and the 809 operations complete in different orders on different stripes. When 810 there are multiple clients who wish to access the same data, a pNFS 811 server MUST avoid these conflicts by implementing a concurrency 812 control policy of single writer XOR multiple readers for a given data 813 region. 815 If a client makes a layout request that conflicts with an existing 816 layout delegation, the request will be rejected with the error 817 NFS4ERR_LAYOUTTRYLATER. This client is then expected to retry the 818 request after a short interval. During this interval, the server 819 SHOULD recall the conflicting portion of the layout delegation from 820 the client that currently holds it. This reject-and-retry approach 821 does not prevent client starvation when there is contention for the 822 layout of a particular file. For this reason, a pNFS server SHOULD 823 implement a mechanism to prevent starvation. One possibility is that 824 the server can maintain a queue of rejected layout requests. Each 825 new layout request can be checked to see if it conflicts with a 826 previous rejected request, and if so, the newer request can be 827 rejected. Once the original requesting client retries its request, 828 its entry in the rejected request queue can be cleared, or the entry 829 in the rejected request queue can be removed when it reaches a 830 certain age. 832 NFSv4 supports mandatory locks and share reservations. These are 833 mechanisms that clients can use to restrict the set of I/O operations 834 that are permissible to other clients. Since all I/O operations 835 ultimately arrive at the NFSv4 server for processing, the server is 836 in a position to enforce these restrictions. However, with pNFS 837 layouts, I/Os will be issued from the clients that hold the layouts 838 directly to the storage devices that host the data. These devices 839 have no knowledge of files, mandatory locks, or share reservations, 840 and are not in a position to enforce such restrictions. For this 841 reason the NFSv4 server MUST NOT grant layouts that conflict with 842 mandatory locks or share reservations. Further, if a conflicting 843 mandatory lock request or a conflicting open request arrives at the 844 server, the server MUST recall the part of the layout in conflict 845 with the request before granting the request. 847 2.4.6. 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 processing the truncate 860 request. These recalls may take time to complete; as explained in 861 [RFC5661], if the server cannot respond to the client SETATTR request 862 in a reasonable amount of time, it SHOULD reply to the client with 863 the 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.7. Layout Hints 883 The SETATTR operation supports a layout hint attribute [RFC5661]. 884 Clients MUST NOT set a layout hint with a layout type (the loh_type 885 field) of LAYOUT4_SCSI_VOLUME. 887 2.4.8. Client Fencing 889 The pNFS SCSI protocol must handle situations in which a system 890 failure, typically a network connectivity issue, requires the server 891 to unilaterally revoke extents from one client in order to transfer 892 the extents to another client. The pNFS server implementation MUST 893 ensure that when resources are transferred to another client, they 894 are not used by the client originally owning them, and this must be 895 ensured against any possible combination of partitions and delays 896 among all of the participants to the protocol (server, storage and 897 client). 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.8.1. PRs - Key Generation 910 To allow fencing individual systems, each system must use a unique 911 Persistent Reservation key. [SPC3] 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.8.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.8.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.8.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 [SPC3] for details. 965 2.4.8.5. Client Recovery After a Fence Action 967 A client that detects a "RESERVATION CONFLICT" SCSI status on the 968 storage devices MUST commit all layouts that use the storage device 969 through the MDS, return all outstanding layouts for the device, 970 forget the device ID and unregister the reservation key. Future 971 GETDEVICEINFO calls may refer to the storage device again, in which 972 case the client will perform a new registration based on the key 973 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 transient errors, NFS4ERR_RECALLCONFLICT and NFS4ERR_TRYLATER, 1027 are used to indicate that the server cannot immediately grant the 1028 layout to the client. In the former case, this is because the server 1029 has recently issued a CB_LAYOUTRECALL to the requesting client, 1030 whereas in the case of NFS4ERR_TRYLATER, the server cannot grant the 1031 request possibly due to sharing conflicts with other clients. In 1032 either case, a reasonable approach for the client is to wait several 1033 milliseconds and retry the request. The client SHOULD track the 1034 number of retries, and if forward progress is not made, the client 1035 SHOULD send the READ or WRITE operation directly to the server. 1037 The error NFS4ERR_LAYOUTUNAVAILABLE may be returned by the server if 1038 layouts are not supported for the requested file or its containing 1039 file system. The server may also return this error code if the 1040 server is the progress of migrating the file from secondary storage, 1041 or for any other reason that causes the server to be unable to supply 1042 the layout. As a result of receiving NFS4ERR_LAYOUTUNAVAILABLE, the 1043 client SHOULD send future READ and WRITE requests directly to the 1044 server. It is expected that a client will not cache the file's 1045 layoutunavailable state forever, particular if the file is closed, 1046 and thus eventually, the client MAY reissue a LAYOUTGET operation. 1048 2.8. Volatile write caches 1050 Many storage devices implement volatile write caches that require an 1051 explicit flush to persist the data from write operations to stable 1052 storage. Storage devices implemeting [SBC3] should indicated a 1053 volatile write cache by setting the WCE bit to 1 in the Caching mode 1054 page. When a volatile write cache is used, the pNFS server must 1055 ensure the volatile write cache has been committed to stable storage 1056 before the LAYOUTCOMMIT operation returns by using one of the 1057 SYNCHRONIZE CACHE commands. 1059 3. Enforcing NFSv4 Semantics 1061 The functionality provided by SCSI Persistent Reservations makes it 1062 possible for the MDS to control access by individual client machines 1063 to specific LUs. Individual client machines may be allowed to or 1064 prevented from reading or writing to certain block devices. Finer- 1065 grained access control methods are not generally available. 1067 For this reason, certain responsibilities for enforcing NFSv4 1068 semantics, including security and locking, are delegated to pNFS 1069 clients when SCSI layouts are being used. The metadata server's role 1070 is to only grant layouts appropriately and the pNFS clients have to 1071 be trusted to only perform accesses allowed by the layout extents 1072 they currently hold (e.g., and not access storage for files on which 1073 a layout extent is not held). In general, the server will not be 1074 able to prevent a client that holds a layout for a file from 1075 accessing parts of the physical disk not covered by the layout. 1076 Similarly, the server will not be able to prevent a client from 1077 accessing blocks covered by a layout that it has already returned. 1078 The pNFS client must respect the layout model for this mapping type 1079 to appropriately respect NFSv4 semantics. 1081 Furthermore, there is no way for the storage to determine the 1082 specific NFSv4 entity (principal, openowner, lockowner) on whose 1083 behalf the IO operation is being done. This fact may limit the 1084 functionality to be supported and require the pNFS client to 1085 implement server policies other than those describable by layouts. 1086 In cases in which layouts previously granted become invalid, the 1087 server has the option of recalling them. In situations in which 1088 communication difficulties prevent this from happening, layouts may 1089 be revoked by the server. This revocation is accompanied by changes 1090 in persistent reservation which have the effect of preventing SCSI 1091 access to the LUs in question by the client. 1093 3.1. Use of Open Stateids 1095 The effective implementation of these NFSv4 semantic constraints is 1096 complicated by the different granularities of the actors for the 1097 different types of the functionality to be enforced: 1099 o To enforce security constraints for particular principals. 1101 o To enforce locking constraints for particular owners (openowners 1102 and lockowners) 1104 Fundamental to enforcing both of these sorts of constraints is the 1105 principle that a pNFS client must not issue a SCSI IO operation 1106 unless it possesses both: 1108 o A valid open stateid for the file in question, performing the IO 1109 that allows IO of the type in question, which is associated with 1110 the openowner and principal on whose behalf the IO is to be done. 1112 o A valid layout stateid for the file in question that covers the 1113 byte range on which the IO is to be done and that allows IO of 1114 that type to be done. 1116 As a result, if the equivalent of IO with an anonymous or write- 1117 bypass stateid is to be done, it MUST NOT by done using the pNFS SCSI 1118 layout type. The client MAY attempt such IO using READs and WRITEs 1119 that do not use pNFS and are directed to the MDS. 1121 When open stateids are revoked, due to lease expiration or any form 1122 of administrative revocation, the server MUST recall all layouts that 1123 allow IO to be done on any of the files for which open revocation 1124 happens. When there is a failure to successfully return those 1125 layouts, the client MUST be fenced. 1127 3.2. Enforcing Security Restrictions 1129 The restriction noted above provides adequate enforcement of 1130 appropriate security restriction when the principal issuing the IO is 1131 the same as that opening the file. The server is responsible for 1132 checking that the IO mode requested by the open is allowed for the 1133 principal doing the OPEN. If the correct sort of IO is done on 1134 behalf of the same principal, then the security restriction is 1135 thereby enforced. 1137 If IO is done by a principal different from the one that opened the 1138 file, the client SHOULD send the IO to be performed by the metadata 1139 server rather than doing it directly to the storage device. 1141 3.3. Enforcing Locking Restrictions 1143 Mandatory enforcement of whole-file locking by means of share 1144 reservations is provided when the pNFS client obeys the requirement 1145 set forth in Section 2.1 above. Since performing IO requires a valid 1146 open stateid an IO that violates an existing share reservation would 1147 only be possible when the server allows conflicting open stateids to 1148 exist. 1150 The nature of the SCSI layout type is such implementation/enforcement 1151 of mandatory byte-range locks is very difficult. Given that layouts 1152 are granted to clients rather than owners, the pNFS client is in no 1153 position to successfully arbitrate among multiple lockowners on the 1154 same client. Suppose lockowner A is doing a write and, while the IO 1155 is pending, lockowner B requests a mandatory byte-range for a byte 1156 range potentially overlapping the pending IO. In such a situation, 1157 the lock request cannot be granted while the IO is pending. In a 1158 non-pNFS environment, the server would have to wait for pending IO 1159 before granting the mandatory byte-range lock. In the pNFS 1160 environment the server does not issue the IO and is thus in no 1161 position to wait for its completion. The server may recall such 1162 layouts but in doing so, it has no way of distinguishing those being 1163 used by lockowners A and B, making it difficult to allow B to perform 1164 IO while forbidding A from doing so. Given this fact, the MDS need 1165 to successfully recall all layouts that overlap the range being 1166 locked before returning a successful response to the LOCK request. 1167 While the lock is in effect, the server SHOULD respond to requests 1168 for layouts which overlap a currently locked area with 1169 NFS4ERR_LAYOUTUNAVAILABLE. To simplify the required logic a server 1170 MAY do this for all layout requests on the file in question as long 1171 as there are any byte-range locks in effect. 1173 Given these difficulties it may be difficult for servers supporting 1174 mandatory byte-range locks to also support SCSI layouts. Servers can 1175 support advisory byte-range locks instead. The NFSv4 protocol 1176 currently has no way of determining whether byte-range lock support 1177 on a particular file system will be mandatory or advisory, except by 1178 trying operation which would conflict if mandatory locking is in 1179 effect. Therefore, to avoid confusion, servers SHOULD NOT switch 1180 between mandatory and advisory byte-range locking based on whether 1181 any SCSI layouts have been obtained or whether a client that has 1182 obtained a SCSI layout has requested a byte-range lock. 1184 4. Security Considerations 1186 Access to SCSI storage devices is logically at a lower layer of the 1187 I/O stack than NFSv4, and hence NFSv4 security is not directly 1188 applicable to protocols that access such storage directly. Depending 1189 on the protocol, some of the security mechanisms provided by NFSv4 1190 (e.g., encryption, cryptographic integrity) may not be available or 1191 may be provided via different means. At one extreme, pNFS with SCSI 1192 layouts can be used with storage access protocols (e.g., serial 1193 attached SCSI ([SAS3]) that provide essentially no security 1194 functionality. At the other extreme, pNFS may be used with storage 1195 protocols such as iSCSI ([RFC7143]) that can provide significant 1196 security functionality. It is the responsibility of those 1197 administering and deploying pNFS with a SCSI storage access protocol 1198 to ensure that appropriate protection is provided to that protocol 1199 (physical security is a common means for protocols not based on IP). 1200 In environments where the security requirements for the storage 1201 protocol cannot be met, pNFS SCSI layouts SHOULD NOT be used. 1203 When security is available for a storage protocol, it is generally at 1204 a different granularity and with a different notion of identity than 1205 NFSv4 (e.g., NFSv4 controls user access to files, iSCSI controls 1206 initiator access to volumes). The responsibility for enforcing 1207 appropriate correspondences between these security layers is placed 1208 upon the pNFS client. As with the issues in the first paragraph of 1209 this section, in environments where the security requirements are 1210 such that client-side protection from access to storage outside of 1211 the layout is not sufficient, pNFS SCSI layouts SHOULD NOT be used. 1213 5. IANA Considerations 1215 IANA is requested to assign a new pNFS layout type in the pNFS Layout 1216 Types Registry as follows (the value 5 is suggested): Layout Type 1217 Name: LAYOUT4_SCSI Value: 0x00000005 RFC: RFCTBD10 How: L (new layout 1218 type) Minor Versions: 1 1220 6. Normative References 1222 [LEGAL] IETF Trust, "Legal Provisions Relating to IETF Documents", 1223 November 2008, . 1226 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1227 Requirement Levels", March 1997. 1229 [RFC4506] Eisler, M., "XDR: External Data Representation Standard", 1230 STD 67, RFC 4506, May 2006. 1232 [RFC5661] Shepler, S., Ed., Eisler, M., Ed., and D. Noveck, Ed., 1233 "Network File System (NFS) Version 4 Minor Version 1 1234 Protocol", RFC 5661, January 2010. 1236 [RFC5662] Shepler, S., Ed., Eisler, M., Ed., and D. Noveck, Ed., 1237 "Network File System (NFS) Version 4 Minor Version 1 1238 External Data Representation Standard (XDR) Description", 1239 RFC 5662, January 2010. 1241 [RFC5663] Black, D., Ed., Fridella, S., Ed., and J. Glasgow, Ed., 1242 "Parallel NFS (pNFS) Block/Volume Layout", RFC 5663, 1243 January 2010. 1245 [RFC6688] Black, D., Ed., Glasgow, J., and S. Faibish, "Parallel NFS 1246 (pNFS) Block Disk Protection", RFC 6688, July 2012. 1248 [RFC7143] Chadalapaka, M., Meth, K., and D. Black, "Internet Small 1249 Computer System Interface (iSCSI) Protocol 1250 (Consolidated)", RFC RFC7143, April 2014. 1252 [SAM-4] INCITS Technical Committee T10, "SCSI Architecture Model - 1253 4 (SAM-4)", ANSI INCITS 447-2008, ISO/IEC 14776-414, 2008. 1255 [SAS3] INCITS Technical Committee T10, "Serial Attached Scsi-3", 1256 ANSI INCITS ANSI INCITS 519-2014, ISO/IEC 14776-154, 2014. 1258 [SBC3] INCITS Technical Committee T10, "SCSI Block Commands-3", 1259 ANSI INCITS INCITS 514-2014, ISO/IEC 14776-323, 2014. 1261 [SPC3] INCITS Technical Committee T10, "SCSI Primary Commands-3", 1262 ANSI INCITS 408-2005, ISO/IEC 14776-453, 2005. 1264 Appendix A. Acknowledgments 1266 Large parts of this document were copied verbatim, and others were 1267 inspired by [RFC5663]. Thank to David Black, Stephen Fridella and 1268 Jason Glasgow for their work on the pNFS block/volume layout 1269 protocol. 1271 David Black, Robert Elliott and Tom Haynes provided a throughout 1272 review of early drafts of this document, and their input lead to the 1273 current form of the document. 1275 David Noveck provided ample feedback to earlier drafts of this 1276 document and wrote the section on enforcing NFSv4 semantics. 1278 Appendix B. RFC Editor Notes 1280 [RFC Editor: please remove this section prior to publishing this 1281 document as an RFC] 1283 [RFC Editor: prior to publishing this document as an RFC, please 1284 replace all occurrences of RFCTBD10 with RFCxxxx where xxxx is the 1285 RFC number of this document] 1287 Author's Address 1289 Christoph Hellwig 1291 Email: hch@lst.de