All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov@gmail.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 15/16] rbd: add 'config_info' sysfs rbd device attribute
Date: Wed, 24 Aug 2016 15:18:39 +0200	[thread overview]
Message-ID: <1472044720-29116-16-git-send-email-idryomov@gmail.com> (raw)
In-Reply-To: <1472044720-29116-1-git-send-email-idryomov@gmail.com>

From: Mike Christie <mchristi@redhat.com>

Export the info used to setup the rbd image, so it can be used to remap
the image.

Signed-off-by: Mike Christie <mchristi@redhat.com>
[idryomov@gmail.com: do_rbd_add() EH]
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 Documentation/ABI/testing/sysfs-bus-rbd |  5 +++++
 drivers/block/rbd.c                     | 23 +++++++++++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-rbd b/Documentation/ABI/testing/sysfs-bus-rbd
index 7bf8d4fa6f63..6dccbf82fcf4 100644
--- a/Documentation/ABI/testing/sysfs-bus-rbd
+++ b/Documentation/ABI/testing/sysfs-bus-rbd
@@ -57,6 +57,11 @@ cluster_fsid
 
 	The ceph cluster UUID.  (August 2016, since 4.9.)
 
+config_info
+
+	The string written into /sys/bus/rbd/add{,_single_major}.  (August
+	2016, since 4.9.)
+
 features
 
 	A hexadecimal encoding of the feature bits for this image.
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 36ebec19dc20..8ff2dc872008 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -370,6 +370,7 @@ struct rbd_device {
 	unsigned long		flags;		/* possibly lock protected */
 	struct rbd_spec		*spec;
 	struct rbd_options	*opts;
+	char			*config_info;	/* add{,_single_major} string */
 
 	struct ceph_object_id	header_oid;
 	struct ceph_object_locator header_oloc;
@@ -4620,6 +4621,14 @@ static ssize_t rbd_cluster_fsid_show(struct device *dev,
 	return sprintf(buf, "%pU\n", &rbd_dev->rbd_client->client->fsid);
 }
 
+static ssize_t rbd_config_info_show(struct device *dev,
+				    struct device_attribute *attr, char *buf)
+{
+	struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
+
+	return sprintf(buf, "%s\n", rbd_dev->config_info);
+}
+
 static ssize_t rbd_pool_show(struct device *dev,
 			     struct device_attribute *attr, char *buf)
 {
@@ -4732,6 +4741,7 @@ 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(cluster_fsid, S_IRUGO, rbd_cluster_fsid_show, NULL);
+static DEVICE_ATTR(config_info, S_IRUSR, rbd_config_info_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(name, S_IRUGO, rbd_name_show, NULL);
@@ -4749,6 +4759,7 @@ static struct attribute *rbd_attrs[] = {
 	&dev_attr_client_addr.attr,
 	&dev_attr_client_id.attr,
 	&dev_attr_cluster_fsid.attr,
+	&dev_attr_config_info.attr,
 	&dev_attr_pool.attr,
 	&dev_attr_pool_id.attr,
 	&dev_attr_name.attr,
@@ -4824,6 +4835,7 @@ static void rbd_dev_free(struct rbd_device *rbd_dev)
 
 	ceph_oid_destroy(&rbd_dev->header_oid);
 	ceph_oloc_destroy(&rbd_dev->header_oloc);
+	kfree(rbd_dev->config_info);
 
 	rbd_put_client(rbd_dev->rbd_client);
 	rbd_spec_put(rbd_dev->spec);
@@ -6223,10 +6235,18 @@ static ssize_t do_rbd_add(struct bus_type *bus,
 	spec = NULL;		/* rbd_dev now owns this */
 	rbd_opts = NULL;	/* rbd_dev now owns this */
 
+	rbd_dev->config_info = kstrdup(buf, GFP_KERNEL);
+	if (!rbd_dev->config_info) {
+		rc = -ENOMEM;
+		goto err_out_rbd_dev;
+	}
+
 	down_write(&rbd_dev->header_rwsem);
 	rc = rbd_dev_image_probe(rbd_dev, 0);
-	if (rc < 0)
+	if (rc < 0) {
+		up_write(&rbd_dev->header_rwsem);
 		goto err_out_rbd_dev;
+	}
 
 	/* If we are mapping a snapshot it must be marked read-only */
 
@@ -6253,7 +6273,6 @@ out:
 	return rc;
 
 err_out_rbd_dev:
-	up_write(&rbd_dev->header_rwsem);
 	rbd_dev_destroy(rbd_dev);
 err_out_client:
 	rbd_put_client(rbdc);
-- 
2.4.3


  parent reply	other threads:[~2016-08-24 13:19 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 13:18 [PATCH 00/16] rbd: support for exclusive-lock + mpath remap bits Ilya Dryomov
2016-08-24 13:18 ` [PATCH 01/16] libceph: rename ceph_entity_name_encode() -> ceph_auth_entity_name_encode() Ilya Dryomov
2016-08-24 18:49   ` Alex Elder
2016-08-24 20:15     ` Ilya Dryomov
2016-08-24 13:18 ` [PATCH 02/16] libceph: support for CEPH_OSD_OP_LIST_WATCHERS Ilya Dryomov
2016-08-24 19:29   ` Alex Elder
2016-08-24 20:43     ` Ilya Dryomov
2016-08-24 13:18 ` [PATCH 03/16] libceph: add ceph_osdc_call() single-page helper Ilya Dryomov
2016-08-24 19:37   ` Alex Elder
2016-08-24 13:18 ` [PATCH 04/16] libceph: support for advisory locking on RADOS objects Ilya Dryomov
2016-08-24 19:42   ` Alex Elder
2016-08-24 20:49     ` Ilya Dryomov
2016-08-24 13:18 ` [PATCH 05/16] libceph: support for lock.lock_info Ilya Dryomov
2016-08-24 19:56   ` Alex Elder
2016-08-24 13:18 ` [PATCH 06/16] libceph: support for blacklisting clients Ilya Dryomov
2016-08-24 19:59   ` Alex Elder
2016-08-24 13:18 ` [PATCH 07/16] libceph: rename ceph_client_id() -> ceph_client_gid() Ilya Dryomov
2016-08-24 20:00   ` Alex Elder
2016-08-24 20:56     ` Ilya Dryomov
2016-08-24 13:18 ` [PATCH 08/16] rbd: introduce a per-device ordered workqueue Ilya Dryomov
2016-08-24 13:18 ` [PATCH 09/16] rbd: retry watch re-registration periodically Ilya Dryomov
2016-08-24 13:18 ` [PATCH 10/16] rbd: support for exclusive-lock feature Ilya Dryomov
2016-08-24 13:18 ` [PATCH 11/16] rbd: print capacity in decimal and features in hex Ilya Dryomov
2016-08-24 13:18 ` [PATCH 12/16] rbd: add 'client_addr' sysfs rbd device attribute Ilya Dryomov
2016-08-24 13:18 ` [PATCH 13/16] rbd: add 'cluster_fsid' " Ilya Dryomov
2016-08-24 13:18 ` [PATCH 14/16] rbd: add 'snap_id' " Ilya Dryomov
2016-08-24 13:18 ` Ilya Dryomov [this message]
2016-08-24 13:18 ` [PATCH 16/16] rbd: add force close option Ilya Dryomov
2016-08-24 18:34 ` [PATCH 00/16] rbd: support for exclusive-lock + mpath remap bits Mike Christie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472044720-29116-16-git-send-email-idryomov@gmail.com \
    --to=idryomov@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.