RFC 8154

Parallel NFS (pNFS) Small Computer System Interface (SCSI) Layout

πŸ“… published May 2017, from ietf

RFC 8154: Parallel NFS (pNFS) Small Computer System Interface (SCSI) Layout ✨

Stream: Internet Engineering Task Force (IETF) 🌸 RFC number: 8154 Title: Parallel NFS (pNFS) Small Computer System Interface (SCSI) Layout Author: C. Hellwig 🧚 Category: Standards Track Date: May 2017 ISSN: 2070-1721 Obsoletes / Updates: This header doesn't list anything it obsoletes or updates πŸ¦‹


Abstract

okay so pNFS (Parallel Network File System) lets the metadata live on a metadata server and the data live on a storage device, so they're split apart for a file πŸ’–. This doc defines the SCSI layout type, which is an extension to pNFS that lets it use SCSI-based block storage devices. it's giving separation of concerns, bestie πŸŽ€


Status of This Memo

this is an Internet Standards Track document πŸ”₯

it's a product of the Internet Engineering Task Force (IETF), so it represents the consensus of the IETF community. it got public review and was approved for publication by the Internet Engineering Steering Group (IESG). if you want more on Internet Standards, check out Section 2 of RFC 7841 πŸ’…

for the current status, any errata, and how to give feedback, go to http://www.rfc-editor.org/info/rfc8154 🫢


© 2017 IETF Trust and the persons identified as the document authors, all rights reserved 🌈

this document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) as they stand on the publication date. please actually read these, bestie, because they explain your rights and restrictions for this doc πŸ“œ

any Code Components pulled out of this document have to include Simplified BSD License text, as described in Section 4.e of the Trust Legal Provisions. they're provided without warranty, as described in the Simplified BSD License πŸ’œ


Table of Contents

1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   3
  1.1.  Conventions Used in This Document . . . . . . . . . . . .   4
  1.2.  General Definitions . . . . . . . . . . . . . . . . . . .   4
  1.3.  Code Components Licensing Notice  . . . . . . . . . . . .   5
  1.4.  XDR Description . . . . . . . . . . . . . . . . . . . . .   5
2.  SCSI Layout Description . . . . . . . . . . . . . . . . . . .   7
  2.1.  Background and Architecture . . . . . . . . . . . . . . .   7
  2.2.  layouttype4 . . . . . . . . . . . . . . . . . . . . . . .   8
  2.3.  GETDEVICEINFO . . . . . . . . . . . . . . . . . . . . . .   8
    2.3.1.  Volume Identification . . . . . . . . . . . . . . . .   8
    2.3.2.  Volume Topology . . . . . . . . . . . . . . . . . . .  10
  2.4.  Data Structures: Extents and Extent Lists . . . . . . . .  12
    2.4.1.  Layout Requests and Extent Lists  . . . . . . . . . .  15
    2.4.2.  Layout Commits  . . . . . . . . . . . . . . . . . . .  16
    2.4.3.  Layout Returns  . . . . . . . . . . . . . . . . . . .  17
    2.4.4.  Layout Revocation . . . . . . . . . . . . . . . . . .  17
    2.4.5.  Client Copy-on-Write Processing . . . . . . . . . . .  17
    2.4.6.  Extents Are Permissions . . . . . . . . . . . . . . .  18
    2.4.7.  Partial-Block Updates . . . . . . . . . . . . . . . .  19
    2.4.8.  End-of-File Processing  . . . . . . . . . . . . . . .  20
    2.4.9.  Layout Hints  . . . . . . . . . . . . . . . . . . . .  20
    2.4.10. Client Fencing  . . . . . . . . . . . . . . . . . . .  21
  2.5.  Crash Recovery Issues . . . . . . . . . . . . . . . . . .  22
  2.6.  Recalling Resources: CB_RECALL_ANY  . . . . . . . . . . .  23
  2.7.  Transient and Permanent Errors  . . . . . . . . . . . . .  23
  2.8.  Volatile Write Caches . . . . . . . . . . . . . . . . . .  24
3.  Enforcing NFSv4 Semantics . . . . . . . . . . . . . . . . . .  24
  3.1.  Use of Open Stateids  . . . . . . . . . . . . . . . . . .  25
  3.2.  Enforcing Security Restrictions . . . . . . . . . . . . .  26
  3.3.  Enforcing Locking Restrictions  . . . . . . . . . . . . .  26
4.  Security Considerations . . . . . . . . . . . . . . . . . . .  27
5.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .  28
6.  Normative References  . . . . . . . . . . . . . . . . . . . .  28
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . .  29
Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .  30

1. Introduction ✨

here's the big picture of a Parallel NFS (pNFS) system πŸ‘‘

        +-----------+
        |+-----------+                                 +-----------+
        ||+-----------+                                |           |
        |||           |       NFSv4.1 + pNFS           |           |
        +||  Clients  |<------------------------------>|   Server  |
         +|           |                                |           |
          +-----------+                                |           |
               |||                                     +-----------+
               |||                                           |
               |||                                           |
               ||| Storage        +-----------+              |
               ||| Protocol       |+-----------+             |
               ||+----------------||+-----------+  Control   |
               |+-----------------|||           |    Protocol|
               +------------------+||  Storage  |------------+
                                   +|  Systems  |
                                    +-----------+

Figure 1

so the basic move is that pNFS-enhanced clients grab enough info from the server to hit the underlying storage directly, on the storage systems πŸ¦‹ for the full tea, check out Section 12 of [RFC5661] 🫢

this doc is all about clients getting to storage devices over block storage protocols built on the SCSI Architecture Model [SAM-5]. think Fibre Channel Protocol (FCP), Internet SCSI (iSCSI), or Serial Attached SCSI (SAS) πŸ”₯ the pNFS SCSI layout needs block-based SCSI command sets, like SCSI Block Commands [SBC3] πŸ’… SCSI command sets for non-block access do exist, but the SCSI layout type doesn't support them. so from here on, any mention of SCSI storage devices implies a block-based SCSI command set, period πŸ“

the Server to Storage System protocol is called the "Control Protocol" 🌸 it's not something this doc needs for interoperability, even though it'll usually be the same SCSI-based storage protocol 🧚

this doc is based on [RFC5663] and changes the block layout type to make a better pNFS layout protocol for SCSI-based storage devices ✨ even with those changes, [RFC5663] is still the defining doc for the existing block layout type πŸ“œ pNFS Block Disk Protection [RFC6688] isn't needed for the SCSI layout type, because the new layout type already bakes mandatory disk access protection into its definition πŸ”’

compared to [RFC5663], this doc uses SCSI persistent reservations to do reliable fencing πŸ’œ it can also do reliable and efficient device discovery by using SCSI device identifiers, instead of probing every device that might be attached to a client πŸ‘‘ and this new layout type makes the I/O path faster by shrinking the LAYOUTCOMMIT payload πŸš€

those last two paragraphs sum up the major functional differences from [RFC5663]. there are some smaller ones too, like the "base" volume type being used here instead of the "simple" volume type in [RFC5663]. but the data structures that describe the volume topology above that level (Section 2.3.2) and the ones that describe extents (Section 2.4) have no significant differences πŸŽ€

1.1. Conventions Used in This Document

the key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119] πŸ€“

1.2. General Definitions

