aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-11-30 18:53:04 -0500
committerSage Weil <sage@inktank.com>2013-02-13 21:29:08 -0500
commitb8d70035b35dc12135d5835b659b229bcd6d4f94 (patch)
tree95b642bf419eb7bbeb147f19a36fcce19f56128e /drivers/block
parentecf7a0318b1b026fb147623c36324fa8c73447a9 (diff)
rbd: use new code for notify ack
Use the new object request tracking mechanism for handling a notify_ack request. Move the callback function below the definition of this so we don't have to do a pre-declaration. This resolves: http://tracker.newdream.net/issues/3754 Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c76
1 files changed, 55 insertions, 21 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index a6a85271380a..1428795571c9 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1349,27 +1349,6 @@ static int rbd_req_sync_notify_ack(struct rbd_device *rbd_dev,
1349 return ret; 1349 return ret;
1350} 1350}
1351 1351
1352static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
1353{
1354 struct rbd_device *rbd_dev = (struct rbd_device *)data;
1355 u64 hver;
1356 int rc;
1357
1358 if (!rbd_dev)
1359 return;
1360
1361 dout("rbd_watch_cb %s notify_id=%llu opcode=%u\n",
1362 rbd_dev->header_name, (unsigned long long) notify_id,
1363 (unsigned int) opcode);
1364 rc = rbd_dev_refresh(rbd_dev, &hver);
1365 if (rc)
1366 rbd_warn(rbd_dev, "got notification but failed to "
1367 " update snaps: %d\n", rc);
1368
1369 rbd_req_sync_notify_ack(rbd_dev, hver, notify_id);
1370}
1371
1372
1373/* 1352/*
1374 * Synchronous osd object method call 1353 * Synchronous osd object method call
1375 */ 1354 */
@@ -1468,6 +1447,7 @@ static void rbd_osd_req_callback(struct ceph_osd_request *osd_req,
1468 case CEPH_OSD_OP_WRITE: 1447 case CEPH_OSD_OP_WRITE:
1469 rbd_osd_write_callback(obj_request, op); 1448 rbd_osd_write_callback(obj_request, op);
1470 break; 1449 break;
1450 case CEPH_OSD_OP_NOTIFY_ACK:
1471 case CEPH_OSD_OP_WATCH: 1451 case CEPH_OSD_OP_WATCH:
1472 rbd_osd_trivial_callback(obj_request, op); 1452 rbd_osd_trivial_callback(obj_request, op);
1473 break; 1453 break;
@@ -1837,6 +1817,60 @@ static int rbd_img_request_submit(struct rbd_img_request *img_request)
1837 return 0; 1817 return 0;
1838} 1818}
1839 1819
1820static int rbd_obj_notify_ack_sync(struct rbd_device *rbd_dev,
1821 u64 ver, u64 notify_id)
1822{
1823 struct rbd_obj_request *obj_request;
1824 struct ceph_osd_req_op *op;
1825 struct ceph_osd_client *osdc;
1826 int ret;
1827
1828 obj_request = rbd_obj_request_create(rbd_dev->header_name, 0, 0,
1829 OBJ_REQUEST_NODATA);
1830 if (!obj_request)
1831 return -ENOMEM;
1832
1833 ret = -ENOMEM;
1834 op = rbd_osd_req_op_create(CEPH_OSD_OP_NOTIFY_ACK, notify_id, ver);
1835 if (!op)
1836 goto out;
1837 obj_request->osd_req = rbd_osd_req_create(rbd_dev, false,
1838 obj_request, op);
1839 rbd_osd_req_op_destroy(op);
1840 if (!obj_request->osd_req)
1841 goto out;
1842
1843 osdc = &rbd_dev->rbd_client->client->osdc;
1844 ret = rbd_obj_request_submit(osdc, obj_request);
1845 if (!ret)
1846 ret = rbd_obj_request_wait(obj_request);
1847out:
1848 rbd_obj_request_put(obj_request);
1849
1850 return ret;
1851}
1852
1853static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
1854{
1855 struct rbd_device *rbd_dev = (struct rbd_device *)data;
1856 u64 hver;
1857 int rc;
1858
1859 if (!rbd_dev)
1860 return;
1861
1862 dout("rbd_watch_cb %s notify_id=%llu opcode=%u\n",
1863 rbd_dev->header_name, (unsigned long long) notify_id,
1864 (unsigned int) opcode);
1865 rc = rbd_dev_refresh(rbd_dev, &hver);
1866 if (rc)
1867 rbd_warn(rbd_dev, "got notification but failed to "
1868 " update snaps: %d\n", rc);
1869
1870 (void) rbd_req_sync_notify_ack; /* avoid a warning */
1871 rbd_obj_notify_ack_sync(rbd_dev, hver, notify_id);
1872}
1873
1840/* 1874/*
1841 * Request sync osd watch/unwatch. The value of "start" determines 1875 * Request sync osd watch/unwatch. The value of "start" determines
1842 * whether a watch request is being initiated or torn down. 1876 * whether a watch request is being initiated or torn down.