Skip to content

Commit daf376a

Browse files
ebblakeaxboe
authored andcommitted
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. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Link: https://lore.kernel.org/r/20230410180611.1051618-2-eblake@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent ff53cd5 commit daf376a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

include/uapi/linux/nbd.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
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 @@
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 {
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 {
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
};

0 commit comments

Comments
 (0)