Commit 9bb2f334 authored by Alex Elder's avatar Alex Elder Committed by Sage Weil

rbd: create pool_id device attribute

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".

Update the documentation to reflect the addition of this new entry.
Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
parent ca1e49a6
...@@ -35,8 +35,14 @@ name ...@@ -35,8 +35,14 @@ name
pool pool
The pool where this rbd image resides. The pool-name pair is unique The name of the storage pool where this rbd image resides.
per rados system. An rbd image name is unique within its pool.
pool_id
The unique identifier for the rbd image's pool. This is
a permanent attribute of the pool. A pool's id will never
change.
size size
......
...@@ -167,7 +167,7 @@ struct rbd_device { ...@@ -167,7 +167,7 @@ struct rbd_device {
int obj_len; int obj_len;
char obj_md_name[RBD_MAX_MD_NAME_LEN]; /* hdr nm. */ char obj_md_name[RBD_MAX_MD_NAME_LEN]; /* hdr nm. */
char pool_name[RBD_MAX_POOL_NAME_LEN]; char pool_name[RBD_MAX_POOL_NAME_LEN];
int poolid; int pool_id;
struct ceph_osd_event *watch_event; struct ceph_osd_event *watch_event;
struct ceph_osd_request *watch_request; struct ceph_osd_request *watch_request;
...@@ -920,7 +920,7 @@ static int rbd_do_request(struct request *rq, ...@@ -920,7 +920,7 @@ static int rbd_do_request(struct request *rq,
layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
layout->fl_stripe_count = cpu_to_le32(1); layout->fl_stripe_count = cpu_to_le32(1);
layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); 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, ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
req, ops); req, ops);
...@@ -1643,7 +1643,7 @@ static int rbd_header_add_snap(struct rbd_device *dev, ...@@ -1643,7 +1643,7 @@ static int rbd_header_add_snap(struct rbd_device *dev,
return -EINVAL; return -EINVAL;
monc = &dev->rbd_client->client->monc; 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); dout("created snapid=%lld\n", new_snapid);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1847,6 +1847,14 @@ static ssize_t rbd_pool_show(struct device *dev, ...@@ -1847,6 +1847,14 @@ static ssize_t rbd_pool_show(struct device *dev,
return sprintf(buf, "%s\n", rbd_dev->pool_name); 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, static ssize_t rbd_name_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -1887,6 +1895,7 @@ static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL); ...@@ -1887,6 +1895,7 @@ static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL);
static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL); 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(client_id, S_IRUGO, rbd_client_id_show, NULL);
static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_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(name, S_IRUGO, rbd_name_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);
...@@ -1897,6 +1906,7 @@ static struct attribute *rbd_attrs[] = { ...@@ -1897,6 +1906,7 @@ static struct attribute *rbd_attrs[] = {
&dev_attr_major.attr, &dev_attr_major.attr,
&dev_attr_client_id.attr, &dev_attr_client_id.attr,
&dev_attr_pool.attr, &dev_attr_pool.attr,
&dev_attr_pool_id.attr,
&dev_attr_name.attr, &dev_attr_name.attr,
&dev_attr_current_snap.attr, &dev_attr_current_snap.attr,
&dev_attr_refresh.attr, &dev_attr_refresh.attr,
...@@ -2430,7 +2440,7 @@ static ssize_t rbd_add(struct bus_type *bus, ...@@ -2430,7 +2440,7 @@ static ssize_t rbd_add(struct bus_type *bus,
rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name); rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name);
if (rc < 0) if (rc < 0)
goto err_out_client; goto err_out_client;
rbd_dev->poolid = rc; rbd_dev->pool_id = rc;
/* register our block device */ /* register our block device */
rc = register_blkdev(0, rbd_dev->name); rc = register_blkdev(0, rbd_dev->name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment