kernel doc: NFSv4.1 Server Implementation

本文档翻译自NFSv4.1 Server Implementation,翻译时文件的最新提交是04f81fb08d067f79c59fe132929a9c81eb9cb74b Documentation: nfs: nfs41-server: convert to ReST,大部分借助于ChatGPT。仅作为我个人的参考,如果你想查阅,建议看英文文档,因为我不确定我记录的中文翻译是否完整和正确。

1 NFSv4.1 Server Implementation

服务器对 minorversion 1 的支持可以通过 /proc/fs/nfsd/versions 控制文件进行控制。读取该文件返回的字符串将分别包含 "+4.1" 或 "-4.1"。

目前,服务器对 minorversion 1 的支持是默认启用的。可以在运行时通过将字符串 "-4.1" 写入 /proc/fs/nfsd/versions 控制文件来禁用它。请注意,要写入该控制文件,必须先停止 nfsd 服务。您可以使用 rpc.nfsd 来完成此操作;参见 rpc.nfsd(8)。

(警告: 较旧的服务器会将 "+4.1" 和 "-4.1" 解释为 "+4" 和 "-4"。因此,旨在同时适用于新旧内核的代码必须在打开或关闭版本 4 的支持之前先打开或关闭 4.1 的支持;rpc.nfsd 可以正确处理这一点。)

nfsd 中的 NFSv4 minorversion 1 (NFSv4.1) 实现基于 RFC 5661。

在 NFSv4.1 的众多新特性中,当前实现侧重于强制实施的 NFSv4.1 Sessions,提供“仅一次”语义以及更好的资源分配控制和限制。

下表摘自 NFSv4.1 文档,列出了在 minor version 1 中强制实现的操作(REQ)、可选操作(OPT)和 NFSv4.0 操作(MNI)。第一列表示 linux 服务器实现尚未支持的操作。

可选功能及其缩写如下:

- **pNFS**  Parallel NFS
- **FDELG** File Delegations
- **DDELG** Directory Delegations

以下缩写表示 Linux 服务器实现的状态。

- **I** Implemented NFSv4.1 operations.
- **NS**    Not Supported.
- **NS\***  Unimplemented optional feature.

1.1 Operations


+-----------------------+----------------------+---------------------+---------------------------+----------------+
| Implementation status | Operation            | REQ,REC, OPT or NMI | Feature (REQ, REC or OPT) | Definition     |
+=======================+======================+=====================+===========================+================+
|                       | ACCESS               | REQ                 |                           | Section 18.1   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | BACKCHANNEL_CTL      | REQ                 |                           | Section 18.33  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | BIND_CONN_TO_SESSION | REQ                 |                           | Section 18.34  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | CLOSE                | REQ                 |                           | Section 18.2   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | COMMIT               | REQ                 |                           | Section 18.3   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | CREATE               | REQ                 |                           | Section 18.4   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | CREATE_SESSION       | REQ                 |                           | Section 18.36  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| NS*                   | DELEGPURGE           | OPT                 | FDELG (REQ)               | Section 18.5   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | DELEGRETURN          | OPT                 | FDELG,                    | Section 18.6   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       |                      |                     | DDELG, pNFS               |                |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       |                      |                     | (REQ)                     |                |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | DESTROY_CLIENTID     | REQ                 |                           | Section 18.50  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | DESTROY_SESSION      | REQ                 |                           | Section 18.37  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | EXCHANGE_ID          | REQ                 |                           | Section 18.35  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | FREE_STATEID         | REQ                 |                           | Section 18.38  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | GETATTR              | REQ                 |                           | Section 18.7   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | GETDEVICEINFO        | OPT                 | pNFS (REQ)                | Section 18.40  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| NS*                   | GETDEVICELIST        | OPT                 | pNFS (OPT)                | Section 18.41  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | GETFH                | REQ                 |                           | Section 18.8   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| NS*                   | GET_DIR_DELEGATION   | OPT                 | DDELG (REQ)               | Section 18.39  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | LAYOUTCOMMIT         | OPT                 | pNFS (REQ)                | Section 18.42  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | LAYOUTGET            | OPT                 | pNFS (REQ)                | Section 18.43  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | LAYOUTRETURN         | OPT                 | pNFS (REQ)                | Section 18.44  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | LINK                 | OPT                 |                           | Section 18.9   |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | LOCK                 | REQ                 |                           | Section 18.10  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | LOCKT                | REQ                 |                           | Section 18.11  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | LOCKU                | REQ                 |                           | Section 18.12  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | LOOKUP               | REQ                 |                           | Section 18.13  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | LOOKUPP              | REQ                 |                           | Section 18.14  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | NVERIFY              | REQ                 |                           | Section 18.15  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | OPEN                 | REQ                 |                           | Section 18.16  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| NS*                   | OPENATTR             | OPT                 |                           | Section 18.17  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | OPEN_CONFIRM         | MNI                 |                           | N/A            |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | OPEN_DOWNGRADE       | REQ                 |                           | Section 18.18  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | PUTFH                | REQ                 |                           | Section 18.19  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | PUTPUBFH             | REQ                 |                           | Section 18.20  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | PUTROOTFH            | REQ                 |                           | Section 18.21  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | READ                 | REQ                 |                           | Section 18.22  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | READDIR              | REQ                 |                           | Section 18.23  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | READLINK             | OPT                 |                           | Section 18.24  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | RECLAIM_COMPLETE     | REQ                 |                           | Section 18.51  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | RELEASE_LOCKOWNER    | MNI                 |                           | N/A            |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | REMOVE               | REQ                 |                           | Section 18.25  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | RENAME               | REQ                 |                           | Section 18.26  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | RENEW                | MNI                 |                           | N/A            |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | RESTOREFH            | REQ                 |                           | Section 18.27  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | SAVEFH               | REQ                 |                           | Section 18.28  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | SECINFO              | REQ                 |                           | Section 18.29  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | SECINFO_NO_NAME      | REC                 | pNFS files                | Section 18.45, |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       |                      |                     | layout (REQ)              | Section 13.12  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | SEQUENCE             | REQ                 |                           | Section 18.46  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | SETATTR              | REQ                 |                           | Section 18.30  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | SETCLIENTID          | MNI                 |                           | N/A            |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | SETCLIENTID_CONFIRM  | MNI                 |                           | N/A            |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| NS                    | SET_SSV              | REQ                 |                           | Section 18.47  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| I                     | TEST_STATEID         | REQ                 |                           | Section 18.48  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | VERIFY               | REQ                 |                           | Section 18.31  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
| NS*                   | WANT_DELEGATION      | OPT                 | FDELG (OPT)               | Section 18.49  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+
|                       | WRITE                | REQ                 |                           | Section 18.32  |
+-----------------------+----------------------+---------------------+---------------------------+----------------+