these definitions are here to give you the context you need as a reader 🧠

  • Byte: an octet, which is a datum exactly 8 bits long πŸ’–
  • Client: the entity that accesses the NFS server's resources. it can be an application with the logic to reach the NFS server directly. it can also be the traditional operating system client that provides remote file system services for a set of applications πŸŽ€
  • Server: the entity in charge of coordinating client access to a set of file systems, identified by a server owner πŸ‘‘
  • Metadata Server (MDS): a pNFS server that provides metadata info for a file system object. it's also responsible for generating layouts for file system objects. and the MDS handles directory-based operations too πŸ¦‹

1.3. Code Components Licensing Notice

the external data representation (XDR) description and the scripts that extract it are Code Components, as described in Section 4 of "Legal Provisions Relating to IETF Documents" [LEGAL] πŸ“œ they're licensed under the terms of that same Section 4 🫢


Part 1 of 7 is done, bestie! πŸ¦‹ more parts are coming, so stay tuned πŸ’…βœ¨

1.4. XDR Description πŸ’…

okay so this section is where the XDR (the [RFC4506] description language) lives. the cool part is you can literally pull the whole thing out of this doc into a ready-to-compile file, no copy-paste drama πŸŽ€

The XDR description is embedded in this document in a way that makes it simple for the reader to extract into a ready-to-compile form. The reader can feed this document into the following shell script to produce the machine-readable XDR description of the NFSv4.1 SCSI layout:

#!/bin/sh
grep '^ *///' $* | sed 's?^ */// ??' | sed 's?^ *///$??'

so if you save that script as "extract.sh" and this document lives in "spec.txt", you just run:

sh extract.sh < spec.txt > scsi_prot.x

and boom, you've got your .x file 🧚

The script basically strips leading white space from each line, plus the sentinel sequence of ///. Every XDR chunk in the doc is marked with that sentinel, so the script can find them all, and the embedded XDR file header comes first. Subsequent XDR descriptions with the sentinel sequence are embedded throughout the document.

⚠️ heads up bestie: the XDR here depends on types from the NFSv4.1 nfs4_prot.x file [RFC5662]. That includes the NFS types that end with a 4, like offset4 and length4, plus more generic types like uint32_t and uint64_t. you need those too or it won't compile πŸ™ˆ

Here's the embedded XDR file header:

/// /*
///  * This code was derived from RFC 8154.
///  * Please reproduce this note if possible.
///  */
/// /*
///  * Copyright (c) 2017 IETF Trust and the persons
///  * identified as authors of the code.  All rights reserved.
///  *
///  * Redistribution and use in source and binary forms, with
///  * or without modification, are permitted provided that the
///  * following conditions are met:
///  *
///  * - Redistributions of source code must retain the above
///  *   copyright notice, this list of conditions and the
///  *   following disclaimer.
///  *
///  * - Redistributions in binary form must reproduce the above
///  *   copyright notice, this list of conditions and the
///  *   following disclaimer in the documentation and/or other
///  *   materials provided with the distribution.
///  *
///  * - Neither the name of Internet Society, IETF or IETF
///  *   Trust, nor the names of specific contributors, may be
///  *   used to endorse or promote products derived from this
///  *   software without specific prior written permission.
///  *
///  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
///  *   AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
///  *   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
///  *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
///  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
///  *   EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
///  *   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
///  *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
///  *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
///  *   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
///  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
///  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
///  *   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
///  *   IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
///  *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///  */
///
/// /*
///  *      nfs4_scsi_layout_prot.x
///  */
///
/// %#include "nfsv41.h"
///

2. SCSI Layout Description πŸ¦‹

2.1. Background and Architecture ✨

okay so the base storage model for SCSI devices is a logical unit (LU) made of a sequential series of fixed-size blocks. the LUs used as devices for NFS SCSI layouts, plus the SCSI initiators used by the pNFS metadata server and clients, MUST support SCSI persistent reservations as defined in [SPC4]. no skipping that one πŸ”₯

a pNFS layout for this SCSI class of storage is the thing that maps from an NFS file (or a portion of one) to the blocks of storage volumes holding that file. the blocks are expressed as extents with 64-bit offsets and lengths, using the existing NFSv4 offset4 and length4 types. clients MUST be able to do I/O to the block extents without touching extra areas of storage (super important for writes!), so extents MUST be aligned to logical block size boundaries of the underlying logical units (typically 512 or 4096 bytes). for complex volume topologies, the server MUST ensure extents are aligned to the logical block size boundaries of the largest logical block size in the volume topology. main character energy for alignment πŸ‘‘

the pNFS operation for requesting a layout (LAYOUTGET) includes the "layoutiomode4 loga_iomode" argument, which says whether the layout is for read-only or read-write use. a read-only layout may contain holes that read as zero, while a read-write layout has allocated but uninitialized storage in those holes (reads as zero, and the client can write to it). this doc also supports client participation in copy-on-write (think file systems with snapshots) by giving both read-only and uninitialized storage for the same range in one layout. reads start out on the read-only storage and writes go to the uninitialized storage. after the first write initializes that storage, all reads go to the now-initialized writable storage, and the matching read-only storage isn't used anymore. it's giving clever 🌈

the SCSI layout solution expands the security responsibilities of pNFS clients, and there are a bunch of environments where the mandatory-to-implement security properties for NFS can't be satisfied. the extra security stuff the client has to handle is below, and the full discussion is in Section 4 ("Security Considerations").

  • Typically, SCSI storage devices provide access control mechanisms (e.g., Logical Unit Number (LUN) mapping and/or masking), which operate at the granularity of individual hosts, not individual blocks. For this reason, block-based protection must be provided by the client software. πŸ”’
  • Similarly, SCSI storage devices typically are not able to validate NFS locks that apply to file regions. For instance, if a file is covered by a mandatory read-only lock, the server can ensure that only readable layouts for the file are granted to pNFS clients. However, it is up to each pNFS client to ensure that the readable layout is used only to service read requests and not to allow writes to the existing parts of the file. πŸ™…β€β™€οΈ

since SCSI storage devices generally can't enforce that kind of file-based security, in environments where pNFS clients can't be trusted to enforce those policies, pNFS SCSI layouts MUST NOT be used. ❌ no exceptions, bestie

2.2. layouttype4 πŸŽ€

the layout4 type defined in [RFC5662] gets extended with a new value like this:

enum layouttype4 {
    LAYOUT4_NFSV4_1_FILES   = 1,
    LAYOUT4_OSD2_OBJECTS    = 2,
    LAYOUT4_BLOCK_VOLUME    = 3,
    LAYOUT4_SCSI            = 5
};

this document defines the structure tied to the layouttype4 value LAYOUT4_SCSI. [RFC5661] specifies the loc_body structure as an XDR type "opaque". the opaque layout is uninterpreted by the generic pNFS client layers, but it obviously has to be interpreted by the layout type implementation 🧚

2.3. GETDEVICEINFO πŸ’œ

2.3.1. Volume Identification πŸ¦‹

