diff options
author | Mike Christie <mchristi@redhat.com> | 2016-08-18 12:38:44 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2016-08-24 17:49:17 -0400 |
commit | 92a58671549f365a962517cc7cccb624dea8581e (patch) | |
tree | 12dc735f12c6e253209d0b69d6a78ea2b743f391 | |
parent | 267fb90b8344eeb6f835734e356b422f78617088 (diff) |
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: Mike Christie <mchristi@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r-- | Documentation/ABI/testing/sysfs-bus-rbd | 4 | ||||
-rw-r--r-- | drivers/block/rbd.c | 10 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-rbd b/Documentation/ABI/testing/sysfs-bus-rbd index 9a655f3f4386..7bf8d4fa6f63 100644 --- a/Documentation/ABI/testing/sysfs-bus-rbd +++ b/Documentation/ABI/testing/sysfs-bus-rbd | |||
@@ -102,6 +102,10 @@ current_snap | |||
102 | 102 | ||
103 | The current snapshot for which the device is mapped. | 103 | The current snapshot for which the device is mapped. |
104 | 104 | ||
105 | snap_id | ||
106 | |||
107 | The current snapshot's id. (August 2016, since 4.9.) | ||
108 | |||
105 | parent | 109 | parent |
106 | 110 | ||
107 | Information identifying the chain of parent images in a layered rbd | 111 | Information identifying the chain of parent images in a layered rbd |
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index c95104a80065..36ebec19dc20 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -4669,6 +4669,14 @@ static ssize_t rbd_snap_show(struct device *dev, | |||
4669 | return sprintf(buf, "%s\n", rbd_dev->spec->snap_name); | 4669 | return sprintf(buf, "%s\n", rbd_dev->spec->snap_name); |
4670 | } | 4670 | } |
4671 | 4671 | ||
4672 | static ssize_t rbd_snap_id_show(struct device *dev, | ||
4673 | struct device_attribute *attr, char *buf) | ||
4674 | { | ||
4675 | struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); | ||
4676 | |||
4677 | return sprintf(buf, "%llu\n", rbd_dev->spec->snap_id); | ||
4678 | } | ||
4679 | |||
4672 | /* | 4680 | /* |
4673 | * For a v2 image, shows the chain of parent images, separated by empty | 4681 | * For a v2 image, shows the chain of parent images, separated by empty |
4674 | * lines. For v1 images or if there is no parent, shows "(no parent | 4682 | * 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); | |||
4730 | static DEVICE_ATTR(image_id, S_IRUGO, rbd_image_id_show, NULL); | 4738 | static DEVICE_ATTR(image_id, S_IRUGO, rbd_image_id_show, NULL); |
4731 | static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh); | 4739 | static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh); |
4732 | static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL); | 4740 | static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL); |
4741 | static DEVICE_ATTR(snap_id, S_IRUGO, rbd_snap_id_show, NULL); | ||
4733 | static DEVICE_ATTR(parent, S_IRUGO, rbd_parent_show, NULL); | 4742 | static DEVICE_ATTR(parent, S_IRUGO, rbd_parent_show, NULL); |
4734 | 4743 | ||
4735 | static struct attribute *rbd_attrs[] = { | 4744 | static struct attribute *rbd_attrs[] = { |
@@ -4745,6 +4754,7 @@ static struct attribute *rbd_attrs[] = { | |||
4745 | &dev_attr_name.attr, | 4754 | &dev_attr_name.attr, |
4746 | &dev_attr_image_id.attr, | 4755 | &dev_attr_image_id.attr, |
4747 | &dev_attr_current_snap.attr, | 4756 | &dev_attr_current_snap.attr, |
4757 | &dev_attr_snap_id.attr, | ||
4748 | &dev_attr_parent.attr, | 4758 | &dev_attr_parent.attr, |
4749 | &dev_attr_refresh.attr, | 4759 | &dev_attr_refresh.attr, |
4750 | NULL | 4760 | NULL |