]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
libceph: add function that reset client's entity addr
authorYan, Zheng <zyan@redhat.com>
Thu, 25 Jul 2019 12:16:39 +0000 (20:16 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 16 Sep 2019 10:06:23 +0000 (12:06 +0200)
This function also re-open connections to OSD/MON, and re-send in-flight
OSD requests after re-opening connections to OSD.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
include/linux/ceph/libceph.h
include/linux/ceph/messenger.h
include/linux/ceph/mon_client.h
include/linux/ceph/osd_client.h
net/ceph/ceph_common.c
net/ceph/messenger.c
net/ceph/mon_client.c
net/ceph/osd_client.c

index 82156da3c6501e12a7bb6d9dcca3108ccefc0593..b9dbda1c26aab52a421e6482e3fe28b9c9679c76 100644 (file)
@@ -293,6 +293,7 @@ struct ceph_client *ceph_create_client(struct ceph_options *opt, void *private);
 struct ceph_entity_addr *ceph_client_addr(struct ceph_client *client);
 u64 ceph_client_gid(struct ceph_client *client);
 extern void ceph_destroy_client(struct ceph_client *client);
+extern void ceph_reset_client_addr(struct ceph_client *client);
 extern int __ceph_open_session(struct ceph_client *client,
                               unsigned long started);
 extern int ceph_open_session(struct ceph_client *client);
index 23895d178149bd2ec5fb7984419976e8e13cbc1a..c4458dc6a7576260ef4981499c60e048768f307d 100644 (file)
@@ -337,6 +337,7 @@ extern void ceph_msgr_flush(void);
 extern void ceph_messenger_init(struct ceph_messenger *msgr,
                                struct ceph_entity_addr *myaddr);
 extern void ceph_messenger_fini(struct ceph_messenger *msgr);
+extern void ceph_messenger_reset_nonce(struct ceph_messenger *msgr);
 
 extern void ceph_con_init(struct ceph_connection *con, void *private,
                        const struct ceph_connection_operations *ops,
index b4d134d3312ab7d1cc7f4f1db8a552fd859e29cc..dbb8a6959a73ed136b388067062dd263098a0fdd 100644 (file)
@@ -109,6 +109,7 @@ extern int ceph_monmap_contains(struct ceph_monmap *m,
 
 extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
 extern void ceph_monc_stop(struct ceph_mon_client *monc);
+extern void ceph_monc_reopen_session(struct ceph_mon_client *monc);
 
 enum {
        CEPH_SUB_MONMAP = 0,
index ad7fe5d10dcd926c1ecb0b3a4ef352737bf4a4cc..d1c3e829f30dc43b311338b079eeabb05e46405b 100644 (file)
@@ -381,6 +381,7 @@ extern void ceph_osdc_cleanup(void);
 extern int ceph_osdc_init(struct ceph_osd_client *osdc,
                          struct ceph_client *client);
 extern void ceph_osdc_stop(struct ceph_osd_client *osdc);
+extern void ceph_osdc_reopen_osds(struct ceph_osd_client *osdc);
 
 extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
                                   struct ceph_msg *msg);
index 4eeea4d5c3ef4bff5b6bd759e0e293808e0c6401..b412a3ccc4fc0487b620ab83600ff420c51d1efd 100644 (file)
@@ -694,6 +694,14 @@ void ceph_destroy_client(struct ceph_client *client)
 }
 EXPORT_SYMBOL(ceph_destroy_client);
 
+void ceph_reset_client_addr(struct ceph_client *client)
+{
+       ceph_messenger_reset_nonce(&client->msgr);
+       ceph_monc_reopen_session(&client->monc);
+       ceph_osdc_reopen_osds(&client->osdc);
+}
+EXPORT_SYMBOL(ceph_reset_client_addr);
+
 /*
  * true if we have the mon map (and have thus joined the cluster)
  */
index 962f521c863ec1b9411d457be7544f1df0a4840f..e4cb3db2ee77ceda556d3656590762df24a043d2 100644 (file)
@@ -3031,6 +3031,12 @@ static void con_fault(struct ceph_connection *con)
 }
 
 
+void ceph_messenger_reset_nonce(struct ceph_messenger *msgr)
+{
+       u32 nonce = le32_to_cpu(msgr->inst.addr.nonce) + 1000000;
+       msgr->inst.addr.nonce = cpu_to_le32(nonce);
+       encode_my_addr(msgr);
+}
 
 /*
  * initialize a new messenger instance
index 0520bf9825aa3edd3436c70bdee15cc9bede07cc..7256c402ebaa32961265d295432df4569fbc6708 100644 (file)
@@ -213,6 +213,13 @@ static void reopen_session(struct ceph_mon_client *monc)
        __open_session(monc);
 }
 
+void ceph_monc_reopen_session(struct ceph_mon_client *monc)
+{
+       mutex_lock(&monc->mutex);
+       reopen_session(monc);
+       mutex_unlock(&monc->mutex);
+}
+
 static void un_backoff(struct ceph_mon_client *monc)
 {
        monc->hunt_mult /= 2; /* reduce by 50% */
index 78ae6e8c953d03427535ea26732d125ed9432531..a252ba80dd82c44339546b58c5762b2d43cfe5a9 100644 (file)
@@ -5086,6 +5086,24 @@ int ceph_osdc_call(struct ceph_osd_client *osdc,
 }
 EXPORT_SYMBOL(ceph_osdc_call);
 
+/*
+ * reset all osd connections
+ */
+void ceph_osdc_reopen_osds(struct ceph_osd_client *osdc)
+{
+       struct rb_node *n;
+
+       down_write(&osdc->lock);
+       for (n = rb_first(&osdc->osds); n; ) {
+               struct ceph_osd *osd = rb_entry(n, struct ceph_osd, o_node);
+
+               n = rb_next(n);
+               if (!reopen_osd(osd))
+                       kick_osd_requests(osd);
+       }
+       up_write(&osdc->lock);
+}
+
 /*
  * init, shutdown
  */