]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: notify clients if the session has already opened
authorXiubo Li <xiubli@redhat.com>
Wed, 9 Mar 2022 07:42:56 +0000 (15:42 +0800)
committerXiubo Li <xiubli@redhat.com>
Thu, 1 Sep 2022 02:07:53 +0000 (10:07 +0800)
If the connection was accidently closed due to the socket issue or
something else the client will try to open the opened sessions, for
now the MDS will just discard the session open request.

But the client will keep waiting the reply from the mds forever.

We need to tell the clients what has happened instead of discard it
directly. And when the client get the session open reply, it can
do what needed.

Fixes: https://tracker.ceph.com/issues/53911
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit f232b020fc36ba33d6ef144bdb9e607beb135763)

src/client/Client.cc
src/mds/Server.cc
src/mds/cephfs_features.cc
src/mds/cephfs_features.h

index e7f5b8b376b5b7e2705d852bd7e45c2e5b05ce45..2f611ec1541de80c9b5c3c7c1115e5d849b1c43e 100644 (file)
@@ -2230,6 +2230,18 @@ void Client::handle_client_session(const MConstRef<MClientSession>& m)
   switch (m->get_op()) {
   case CEPH_SESSION_OPEN:
     {
+      if (session->state == MetaSession::STATE_OPEN) {
+        ldout(cct, 10) << "mds." << from << " already opened, ignore it"
+                       << dendl;
+        return;
+      }
+      /*
+       * The connection maybe broken and the session in client side
+       * has been reinitialized, need to update the seq anyway.
+       */
+      if (!session->seq && m->get_seq())
+        session->seq = m->get_seq();
+
       feature_bitset_t missing_features(CEPHFS_FEATURES_CLIENT_REQUIRED);
       missing_features -= m->supported_features;
       if (!missing_features.empty()) {
index b01eb92b368495267b73ed4717244e92858205a3..6d04da9cbf2192512452461a91668bc93459e260 100644 (file)
@@ -585,7 +585,23 @@ void Server::handle_client_session(const cref_t<MClientSession> &m)
        session->is_stale() ||
        session->is_killing() ||
        terminating_sessions) {
-      dout(10) << "currently open|opening|stale|killing, dropping this req" << dendl;
+      if (m->supported_features.test(CEPHFS_FEATURE_NOTIFY_SESSION_STATE)) {
+       if (session->is_open() && !mds->is_stopping()) {
+          dout(10) << "currently already opened" << dendl;
+
+          auto reply = make_message<MClientSession>(CEPH_SESSION_OPEN,
+                                                    session->get_push_seq());
+          if (session->info.has_feature(CEPHFS_FEATURE_MIMIC))
+            reply->supported_features = supported_features;
+          mds->send_message_client(reply, session);
+          if (mdcache->is_readonly()) {
+            auto m = make_message<MClientSession>(CEPH_SESSION_FORCE_RO);
+            mds->send_message_client(m, session);
+          }
+       }
+      }
+      dout(10) << "currently " << session->get_state_name()
+               << ", dropping this req" << dendl;
       return;
     }
     ceph_assert(session->is_closed() || session->is_closing());
index 3709ca8b9b4aff61359c8cb3ecfa3b82b77bc2d3..419cf8d549775e530fe55968eb6c3d350cad3c80 100644 (file)
@@ -23,6 +23,7 @@ static const std::array feature_names
   "deleg_ino",
   "metric_collect",
   "alternate_name",
+  "notify_session_state",
 };
 static_assert(feature_names.size() == CEPHFS_FEATURE_MAX + 1);
 
index e934914ba5bb23857b5adc6d6c3397ed7ce4f8be..7cf130ae6b2209bcee7cb0aa1bb56a60e7bcb496 100644 (file)
@@ -30,20 +30,21 @@ namespace ceph {
 #define CEPHFS_CURRENT_RELEASE  CEPH_RELEASE_QUINCY
 
 // The first 5 bits are reserved for old ceph releases.
-#define CEPHFS_FEATURE_JEWEL           5
-#define CEPHFS_FEATURE_KRAKEN          6
-#define CEPHFS_FEATURE_LUMINOUS                7
-#define CEPHFS_FEATURE_MIMIC           8
-#define CEPHFS_FEATURE_REPLY_ENCODING   9
-#define CEPHFS_FEATURE_RECLAIM_CLIENT  10
-#define CEPHFS_FEATURE_LAZY_CAP_WANTED  11
-#define CEPHFS_FEATURE_MULTI_RECONNECT  12
-#define CEPHFS_FEATURE_NAUTILUS         12
-#define CEPHFS_FEATURE_DELEG_INO        13
-#define CEPHFS_FEATURE_OCTOPUS          13
-#define CEPHFS_FEATURE_METRIC_COLLECT   14
-#define CEPHFS_FEATURE_ALTERNATE_NAME   15
-#define CEPHFS_FEATURE_MAX              15
+#define CEPHFS_FEATURE_JEWEL                5
+#define CEPHFS_FEATURE_KRAKEN               6
+#define CEPHFS_FEATURE_LUMINOUS             7
+#define CEPHFS_FEATURE_MIMIC                8
+#define CEPHFS_FEATURE_REPLY_ENCODING       9
+#define CEPHFS_FEATURE_RECLAIM_CLIENT       10
+#define CEPHFS_FEATURE_LAZY_CAP_WANTED      11
+#define CEPHFS_FEATURE_MULTI_RECONNECT      12
+#define CEPHFS_FEATURE_NAUTILUS             12
+#define CEPHFS_FEATURE_DELEG_INO            13
+#define CEPHFS_FEATURE_OCTOPUS              13
+#define CEPHFS_FEATURE_METRIC_COLLECT       14
+#define CEPHFS_FEATURE_ALTERNATE_NAME       15
+#define CEPHFS_FEATURE_NOTIFY_SESSION_STATE 16
+#define CEPHFS_FEATURE_MAX                  16
 
 #define CEPHFS_FEATURES_ALL {          \
   0, 1, 2, 3, 4,                       \
@@ -60,6 +61,7 @@ namespace ceph {
   CEPHFS_FEATURE_OCTOPUS,               \
   CEPHFS_FEATURE_METRIC_COLLECT,        \
   CEPHFS_FEATURE_ALTERNATE_NAME,        \
+  CEPHFS_FEATURE_NOTIFY_SESSION_STATE,  \
 }
 
 #define CEPHFS_METRIC_FEATURES_ALL {           \