SCSI targets implementing [SPC4] export unique LU names for each LU through the Device Identification Vital Product Data (VPD) page (page code 0x83), which you can grab with the INQUIRY command with the Enable VPD (EVPD) bit set to one. this doc only uses a subset of that info to identify the LUs backing pNFS SCSI layouts. the Device Identification VPD page descriptors used to identify LUs for pNFS SCSI layouts must adhere to the following restrictions:

  1. The ASSOCIATION MUST be set to 0 (The "DESIGNATOR" field is associated with the addressed logical unit).
  2. The DESIGNATOR TYPE MUST be set to one of four values that are required for the mandatory logical unit name in Section 7.7.3 of [SPC4], as explicitly listed in the pnfs_scsi_designator_type enumeration:
    • PS_DESIGNATOR_T10 - based on T10 vendor ID
    • PS_DESIGNATOR_EUI64 - based on EUI-64
    • PS_DESIGNATOR_NAA - Network Address Authority (NAA)
    • PS_DESIGNATOR_NAME - SCSI name string
  3. Any other association or designator type MUST NOT be used. Use of T10 vendor IDs is discouraged when one of the other types can be used. πŸ™ƒ

the "CODE SET" VPD page field gets stored in the sbv_code_set field of the pnfs_scsi_base_volume_info4 data structure, the "DESIGNATOR TYPE" is stored in sbv_designator_type, and the DESIGNATOR is stored in sbv_designator. because an XDR array is used, the "DESIGNATOR LENGTH" field doesn't need to be set separately. only certain combos of sbv_code_set and sbv_designator_type are valid, so check [SPC4] for the details. also note that ASCII MAY be used as the code set for UTF-8 text that contains only printable ASCII characters. ✍️

ALSO, a Device Identification VPD page MAY contain multiple descriptors with the same association, code set, and designator type. so NFS clients MUST check all the descriptors for a possible match to sbv_code_set, sbv_designator_type, and sbv_designator. don't stop at the first one, periodt πŸ’…

storage devices like storage arrays can have multiple physical network interfaces that don't need to be connected to a common network. that means a pNFS client can have simultaneous multipath access to the same storage volumes through different ports on different networks. picking one or multiple ports to access the storage device is left up to the client 🌸

last thing: the server returns a persistent reservation key in the sbv_pr_key field. see Section 2.4.10 for more details on how persistent reservations get used πŸ”‘

2.3.2. Volume Topology ✨

okay so the SCSI layout's volume topology is described using the volume types below πŸŽ€ The pieces of the topology sit in an array, and a piece can point at other pieces by using their array indices. Those pointers are where the MAY lives, so a component MAY refer to other components this way πŸ¦‹

/// enum pnfs_scsi_volume_type4 {
///     PNFS_SCSI_VOLUME_SLICE  = 1,  /* volume is a slice of
///                                      another volume */
///     PNFS_SCSI_VOLUME_CONCAT = 2,  /* volume is a
///                                      concatenation of
///                                      multiple volumes */
///     PNFS_SCSI_VOLUME_STRIPE = 3   /* volume is striped across
///                                      multiple volumes */
///     PNFS_SCSI_VOLUME_BASE   = 4,  /* volume maps to a single
///                                      LU */
/// };
///

/// /*
///  * Code sets from SPC-4.
///  */
/// enum pnfs_scsi_code_set {
///     PS_CODE_SET_BINARY     = 1,
///     PS_CODE_SET_ASCII      = 2,
///     PS_CODE_SET_UTF8       = 3
/// };
///
/// /*
///  * Designator types taken from SPC-4.
///  *
///  * Other values are allocated in SPC-4 but are not mandatory to
///  * implement or aren't logical unit names.
///  */
/// enum pnfs_scsi_designator_type {
///     PS_DESIGNATOR_T10      = 1,
///     PS_DESIGNATOR_EUI64    = 2,
///     PS_DESIGNATOR_NAA      = 3,
///     PS_DESIGNATOR_NAME     = 8
/// };
///
/// /*
///  * Logical unit name + reservation key.
///  */
/// struct pnfs_scsi_base_volume_info4 {
///     pnfs_scsi_code_set             sbv_code_set;
///     pnfs_scsi_designator_type      sbv_designator_type;
///     opaque                         sbv_designator<>;
///     uint64_t                       sbv_pr_key;
/// };
///

/// struct pnfs_scsi_slice_volume_info4 {
///     offset4  ssv_start;            /* offset of the start of
///                                       the slice in bytes */
///     length4  ssv_length;           /* length of slice in
///                                       bytes */
///     uint32_t ssv_volume;           /* array index of sliced
///                                       volume */
/// };
///

///
/// struct pnfs_scsi_concat_volume_info4 {
///     uint32_t  scv_volumes<>;       /* array indices of volumes
///                                       that are concatenated */
/// };

///
/// struct pnfs_scsi_stripe_volume_info4 {
///     length4  ssv_stripe_unit;      /* size of stripe in bytes */
///     uint32_t ssv_volumes<>;        /* array indices of
///                                       volumes that are striped
///                                       across -- MUST be same
///                                       size */
/// };

///
/// union pnfs_scsi_volume4 switch (pnfs_scsi_volume_type4 type) {
///     case PNFS_SCSI_VOLUME_BASE:
///         pnfs_scsi_base_volume_info4 sv_simple_info;
///     case PNFS_SCSI_VOLUME_SLICE:
///         pnfs_scsi_slice_volume_info4 sv_slice_info;
///     case PNFS_SCSI_VOLUME_CONCAT:
///         pnfs_scsi_concat_volume_info4 sv_concat_info;
///     case PNFS_SCSI_VOLUME_STRIPE:
///         pnfs_scsi_stripe_volume_info4 sv_stripe_info;
/// };
///
/// /* SCSI layout-specific type for da_addr_body */
/// struct pnfs_scsi_deviceaddr4 {
///     pnfs_scsi_volume4 sda_volumes<>; /* array of volumes */
/// };
///

The pnfs_scsi_deviceaddr4 structure is basically a big bucket that lets you nest volumes as deep as you like πŸͺ† The aggregations you're allowed to build are stripes, concatenations, and slices. Here's the lowkey important bit: a volume topology written in pnfs_scsi_deviceaddr4 will always resolve down to a set of pnfs_scsi_volume_type4 PNFS_SCSI_VOLUME_BASE volumes πŸ’€ The array is ordered so that the root of the hierarchy is the last element. Concat, slice, and stripe volumes MUST refer to volumes defined by lower indexed elements of the array. No cap, that ordering is the whole game 🧚

The server hands back pnfs_scsi_deviceaddr4 as the storage-protocol-specific opaque field da_addr_body inside the device_addr4 structure, once a GETDEVICEINFO operation succeeds [RFC5661] πŸ’œ

As we said earlier, every device_addr4 eventually resolves to volumes of type PNFS_SCSI_VOLUME_BASE 🌈 Complicated hierarchies can be made of dozens of volumes, each with a bunch of components, so the device address can easily need several kilobytes 😭 The client SHOULD be prepared to allocate a large buffer to hold the result. If the server returns NFS4ERR_TOOSMALL, the client SHOULD allocate a buffer of at least gdir_mincount_bytes to hold the expected result, and then retry the GETDEVICEINFO request 🫢


2.4. Data Structures: Extents and Extent Lists 🌸

A pNFS SCSI layout is a list of extents sitting inside a flat array of data blocks on a volume πŸ“ You can find out the details of the volume topology by using the GETDEVICEINFO operation. The SCSI layout describes the individual block extents on the volume that make up the file. The offsets and length in an extent are measured in bytes.

