From 6b88cca6e8c843ce8f16438ae46058f13f3c77f7 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 9 Jan 2009 12:48:24 -0800 Subject: [PATCH] kclient: separate flag for got_safe and got_unsafe Slightly more informative debugging messages. Avoid doing the safe cleanup twice. And the distinction will be important when replaying unsafe requests to the mds during reconnect. I think. --- src/kernel/mds_client.c | 49 ++++++++++++++++++++++++++--------------- src/kernel/mds_client.h | 2 +- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/kernel/mds_client.c b/src/kernel/mds_client.c index e0d3851e05434..3a8ec32cf1bed 100644 --- a/src/kernel/mds_client.c +++ b/src/kernel/mds_client.c @@ -1273,27 +1273,36 @@ void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, struct ceph_msg *msg) } dout(10, "handle_reply %p expected_cap=%p\n", req, req->r_expected_cap); mds = le32_to_cpu(msg->hdr.src.name.num); - if (req->r_got_reply) { - if (head->safe) { - /* - We already handled the unsafe response, now do the cleanup. - Shouldn't we check the safe response to see if it matches - the unsafe one? - */ - complete(&req->r_safe_completion); - __unregister_request(mdsc, req); - dout(10, "got safe reply %llu, mds%d\n", - tid, mds); - ceph_msg_put(req->r_request); - req->r_request = NULL; - } else { - dout(0, "got another _unsafe_ reply %llu, mds%d\n", - tid, mds); - } + + /* dup? */ + if ((req->r_got_unsafe && !head->safe) || + (req->r_got_safe && head->safe)) { + dout(0, "got a dup %s reply on %llu from mds%d\n", + head->safe ? "safe":"unsafe", tid, mds); + mutex_unlock(&mdsc->mutex); + ceph_mdsc_put_request(req); + return; + } + + if (req->r_got_unsafe && head->safe) { + /* + * We already handled the unsafe response, now + * do the cleanup. Shouldn't we check the + * safe response to see if it matches the + * unsafe one? + */ + complete(&req->r_safe_completion); + __unregister_request(mdsc, req); + dout(10, "got safe reply %llu, mds%d\n", + tid, mds); + ceph_msg_put(req->r_request); + req->r_request = NULL; + req->r_got_safe = true; mutex_unlock(&mdsc->mutex); ceph_mdsc_put_request(req); return; } + if (req->r_session && req->r_session->s_mds != mds) { ceph_put_mds_session(req->r_session); req->r_session = __ceph_lookup_mds_session(mdsc, mds); @@ -1306,7 +1315,11 @@ void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, struct ceph_msg *msg) return; } BUG_ON(req->r_reply); - req->r_got_reply = 1; + + if (head->safe) + req->r_got_safe = true; + else + req->r_got_unsafe = true; /* take the snap sem -- we may be are adding a cap here */ down_write(&mdsc->snap_rwsem); diff --git a/src/kernel/mds_client.h b/src/kernel/mds_client.h index 5cd8d8cc3617d..4334fe454bbee 100644 --- a/src/kernel/mds_client.h +++ b/src/kernel/mds_client.h @@ -174,7 +174,7 @@ struct ceph_mds_request { atomic_t r_ref; struct completion r_completion; struct completion r_safe_completion; - int r_got_reply; + bool r_got_unsafe, r_got_safe; }; /* -- 2.39.5