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