]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Added timer event to periodically resend map request
authorPatience Warnick <patience@cranium.pelton.net>
Mon, 7 Apr 2008 16:37:05 +0000 (09:37 -0700)
committerPatience Warnick <patience@cranium.pelton.net>
Mon, 7 Apr 2008 16:37:05 +0000 (09:37 -0700)
src/kernel/mon_client.c

index e60aee933bb5b9b3de8af24e7bc525ce7831ec56..f853873739851a731c49260a47819b723dfa23eb 100644 (file)
@@ -66,6 +66,40 @@ static int pick_mon(struct ceph_mon_client *monc, int notmon)
        return monc->last_mon;
 }
 
+/*
+ * delay work with exponential backoff
+ */
+void ceph_delayed_work(struct delayed_work *dwork, unsigned long *delay)
+{
+
+        dout(10, "ceph_delayed_work started\n");
+       schedule_delayed_work(dwork, *delay);
+       if (*delay < MAX_DELAY_INTERVAL)
+               *delay *= 2;
+       else
+               *delay = MAX_DELAY_INTERVAL;
+
+}
+
+/*
+ * worker function for request mdsmap 
+ */
+static void work_monc_request_mdsmap(struct work_struct *work)
+{
+       struct  ceph_mon_client *monc =
+                container_of(work, struct ceph_mon_client, delayed_work.work);
+       static int count = 0;
+
+       dout(5, "work_monc_request_mdsmap send map request count %d\n", count);
+
+       if (count > 5) {
+       ceph_msg_send(monc->client->msgr, monc->msg, 0);
+       }
+
+       /* keep sending request until we receive mds map */
+       ceph_delayed_work(&monc->delayed_work, &monc->delay);
+       ++count;
+}
 
 int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
 {
@@ -77,24 +111,25 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
                return -ENOMEM;
        spin_lock_init(&monc->lock);
        INIT_RADIX_TREE(&monc->statfs_request_tree, GFP_KERNEL);
+       INIT_DELAYED_WORK(&monc->delayed_work, work_monc_request_mdsmap);
        monc->last_tid = 0;
        monc->want_mdsmap = 0;
        return 0;
 }
 
+
 int ceph_monc_request_mdsmap(struct ceph_mon_client *monc, __u32 have)
 {
-       struct ceph_msg *msg;
        int mon = pick_mon(monc, -1);
 
        dout(5, "ceph_monc_request_mdsmap from mon%d have %u\n", mon, have);
        monc->want_mdsmap = have;
-       msg = ceph_msg_new(CEPH_MSG_MDS_GETMAP, sizeof(__u32), 0, 0, 0);
-       if (IS_ERR(msg))
-               return PTR_ERR(msg);
-       *(__le32*)msg->front.iov_base = cpu_to_le32(have);
-       msg->hdr.dst = monc->monmap->mon_inst[mon];
-       ceph_msg_send(monc->client->msgr, msg, 0);
+       monc->msg = ceph_msg_new(CEPH_MSG_MDS_GETMAP, sizeof(__u32), 0, 0, 0);
+       if (IS_ERR(monc->msg))
+               return PTR_ERR(monc->msg);
+       *(__le32*)monc->msg->front.iov_base = cpu_to_le32(have);
+       monc->msg->hdr.dst = monc->monmap->mon_inst[mon];
+       ceph_delayed_work(&monc->delayed_work, &monc->delay);
        return 0;
 }
 
@@ -104,6 +139,8 @@ int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, __u32 have)
                monc->want_mdsmap = 0;
                dout(5, "ceph_monc_got_mdsmap have %u > wanted %u\n", 
                     have, monc->want_mdsmap);
+               /* we got map so take map request out of queue */
+               cancel_delayed_work_sync(&monc->delayed_work);
                return 0;
        } else {
                dout(5, "ceph_monc_got_mdsmap have %u <= wanted %u *****\n",