aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYan, Zheng <zheng.z.yan@intel.com>2013-06-24 02:41:27 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-09 15:24:25 -0500
commitef0b67e4b1f57d14f314a206338e5dd806a08b21 (patch)
tree747e98c1472a24f299eda29b1e84e4213745033c
parent724184c7a1fc44955f8900c382f18545423bc486 (diff)
libceph: call r_unsafe_callback when unsafe reply is received
commit 61c5d6bf7074ee32d014dcdf7698dc8c59eb712d upstream. We can't use !req->r_sent to check if OSD request is sent for the first time, this is because __cancel_request() zeros req->r_sent when OSD map changes. Rather than adding a new variable to struct ceph_osd_request to indicate if it's sent for the first time, We can call the unsafe callback only when unsafe OSD reply is received. If OSD's first reply is safe, just skip calling the unsafe callback. The purpose of unsafe callback is adding unsafe request to a list, so that fsync(2) can wait for the safe reply. fsync(2) doesn't need to wait for a write(2) that hasn't returned yet. So it's OK to add request to the unsafe list when the first OSD reply is received. (ceph_sync_write() returns after receiving the first OSD reply) Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com> Reviewed-by: Sage Weil <sage@inktank.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/ceph/osd_client.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 3e46e538cbf5..b0e9ed6aeb80 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1337,10 +1337,6 @@ static void __send_request(struct ceph_osd_client *osdc,
1337 1337
1338 ceph_msg_get(req->r_request); /* send consumes a ref */ 1338 ceph_msg_get(req->r_request); /* send consumes a ref */
1339 1339
1340 /* Mark the request unsafe if this is the first timet's being sent. */
1341
1342 if (!req->r_sent && req->r_unsafe_callback)
1343 req->r_unsafe_callback(req, true);
1344 req->r_sent = req->r_osd->o_incarnation; 1340 req->r_sent = req->r_osd->o_incarnation;
1345 1341
1346 ceph_con_send(&req->r_osd->o_con, req->r_request); 1342 ceph_con_send(&req->r_osd->o_con, req->r_request);
@@ -1431,8 +1427,6 @@ static void handle_osds_timeout(struct work_struct *work)
1431 1427
1432static void complete_request(struct ceph_osd_request *req) 1428static void complete_request(struct ceph_osd_request *req)
1433{ 1429{
1434 if (req->r_unsafe_callback)
1435 req->r_unsafe_callback(req, false);
1436 complete_all(&req->r_safe_completion); /* fsync waiter */ 1430 complete_all(&req->r_safe_completion); /* fsync waiter */
1437} 1431}
1438 1432
@@ -1559,14 +1553,20 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg,
1559 mutex_unlock(&osdc->request_mutex); 1553 mutex_unlock(&osdc->request_mutex);
1560 1554
1561 if (!already_completed) { 1555 if (!already_completed) {
1556 if (req->r_unsafe_callback &&
1557 result >= 0 && !(flags & CEPH_OSD_FLAG_ONDISK))
1558 req->r_unsafe_callback(req, true);
1562 if (req->r_callback) 1559 if (req->r_callback)
1563 req->r_callback(req, msg); 1560 req->r_callback(req, msg);
1564 else 1561 else
1565 complete_all(&req->r_completion); 1562 complete_all(&req->r_completion);
1566 } 1563 }
1567 1564
1568 if (flags & CEPH_OSD_FLAG_ONDISK) 1565 if (flags & CEPH_OSD_FLAG_ONDISK) {
1566 if (req->r_unsafe_callback && already_completed)
1567 req->r_unsafe_callback(req, false);
1569 complete_request(req); 1568 complete_request(req);
1569 }
1570 1570
1571done: 1571done:
1572 dout("req=%p req->r_linger=%d\n", req, req->r_linger); 1572 dout("req=%p req->r_linger=%d\n", req, req->r_linger);