1.2 Callback Operations

+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| Implementation status | Operation               | REQ,REC, OPT or NMI | Feature (REQ, REC or OPT) | Definition    |
+=======================+=========================+=====================+===========================+===============+
|                       | CB_GETATTR              | OPT                 | FDELG (REQ)               | Section 20.1  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| I                     | CB_LAYOUTRECALL         | OPT                 | pNFS (REQ)                | Section 20.3  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| NS*                   | CB_NOTIFY               | OPT                 | DDELG (REQ)               | Section 20.4  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| NS*                   | CB_NOTIFY_DEVICEID      | OPT                 | pNFS (OPT)                | Section 20.12 |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| NS*                   | CB_NOTIFY_LOCK          | OPT                 |                           | Section 20.11 |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| NS*                   | CB_PUSH_DELEG           | OPT                 | FDELG (OPT)               | Section 20.5  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       | CB_RECALL               | OPT                 | FDELG,                    | Section 20.2  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | DDELG, pNFS               |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | (REQ)                     |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| NS*                   | CB_RECALL_ANY           | OPT                 | FDELG,                    | Section 20.6  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | DDELG, pNFS               |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | (REQ)                     |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| NS                    | CB_RECALL_SLOT          | REQ                 |                           | Section 20.8  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| NS*                   | CB_RECALLABLE_OBJ_AVAIL | OPT                 | DDELG, pNFS               | Section 20.7  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | (REQ)                     |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| I                     | CB_SEQUENCE             | OPT                 | FDELG,                    | Section 20.9  |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | DDELG, pNFS               |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | (REQ)                     |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
| NS*                   | CB_WANTS_CANCELLED      | OPT                 | FDELG,                    | Section 20.10 |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | DDELG, pNFS               |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+
|                       |                         |                     | (REQ)                     |               |
+-----------------------+-------------------------+---------------------+---------------------------+---------------+

1.3 Implementation notes:

SSV:
规范声称这是强制性的,但我们实际上不知道任何实现,所以我们现在忽略它。服务器在 EXCHANGE_ID 上返回 NFS4ERR_ENCR_ALG_UNSUPP,这应该是面向未来的。

后通道上的 GSS:
同样,理论上是强制性的,但没有广泛实现(特别是当前的 Linux 客户端不请求它)。我们在 CREATE_SESSION 上返回 NFS4ERR_ENCR_ALG_UNSUPP。

DELEGPURGE:
仅对支持 CLAIM_DELEGATE_PREV 和/或 CLAIM_DELEG_PREV_FH 的服务器是强制性的(这允许客户端在重启后保留委托)。因此,我们目前不需要实现它。

EXCHANGE_ID:
忽略实现 ID。

CREATE_SESSION:
忽略后通道属性。

SEQUENCE:
不支持动态槽表重新协商(可选)。

非标准复合限制:
不支持会话前通道 RPC 复合,该复合要求同时具有 ca_maxrequestsize 请求和 ca_maxresponsesize 响应,因此我们可能无法履行在 CREATE_SESSION 前通道协商中做出的承诺。

另见: http://wiki.linux-nfs.org/wiki/index.php/Server_4.0_and_4.1_issues。