/// enum pnfs_scsi_extent_state4 {
///     PNFS_SCSI_READ_WRITE_DATA = 0, /* the data located by
///                                       this extent is valid
///                                       for reading and
///                                       writing. */
///     PNFS_SCSI_READ_DATA      = 1,  /* the data located by this
///                                       extent is valid for
///                                       reading only; it may not
///                                       be written. */
///     PNFS_SCSI_INVALID_DATA   = 2,  /* the location is valid; the
///                                       data is invalid.  It is a
///                                       newly (pre-)allocated
///                                       extent.  The client MUST
///                                       not read from this
///                                       space. */
///     PNFS_SCSI_NONE_DATA      = 3   /* the location is invalid.
///                                       It is a hole in the file.
///                                       The client MUST NOT read
///                                       from or write to this
///                                       space. */
/// };

///
/// struct pnfs_scsi_extent4 {
///     deviceid4    se_vol_id;         /* id of the volume on
///                                        which extent of file is
///                                        stored */
///     offset4      se_file_offset;    /* starting byte offset
///                                        in the file */
///     length4      se_length;         /* size in bytes of the
///                                        extent */
///     offset4      se_storage_offset; /* starting byte offset
///                                        in the volume */
///     pnfs_scsi_extent_state4 se_state;
///                                     /* state of this extent */
/// };
///

/// /* SCSI layout-specific type for loc_body */
/// struct pnfs_scsi_layout4 {
///     pnfs_scsi_extent4 sl_extents<>;
///                                    /* extents that make up this
///                                       layout */
/// };
///

The SCSI layout is a list of extents that map regions of the file to locations on a volume πŸ—ΊοΈ The se_storage_offset field in each extent points to a location on the volume named by the se_vol_id field in that extent. And se_vol_id is just shorthand for the whole topology of the volume the file lives on 🧠 The client is responsible for translating that volume-relative offset into an offset on the right underlying SCSI LU, so that part is on the client, bestie πŸ’…

Each extent maps a region of the file onto a chunk of the specified LU. The se_file_offset, se_length, and se_state fields are valid for every extent the server returns. The se_storage_offset field is trickier, though: how you read it depends on the value of se_state, as follows (in increasing order):

  • PNFS_SCSI_READ_WRITE_DATA se_storage_offset is valid and points to valid/initialized data that can be read and written. ✍️
  • PNFS_SCSI_READ_DATA se_storage_offset is valid and points to valid/initialized data that can only be read. Write operations are prohibited. 🚫
  • PNFS_SCSI_INVALID_DATA se_storage_offset is valid but points to invalid, uninitialized data. This data MUST not be read from the disk until it has been initialized. A read request for a PNFS_SCSI_INVALID_DATA extent MUST fill the user buffer with zeros, unless the extent is covered by a PNFS_SCSI_READ_DATA extent of a copy-on-write file system. Write requests MUST write whole server-sized blocks to the disk; bytes not initialized by the user MUST be set to zero. Any write to storage in a PNFS_SCSI_INVALID_DATA extent changes the written portion of the extent to PNFS_SCSI_READ_WRITE_DATA; the pNFS client is responsible for reporting this change via LAYOUTCOMMIT. πŸ₯Ή
  • PNFS_SCSI_NONE_DATA se_storage_offset is not valid, and this extent MAY not be used to satisfy write requests. Read requests MAY be satisfied by zero-filling as for PNFS_SCSI_INVALID_DATA. PNFS_SCSI_NONE_DATA extents MAY be returned by requests for readable extents; they are never returned if the request was for a writable extent. πŸ•³οΈ

An extent list holds all the relevant extents, ordered by increasing se_file_offset for each extent. If two extents tie on that, they're broken by increasing order of the extent state (se_state) πŸŽ€

2.4.1. Layout Requests and Extent Lists ✨

Okay bestie, every layout request comes in with at least three parameters πŸŽ€: the file offset, the desired size, and the minimum size. πŸ’– If the status of a request says success, the extent list that comes back MUST meet these criteria:

  • A request for a readable (but not writable) layout MUST return either PNFS_SCSI_READ_DATA or PNFS_SCSI_NONE_DATA extents. It SHALL NOT return PNFS_SCSI_INVALID_DATA or PNFS_SCSI_READ_WRITE_DATA extents. πŸ™ˆ
  • A request for a writable layout MUST return PNFS_SCSI_READ_WRITE_DATA or PNFS_SCSI_INVALID_DATA extents, and it MAY return additional PNFS_SCSI_READ_DATA extents for ranges covered by PNFS_SCSI_INVALID_DATA extents, so clients can do copy-on-write operations. πŸ¦‹ A request for a writable layout SHALL NOT return PNFS_SCSI_NONE_DATA extents.
  • The first extent in the list MUST contain the requested starting offset. 🎯
  • The total size of extents within the requested range MUST cover at least the minimum size. There is one exception: the total size MAY be smaller if only readable extents were requested and EOF is encountered. 🌸
  • Extents in the extent list MUST be logically contiguous for a read-only layout. For a read-write layout, the set of writable extents (i.e., excluding PNFS_SCSI_READ_DATA extents) MUST be logically contiguous. Every PNFS_SCSI_READ_DATA extent in a read-write layout MUST be covered by one or more PNFS_SCSI_INVALID_DATA extents. This overlap of PNFS_SCSI_READ_DATA and PNFS_SCSI_INVALID_DATA extents is the only permitted extent overlap. 🧚
  • Extents MUST be ordered in the list by starting offset, with PNFS_SCSI_READ_DATA extents preceding PNFS_SCSI_INVALID_DATA extents in the case of equal se_file_offsets. πŸ‘‘

According to [RFC5661], if the minimum requested size, loga_minlength, is zero, that's a signal to the metadata server that the client wants any layout at offset loga_offset or less that the metadata server has "readily available". ✨ Since there's no clear definition of that phrase for the SCSI layout type, the metadata server SHOULD do the following when loga_minlength is zero:

  • when processing requests for readable layouts, return all such layouts, even if some extents are in the PNFS_SCSI_NONE_DATA state. πŸ’…
  • when processing requests for writable layouts, return extents that can be returned in the PNFS_SCSI_READ_WRITE_DATA state. πŸ”₯

2.4.2. Layout Commits πŸ’Œ

The pnfs_scsi_layoutupdate4 data structure is what the client sends as the SCSI layout-specific argument in a LAYOUTCOMMIT operation. πŸ“¦ Here's the code:

     ///
     /// /* SCSI layout-specific type for lou_body */
     ///
     /// struct pnfs_scsi_range4 {
     ///     offset4      sr_file_offset;   /* starting byte offset
     ///                                       in the file */
     ///     length4      sr_length;        /* size in bytes */
     /// };
     ///
     /// struct pnfs_scsi_layoutupdate4 {
     ///     pnfs_scsi_range4 slu_commit_list<>;
     ///                                    /* list of extents that
     ///                                     * now contain valid data.
     ///                                     */
     /// };

The slu_commit_list field is a list of regions in the file layout that used to be in the PNFS_SCSI_INVALID_DATA state but have been written by the client. Those regions SHOULD now be considered in the PNFS_SCSI_READ_WRITE_DATA state. πŸŽ€ The extents in the commit list MUST be disjoint and MUST be sorted by sr_file_offset. πŸ“‹

Implementors should be aware that a server MAY be unable to commit regions at a granularity smaller than a file system block (typically 4 KB or 8 KB). 🧐 As noted above, the block size that the server uses is available as an NFSv4 attribute. Any extents included in the slu_commit_list MUST be aligned to this granularity and have a size that is a multiple of this granularity. πŸ“

