]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: list unsafe requests in the MDS session
authorSage Weil <sage@newdream.net>
Fri, 9 Jan 2009 20:55:59 +0000 (12:55 -0800)
committerSage Weil <sage@newdream.net>
Fri, 9 Jan 2009 22:16:17 +0000 (14:16 -0800)
This easily defines the requests needed during reconnect without having
to consult the larger request table.

src/kernel/mds_client.c
src/kernel/mds_client.h

index 66c45f59252a2dbe4fbeec629143879d8c558333..8fc58a70a4a363a2ec3a9d6546f1019fed705e26 100644 (file)
@@ -327,6 +327,7 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc,
        s->s_nr_caps = 0;
        atomic_set(&s->s_ref, 1);
        init_completion(&s->s_completion);
+       INIT_LIST_HEAD(&s->s_unsafe);
 
        dout(10, "register_session mds%d\n", mds);
        if (mds >= mdsc->max_sessions) {
@@ -1292,18 +1293,18 @@ void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
 
        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?
+                * We already handled the unsafe response, now do the
+                * cleanup.  No need to examine the response; the MDS
+                * doesn't include any result info in the safe
+                * response.  And even if it did, there is nothing
+                * useful we could do with a revised return value.
                 */
+               dout(10, "got safe reply %llu, mds%d\n", tid, mds);
+               BUG_ON(req->r_session == NULL);
                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;
+               list_del_init(&req->r_unsafe_item);
                mutex_unlock(&mdsc->mutex);
                ceph_mdsc_put_request(req);
                return;
@@ -1324,8 +1325,10 @@ void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
 
        if (head->safe)
                req->r_got_safe = true;
-       else
+       else {
                req->r_got_unsafe = true;
+               list_add_tail(&req->r_unsafe_item, &req->r_session->s_unsafe);
+       }
 
        /* take the snap sem -- we may be are adding a cap here */
        down_write(&mdsc->snap_rwsem);
index 4334fe454bbee966aeace697f0f9581df2af92cc..0f0a6445521071f723225f52ff48b31a350214ff 100644 (file)
@@ -119,6 +119,7 @@ struct ceph_mds_session {
        int               s_nr_caps;
        atomic_t          s_ref;
        struct completion s_completion;
+       struct list_head  s_unsafe;   /* unsafe requests */
 };
 
 /*
@@ -174,6 +175,7 @@ struct ceph_mds_request {
        atomic_t          r_ref;
        struct completion r_completion;
        struct completion r_safe_completion;
+       struct list_head  r_unsafe_item;  /* per-session unsafe list item */
        bool              r_got_unsafe, r_got_safe;
 };