Commit eb845ff1 authored by Yan, Zheng's avatar Yan, Zheng Committed by Sage Weil

libceph: fix safe completion

handle_reply() calls complete_request() only if the first OSD reply
has ONDISK flag.
Signed-off-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: default avatarSage Weil <sage@inktank.com>
parent d552c619
...@@ -145,7 +145,6 @@ struct ceph_osd_request { ...@@ -145,7 +145,6 @@ struct ceph_osd_request {
s32 r_reply_op_result[CEPH_OSD_MAX_OP]; s32 r_reply_op_result[CEPH_OSD_MAX_OP];
int r_got_reply; int r_got_reply;
int r_linger; int r_linger;
int r_completed;
struct ceph_osd_client *r_osdc; struct ceph_osd_client *r_osdc;
struct kref r_kref; struct kref r_kref;
......
...@@ -1522,6 +1522,8 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg, ...@@ -1522,6 +1522,8 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg,
for (i = 0; i < numops; i++) for (i = 0; i < numops; i++)
req->r_reply_op_result[i] = ceph_decode_32(&p); req->r_reply_op_result[i] = ceph_decode_32(&p);
already_completed = req->r_got_reply;
if (!req->r_got_reply) { if (!req->r_got_reply) {
req->r_result = result; req->r_result = result;
...@@ -1552,16 +1554,14 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg, ...@@ -1552,16 +1554,14 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg,
((flags & CEPH_OSD_FLAG_WRITE) == 0)) ((flags & CEPH_OSD_FLAG_WRITE) == 0))
__unregister_request(osdc, req); __unregister_request(osdc, req);
already_completed = req->r_completed;
req->r_completed = 1;
mutex_unlock(&osdc->request_mutex); mutex_unlock(&osdc->request_mutex);
if (already_completed)
goto done;
if (!already_completed) {
if (req->r_callback) if (req->r_callback)
req->r_callback(req, msg); req->r_callback(req, msg);
else else
complete_all(&req->r_completion); complete_all(&req->r_completion);
}
if (flags & CEPH_OSD_FLAG_ONDISK) if (flags & CEPH_OSD_FLAG_ONDISK)
complete_request(req); complete_request(req);
...@@ -2121,7 +2121,6 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc, ...@@ -2121,7 +2121,6 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc,
__register_request(osdc, req); __register_request(osdc, req);
req->r_sent = 0; req->r_sent = 0;
req->r_got_reply = 0; req->r_got_reply = 0;
req->r_completed = 0;
rc = __map_request(osdc, req, 0); rc = __map_request(osdc, req, 0);
if (rc < 0) { if (rc < 0) {
if (nofail) { if (nofail) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment