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