From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH] rbd: create pool_id device attribute
Date: Thu, 12 Jul 2012 12:05:20 -0500 [thread overview]
Message-ID: <4FFF03D0.2010604@inktank.com> (raw)
In-Reply-To: <4FFD875B.3060608@inktank.com>
Add an entry under /sys/bus/rbd/devices/<N>/ named "pool_id" that
provides the id for the pool the rbd image is assocatied with. This
is in addition to the pool name already provided.
Rename the "poolid" field in struct rbd_device to be "pool_id".
Signed-off-by: Alex Elder <elder@inktank.com>
---
drivers/block/rbd.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
Index: b/drivers/block/rbd.c
===================================================================
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -167,7 +167,7 @@ struct rbd_device {
int obj_len;
char obj_md_name[RBD_MAX_MD_NAME_LEN]; /* hdr nm. */
char pool_name[RBD_MAX_POOL_NAME_LEN];
- int poolid;
+ int pool_id;
struct ceph_osd_event *watch_event;
struct ceph_osd_request *watch_request;
@@ -920,7 +920,7 @@ static int rbd_do_request(struct request
layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
layout->fl_stripe_count = cpu_to_le32(1);
layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
- layout->fl_pg_pool = cpu_to_le32(dev->poolid);
+ layout->fl_pg_pool = cpu_to_le32(dev->pool_id);
ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
req, ops);
@@ -1643,7 +1643,7 @@ static int rbd_header_add_snap(struct rb
return -EINVAL;
monc = &dev->rbd_client->client->monc;
- ret = ceph_monc_create_snapid(monc, dev->poolid, &new_snapid);
+ ret = ceph_monc_create_snapid(monc, dev->pool_id, &new_snapid);
dout("created snapid=%lld\n", new_snapid);
if (ret < 0)
return ret;
@@ -1847,6 +1847,14 @@ static ssize_t rbd_pool_show(struct devi
return sprintf(buf, "%s\n", rbd_dev->pool_name);
}
+static ssize_t rbd_pool_id_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
+
+ return sprintf(buf, "%d\n", rbd_dev->pool_id);
+}
+
static ssize_t rbd_name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -1887,6 +1895,7 @@ static DEVICE_ATTR(size, S_IRUGO, rbd_si
static DEVICE_ATTR(major, S_IRUGO, rbd_major_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_id, S_IRUGO, rbd_pool_id_show, NULL);
static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL);
static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
@@ -1897,6 +1906,7 @@ static struct attribute *rbd_attrs[] = {
&dev_attr_major.attr,
&dev_attr_client_id.attr,
&dev_attr_pool.attr,
+ &dev_attr_pool_id.attr,
&dev_attr_name.attr,
&dev_attr_current_snap.attr,
&dev_attr_refresh.attr,
@@ -2430,7 +2440,7 @@ static ssize_t rbd_add(struct bus_type *
rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name);
if (rc < 0)
goto err_out_client;
- rbd_dev->poolid = rc;
+ rbd_dev->pool_id = rc;
/* register our block device */
rc = register_blkdev(0, rbd_dev->name);
next prev parent reply other threads:[~2012-07-12 17:05 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 13:49 [PATCH 00/16] rbd: updates and enhancements Alex Elder
2012-07-11 14:00 ` [PATCH 01/16] libceph: fix off-by-one bug in ceph_encode_filepath() Alex Elder
2012-07-11 16:59 ` Yehuda Sadeh
2012-07-11 18:35 ` Josh Durgin
2012-07-11 14:00 ` [PATCH 02/16] rbd: drop a useless local variable Alex Elder
2012-07-11 16:58 ` Yehuda Sadeh Weinraub
2012-07-11 18:36 ` Josh Durgin
2012-07-11 14:00 ` [PATCH 03/16] libceph: define ceph_decode_string() Alex Elder
2012-07-11 17:13 ` Yehuda Sadeh
2012-07-11 18:43 ` Josh Durgin
2012-07-11 22:09 ` [PATCH v2 " Alex Elder
2012-07-12 17:13 ` Alex Elder
2012-07-11 14:01 ` [PATCH 04/16] libceph: define ceph_extract_encoded_string() Alex Elder
2012-07-11 17:20 ` Yehuda Sadeh
2012-07-11 17:45 ` Sage Weil
2012-07-11 19:14 ` Alex Elder
2012-07-11 19:26 ` Yehuda Sadeh
2012-07-11 22:10 ` [PATCH v2 " Alex Elder
2012-07-12 17:13 ` [PATCH v3 " Alex Elder
2012-07-12 18:20 ` Sage Weil
2012-07-12 19:48 ` Alex Elder
2012-07-12 22:47 ` Alex Elder
2012-07-12 22:47 ` [PATCH v4 " Alex Elder
2012-07-11 14:01 ` [PATCH 05/16] rbd: define dup_token() Alex Elder
2012-07-11 17:48 ` Yehuda Sadeh
2012-07-11 21:50 ` Alex Elder
2012-07-11 18:50 ` Josh Durgin
2012-07-11 14:01 ` [PATCH 06/16] rbd: rename rbd_dev->block_name Alex Elder
2012-07-11 17:55 ` Yehuda Sadeh
2012-07-11 19:02 ` Josh Durgin
2012-07-11 22:13 ` Alex Elder
2012-07-11 14:01 ` [PATCH 07/16] rbd: dynamically allocate object prefix Alex Elder
2012-07-11 19:12 ` Josh Durgin
2012-07-11 19:17 ` Alex Elder
2012-07-12 17:24 ` [PATCH v2 " Alex Elder
2012-07-12 17:42 ` Josh Durgin
2012-07-11 14:02 ` [PATCH 08/16] rbd: don't store pool name in struct rbd_dev Alex Elder
2012-07-11 19:36 ` Josh Durgin
2012-07-11 20:19 ` Sage Weil
2012-07-11 22:25 ` Alex Elder
2012-07-11 23:32 ` Josh Durgin
2012-07-12 2:59 ` Alex Elder
2012-07-12 4:19 ` Josh Durgin
2012-07-12 17:05 ` Alex Elder
2012-07-12 17:05 ` Alex Elder [this message]
2012-07-12 17:16 ` [PATCH] rbd: create pool_id device attribute Josh Durgin
2012-07-12 17:35 ` Alex Elder
2012-07-12 17:05 ` [PATCH] rbd: dynamically allocate pool name Alex Elder
2012-07-12 17:21 ` Josh Durgin
2012-07-11 14:02 ` [PATCH 09/16] rbd: dynamically allocate image header name Alex Elder
2012-07-11 20:41 ` Josh Durgin
2012-07-11 14:02 ` [PATCH 10/16] rbd: dynamically allocate image name Alex Elder
2012-07-11 20:49 ` Josh Durgin
2012-07-11 20:52 ` Josh Durgin
2012-07-12 11:12 ` Alex Elder
2012-07-11 14:02 ` [PATCH 11/16] rbd: dynamically allocate snapshot name Alex Elder
2012-07-11 20:53 ` Josh Durgin
2012-07-11 14:02 ` [PATCH 12/16] rbd: use rbd_dev consistently Alex Elder
2012-07-11 20:56 ` Josh Durgin
2012-07-11 14:02 ` [PATCH 13/16] rbd: rename some fields in struct rbd_dev Alex Elder
2012-07-11 21:01 ` Josh Durgin
2012-07-12 11:14 ` Alex Elder
2012-07-11 14:02 ` [PATCH 14/16] rbd: more symbol renames Alex Elder
2012-07-11 21:03 ` Josh Durgin
2012-07-12 11:15 ` Alex Elder
2012-07-11 14:03 ` [PATCH 15/16] rbd: option " Alex Elder
2012-07-11 21:07 ` Josh Durgin
2012-07-11 14:03 ` [PATCH 16/16] rbd: kill num_reply parameters Alex Elder
2012-07-11 21:07 ` Josh Durgin
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=4FFF03D0.2010604@inktank.com \
--to=elder@inktank.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox