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)
{
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;
}
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",