Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 005a07bf authored by Ilya Dryomov's avatar Ilya Dryomov
Browse files

rbd: add 'client_addr' sysfs rbd device attribute



Export client addr/nonce, so userspace can check if a image is being
blacklisted.

Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
[idryomov@gmail.com: ceph_client_addr(), endianess fix]
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent ca7909e8
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -43,6 +43,12 @@ Description: Available only if rbd module is inserted with single_major
Entries under /sys/bus/rbd/devices/<dev-id>/
Entries under /sys/bus/rbd/devices/<dev-id>/
--------------------------------------------
--------------------------------------------


client_addr

	The ceph unique client entity_addr_t (address + nonce).
	The format is <address>:<port>/<nonce>: '1.2.3.4:1234/5678' or
	'[1:2:3:4:5:6:7:8]:1234/5678'.  (August 2016, since 4.9.)

client_id
client_id


	The ceph unique client id that was assigned for this specific session.
	The ceph unique client id that was assigned for this specific session.
+13 −0
Original line number Original line Diff line number Diff line
@@ -4592,6 +4592,17 @@ static ssize_t rbd_minor_show(struct device *dev,
	return sprintf(buf, "%d\n", rbd_dev->minor);
	return sprintf(buf, "%d\n", rbd_dev->minor);
}
}


static ssize_t rbd_client_addr_show(struct device *dev,
				    struct device_attribute *attr, char *buf)
{
	struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
	struct ceph_entity_addr *client_addr =
	    ceph_client_addr(rbd_dev->rbd_client->client);

	return sprintf(buf, "%pISpc/%u\n", &client_addr->in_addr,
		       le32_to_cpu(client_addr->nonce));
}

static ssize_t rbd_client_id_show(struct device *dev,
static ssize_t rbd_client_id_show(struct device *dev,
				  struct device_attribute *attr, char *buf)
				  struct device_attribute *attr, char *buf)
{
{
@@ -4702,6 +4713,7 @@ static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL);
static DEVICE_ATTR(features, S_IRUGO, rbd_features_show, NULL);
static DEVICE_ATTR(features, S_IRUGO, rbd_features_show, NULL);
static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL);
static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL);
static DEVICE_ATTR(minor, S_IRUGO, rbd_minor_show, NULL);
static DEVICE_ATTR(minor, S_IRUGO, rbd_minor_show, NULL);
static DEVICE_ATTR(client_addr, S_IRUGO, rbd_client_addr_show, NULL);
static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL);
static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL);
static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL);
static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL);
static DEVICE_ATTR(pool_id, S_IRUGO, rbd_pool_id_show, NULL);
static DEVICE_ATTR(pool_id, S_IRUGO, rbd_pool_id_show, NULL);
@@ -4716,6 +4728,7 @@ static struct attribute *rbd_attrs[] = {
	&dev_attr_features.attr,
	&dev_attr_features.attr,
	&dev_attr_major.attr,
	&dev_attr_major.attr,
	&dev_attr_minor.attr,
	&dev_attr_minor.attr,
	&dev_attr_client_addr.attr,
	&dev_attr_client_id.attr,
	&dev_attr_client_id.attr,
	&dev_attr_pool.attr,
	&dev_attr_pool.attr,
	&dev_attr_pool_id.attr,
	&dev_attr_pool_id.attr,
+1 −0
Original line number Original line Diff line number Diff line
@@ -264,6 +264,7 @@ extern struct ceph_client *ceph_create_client(struct ceph_options *opt,
					      void *private,
					      void *private,
					      u64 supported_features,
					      u64 supported_features,
					      u64 required_features);
					      u64 required_features);
struct ceph_entity_addr *ceph_client_addr(struct ceph_client *client);
u64 ceph_client_gid(struct ceph_client *client);
u64 ceph_client_gid(struct ceph_client *client);
extern void ceph_destroy_client(struct ceph_client *client);
extern void ceph_destroy_client(struct ceph_client *client);
extern int __ceph_open_session(struct ceph_client *client,
extern int __ceph_open_session(struct ceph_client *client,
+6 −0
Original line number Original line Diff line number Diff line
@@ -566,6 +566,12 @@ int ceph_print_client_options(struct seq_file *m, struct ceph_client *client)
}
}
EXPORT_SYMBOL(ceph_print_client_options);
EXPORT_SYMBOL(ceph_print_client_options);


struct ceph_entity_addr *ceph_client_addr(struct ceph_client *client)
{
	return &client->msgr.inst.addr;
}
EXPORT_SYMBOL(ceph_client_addr);

u64 ceph_client_gid(struct ceph_client *client)
u64 ceph_client_gid(struct ceph_client *client)
{
{
	return client->monc.auth->global_id;
	return client->monc.auth->global_id;