History

uapi nbd: improve doc links to userspace spec

The uapi <linux/nbd.h> header intentionally documents only the NBD server features that the kernel module will utilize as a client. But while it already had one mention of skipped bits due to userspace extensions, it did not actually direct the reader to the canonical source to learn about those extensions. While touching comments, fix an outdated reference that listed only READ and WRITE as commands.

Eric Blake committed 3 years ago

Commit daf376a1 parent ff53cd51 file · +12 −3Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/nbd.h+12−3
@@ -11,6 +11,8 @@ · 10 unmodified lines
1111 * Cleanup PARANOIA usage & code.
1212 * 2004/02/19 Paul Clements
1313 * Removed PARANOIA, plus various cleanup and comments
14+ * 2023 Copyright Red Hat
15+ * Link to userspace extensions.
1416 */
1517
1618 #ifndef _UAPILINUX_NBD_H
@@ -30,12 +32,18 @@ · 13 unmodified lines
3032 #define NBD_SET_TIMEOUT _IO( 0xab, 9 )
3133 #define NBD_SET_FLAGS _IO( 0xab, 10)
3234
35+/*
36+ * See also https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md
37+ * for additional userspace extensions not yet utilized in the kernel module.
38+ */
39+
3340 enum {
3441 NBD_CMD_READ = 0,
3542 NBD_CMD_WRITE = 1,
3643 NBD_CMD_DISC = 2,
3744 NBD_CMD_FLUSH = 3,
3845 NBD_CMD_TRIM = 4
46+ /* userspace defines additional extension commands */
3947 };
4048
4149 /* values for flags field, these are server interaction specific. */
@@ -64,14 +72,15 @@ enum { · 22 unmodified lines
6472 #define NBD_REQUEST_MAGIC 0x25609513
6573 #define NBD_REPLY_MAGIC 0x67446698
6674 /* Do *not* use magics: 0x12560953 0x96744668. */
75+/* magic 0x668e33ef for structured reply not supported by kernel yet */
6776
6877 /*
6978 * This is the packet used for communication between client and
7079 * server. All data are in network byte order.
7180 */
7281 struct nbd_request {
73− __be32 magic;
74− __be32 type; /* == READ || == WRITE */
82+ __be32 magic; /* NBD_REQUEST_MAGIC */
83+ __be32 type; /* See NBD_CMD_* */
7584 char handle[8];
7685 __be64 from;
7786 __be32 len;
@@ -82,7 +91,7 @@ struct nbd_request { · 4 unmodified lines
8291 * it has completed an I/O request (or an error occurs).
8392 */
8493 struct nbd_reply {
85− __be32 magic;
94+ __be32 magic; /* NBD_REPLY_MAGIC */
8695 __be32 error; /* 0 = ok, else error */
8796 char handle[8]; /* handle you got from request */
8897 };