diff mbox

[v2] rbd: show the rbd options in sysfs

Message ID 1522044280-27647-1-git-send-email-dongsheng.yang@easystack.cn (mailing list archive)
State New, archived
Headers show

Commit Message

Dongsheng Yang March 26, 2018, 6:04 a.m. UTC
We need to know the rbd options for a rbd device, such as whether lock_on_read
is true or false. then this patch introduce a rbd_options to show the rbd options in sysfs.

Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
---
 drivers/block/rbd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 49e227e..588b65a 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4129,6 +4129,18 @@  static ssize_t rbd_image_refresh(struct device *dev,
 	return size;
 }
 
+static ssize_t rbd_options_show(struct device *dev,
+			     struct device_attribute *attr, char *buf)
+{
+	struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
+
+	return sprintf(buf, "queue_depth=%llu,read_only=%s,lock_on_read=%s,exclusive=%s\n",
+		(unsigned long long)rbd_dev->opts->queue_depth,
+		rbd_dev->opts->read_only? "true" : "false",
+		rbd_dev->opts->lock_on_read? "true" : "false",
+		rbd_dev->opts->exclusive? "true" : "false");
+}
+
 static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL);
 static DEVICE_ATTR(features, S_IRUGO, rbd_features_show, NULL);
 static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL);
@@ -4145,6 +4157,7 @@  static ssize_t rbd_image_refresh(struct device *dev,
 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(rbd_options, S_IRUGO, rbd_options_show, NULL);
 
 static struct attribute *rbd_attrs[] = {
 	&dev_attr_size.attr,
@@ -4163,6 +4176,7 @@  static ssize_t rbd_image_refresh(struct device *dev,
 	&dev_attr_snap_id.attr,
 	&dev_attr_parent.attr,
 	&dev_attr_refresh.attr,
+	&dev_attr_rbd_options.attr,
 	NULL
 };