18c2ecf20Sopenharmony_ciWhat:		/sys/class/rnbd-client
28c2ecf20Sopenharmony_ciDate:		Feb 2020
38c2ecf20Sopenharmony_ciKernelVersion:	5.7
48c2ecf20Sopenharmony_ciContact:	Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
58c2ecf20Sopenharmony_ciDescription:	Provide information about RNBD-client.
68c2ecf20Sopenharmony_ci		All sysfs files that are not read-only provide the usage information on read:
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci		Example::
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci		    # cat /sys/class/rnbd-client/ctl/map_device
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci		    > Usage: echo "sessname=<name of the rtrs session> path=<[srcaddr,]dstaddr>
138c2ecf20Sopenharmony_ci		    > [path=<[srcaddr,]dstaddr>] device_path=<full path on remote side>
148c2ecf20Sopenharmony_ci		    > [access_mode=<ro|rw|migration>] > map_device
158c2ecf20Sopenharmony_ci		    >
168c2ecf20Sopenharmony_ci		    > addr ::= [ ip:<ipv4> | ip:<ipv6> | gid:<gid> ]
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciWhat:		/sys/class/rnbd-client/ctl/map_device
198c2ecf20Sopenharmony_ciDate:		Feb 2020
208c2ecf20Sopenharmony_ciKernelVersion:	5.7
218c2ecf20Sopenharmony_ciContact:	Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
228c2ecf20Sopenharmony_ciDescription:	Expected format is the following::
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci		    sessname=<name of the rtrs session>
258c2ecf20Sopenharmony_ci		    path=<[srcaddr,]dstaddr> [path=<[srcaddr,]dstaddr> ...]
268c2ecf20Sopenharmony_ci		    device_path=<full path on remote side>
278c2ecf20Sopenharmony_ci		    [access_mode=<ro|rw|migration>]
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci		Where:
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci		sessname:
328c2ecf20Sopenharmony_ci		    accepts a string not bigger than 256 chars, which identifies
338c2ecf20Sopenharmony_ci		    a given session on the client and on the server.
348c2ecf20Sopenharmony_ci		    I.e. "clt_hostname-srv_hostname" could be a natural choice.
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci		path:
378c2ecf20Sopenharmony_ci		    describes a connection between the client and the server by
388c2ecf20Sopenharmony_ci		    specifying destination and, when required, the source address.
398c2ecf20Sopenharmony_ci		    The addresses are to be provided in the following format::
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci			ip:<IPv6>
428c2ecf20Sopenharmony_ci			ip:<IPv4>
438c2ecf20Sopenharmony_ci			gid:<GID>
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci		for example::
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci		    path=ip:10.0.0.66
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci		The single addr is treated as the destination.
508c2ecf20Sopenharmony_ci		The connection will be established to this server from any client IP address.
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci		::
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci		    path=ip:10.0.0.66,ip:10.0.1.66
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci		First addr is the source address and the second is the destination.
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci		If multiple "path=" options are specified multiple connection
598c2ecf20Sopenharmony_ci		will be established and data will be sent according to
608c2ecf20Sopenharmony_ci		the selected multipath policy (see RTRS mp_policy sysfs entry description).
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci		device_path:
638c2ecf20Sopenharmony_ci		    Path to the block device on the server side. Path is specified
648c2ecf20Sopenharmony_ci		    relative to the directory on server side configured in the
658c2ecf20Sopenharmony_ci		    'dev_search_path' module parameter of the rnbd_server.
668c2ecf20Sopenharmony_ci		    The rnbd_server prepends the <device_path> received from client
678c2ecf20Sopenharmony_ci		    with <dev_search_path> and tries to open the
688c2ecf20Sopenharmony_ci		    <dev_search_path>/<device_path> block device.  On success,
698c2ecf20Sopenharmony_ci		    a /dev/rnbd<N> device file, a /sys/block/rnbd_client/rnbd<N>/
708c2ecf20Sopenharmony_ci		    directory and an entry in /sys/class/rnbd-client/ctl/devices
718c2ecf20Sopenharmony_ci		    will be created.
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci		If 'dev_search_path' contains '%SESSNAME%', then each session can
748c2ecf20Sopenharmony_ci		have different devices namespace, e.g. server was configured with
758c2ecf20Sopenharmony_ci		the following parameter "dev_search_path=/run/rnbd-devs/%SESSNAME%",
768c2ecf20Sopenharmony_ci		client has this string "sessname=blya device_path=sda", then server
778c2ecf20Sopenharmony_ci		will try to open: /run/rnbd-devs/blya/sda.
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci		access_mode:
808c2ecf20Sopenharmony_ci		    the access_mode parameter specifies if the device is to be
818c2ecf20Sopenharmony_ci		    mapped as "ro" read-only or "rw" read-write. The server allows
828c2ecf20Sopenharmony_ci		    a device to be exported in rw mode only once. The "migration"
838c2ecf20Sopenharmony_ci		    access mode has to be specified if a second mapping in read-write
848c2ecf20Sopenharmony_ci		    mode is desired.
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci		By default "rw" is used.
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci		Exit Codes:
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci		If the device is already mapped it will fail with EEXIST. If the input
918c2ecf20Sopenharmony_ci		has an invalid format it will return EINVAL. If the device path cannot
928c2ecf20Sopenharmony_ci		be found on the server, it will fail with ENOENT.
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci		Finding device file after mapping
958c2ecf20Sopenharmony_ci		---------------------------------
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci		After mapping, the device file can be found by:
988c2ecf20Sopenharmony_ci		o  The symlink /sys/class/rnbd-client/ctl/devices/<device_id>
998c2ecf20Sopenharmony_ci		points to /sys/block/<dev-name>. The last part of the symlink destination
1008c2ecf20Sopenharmony_ci		is the same as the device name.  By extracting the last part of the
1018c2ecf20Sopenharmony_ci		path the path to the device /dev/<dev-name> can be build.
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci		* /dev/block/$(cat /sys/class/rnbd-client/ctl/devices/<device_id>/dev)
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci		How to find the <device_id> of the device is described on the next
1068c2ecf20Sopenharmony_ci		section.
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ciWhat:		/sys/class/rnbd-client/ctl/devices/
1098c2ecf20Sopenharmony_ciDate:		Feb 2020
1108c2ecf20Sopenharmony_ciKernelVersion:	5.7
1118c2ecf20Sopenharmony_ciContact:	Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
1128c2ecf20Sopenharmony_ciDescription:	For each device mapped on the client a new symbolic link is created as
1138c2ecf20Sopenharmony_ci		/sys/class/rnbd-client/ctl/devices/<device_id>, which points
1148c2ecf20Sopenharmony_ci		to the block device created by rnbd (/sys/block/rnbd<N>/).
1158c2ecf20Sopenharmony_ci		The <device_id> of each device is created as follows:
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci		- If the 'device_path' provided during mapping contains slashes ("/"),
1188c2ecf20Sopenharmony_ci		  they are replaced by exclamation mark ("!") and used as as the
1198c2ecf20Sopenharmony_ci		  <device_id>. Otherwise, the <device_id> will be the same as the
1208c2ecf20Sopenharmony_ci		  "device_path" provided.
121