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