Skip to content

Commit eb845ff

Browse files
Yan, ZhengSage Weil
authored andcommitted
libceph: fix safe completion
handle_reply() calls complete_request() only if the first OSD reply has ONDISK flag. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com> Reviewed-by: Sage Weil <sage@inktank.com>
1 parent d552c61 commit eb845ff

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

‎include/linux/ceph/osd_client.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ struct ceph_osd_request {
145145
s32 r_reply_op_result[CEPH_OSD_MAX_OP];
146146
int r_got_reply;
147147
int r_linger;
148-
int r_completed;
149148

150149
struct ceph_osd_client *r_osdc;
151150
struct kref r_kref;

‎net/ceph/osd_client.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,8 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg,
15221522
for (i = 0; i < numops; i++)
15231523
req->r_reply_op_result[i] = ceph_decode_32(&p);
15241524

1525+
already_completed = req->r_got_reply;
1526+
15251527
if (!req->r_got_reply) {
15261528

15271529
req->r_result = result;
@@ -1552,16 +1554,14 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg,
15521554
((flags & CEPH_OSD_FLAG_WRITE) == 0))
15531555
__unregister_request(osdc, req);
15541556

1555-
already_completed = req->r_completed;
1556-
req->r_completed = 1;
15571557
mutex_unlock(&osdc->request_mutex);
1558-
if (already_completed)
1559-
goto done;
15601558

1561-
if (req->r_callback)
1562-
req->r_callback(req, msg);
1563-
else
1564-
complete_all(&req->r_completion);
1559+
if (!already_completed) {
1560+
if (req->r_callback)
1561+
req->r_callback(req, msg);
1562+
else
1563+
complete_all(&req->r_completion);
1564+
}
15651565

15661566
if (flags & CEPH_OSD_FLAG_ONDISK)
15671567
complete_request(req);
@@ -2121,7 +2121,6 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc,
21212121
__register_request(osdc, req);
21222122
req->r_sent = 0;
21232123
req->r_got_reply = 0;
2124-
req->r_completed = 0;
21252124
rc = __map_request(osdc, req, 0);
21262125
if (rc < 0) {
21272126
if (nofail) {

0 commit comments

Comments
 (0)