History

nbd: add a basic netlink interface

The existing ioctl interface for configuring NBD devices is a bit cumbersome and hard to extend. The other problem is we leave a userspace app sitting in it's syscall until the device disconnects, which is less than ideal. This patch introduces a netlink interface for adding and disconnecting nbd devices. This has the benefits of being easily extendable without breaking older userspace applications, and allows us to configure a nbd device without leaving a userspace app sitting waiting for the device to disconnect. With this interface we also gain the ability to configure more devices than are preallocated at insmod time. We also have gained the ability to not specify a particular device and be provided one for us so that userspace doesn't need to find a free device to configure.

Josef Bacik committed 9 years ago

Commit e46c7281 parent 29eaadc2 files · +359 −26Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/nbd-netlink.h+69−0
@@ -0,0 +1,69 @@
1/*
2 * Copyright (C) 2017 Facebook. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
17 */
18#ifndef _UAPILINUX_NBD_NETLINK_H
19#define _UAPILINUX_NBD_NETLINK_H
20
21#define NBD_GENL_FAMILY_NAME "nbd"
22#define NBD_GENL_VERSION 0x1
23
24/* Configuration policy attributes, used for CONNECT */
25enum {
26 NBD_ATTR_UNSPEC,
27 NBD_ATTR_INDEX,
28 NBD_ATTR_SIZE_BYTES,
29 NBD_ATTR_BLOCK_SIZE_BYTES,
30 NBD_ATTR_TIMEOUT,
31 NBD_ATTR_SERVER_FLAGS,
32 NBD_ATTR_CLIENT_FLAGS,
33 NBD_ATTR_SOCKETS,
34 __NBD_ATTR_MAX,
35};
36#define NBD_ATTR_MAX (__NBD_ATTR_MAX - 1)
37
38/*
39 * This is the format for multiple sockets with NBD_ATTR_SOCKETS
40 *
41 * [NBD_ATTR_SOCKETS]
42 * [NBD_SOCK_ITEM]
43 * [NBD_SOCK_FD]
44 * [NBD_SOCK_ITEM]
45 * [NBD_SOCK_FD]
46 */
47enum {
48 NBD_SOCK_ITEM_UNSPEC,
49 NBD_SOCK_ITEM,
50 __NBD_SOCK_ITEM_MAX,
51};
52#define NBD_SOCK_ITEM_MAX (__NBD_SOCK_ITEM_MAX - 1)
53
54enum {
55 NBD_SOCK_UNSPEC,
56 NBD_SOCK_FD,
57 __NBD_SOCK_MAX,
58};
59#define NBD_SOCK_MAX (__NBD_SOCK_MAX - 1)
60
61enum {
62 NBD_CMD_UNSPEC,
63 NBD_CMD_CONNECT,
64 NBD_CMD_DISCONNECT,
65 __NBD_CMD_MAX,
66};
67#define NBD_CMD_MAX (__NBD_CMD_MAX - 1)
68
69#endif /* _UAPILINUX_NBD_NETLINK_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t