Since the block in question is in state PNFS_SCSI_INVALID_DATA, byte ranges that weren't written SHOULD be filled with zeros. 0️⃣ This applies even if it looks like the area being written is beyond what the client believes to be the end of file. πŸ™ƒ

2.4.3. Layout Returns πŸ¦‹

A LAYOUTRETURN operation is the client explicitly releasing resources it's holding. 🫢 This MAY be done in response to a CB_LAYOUTRECALL, or before any recall, so a future CB_LAYOUTRECALL is avoided. ✨ When the LAYOUTRETURN operation specifies a LAYOUTRETURN4_FILE return type, the layoutreturn_file4 data structure says which region of the file layout the client no longer needs. 🌈

The LAYOUTRETURN operation doesn't carry any data specific to the SCSI layout. The opaque lrf_body field of the layoutreturn_file4 data structure MUST have length zero. πŸ™…β€β™€οΈ

2.4.4. Layout Revocation πŸ’€

Layouts MAY be unilaterally revoked by the server. That can happen when the client's lease time runs out, or when the client doesn't return a recalled layout in a timely manner. 😬 For the SCSI layout type, the server does this by fencing the client off from access to storage, as described in Section 2.4.10. 🚫 When this happens, all I/Os issued by the fenced-off client MUST be rejected by the storage, and that includes any in-flight I/Os the client issued before the layout was revoked. It's giving no escape. πŸ”’

Note that this operation can only work at the host/LU level. ⚠️ So if one of a client's layouts is unilaterally revoked by the server, it will effectively render useless all of the client's layouts for files located on the storage units that make up the volume. Even layouts for files in other file systems can end up useless. 😭 See Section 2.4.10.5 for a discussion of recovery from fencing. 🧯

2.4.5. Client Copy-on-Write Processing πŸ”₯

Copy-on-write is a mechanism used to support file and/or file system snapshots. πŸ“Έ When writing to unaligned regions, or to regions smaller than a file system block, the writer MUST copy the portions of the original file data to a new location on disk. πŸ’Ύ This behavior can be implemented either on the client or the server. πŸ€·β€β™€οΈ The paragraphs below describe how a pNFS SCSI layout client handles access to a file that needs copy-on-write semantics. πŸ‘€

Distinguishing the PNFS_SCSI_READ_WRITE_DATA and PNFS_SCSI_READ_DATA extent types, together with the allowed overlap of PNFS_SCSI_READ_DATA extents with PNFS_SCSI_INVALID_DATA extents, lets pNFS clients do copy-on-write processing. 🧠 In classic NFS, the server would do this operation. But pNFS lets clients do direct block access, so it makes sense for clients to take part in copy-on-write operations too. 🌸 All SCSI pNFS clients MUST support this copy-on-write processing. πŸ’–

When a client wants to write data covered by a PNFS_SCSI_READ_DATA extent, it MUST have requested a writable layout from the server. That layout will contain PNFS_SCSI_INVALID_DATA extents covering all the data ranges of that layout's PNFS_SCSI_READ_DATA extents. 🧩 More precisely, for any se_file_offset range covered by one or more PNFS_SCSI_READ_DATA extents in a writable layout, the server MUST include one or more PNFS_SCSI_INVALID_DATA extents in the layout that cover the same se_file_offset range. πŸŽ€

When writing to an area like that, the client MUST effectively copy the data from the PNFS_SCSI_READ_DATA extent for any partial blocks of the se_file_offset and range. Then it merges in the changes to be written and writes the result to the PNFS_SCSI_INVALID_DATA extent for the blocks of that se_file_offset and range. πŸͺ„ So if entire blocks are being overwritten by an operation, the corresponding PNFS_SCSI_READ_DATA blocks don't need to be fetched. But any partial-block writes MUST be merged with data fetched via PNFS_SCSI_READ_DATA extents before the result gets stored via PNFS_SCSI_INVALID_DATA extents. πŸ§ƒ For the purposes of this discussion, "entire blocks" and "partial blocks" refer to the block size of the server's file system. πŸ“

Storing data in a PNFS_SCSI_INVALID_DATA extent converts the written portion of that extent to a PNFS_SCSI_READ_WRITE_DATA extent. βœ… All subsequent reads MUST be performed from this extent, and the corresponding portion of the PNFS_SCSI_READ_DATA extent MUST NOT be used after data has been stored in a PNFS_SCSI_INVALID_DATA extent. 🚷 If a client writes only a portion of an extent, the extent MAY be split at block-aligned boundaries. βœ‚οΈ

When a client wants to write data to a PNFS_SCSI_INVALID_DATA extent that isn't covered by a PNFS_SCSI_READ_DATA extent, it MUST treat that write exactly like a write to a file not involved with copy-on-write semantics. πŸ’… So data MUST be written in at least block-sized increments and aligned to multiples of block-sized offsets, and unwritten portions of blocks MUST be zero filled. 🫧

2.4.6. Extents Are Permissions ✨

okay bestie, this one is sooo important 🫢 layout extents handed to pNFS clients are basically permission slips. PNFS_SCSI_READ_DATA and PNFS_SCSI_NONE_DATA are read-only (and PNFS_SCSI_NONE_DATA reads as zeros πŸ™ˆ), while PNFS_SCSI_READ_WRITE_DATA and PNFS_SCSI_INVALID_DATA are read-write (PNFS_SCSI_INVALID_DATA also reads as zeros, and any write turns it into PNFS_SCSI_READ_WRITE_DATA πŸ’…). This is the only way a client gets permission to do direct I/O to storage devices, so a pNFS client MUST NOT perform direct I/O operations that aren't permitted by an extent it holds. 🚫 Because clients follow this rule, the pNFS server stays in charge of any storage device operations that could conflict. It can figure out what actually conflicts and avoid it by granting and recalling extents to and from clients. Main character server energy πŸ‘‘

If a client makes a layout request that clashes with an existing layout delegation, the request gets rejected with NFS4ERR_LAYOUTTRYLATER. The client is then expected to retry after a short interval πŸ¦‹ During that wait, the server SHOULD recall the conflicting part of the layout delegation from whichever client is holding it. ngl, this reject-and-retry approach doesn't stop client starvation when a bunch of people are fighting over the layout of one file 😭 So a pNFS server SHOULD implement a mechanism to prevent starvation. One idea: the server keeps a queue of rejected layout requests. Every new layout request gets checked against the queue, and if it conflicts with a previously rejected request, the newer one can be rejected. Once the original client retries, its queue entry can be cleared, or the entry can be removed once it gets old enough 🌸

NFSv4 supports mandatory locks and share reservations. Clients use these to limit which I/O operations other clients are allowed to do πŸ”’ All I/O eventually lands on the NFSv4 server, so the server is in a great spot to enforce those restrictions. BUT with pNFS layouts, the clients holding the layouts send I/O straight to the storage devices that host the data πŸ’€ Those devices have zero knowledge of files, mandatory locks, or share reservations, so they can't enforce anything. That's why the NFSv4 server MUST NOT grant layouts that conflict with mandatory locks or share reservations. And if a conflicting mandatory lock request or a conflicting OPEN request shows up, the server MUST recall the part of the layout that's in conflict before it grants that request πŸ”₯


2.4.7. Partial-Block Updates 🧱

