Skip to contentSkip to conversation

ceph: add session already open notify support

PATCH Superseded Xiubo Li 2 participants 5 messages May 26, 2022 – May 27, 2022 Ceph client

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xiubo Li

author
#0 lore raw

PATCH 1/1 ceph: add session already open notify support

If the connection was accidently closed due to the socket issue or something else the clients will try to open the opened sessions, the MDSes will send the session open reply one more time if the clients support the notify feature.

When the clients retry to open the sessions the s_seq will be 0 as default, we need to update it anyway.

URL: https://tracker.ceph.com/issues/53911

---
 fs/ceph/mds_client.c | 25 ++++++++++++++++++++-----
 fs/ceph/mds_client.h |  5 ++++-
 2 files changed, 24 insertions(+), 6 deletions(-)
fs/ceph/mds_client.c +20 -5
index 4ced8d1e18ba..3e528b89b77a 100644
@@ -3569,11 +3569,26 @@ static void handle_session(struct ceph_mds_session *session,
 	case CEPH_SESSION_OPEN:
 		if (session->s_state == CEPH_MDS_SESSION_RECONNECTING)
 			pr_info("mds%d reconnect success\n", session->s_mds);
-		session->s_state = CEPH_MDS_SESSION_OPEN;
-		session->s_features = features;
-		renewed_caps(mdsc, session, 0);
-		if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT, &session->s_features))
-			metric_schedule_delayed(&mdsc->metric);
+
+		if (session->s_state == CEPH_MDS_SESSION_OPEN) {
+			pr_info("mds%d already opened\n", session->s_mds);
+		} else {
+			session->s_state = CEPH_MDS_SESSION_OPEN;
+			session->s_features = features;
+			renewed_caps(mdsc, session, 0);
+			if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT,
+				     &session->s_features))
+				metric_schedule_delayed(&mdsc->metric);
+		}
+
+		/*
+		 * The connection maybe broken and the session in client
+		 * side has been reinitialized, need to update the seq
+		 * anyway.
+		 */
+		if (!session->s_seq && seq)
+			session->s_seq = seq;
+
 		wake = 1;
 		if (mdsc->stopping)
 			__close_session(mdsc, session);
fs/ceph/mds_client.h +4 -1
index d8ec2ac93da3..256e3eada6c1 100644
@@ -29,8 +29,10 @@ enum ceph_feature_type {
 	CEPHFS_FEATURE_MULTI_RECONNECT,
 	CEPHFS_FEATURE_DELEG_INO,
 	CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_ALTERNATE_NAME,
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
 
-	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
 };
 
 #define CEPHFS_FEATURES_CLIENT_SUPPORTED {	\
@@ -41,6 +43,7 @@ enum ceph_feature_type {
 	CEPHFS_FEATURE_MULTI_RECONNECT,		\
 	CEPHFS_FEATURE_DELEG_INO,		\
 	CEPHFS_FEATURE_METRIC_COLLECT,		\
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,	\
 }
 
 /*
Signature · 1 line
2.36.0.rc1
#1 lore raw
Quoted 21 lines · Xiubo Li

If the connection was accidently closed due to the socket issue or something else the clients will try to open the opened sessions, the MDSes will send the session open reply one more time if the clients support the notify feature.

When the clients retry to open the sessions the s_seq will be 0 as default, we need to update it anyway.

URL: https://tracker.ceph.com/issues/53911

---
 fs/ceph/mds_client.c | 25 ++++++++++++++++++++-----
 fs/ceph/mds_client.h |  5 ++++-
 2 files changed, 24 insertions(+), 6 deletions(-)
fs/ceph/mds_client.c +0 -0
index 4ced8d1e18ba..3e528b89b77a 100644
@@ -3569,11 +3569,26 @@ static void handle_session(struct ceph_mds_session *session,
 	case CEPH_SESSION_OPEN:

fs/ceph/mds_client.c static void handle_session(struct ceph_mds_session *session, · line 3574

Quoted 10 lines
fs/ceph/mds_client.c +3 -5
 		if (session->s_state == CEPH_MDS_SESSION_RECONNECTING)
 			pr_info("mds%d reconnect success\n", session->s_mds);
-		session->s_state = CEPH_MDS_SESSION_OPEN;
-		session->s_features = features;
-		renewed_caps(mdsc, session, 0);
-		if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT, &session->s_features))
-			metric_schedule_delayed(&mdsc->metric);
+
+		if (session->s_state == CEPH_MDS_SESSION_OPEN) {
+			pr_info("mds%d already opened\n", session->s_mds);

Does the above pr_info actually help anything? What will the admin do with this info? I'd probably just skip this since this is sort of expected to happen from time to time.

Quoted 37 lines
fs/ceph/mds_client.c +17 -0
+		} else {
+			session->s_state = CEPH_MDS_SESSION_OPEN;
+			session->s_features = features;
+			renewed_caps(mdsc, session, 0);
+			if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT,
+				     &session->s_features))
+				metric_schedule_delayed(&mdsc->metric);
+		}
+
+		/*
+		 * The connection maybe broken and the session in client
+		 * side has been reinitialized, need to update the seq
+		 * anyway.
+		 */
+		if (!session->s_seq && seq)
+			session->s_seq = seq;
+
 		wake = 1;
 		if (mdsc->stopping)
 			__close_session(mdsc, session);
fs/ceph/mds_client.h +3 -1
index d8ec2ac93da3..256e3eada6c1 100644
@@ -29,8 +29,10 @@ enum ceph_feature_type {
 	CEPHFS_FEATURE_MULTI_RECONNECT,
 	CEPHFS_FEATURE_DELEG_INO,
 	CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_ALTERNATE_NAME,
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
 
-	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
 };
 
 #define CEPHFS_FEATURES_CLIENT_SUPPORTED {	\

fs/ceph/mds_client.h enum ceph_feature_type { · line 49

Quoted 7 lines
fs/ceph/mds_client.h +1 -0
@@ -41,6 +43,7 @@ enum ceph_feature_type {
 	CEPHFS_FEATURE_MULTI_RECONNECT,		\
 	CEPHFS_FEATURE_DELEG_INO,		\
 	CEPHFS_FEATURE_METRIC_COLLECT,		\
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,	\
 }
 
 /*

The rest looks OK though.

Signature · 1 line
Jeff Layton <[email protected]>
author
#2 lore raw
Quoted 27 lines · Jeff Layton
Quoted 26 lines · Xiubo Li

If the connection was accidently closed due to the socket issue or something else the clients will try to open the opened sessions, the MDSes will send the session open reply one more time if the clients support the notify feature.

When the clients retry to open the sessions the s_seq will be 0 as default, we need to update it anyway.

URL: https://tracker.ceph.com/issues/53911

---
  fs/ceph/mds_client.c | 25 ++++++++++++++++++++-----
  fs/ceph/mds_client.h |  5 ++++-
  2 files changed, 24 insertions(+), 6 deletions(-)
fs/ceph/mds_client.c +0 -3
index 4ced8d1e18ba..3e528b89b77a 100644
@@ -3569,11 +3569,26 @@ static void handle_session(struct ceph_mds_session *session,
  	case CEPH_SESSION_OPEN:
  		if (session->s_state == CEPH_MDS_SESSION_RECONNECTING)
  			pr_info("mds%d reconnect success\n", session->s_mds);
-		session->s_state = CEPH_MDS_SESSION_OPEN;
-		session->s_features = features;
-		renewed_caps(mdsc, session, 0);
Quoted 8 lines

fs/ceph/mds_client.c static void handle_session(struct ceph_mds_session *session, · line 3574

Quoted 5 lines
fs/ceph/mds_client.c +3 -2
-		if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT, &session->s_features))
-			metric_schedule_delayed(&mdsc->metric);
+
+		if (session->s_state == CEPH_MDS_SESSION_OPEN) {
+			pr_info("mds%d already opened\n", session->s_mds);

Does the above pr_info actually help anything? What will the admin do with this info? I'd probably just skip this since this is sort of expected to happen from time to time.

Currently from the MDS side code, it won't be allowed to send the session open reply more than once. So this should be something wrong somewhere just like this issue we are fixing. So it's should be okay, but maybe a warning instead ?

Quoted 45 lines
Quoted 37 lines
fs/ceph/mds_client.c +17 -0
+		} else {
+			session->s_state = CEPH_MDS_SESSION_OPEN;
+			session->s_features = features;
+			renewed_caps(mdsc, session, 0);
+			if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT,
+				     &session->s_features))
+				metric_schedule_delayed(&mdsc->metric);
+		}
+
+		/*
+		 * The connection maybe broken and the session in client
+		 * side has been reinitialized, need to update the seq
+		 * anyway.
+		 */
+		if (!session->s_seq && seq)
+			session->s_seq = seq;
+
  		wake = 1;
  		if (mdsc->stopping)
  			__close_session(mdsc, session);
fs/ceph/mds_client.h +3 -1
index d8ec2ac93da3..256e3eada6c1 100644
@@ -29,8 +29,10 @@ enum ceph_feature_type {
  	CEPHFS_FEATURE_MULTI_RECONNECT,
  	CEPHFS_FEATURE_DELEG_INO,
  	CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_ALTERNATE_NAME,
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
 
-	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
  };
 
  #define CEPHFS_FEATURES_CLIENT_SUPPORTED {	\

fs/ceph/mds_client.h enum ceph_feature_type { · line 49

Quoted 7 lines
fs/ceph/mds_client.h +1 -0
@@ -41,6 +43,7 @@ enum ceph_feature_type {
  	CEPHFS_FEATURE_MULTI_RECONNECT,		\
  	CEPHFS_FEATURE_DELEG_INO,		\
  	CEPHFS_FEATURE_METRIC_COLLECT,		\
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,	\
  }
 
  /*

The rest looks OK though.

#3 lore raw
Quoted 37 lines · Xiubo Li
Quoted 27 lines · Jeff Layton
Quoted 26 lines · Xiubo Li

If the connection was accidently closed due to the socket issue or something else the clients will try to open the opened sessions, the MDSes will send the session open reply one more time if the clients support the notify feature.

When the clients retry to open the sessions the s_seq will be 0 as default, we need to update it anyway.

URL: https://tracker.ceph.com/issues/53911

---
  fs/ceph/mds_client.c | 25 ++++++++++++++++++++-----
  fs/ceph/mds_client.h |  5 ++++-
  2 files changed, 24 insertions(+), 6 deletions(-)
fs/ceph/mds_client.c +0 -3
index 4ced8d1e18ba..3e528b89b77a 100644
@@ -3569,11 +3569,26 @@ static void handle_session(struct ceph_mds_session *session,
  	case CEPH_SESSION_OPEN:
  		if (session->s_state == CEPH_MDS_SESSION_RECONNECTING)
  			pr_info("mds%d reconnect success\n", session->s_mds);
-		session->s_state = CEPH_MDS_SESSION_OPEN;
-		session->s_features = features;
-		renewed_caps(mdsc, session, 0);
Quoted 8 lines

fs/ceph/mds_client.c static void handle_session(struct ceph_mds_session *session, · line 3574

Quoted 5 lines
fs/ceph/mds_client.c +3 -2
-		if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT, &session->s_features))
-			metric_schedule_delayed(&mdsc->metric);
+
+		if (session->s_state == CEPH_MDS_SESSION_OPEN) {
+			pr_info("mds%d already opened\n", session->s_mds);

Does the above pr_info actually help anything? What will the admin do with this info? I'd probably just skip this since this is sort of expected to happen from time to time.

Quoted 5 lines

Currently from the MDS side code, it won't be allowed to send the session open reply more than once. So this should be something wrong somewhere just like this issue we are fixing. So it's should be okay, but maybe a warning instead ?

Ok. I'd probably go with pr_notice instead. It's not indicative of a kernel bug, necessarily, and we don't really need the admin to take any action (other than maybe report it to the ceph administrators).

Quoted 47 lines
Quoted 46 lines
Quoted 38 lines
fs/ceph/mds_client.c +17 -0
+		} else {
+			session->s_state = CEPH_MDS_SESSION_OPEN;
+			session->s_features = features;
+			renewed_caps(mdsc, session, 0);
+			if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT,
+				     &session->s_features))
+				metric_schedule_delayed(&mdsc->metric);
+		}
+
+		/*
+		 * The connection maybe broken and the session in client
+		 * side has been reinitialized, need to update the seq
+		 * anyway.
+		 */
+		if (!session->s_seq && seq)
+			session->s_seq = seq;
+
  		wake = 1;
  		if (mdsc->stopping)
  			__close_session(mdsc, session);
fs/ceph/mds_client.h +3 -1
index d8ec2ac93da3..256e3eada6c1 100644
@@ -29,8 +29,10 @@ enum ceph_feature_type {
  	CEPHFS_FEATURE_MULTI_RECONNECT,
  	CEPHFS_FEATURE_DELEG_INO,
  	CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_ALTERNATE_NAME,
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
 
-	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
  };
 
  #define CEPHFS_FEATURES_CLIENT_SUPPORTED {	\

fs/ceph/mds_client.h enum ceph_feature_type { · line 49

Quoted 7 lines
fs/ceph/mds_client.h +1 -0
@@ -41,6 +43,7 @@ enum ceph_feature_type {
  	CEPHFS_FEATURE_MULTI_RECONNECT,		\
  	CEPHFS_FEATURE_DELEG_INO,		\
  	CEPHFS_FEATURE_METRIC_COLLECT,		\
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,	\
  }
 
  /*

The rest looks OK though.

Signature · 1 line
Jeff Layton <[email protected]>
author
#4 lore raw
Quoted 37 lines · Jeff Layton
Quoted 36 lines · Xiubo Li
Quoted 35 lines · Jeff Layton
Quoted 21 lines · Xiubo Li

If the connection was accidently closed due to the socket issue or something else the clients will try to open the opened sessions, the MDSes will send the session open reply one more time if the clients support the notify feature.

When the clients retry to open the sessions the s_seq will be 0 as default, we need to update it anyway.

URL: https://tracker.ceph.com/issues/53911

---
   fs/ceph/mds_client.c | 25 ++++++++++++++++++++-----
   fs/ceph/mds_client.h |  5 ++++-
   2 files changed, 24 insertions(+), 6 deletions(-)
fs/ceph/mds_client.c +0 -0
index 4ced8d1e18ba..3e528b89b77a 100644
@@ -3569,11 +3569,26 @@ static void handle_session(struct ceph_mds_session *session,
   	case CEPH_SESSION_OPEN:

fs/ceph/mds_client.c static void handle_session(struct ceph_mds_session *session, · line 3574

Quoted 10 lines
fs/ceph/mds_client.c +3 -5
   		if (session->s_state == CEPH_MDS_SESSION_RECONNECTING)
   			pr_info("mds%d reconnect success\n", session->s_mds);
-		session->s_state = CEPH_MDS_SESSION_OPEN;
-		session->s_features = features;
-		renewed_caps(mdsc, session, 0);
-		if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT, &session->s_features))
-			metric_schedule_delayed(&mdsc->metric);
+
+		if (session->s_state == CEPH_MDS_SESSION_OPEN) {
+			pr_info("mds%d already opened\n", session->s_mds);

Does the above pr_info actually help anything? What will the admin do with this info? I'd probably just skip this since this is sort of expected to happen from time to time.

Quoted 8 lines
Quoted 5 lines

Currently from the MDS side code, it won't be allowed to send the session open reply more than once. So this should be something wrong somewhere just like this issue we are fixing. So it's should be okay, but maybe a warning instead ?

Ok. I'd probably go with pr_notice instead. It's not indicative of a kernel bug, necessarily, and we don't really need the admin to take any action (other than maybe report it to the ceph administrators).

Sure, will switch to notice instead.

Thanks

-- Xiubo

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
Quoted 37 lines
fs/ceph/mds_client.c +17 -0
+		} else {
+			session->s_state = CEPH_MDS_SESSION_OPEN;
+			session->s_features = features;
+			renewed_caps(mdsc, session, 0);
+			if (test_bit(CEPHFS_FEATURE_METRIC_COLLECT,
+				     &session->s_features))
+				metric_schedule_delayed(&mdsc->metric);
+		}
+
+		/*
+		 * The connection maybe broken and the session in client
+		 * side has been reinitialized, need to update the seq
+		 * anyway.
+		 */
+		if (!session->s_seq && seq)
+			session->s_seq = seq;
+
   		wake = 1;
   		if (mdsc->stopping)
   			__close_session(mdsc, session);
fs/ceph/mds_client.h +3 -1
index d8ec2ac93da3..256e3eada6c1 100644
@@ -29,8 +29,10 @@ enum ceph_feature_type {
   	CEPHFS_FEATURE_MULTI_RECONNECT,
   	CEPHFS_FEATURE_DELEG_INO,
   	CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_ALTERNATE_NAME,
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
 
-	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT,
+	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_NOTIFY_SESSION_STATE,
   };
 
   #define CEPHFS_FEATURES_CLIENT_SUPPORTED {	\

fs/ceph/mds_client.h enum ceph_feature_type { · line 49

Quoted 7 lines
fs/ceph/mds_client.h +1 -0
@@ -41,6 +43,7 @@ enum ceph_feature_type {
   	CEPHFS_FEATURE_MULTI_RECONNECT,		\
   	CEPHFS_FEATURE_DELEG_INO,		\
   	CEPHFS_FEATURE_METRIC_COLLECT,		\
+	CEPHFS_FEATURE_NOTIFY_SESSION_STATE,	\
   }
 
   /*

The rest looks OK though.