aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-07-12 11:46:35 -0400
committerSage Weil <sage@inktank.com>2012-07-30 12:30:00 -0400
commit9bb2f334b9b5f2eb6030b7988b7f2302c3115bbb (patch)
tree8e43a1a384101819c97d5ab9114c2bf748431463 /drivers/block/rbd.c
parentca1e49a6afe87ea4e2d3e73e10d1d3c0fad2aa3f (diff)
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: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 523413bdca92..80320fd1c621 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -167,7 +167,7 @@ struct rbd_device {
167 int obj_len; 167 int obj_len;
168 char obj_md_name[RBD_MAX_MD_NAME_LEN]; /* hdr nm. */ 168 char obj_md_name[RBD_MAX_MD_NAME_LEN]; /* hdr nm. */
169 char pool_name[RBD_MAX_POOL_NAME_LEN]; 169 char pool_name[RBD_MAX_POOL_NAME_LEN];
170 int poolid; 170 int pool_id;
171 171
172 struct ceph_osd_event *watch_event; 172 struct ceph_osd_event *watch_event;
173 struct ceph_osd_request *watch_request; 173 struct ceph_osd_request *watch_request;
@@ -920,7 +920,7 @@ static int rbd_do_request(struct request *rq,
920 layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); 920 layout->fl_stripe_unit = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
921 layout->fl_stripe_count = cpu_to_le32(1); 921 layout->fl_stripe_count = cpu_to_le32(1);
922 layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); 922 layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
923 layout->fl_pg_pool = cpu_to_le32(dev->poolid); 923 layout->fl_pg_pool = cpu_to_le32(dev->pool_id);
924 ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno, 924 ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
925 req, ops); 925 req, ops);
926 926
@@ -1643,7 +1643,7 @@ static int rbd_header_add_snap(struct rbd_device *dev,
1643 return -EINVAL; 1643 return -EINVAL;
1644 1644
1645 monc = &dev->rbd_client->client->monc; 1645 monc = &dev->rbd_client->client->monc;
1646 ret = ceph_monc_create_snapid(monc, dev->poolid, &new_snapid); 1646 ret = ceph_monc_create_snapid(monc, dev->pool_id, &new_snapid);
1647 dout("created snapid=%lld\n", new_snapid); 1647 dout("created snapid=%lld\n", new_snapid);
1648 if (ret < 0) 1648 if (ret < 0)
1649 return ret; 1649 return ret;
@@ -1847,6 +1847,14 @@ static ssize_t rbd_pool_show(struct device *dev,
1847 return sprintf(buf, "%s\n", rbd_dev->pool_name); 1847 return sprintf(buf, "%s\n", rbd_dev->pool_name);
1848} 1848}
1849 1849
1850static ssize_t rbd_pool_id_show(struct device *dev,
1851 struct device_attribute *attr, char *buf)
1852{
1853 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
1854
1855 return sprintf(buf, "%d\n", rbd_dev->pool_id);
1856}
1857
1850static ssize_t rbd_name_show(struct device *dev, 1858static ssize_t rbd_name_show(struct device *dev,
1851 struct device_attribute *attr, char *buf) 1859 struct device_attribute *attr, char *buf)
1852{ 1860{
@@ -1887,6 +1895,7 @@ static DEVICE_ATTR(size, S_IRUGO, rbd_size_show, NULL);
1887static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL); 1895static DEVICE_ATTR(major, S_IRUGO, rbd_major_show, NULL);
1888static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL); 1896static DEVICE_ATTR(client_id, S_IRUGO, rbd_client_id_show, NULL);
1889static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL); 1897static DEVICE_ATTR(pool, S_IRUGO, rbd_pool_show, NULL);
1898static DEVICE_ATTR(pool_id, S_IRUGO, rbd_pool_id_show, NULL);
1890static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL); 1899static DEVICE_ATTR(name, S_IRUGO, rbd_name_show, NULL);
1891static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh); 1900static DEVICE_ATTR(refresh, S_IWUSR, NULL, rbd_image_refresh);
1892static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL); 1901static DEVICE_ATTR(current_snap, S_IRUGO, rbd_snap_show, NULL);
@@ -1897,6 +1906,7 @@ static struct attribute *rbd_attrs[] = {
1897 &dev_attr_major.attr, 1906 &dev_attr_major.attr,
1898 &dev_attr_client_id.attr, 1907 &dev_attr_client_id.attr,
1899 &dev_attr_pool.attr, 1908 &dev_attr_pool.attr,
1909 &dev_attr_pool_id.attr,
1900 &dev_attr_name.attr, 1910 &dev_attr_name.attr,
1901 &dev_attr_current_snap.attr, 1911 &dev_attr_current_snap.attr,
1902 &dev_attr_refresh.attr, 1912 &dev_attr_refresh.attr,
@@ -2430,7 +2440,7 @@ static ssize_t rbd_add(struct bus_type *bus,
2430 rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name); 2440 rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name);
2431 if (rc < 0) 2441 if (rc < 0)
2432 goto err_out_client; 2442 goto err_out_client;
2433 rbd_dev->poolid = rc; 2443 rbd_dev->pool_id = rc;
2434 2444
2435 /* register our block device */ 2445 /* register our block device */
2436 rc = register_blkdev(0, rbd_dev->name); 2446 rc = register_blkdev(0, rbd_dev->name);