SCSI storage devices don't do byte granularity access. They can only do reads and writes atomically at the block level πŸ“ So writing anything smaller than a block, or anything that isn't block aligned, means read-modify-write cycles. Here's the tea: if several clients write to the same block, data can get corrupted even when the byte ranges the apps wrote don't overlap at all 😱 So when multiple clients want to access the same block, a pNFS server MUST prevent these conflicts by using a concurrency control policy of single writer XOR multiple readers for each data block ✨


2.4.8. End-of-File Processing πŸ“„

The end-of-file location can change in two ways. It can change implicitly, as a result of a WRITE or LAYOUTCOMMIT past the current end of file, or explicitly, as a result of a SETATTR request πŸ’– Usually, when an NFSv4 client truncates a file with SETATTR, the server frees any disk blocks belonging to the file beyond the new end-of-file byte. It also MUST write zeros to the part of the new end-of-file block that's past the new end-of-file byte 🧹 Those actions make any pNFS layouts pointing at the freed or written blocks semantically invalid πŸ™ƒ That's why the server MUST recall from clients any portions of pNFS layouts that refer to blocks the server is about to free or write, before it does the file truncation. Recalls can take a while to finish. As [RFC5661] explains, if the server can't respond to the client's SETATTR request in a reasonable amount of time, it SHOULD reply with the error NFS4ERR_DELAY ⏳

Blocks in the PNFS_SCSI_INVALID_DATA state that sit beyond the new end-of-file block are a special case 🧚 The server has reserved those blocks for a pNFS client holding a writable layout for the file. But the client hasn't committed them yet, so they aren't part of the file mapping on disk. The server MAY free these blocks while it processes the SETATTR request. If it does, the server MUST recall any layouts from pNFS clients that refer to those blocks before it processes the truncate. If the server does not free the PNFS_SCSI_INVALID_DATA blocks while handling the SETATTR request, it doesn't need to recall layouts that only refer to those PNFS_SCSI_INVALID_DATA blocks 🌈

When a file gets extended implicitly by a WRITE or LAYOUTCOMMIT past the current end of file, or extended explicitly by a SETATTR request, the server doesn't need to recall any portions of any pNFS layouts πŸŽ€


2.4.9. Layout Hints 🚫

The layout hint attribute from [RFC5661] isn't supported by the SCSI layout, so it's a no-go πŸ™…β€β™€οΈ The pNFS server MUST reject setting a layout hint attribute with a loh_type value of LAYOUT4_SCSI_VOLUME during OPEN or SETATTR operations. On a file system that only supports the SCSI layout, a server MUST NOT report the layout_hint attribute in the supported_attrs attribute. Bestie, don't even advertise it πŸ’…


2.4.10. Client Fencing 🚧

The pNFS SCSI protocol has to handle situations where a system failure, usually some kind of network connectivity issue, means the server has to unilaterally revoke a client's extents after that client doesn't respond to a CB_LAYOUTRECALL request 😀 The fix is to fence off the non-responding client so it can't access the storage device.

The pNFS SCSI protocol does fencing with persistent reservations (PRs), which is pretty similar to how existing shared disk file systems do it πŸ” The MDS puts a PR of type "Exclusive Access - Registrants Only" on each SCSI LU exported to pNFS clients. That blocks access from any client that doesn't have an outstanding device ID giving it a reservation key for the LU, and it lets the MDS revoke access to the logical unit at any time πŸ‘‘


2.4.10.1. PRs -- Key Generation πŸ—οΈ

To fence individual systems, each system MUST use a unique persistent reservation key πŸ”‘ [SPC4] doesn't say how to generate keys, so this document hands that job to the MDS. The MDS MUST generate a key for itself before exporting a volume, and a key for each client that accesses SCSI layout volumes. Individuals keys for each volume that a client can access are permitted but not required πŸ¦‹


2.4.10.2. PRs -- MDS Registration and Reservation πŸ“

Before the MDS returns a PNFS_SCSI_VOLUME_BASE volume to the client, it has to get the volume ready for fencing with PRs ✨ It does this by registering the reservation generated for the MDS with the device, using the "PERSISTENT RESERVE OUT" command with a service action of "REGISTER". Then it sends a "PERSISTENT RESERVE OUT" command with a service action of "RESERVE" and the "TYPE" field set to 8h (Exclusive Access - Registrants Only). To make sure all I_T nexuses (see Section 3.1.45 of [SAM-5]) are registered, the MDS SHOULD set the "All Target Ports" (ALL_TG_PT) bit when registering the key, or otherwise make sure the registration happens for each target port. It MUST do registration for each initiator port 🫢


2.4.10.3. PRs -- Client Registration πŸ™‹β€β™€οΈ

Before the client does its first I/O to a device returned from a GETDEVICEINFO operation, it registers the registration key returned in sbv_pr_key with the storage device. It does this by issuing a "PERSISTENT RESERVE OUT" command with a service action of REGISTER and the "SERVICE ACTION RESERVATION KEY" set to the reservation key returned in sbv_pr_key πŸ’– To make sure all I_T nexuses are registered, the client SHOULD set the "All Target Ports" (ALL_TG_PT) bit when registering the key, or otherwise make sure the registration happens for each target port. It MUST do registration for each initiator port too 🌸

When a client stops using a device it got earlier from GETDEVICEINFO, it MUST unregister the key it registered earlier. It does that by issuing a "PERSISTENT RESERVE OUT" command with a service action of "REGISTER" and the "RESERVATION KEY" set to the earlier registered reservation key 🧹


2.4.10.4. PRs -- Fencing Action 🚨

If a client stops responding, the MDS fences it by issuing a "PERSISTENT RESERVE OUT" command. The service action is "PREEMPT" or "PREEMPT AND ABORT", the "RESERVATION KEY" field is set to the server's reservation key, the service action "RESERVATION KEY" field is set to the reservation key associated with the non-responding client, and the "TYPE" field is set to 8h (Exclusive Access - Registrants Only) πŸ₯·

After the MDS preempts a client, all of that client's I/O to the LU fails πŸ’€ At this point the client SHOULD return any layout that refers to the device ID pointing to the LU. Also, the client can tell I/O errors caused by fencing apart from other errors, because they come back with the "RESERVATION CONFLICT" SCSI status. Check [SPC4] for the details πŸ“š


2.4.10.5. Client Recovery after a Fence Action πŸ›Ÿ

If a client detects a "RESERVATION CONFLICT" SCSI status (an I/O error) on the storage devices, it MUST commit all layouts that use the storage device through the MDS, return all outstanding layouts for the device, forget the device ID, and unregister the reservation key 🫠 Future GETDEVICEINFO calls MAY point to the storage device again. If they do, the client registers again, using the key it's given (via sbv_pr_key) at that time 🌈


2.5. Crash Recovery Issues πŸ’«

A critical requirement in crash recovery is that both the client and the server know when the other one has failed πŸ‘€ It's also required that a client sees a consistent view of data across server restarts. These requirements and a full discussion of crash recovery issues are covered in Section 8.4 ("Crash Recovery") of the NFSv4.1 specification [RFC5661]. This document adds extra crash recovery material that's specific to the SCSI layout 🧠

When the server crashes while the client holds a writable layout, the client has written data to blocks covered by that layout, and those blocks are still in the PNFS_SCSI_INVALID_DATA state, the client has two options for recovery 🧩 If the data written to those blocks is still in the client's cache, the client can simply rewrite the data via NFSv4 once the server is back online. But if the data is no longer in the client's cache, the client MUST NOT attempt to source the data from the data servers 🚫 Instead, it SHOULD try to commit the blocks in question to the server during the server's recovery grace period, by sending a LAYOUTCOMMIT with the "loca_reclaim" flag set to true. This process is described in detail in Section 18.42.4 of [RFC5661] πŸŽ‰

