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

Commit 92a58671 authored by Mike Christie's avatar Mike Christie Committed by Ilya Dryomov
Browse files

rbd: add 'snap_id' sysfs rbd device attribute



Export snap id in sysfs, so tools like multipathd can use it in a uuid.

Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 267fb90b
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -102,6 +102,10 @@ current_snap


	The current snapshot for which the device is mapped.
	The current snapshot for which the device is mapped.


snap_id

	The current snapshot's id.  (August 2016, since 4.9.)

parent
parent


	Information identifying the chain of parent images in a layered rbd
	Information identifying the chain of parent images in a layered rbd
+10 −0
Original line number Original line Diff line number Diff line
@@ -4669,6 +4669,14 @@ static ssize_t rbd_snap_show(struct device *dev,
	return sprintf(buf, "%s\n", rbd_dev->spec->snap_name);
	return sprintf(buf, "%s\n", rbd_dev->spec->snap_name);
}
}


static ssize_t rbd_snap_id_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);

	return sprintf(buf, "%llu\n", rbd_dev->spec->snap_id);
}

/*
/*
 * For a v2 image, shows the chain of parent images, separated by empty
 * For a v2 image, shows the chain of parent images, separated by empty
 * lines.  For v1 images or if there is no parent, shows "(no parent
 * lines.  For v1 images or if there is no parent, shows "(no parent
@@ -4730,6 +4738,7 @@ static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL);
static DEVICE_ATTR(image_id, S_IRUGO, rbd_image_id_show, NULL);
static DEVICE_ATTR(image_id, S_IRUGO, rbd_image_id_show, NULL);
static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
static DEVICE_ATTR(snap_id, S_IRUGO, rbd_snap_id_show, NULL);
static DEVICE_ATTR(parent, S_IRUGO, rbd_parent_show, NULL);
static DEVICE_ATTR(parent, S_IRUGO, rbd_parent_show, NULL);


static struct attribute *rbd_attrs[] = {
static struct attribute *rbd_attrs[] = {
@@ -4745,6 +4754,7 @@ static struct attribute *rbd_attrs[] = {
	&dev_attr_name.attr,
	&dev_attr_name.attr,
	&dev_attr_image_id.attr,
	&dev_attr_image_id.attr,
	&dev_attr_current_snap.attr,
	&dev_attr_current_snap.attr,
	&dev_attr_snap_id.attr,
	&dev_attr_parent.attr,
	&dev_attr_parent.attr,
	&dev_attr_refresh.attr,
	&dev_attr_refresh.attr,
	NULL
	NULL