summaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@dreamhost.com>2012-01-24 11:08:37 -0500
committerAlex Elder <elder@dreamhost.com>2012-03-22 11:47:47 -0400
commit1dbb439913f0fc0bc30d36411a4a3b3202c0aab1 (patch)
tree7da9c0818f6ce8cff9068732fed25fd62d05ebd0 /drivers/block/rbd.c
parentee57741c5209154b8ef124bcaa2496da1b69a988 (diff)
rbd: do not duplicate ceph_client pointer in rbd_device
The rbd_device structure maintains a duplicate copy of the ceph_client pointer maintained in its rbd_client structure. There appears to be no good reason for this, and its presence presents a risk of them getting out of synch or otherwise misused. So kill it off, and use the rbd_client copy only. Signed-off-by: Alex Elder <elder@dreamhost.com> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index ed6711e35323..dcdfe8dbf4f1 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -140,7 +140,6 @@ struct rbd_device {
140 struct gendisk *disk; /* blkdev's gendisk and rq */ 140 struct gendisk *disk; /* blkdev's gendisk and rq */
141 struct request_queue *q; 141 struct request_queue *q;
142 142
143 struct ceph_client *client;
144 struct rbd_client *rbd_client; 143 struct rbd_client *rbd_client;
145 144
146 char name[DEV_NAME_LEN]; /* blkdev name, e.g. rbd3 */ 145 char name[DEV_NAME_LEN]; /* blkdev name, e.g. rbd3 */
@@ -388,7 +387,6 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr,
388 /* using an existing client */ 387 /* using an existing client */
389 kref_get(&rbdc->kref); 388 kref_get(&rbdc->kref);
390 rbd_dev->rbd_client = rbdc; 389 rbd_dev->rbd_client = rbdc;
391 rbd_dev->client = rbdc->client;
392 spin_unlock(&node_lock); 390 spin_unlock(&node_lock);
393 return 0; 391 return 0;
394 } 392 }
@@ -401,7 +399,6 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr,
401 } 399 }
402 400
403 rbd_dev->rbd_client = rbdc; 401 rbd_dev->rbd_client = rbdc;
404 rbd_dev->client = rbdc->client;
405 return 0; 402 return 0;
406done_err: 403done_err:
407 kfree(rbd_opts); 404 kfree(rbd_opts);
@@ -435,7 +432,6 @@ static void rbd_put_client(struct rbd_device *rbd_dev)
435 kref_put(&rbd_dev->rbd_client->kref, rbd_client_release); 432 kref_put(&rbd_dev->rbd_client->kref, rbd_client_release);
436 spin_unlock(&node_lock); 433 spin_unlock(&node_lock);
437 rbd_dev->rbd_client = NULL; 434 rbd_dev->rbd_client = NULL;
438 rbd_dev->client = NULL;
439} 435}
440 436
441/* 437/*
@@ -858,6 +854,7 @@ static int rbd_do_request(struct request *rq,
858 struct rbd_request *req_data; 854 struct rbd_request *req_data;
859 struct ceph_osd_request_head *reqhead; 855 struct ceph_osd_request_head *reqhead;
860 struct rbd_image_header *header = &dev->header; 856 struct rbd_image_header *header = &dev->header;
857 struct ceph_osd_client *osdc;
861 858
862 req_data = kzalloc(sizeof(*req_data), GFP_NOIO); 859 req_data = kzalloc(sizeof(*req_data), GFP_NOIO);
863 if (!req_data) { 860 if (!req_data) {
@@ -876,11 +873,9 @@ static int rbd_do_request(struct request *rq,
876 873
877 down_read(&header->snap_rwsem); 874 down_read(&header->snap_rwsem);
878 875
879 req = ceph_osdc_alloc_request(&dev->client->osdc, flags, 876 osdc = &dev->rbd_client->client->osdc;
880 snapc, 877 req = ceph_osdc_alloc_request(osdc, flags, snapc, ops,
881 ops, 878 false, GFP_NOIO, pages, bio);
882 false,
883 GFP_NOIO, pages, bio);
884 if (!req) { 879 if (!req) {
885 up_read(&header->snap_rwsem); 880 up_read(&header->snap_rwsem);
886 ret = -ENOMEM; 881 ret = -ENOMEM;
@@ -909,8 +904,8 @@ static int rbd_do_request(struct request *rq,
909 layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER); 904 layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
910 layout->fl_pg_preferred = cpu_to_le32(-1); 905 layout->fl_pg_preferred = cpu_to_le32(-1);
911 layout->fl_pg_pool = cpu_to_le32(dev->poolid); 906 layout->fl_pg_pool = cpu_to_le32(dev->poolid);
912 ceph_calc_raw_layout(&dev->client->osdc, layout, snapid, 907 ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
913 ofs, &len, &bno, req, ops); 908 req, ops);
914 909
915 ceph_osdc_build_request(req, ofs, &len, 910 ceph_osdc_build_request(req, ofs, &len,
916 ops, 911 ops,
@@ -920,16 +915,16 @@ static int rbd_do_request(struct request *rq,
920 up_read(&header->snap_rwsem); 915 up_read(&header->snap_rwsem);
921 916
922 if (linger_req) { 917 if (linger_req) {
923 ceph_osdc_set_request_linger(&dev->client->osdc, req); 918 ceph_osdc_set_request_linger(osdc, req);
924 *linger_req = req; 919 *linger_req = req;
925 } 920 }
926 921
927 ret = ceph_osdc_start_request(&dev->client->osdc, req, false); 922 ret = ceph_osdc_start_request(osdc, req, false);
928 if (ret < 0) 923 if (ret < 0)
929 goto done_err; 924 goto done_err;
930 925
931 if (!rbd_cb) { 926 if (!rbd_cb) {
932 ret = ceph_osdc_wait_request(&dev->client->osdc, req); 927 ret = ceph_osdc_wait_request(osdc, req);
933 if (ver) 928 if (ver)
934 *ver = le64_to_cpu(req->r_reassert_version.version); 929 *ver = le64_to_cpu(req->r_reassert_version.version);
935 dout("reassert_ver=%lld\n", 930 dout("reassert_ver=%lld\n",
@@ -1227,7 +1222,7 @@ static int rbd_req_sync_watch(struct rbd_device *dev,
1227 u64 ver) 1222 u64 ver)
1228{ 1223{
1229 struct ceph_osd_req_op *ops; 1224 struct ceph_osd_req_op *ops;
1230 struct ceph_osd_client *osdc = &dev->client->osdc; 1225 struct ceph_osd_client *osdc = &dev->rbd_client->client->osdc;
1231 1226
1232 int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_WATCH, 0); 1227 int ret = rbd_create_rw_ops(&ops, 1, CEPH_OSD_OP_WATCH, 0);
1233 if (ret < 0) 1228 if (ret < 0)
@@ -1314,7 +1309,7 @@ static int rbd_req_sync_notify(struct rbd_device *dev,
1314 const char *obj) 1309 const char *obj)
1315{ 1310{
1316 struct ceph_osd_req_op *ops; 1311 struct ceph_osd_req_op *ops;
1317 struct ceph_osd_client *osdc = &dev->client->osdc; 1312 struct ceph_osd_client *osdc = &dev->rbd_client->client->osdc;
1318 struct ceph_osd_event *event; 1313 struct ceph_osd_event *event;
1319 struct rbd_notify_info info; 1314 struct rbd_notify_info info;
1320 int payload_len = sizeof(u32) + sizeof(u32); 1315 int payload_len = sizeof(u32) + sizeof(u32);
@@ -1623,13 +1618,14 @@ static int rbd_header_add_snap(struct rbd_device *dev,
1623 int ret; 1618 int ret;
1624 void *data, *p, *e; 1619 void *data, *p, *e;
1625 u64 ver; 1620 u64 ver;
1621 struct ceph_mon_client *monc;
1626 1622
1627 /* we should create a snapshot only if we're pointing at the head */ 1623 /* we should create a snapshot only if we're pointing at the head */
1628 if (dev->cur_snap) 1624 if (dev->cur_snap)
1629 return -EINVAL; 1625 return -EINVAL;
1630 1626
1631 ret = ceph_monc_create_snapid(&dev->client->monc, dev->poolid, 1627 monc = &dev->rbd_client->client->monc;
1632 &new_snapid); 1628 ret = ceph_monc_create_snapid(monc, dev->poolid, &new_snapid);
1633 dout("created snapid=%lld\n", new_snapid); 1629 dout("created snapid=%lld\n", new_snapid);
1634 if (ret < 0) 1630 if (ret < 0)
1635 return ret; 1631 return ret;
@@ -1809,7 +1805,8 @@ static ssize_t rbd_client_id_show(struct device *dev,
1809{ 1805{
1810 struct rbd_device *rbd_dev = dev_to_rbd(dev); 1806 struct rbd_device *rbd_dev = dev_to_rbd(dev);
1811 1807
1812 return sprintf(buf, "client%lld\n", ceph_client_id(rbd_dev->client)); 1808 return sprintf(buf, "client%lld\n",
1809 ceph_client_id(rbd_dev->rbd_client->client));
1813} 1810}
1814 1811
1815static ssize_t rbd_pool_show(struct device *dev, 1812static ssize_t rbd_pool_show(struct device *dev,
@@ -2233,7 +2230,7 @@ static ssize_t rbd_add(struct bus_type *bus,
2233 mutex_unlock(&ctl_mutex); 2230 mutex_unlock(&ctl_mutex);
2234 2231
2235 /* pick the pool */ 2232 /* pick the pool */
2236 osdc = &rbd_dev->client->osdc; 2233 osdc = &rbd_dev->rbd_client->client->osdc;
2237 rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name); 2234 rc = ceph_pg_poolid_by_name(osdc->osdmap, rbd_dev->pool_name);
2238 if (rc < 0) 2235 if (rc < 0)
2239 goto err_out_client; 2236 goto err_out_client;
@@ -2312,9 +2309,12 @@ static void rbd_dev_release(struct device *dev)
2312 struct rbd_device *rbd_dev = 2309 struct rbd_device *rbd_dev =
2313 container_of(dev, struct rbd_device, dev); 2310 container_of(dev, struct rbd_device, dev);
2314 2311
2315 if (rbd_dev->watch_request) 2312 if (rbd_dev->watch_request) {
2316 ceph_osdc_unregister_linger_request(&rbd_dev->client->osdc, 2313 struct ceph_client *client = rbd_dev->rbd_client->client;
2314
2315 ceph_osdc_unregister_linger_request(&client->osdc,
2317 rbd_dev->watch_request); 2316 rbd_dev->watch_request);
2317 }
2318 if (rbd_dev->watch_event) 2318 if (rbd_dev->watch_event)
2319 rbd_req_sync_unwatch(rbd_dev, rbd_dev->obj_md_name); 2319 rbd_req_sync_unwatch(rbd_dev, rbd_dev->obj_md_name);
2320 2320