2.6. Recalling Resources: CB_RECALL_ANY πŸ“£

okay so the server MAY decide that it can't hold all the state for layouts without running out of resources 😭 if that happens, it's free to recall individual layouts using CB_LAYOUTRECALL to lighten the load, or it MAY choose to ask the client to return any layout 🫢

The NFSv4.1 specification [RFC5661] defines the following types:

       const RCA4_TYPE_MASK_BLK_LAYOUT = 4;

       struct CB_RECALL_ANY4args {
              uint32_t      craa_objects_to_keep;
              bitmap4       craa_type_mask;
       };

bestie, here's the vibe πŸ’… when the server sends a CB_RECALL_ANY request to a client and sets the RCA4_TYPE_MASK_BLK_LAYOUT bit in craa_type_mask, the client SHOULD immediately respond with NFS4_OK. then it asynchronously returns complete file layouts until the number of files with layouts cached on the client is less than craa_object_to_keep ✨ (yes, that's the spelling in the spec, so we keep it πŸ™ˆ)

2.7. Transient and Permanent Errors ⏳

the server can answer LAYOUTGET with a bunch of different error statuses πŸŽ€ some of them are just temporary vibes, and others are more "not happening soon" energy πŸ’€

NFS4ERR_RECALLCONFLICT means the server recently sent a CB_LAYOUTRECALL to the requesting client, so the client has to deal with that recall before it can process the layout request πŸ”₯ the client can wait for the recall to arrive and get processed, or it can retry as NFS4ERR_TRYLATER, which we'll get to in a sec 🧚

NFS4ERR_TRYLATER shows up when the server can't hand over the layout right now 🌸 this might be because of limits on writable sharing of blocks by multiple clients, or because of a clash with a recallable lock (like a delegation, for example). either way, a reasonable move is for the client to wait several milliseconds and retry πŸ“ the client SHOULD keep track of how many retries it's done, and if it isn't making forward progress, the client SHOULD abandon the attempt to get a layout and do its READ and WRITE operations by sending them to the server πŸ™ˆ

NFS4ERR_LAYOUTUNAVAILABLE MAY be returned by the server if layouts aren't supported for the requested file or its containing file system πŸ’… the server MAY also send this error if it's in the middle of migrating the file from secondary storage, if there's a conflicting lock that would stop the layout from being granted, or if any other reason leaves the server unable to supply the layout 😭 when a client gets NFS4ERR_LAYOUTUNAVAILABLE, it SHOULD abandon the attempt to get a layout and send its READ and WRITE operations to the MDS instead. it's not expected that a client will cache the file's layoutunavailable state forever πŸ¦‹ so when the file is closed or opened by the client, issuing a new LAYOUTGET is appropriate ✨

2.8. Volatile Write Caches 🧊

many storage devices have volatile write caches that need an explicit flush to save the data from write operations to stable storage 🫧 storage devices implementing [SBC3] should show that they have a volatile write cache by setting the Write Cache Enable (WCE) bit to 1 in the Caching mode page πŸ’– when a volatile write cache is in use, the pNFS server MUST make sure the volatile write cache has been committed to stable storage before the LAYOUTCOMMIT operation returns, by using one of the SYNCHRONIZE CACHE commands πŸ”₯ no skipping this one, periodt πŸ’€

3. Enforcing NFSv4 Semantics πŸ›‘οΈ

the SCSI persistent reservations feature lets the MDS control which individual client machines get access to specific LUs πŸŽ€ clients can be allowed to read or write certain block devices, or they can be stopped from doing so πŸ™… finer-grained access control methods are not generally available 😭

so, certain responsibilities for enforcing NFSv4 semantics (security and locking included) get handed off to pNFS clients when SCSI layouts are in use 🫢 the metadata server's whole job is to grant layouts appropriately, and the pNFS clients have to be trusted to only do the accesses the layout extents they hold allow (so, no touching storage for files where they don't hold a layout extent) πŸ‘‘ in general, the server can't stop a client holding a layout for a file from accessing parts of the physical disk that the layout doesn't cover πŸ™ˆ it also can't stop a client from accessing blocks covered by a layout the client already returned πŸ’€ the pNFS client has to respect the layout model for this mapping type so it respects NFSv4 semantics properly πŸ’œ

there's more: the storage has no way to tell which NFSv4 entity (principal, openowner, or lockowner) an I/O operation is being done for πŸ₯Ί that can limit what functionality gets supported, and it may mean the pNFS client has to carry out server policies that layouts can't describe 😀 if layouts that were granted become invalid, the server can choose to recall them πŸ” if communication problems stop that from happening, the server may revoke the layouts 🚫 and that revocation comes with changes to persistent reservations that stop the client from doing SCSI access to the LUs in question ✨

3.1. Use of Open Stateids πŸ”‘

making these NFSv4 semantic constraints work is kinda complicated, because the actors have different granularities for the different types of functionality being enforced 🧩

  • to enforce security constraints for particular principals.
  • to enforce locking constraints for particular owners (openowners and lockowners).

the big idea underneath both of these is that a pNFS client must not issue a SCSI I/O operation unless it has both of these things πŸ’œ

  • a valid open stateid for the file in question, which allows the type of I/O being done and is associated with the openowner and principal the I/O is done on behalf of.
  • a valid layout stateid for the file in question that covers the byte range the I/O is for and allows that type of I/O.

so, if the equivalent of I/O with an anonymous or write-bypass stateid is going to happen, it MUST NOT be done using the pNFS SCSI layout type πŸ™…β€β™€οΈ the client MAY try that kind of I/O using READs and WRITEs that don't use pNFS and are directed to the MDS πŸ¦‹

when open stateids get revoked (because of lease expiration or any form of administrative revocation), the server MUST recall all layouts that allow I/O on any of the files where the open revocation happened. if those layouts can't be returned successfully, the client MUST be fenced 🚨

3.2. Enforcing Security Restrictions πŸ”’

the restriction above does enough to enforce security restrictions when the principal doing the I/O is the same one that opened the file ✨ the server is responsible for checking that the I/O mode requested by the OPEN is allowed for the principal doing the OPEN πŸ‘‘ if the right sort of I/O gets done on behalf of that same principal, the security restriction is enforced 🫢

if I/O is done by a different principal than the one that opened the file, the client SHOULD send that I/O to the metadata server instead of doing it directly to the storage device πŸ“

3.3. Enforcing Locking Restrictions πŸ”

mandatory whole-file locking through share reservations is enforced when the pNFS client follows the requirement set out in Section 3.1 πŸ’– since doing I/O needs a valid open stateid, an I/O that breaks an existing share reservation could only happen if the server let conflicting open stateids exist πŸ™ˆ

