xref: /linux/Documentation/ABI/testing/sysfs-class-rnbd-client (revision 07c7b547a79605f1041d55b84d91a4a4d9c5b363)
1What:		/sys/class/rnbd-client
2Date:		Feb 2020
3KernelVersion:	5.7
4Contact:	Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
5Description:	Provide information about RNBD-client.
6		All sysfs files that are not read-only provide the usage information on read:
7
8		Example:
9		# cat /sys/class/rnbd-client/ctl/map_device
10
11		> Usage: echo "sessname=<name of the rtrs session> path=<[srcaddr,]dstaddr>
12		> [path=<[srcaddr,]dstaddr>] device_path=<full path on remote side>
13		> [access_mode=<ro|rw|migration>] > map_device
14		>
15		> addr ::= [ ip:<ipv4> | ip:<ipv6> | gid:<gid> ]
16
17What:		/sys/class/rnbd-client/ctl/map_device
18Date:		Feb 2020
19KernelVersion:	5.7
20Contact:	Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
21Description:	Expected format is the following:
22
23		sessname=<name of the rtrs session>
24		path=<[srcaddr,]dstaddr> [path=<[srcaddr,]dstaddr> ...]
25		device_path=<full path on remote side>
26		[access_mode=<ro|rw|migration>]
27
28		Where:
29
30		sessname: accepts a string not bigger than 256 chars, which identifies
31		a given session on the client and on the server.
32		I.e. "clt_hostname-srv_hostname" could be a natural choice.
33
34		path:     describes a connection between the client and the server by
35		specifying destination and, when required, the source address.
36		The addresses are to be provided in the following format:
37
38		ip:<IPv6>
39		ip:<IPv4>
40		gid:<GID>
41
42		for example:
43
44		path=ip:10.0.0.66
45		The single addr is treated as the destination.
46		The connection will be established to this server from any client IP address.
47
48		path=ip:10.0.0.66,ip:10.0.1.66
49		First addr is the source address and the second is the destination.
50
51		If multiple "path=" options are specified multiple connection
52		will be established and data will be sent according to
53		the selected multipath policy (see RTRS mp_policy sysfs entry description).
54
55		device_path: Path to the block device on the server side. Path is specified
56		relative to the directory on server side configured in the
57		'dev_search_path' module parameter of the rnbd_server.
58		The rnbd_server prepends the <device_path> received from client
59		with <dev_search_path> and tries to open the
60		<dev_search_path>/<device_path> block device.  On success,
61		a /dev/rnbd<N> device file, a /sys/block/rnbd_client/rnbd<N>/
62		directory and an entry in /sys/class/rnbd-client/ctl/devices
63		will be created.
64
65		If 'dev_search_path' contains '%SESSNAME%', then each session can
66		have different devices namespace, e.g. server was configured with
67		the following parameter "dev_search_path=/run/rnbd-devs/%SESSNAME%",
68		client has this string "sessname=blya device_path=sda", then server
69		will try to open: /run/rnbd-devs/blya/sda.
70
71		access_mode: the access_mode parameter specifies if the device is to be
72		mapped as "ro" read-only or "rw" read-write. The server allows
73		a device to be exported in rw mode only once. The "migration"
74		access mode has to be specified if a second mapping in read-write
75		mode is desired.
76
77		By default "rw" is used.
78
79		Exit Codes:
80
81		If the device is already mapped it will fail with EEXIST. If the input
82		has an invalid format it will return EINVAL. If the device path cannot
83		be found on the server, it will fail with ENOENT.
84
85		Finding device file after mapping
86		---------------------------------
87
88		After mapping, the device file can be found by:
89		o  The symlink /sys/class/rnbd-client/ctl/devices/<device_id>
90		points to /sys/block/<dev-name>. The last part of the symlink destination
91		is the same as the device name.  By extracting the last part of the
92		path the path to the device /dev/<dev-name> can be build.
93
94		o /dev/block/$(cat /sys/class/rnbd-client/ctl/devices/<device_id>/dev)
95
96		How to find the <device_id> of the device is described on the next
97		section.
98
99What:		/sys/class/rnbd-client/ctl/devices/
100Date:		Feb 2020
101KernelVersion:	5.7
102Contact:	Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
103Description:	For each device mapped on the client a new symbolic link is created as
104		/sys/class/rnbd-client/ctl/devices/<device_id>, which points
105		to the block device created by rnbd (/sys/block/rnbd<N>/).
106		The <device_id> of each device is created as follows:
107
108		- If the 'device_path' provided during mapping contains slashes ("/"),
109		they are replaced by exclamation mark ("!") and used as as the
110		<device_id>. Otherwise, the <device_id> will be the same as the
111		"device_path" provided.
112