aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-11-20 15:17:17 -0500
committerAlex Elder <elder@inktank.com>2013-01-17 17:34:59 -0500
commit8b84de7940b69fd7326946ba244621aa5fc412e0 (patch)
treee485144bdb7078a512c60e3c30dac24203fed047 /drivers/block/rbd.c
parent5efea49a98d1a3b3a7301d3a17f826ad4c31b290 (diff)
rbd: assign watch request more directly
Both rbd_req_sync_op() and rbd_do_request() have a "linger" parameter, which is the address of a pointer that should refer to the osd request structure used to issue a request to an osd. Only one case ever supplies a non-null "linger" argument: an CEPH_OSD_OP_WATCH start. And in that one case it is assigned &rbd_dev->watch_request. Within rbd_do_request() (where the assignment ultimately gets made) we know the rbd_dev and therefore its watch_request field. We also know whether the op being sent is CEPH_OSD_OP_WATCH start. Stop opaquely passing down the "linger" pointer, and instead just assign the value directly inside rbd_do_request() when it's needed. This makes it unnecessary for rbd_req_sync_watch() to make arrangements to hold a value that's not available until a bit later. This more clearly separates setting up a watch request from submitting it. 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.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 3802a7857280..a3a11c3c1cac 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1158,7 +1158,6 @@ static int rbd_do_request(struct request *rq,
1158 int coll_index, 1158 int coll_index,
1159 void (*rbd_cb)(struct ceph_osd_request *, 1159 void (*rbd_cb)(struct ceph_osd_request *,
1160 struct ceph_msg *), 1160 struct ceph_msg *),
1161 struct ceph_osd_request **linger_req,
1162 u64 *ver) 1161 u64 *ver)
1163{ 1162{
1164 struct ceph_osd_client *osdc; 1163 struct ceph_osd_client *osdc;
@@ -1210,9 +1209,9 @@ static int rbd_do_request(struct request *rq,
1210 ceph_osdc_build_request(osd_req, ofs, len, 1, op, 1209 ceph_osdc_build_request(osd_req, ofs, len, 1, op,
1211 snapc, snapid, &mtime); 1210 snapc, snapid, &mtime);
1212 1211
1213 if (linger_req) { 1212 if (op->op == CEPH_OSD_OP_WATCH && op->watch.flag) {
1214 ceph_osdc_set_request_linger(osdc, osd_req); 1213 ceph_osdc_set_request_linger(osdc, osd_req);
1215 *linger_req = osd_req; 1214 rbd_dev->watch_request = osd_req;
1216 } 1215 }
1217 1216
1218 ret = ceph_osdc_start_request(osdc, osd_req, false); 1217 ret = ceph_osdc_start_request(osdc, osd_req, false);
@@ -1296,7 +1295,6 @@ static int rbd_req_sync_op(struct rbd_device *rbd_dev,
1296 const char *object_name, 1295 const char *object_name,
1297 u64 ofs, u64 inbound_size, 1296 u64 ofs, u64 inbound_size,
1298 char *inbound, 1297 char *inbound,
1299 struct ceph_osd_request **linger_req,
1300 u64 *ver) 1298 u64 *ver)
1301{ 1299{
1302 int ret; 1300 int ret;
@@ -1317,7 +1315,7 @@ static int rbd_req_sync_op(struct rbd_device *rbd_dev,
1317 op, 1315 op,
1318 NULL, 0, 1316 NULL, 0,
1319 NULL, 1317 NULL,
1320 linger_req, ver); 1318 ver);
1321 if (ret < 0) 1319 if (ret < 0)
1322 goto done; 1320 goto done;
1323 1321
@@ -1383,7 +1381,7 @@ static int rbd_do_op(struct request *rq,
1383 flags, 1381 flags,
1384 op, 1382 op,
1385 coll, coll_index, 1383 coll, coll_index,
1386 rbd_req_cb, 0, NULL); 1384 rbd_req_cb, NULL);
1387 if (ret < 0) 1385 if (ret < 0)
1388 rbd_coll_end_req_index(rq, coll, coll_index, 1386 rbd_coll_end_req_index(rq, coll, coll_index,
1389 (s32)ret, seg_len); 1387 (s32)ret, seg_len);
@@ -1410,7 +1408,7 @@ static int rbd_req_sync_read(struct rbd_device *rbd_dev,
1410 return -ENOMEM; 1408 return -ENOMEM;
1411 1409
1412 ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ, 1410 ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ,
1413 op, object_name, ofs, len, buf, NULL, ver); 1411 op, object_name, ofs, len, buf, ver);
1414 rbd_osd_req_op_destroy(op); 1412 rbd_osd_req_op_destroy(op);
1415 1413
1416 return ret; 1414 return ret;
@@ -1436,7 +1434,7 @@ static int rbd_req_sync_notify_ack(struct rbd_device *rbd_dev,
1436 CEPH_OSD_FLAG_READ, 1434 CEPH_OSD_FLAG_READ,
1437 op, 1435 op,
1438 NULL, 0, 1436 NULL, 0,
1439 rbd_simple_req_cb, 0, NULL); 1437 rbd_simple_req_cb, NULL);
1440 1438
1441 rbd_osd_req_op_destroy(op); 1439 rbd_osd_req_op_destroy(op);
1442 1440
@@ -1469,7 +1467,6 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
1469 */ 1467 */
1470static int rbd_req_sync_watch(struct rbd_device *rbd_dev, int start) 1468static int rbd_req_sync_watch(struct rbd_device *rbd_dev, int start)
1471{ 1469{
1472 struct ceph_osd_request **linger_req = NULL;
1473 struct ceph_osd_req_op *op; 1470 struct ceph_osd_req_op *op;
1474 int ret = 0; 1471 int ret = 0;
1475 1472
@@ -1481,7 +1478,6 @@ static int rbd_req_sync_watch(struct rbd_device *rbd_dev, int start)
1481 &rbd_dev->watch_event); 1478 &rbd_dev->watch_event);
1482 if (ret < 0) 1479 if (ret < 0)
1483 return ret; 1480 return ret;
1484 linger_req = &rbd_dev->watch_request;
1485 } else { 1481 } else {
1486 rbd_assert(rbd_dev->watch_request != NULL); 1482 rbd_assert(rbd_dev->watch_request != NULL);
1487 } 1483 }
@@ -1493,7 +1489,7 @@ static int rbd_req_sync_watch(struct rbd_device *rbd_dev, int start)
1493 ret = rbd_req_sync_op(rbd_dev, 1489 ret = rbd_req_sync_op(rbd_dev,
1494 CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK, 1490 CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK,
1495 op, rbd_dev->header_name, 1491 op, rbd_dev->header_name,
1496 0, 0, NULL, linger_req, NULL); 1492 0, 0, NULL, NULL);
1497 1493
1498 /* Cancel the event if we're tearing down, or on error */ 1494 /* Cancel the event if we're tearing down, or on error */
1499 1495
@@ -1537,7 +1533,7 @@ static int rbd_req_sync_exec(struct rbd_device *rbd_dev,
1537 1533
1538 ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ, op, 1534 ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ, op,
1539 object_name, 0, inbound_size, inbound, 1535 object_name, 0, inbound_size, inbound,
1540 NULL, ver); 1536 ver);
1541 1537
1542 rbd_osd_req_op_destroy(op); 1538 rbd_osd_req_op_destroy(op);
1543 1539