here's where it gets messy 😭 the SCSI layout type makes mandatory byte-range locks really hard to enforce πŸ’€ since layouts are granted to clients and not owners, the pNFS client has no way to arbitrate between multiple lockowners on the same client πŸ₯€ picture this: lockowner A is doing a write, and while that I/O is pending, lockowner B asks for a mandatory byte-range lock on a range that might overlap the pending I/O 😬 the lock request can't be granted while the I/O is pending πŸ›‘ in a non-pNFS setup, the server would wait for the pending I/O before granting the mandatory lock 🫧 in a pNFS setup, though, the server doesn't issue the I/O itself, so it can't wait for it to finish πŸ™ƒ the server may recall such layouts, but then it has no way to tell which ones belong to lockowners A and B, which makes it hard to let B do I/O while stopping A from doing the same πŸ˜΅β€πŸ’« so the MDS needs to successfully recall all layouts that overlap the range being locked before it returns a successful response to the LOCK request πŸ”₯ while the lock is in effect, the server SHOULD answer requests for layouts that overlap a currently locked area with NFS4ERR_LAYOUTUNAVAILABLE πŸ’… to keep the logic simple, a server MAY do this for all layout requests on that file as long as any byte-range locks are in effect 🧠

because of all that, it can be hard for servers that support mandatory byte-range locks to also support SCSI layouts 😩 servers can support advisory byte-range locks instead 🌈 the NFSv4 protocol doesn't currently have a way to tell whether byte-range lock support on a file system will be mandatory or advisory, except by trying an operation, which would conflict if mandatory locking were in effect πŸ™ˆ so, to avoid confusion, servers SHOULD NOT switch between mandatory and advisory byte-range locking based on whether any SCSI layouts have been obtained, or whether a client holding a SCSI layout has asked for a byte-range lock πŸ’œβœ¨

4. Security Considerations ✨

Okay bestie, security time πŸ”’ Accessing SCSI storage happens way down at a lower layer of the I/O stack than NFSv4 does, so NFSv4 security isn't directly applicable to protocols that touch that storage directly πŸ₯Ί. Depending on the protocol, some NFSv4 security mechanisms (like encryption and cryptographic integrity) might not be available, or they might show up through different means 🫠. At one extreme, pNFS with SCSI layouts can be paired with storage access protocols like Serial Attached SCSI [SAS3] that provide essentially no security functionality πŸ’€. At the other extreme, pNFS can be used with storage protocols like iSCSI [RFC7143] that can provide significant security functionality πŸ”.

It's on the people administering and deploying pNFS with a SCSI storage access protocol to make sure that protocol gets appropriate protection. Physical security is a common move for protocols that aren't based on IP 🏰. If the security requirements for the storage protocol can't be met, pNFS SCSI layouts SHOULD NOT be used 🚫.

When you're using IP-based storage protocols like iSCSI, IPsec should be used, as outlined in [RFC3723] and updated in [RFC7146] πŸ›‘οΈ.

When security is available for a storage protocol, it's usually at a different granularity and with a different notion of identity than NFSv4 🀯. Like, NFSv4 controls user access to files, while iSCSI controls initiator access to volumes. The responsibility for enforcing correct correspondences between these security layers lands on the pNFS client πŸ‘€. Same vibe as the first paragraph of this section: if the security requirements are such that client-side protection from access to storage outside of the layout isn't enough, pNFS SCSI layouts SHOULD NOT be used 🚨.


5. IANA Considerations πŸ“‹

IANA has assigned a new pNFS layout type in the "pNFS Layout Types Registry" as follows πŸ’…:

Layout Type Name: LAYOUT4_SCSI
Value:            0x00000005
RFC:              RFC 8154
How:              L
Minor Versions:   1

6. Normative References πŸ“š

Here's the full reference list, copied exactly so every detail is still there ✨:

   [LEGAL]    IETF Trust, "Legal Provisions Relating to IETF Documents",
              March 2015, <http://trustee.ietf.org/docs/
              IETF-Trust-License-Policy.pdf>.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <http://www.rfc-editor.org/info/rfc2119>.

   [RFC3723]  Aboba, B., Tseng, J., Walker, J., Rangan, V., and F.
              Travostino, "Securing Block Storage Protocols over IP",
              RFC 3723, DOI 10.17487/RFC3723, April 2004,
              <http://www.rfc-editor.org/info/rfc3723>.

   [RFC4506]  Eisler, M., Ed., "XDR: External Data Representation
              Standard", STD 67, RFC 4506, DOI 10.17487/RFC4506, May
              2006, <http://www.rfc-editor.org/info/rfc4506>.

   [RFC5661]  Shepler, S., Ed., Eisler, M., Ed., and D. Noveck, Ed.,
              "Network File System (NFS) Version 4 Minor Version 1
              Protocol", RFC 5661, DOI 10.17487/RFC5661, January 2010,
              <http://www.rfc-editor.org/info/rfc5661>.

   [RFC5662]  Shepler, S., Ed., Eisler, M., Ed., and D. Noveck, Ed.,
              "Network File System (NFS) Version 4 Minor Version 1
              External Data Representation Standard (XDR) Description",
              RFC 5662, DOI 10.17487/RFC5662, January 2010,
              <http://www.rfc-editor.org/info/rfc5662>.

   [RFC5663]  Black, D., Fridella, S., and J. Glasgow, "Parallel NFS
              (pNFS) Block/Volume Layout", RFC 5663,
              DOI 10.17487/RFC5663, January 2010,
              <http://www.rfc-editor.org/info/rfc5663>.

   [RFC6688]  Black, D., Ed., Glasgow, J., and S. Faibish, "Parallel NFS
              (pNFS) Block Disk Protection", RFC 6688,
              DOI 10.17487/RFC6688, July 2012,
              <http://www.rfc-editor.org/info/rfc6688>.

   [RFC7143]  Chadalapaka, M., Satran, J., Meth, K., and D. Black,
              "Internet Small Computer System Interface (iSCSI) Protocol
              (Consolidated)", RFC 7143, DOI 10.17487/RFC7143, April
              2014, <http://www.rfc-editor.org/info/rfc7143>.

   [RFC7146]  Black, D. and P. Koning, "Securing Block Storage Protocols
              over IP: RFC 3723 Requirements Update for IPsec v3",
              RFC 7146, DOI 10.17487/RFC7146, April 2014,
              <http://www.rfc-editor.org/info/rfc7146>.

   [SAM-5]    INCITS Technical Committee T10, "Information Technology -
              SCSI Architecture Model - 5 (SAM-5)", ANSI
              INCITS 515-2016, 2016.

   [SAS3]     INCITS Technical Committee T10, "Information technology -
              Serial Attached SCSI-3 (SAS-3)", ANSI INCITS 519-2014,
              ISO/IEC 14776-154, 2014.

   [SBC3]     INCITS Technical Committee T10, "Information Technology -
              SCSI Block Commands - 3 (SBC-3)", ANSI INCITS 514-2014,
              ISO/IEC 14776-323, 2014.

   [SPC4]     INCITS Technical Committee T10, "Information Technology -
              SCSI Primary Commands - 4 (SPC-4)", ANSI INCITS 513-2015,
              2015.

Acknowledgments 🫢

Okay big shoutout time πŸ’œ. A bunch of this document was copied word-for-word from [RFC5663], and some parts were inspired by it. Huge thanks to David Black, Stephen Fridella, and Jason Glasgow for their work on the pNFS block/volume layout protocol πŸ‘‘.

David Black, Robert Elliott, and Tom Haynes gave a thorough review of drafts of this document, and their input shaped the current form of it 🌸.

David Noveck gave ample feedback on various drafts of this document, wrote the section on enforcing NFSv4 semantics, and rewrote various sections to better catch the intent πŸ”₯. Literally iconic.

Author's Address πŸ’Œ

Christoph Hellwig

Email: hch@lst.de

πŸ“¦ where this page comes from