Skip to contentSkip to conversation

ceph: fix incorrectly counting the export targets

PATCH Superseded [email protected] 2 participants 4 messages Aug 30, 2021 Ceph client

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix incorrectly counting the export targets

From: Xiubo Li <[email protected]>

---
 fs/ceph/mds_client.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ceph/mds_client.c +5 -3
index 7ddc36c14b92..aa0ab069db40 100644
@@ -4434,7 +4434,7 @@ static void check_new_map(struct ceph_mds_client *mdsc,
 			  struct ceph_mdsmap *newmap,
 			  struct ceph_mdsmap *oldmap)
 {
-	int i, err;
+	int i, j, err;
 	int oldstate, newstate;
 	struct ceph_mds_session *s;
 	unsigned long targets[DIV_ROUND_UP(CEPH_MAX_MDS, sizeof(unsigned long))] = {0};
@@ -4443,8 +4443,10 @@ static void check_new_map(struct ceph_mds_client *mdsc,
 	     newmap->m_epoch, oldmap->m_epoch);
 
 	if (newmap->m_info) {
-		for (i = 0; i < newmap->m_info->num_export_targets; i++)
-			set_bit(newmap->m_info->export_targets[i], targets);
+		for (i = 0; i < newmap->m_num_active_mds; i++) {
+			for (j = 0; j < newmap->m_info[i].num_export_targets; j++)
+				set_bit(newmap->m_info[i].export_targets[j], targets);
+		}
 	}
 
 	for (i = 0; i < oldmap->possible_max_rank && i < mdsc->max_sessions; i++) {
Signature · 1 line
2.27.0
#1 lore raw
Quoted 23 lines · On Mon, 2021-08-30 at 20:33 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

---
 fs/ceph/mds_client.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ceph/mds_client.c +1 -1
index 7ddc36c14b92..aa0ab069db40 100644
@@ -4434,7 +4434,7 @@ static void check_new_map(struct ceph_mds_client *mdsc,
 			  struct ceph_mdsmap *newmap,
 			  struct ceph_mdsmap *oldmap)
 {
-	int i, err;
+	int i, j, err;
 	int oldstate, newstate;
 	struct ceph_mds_session *s;
 	unsigned long targets[DIV_ROUND_UP(CEPH_MAX_MDS, sizeof(unsigned long))] = {0};
@@ -4443,8 +4443,10 @@ static void check_new_map(struct ceph_mds_client *mdsc,
 	     newmap->m_epoch, oldmap->m_epoch);
 

fs/ceph/mds_client.c static void check_new_map(struct ceph_mds_client *mdsc, · line 4452

Quoted 10 lines
fs/ceph/mds_client.c +4 -2
 	if (newmap->m_info) {
-		for (i = 0; i < newmap->m_info->num_export_targets; i++)
-			set_bit(newmap->m_info->export_targets[i], targets);
+		for (i = 0; i < newmap->m_num_active_mds; i++) {
+			for (j = 0; j < newmap->m_info[i].num_export_targets; j++)
+				set_bit(newmap->m_info[i].export_targets[j], targets);
+		}
 	}
 
 	for (i = 0; i < oldmap->possible_max_rank && i < mdsc->max_sessions; i++) {

Looks sane. I'll plan to fold this into "ceph: reconnect to the export targets on new mdsmaps".

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>
author
#2 lore raw
Quoted 33 lines · Jeff Layton
Quoted 32 lines · On Mon, 2021-08-30 at 20:33 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

---
  fs/ceph/mds_client.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
fs/ceph/mds_client.c +5 -3
index 7ddc36c14b92..aa0ab069db40 100644
@@ -4434,7 +4434,7 @@ static void check_new_map(struct ceph_mds_client *mdsc,
  			  struct ceph_mdsmap *newmap,
  			  struct ceph_mdsmap *oldmap)
  {
-	int i, err;
+	int i, j, err;
  	int oldstate, newstate;
  	struct ceph_mds_session *s;
  	unsigned long targets[DIV_ROUND_UP(CEPH_MAX_MDS, sizeof(unsigned long))] = {0};
@@ -4443,8 +4443,10 @@ static void check_new_map(struct ceph_mds_client *mdsc,
  	     newmap->m_epoch, oldmap->m_epoch);
 
  	if (newmap->m_info) {
-		for (i = 0; i < newmap->m_info->num_export_targets; i++)
-			set_bit(newmap->m_info->export_targets[i], targets);
+		for (i = 0; i < newmap->m_num_active_mds; i++) {
+			for (j = 0; j < newmap->m_info[i].num_export_targets; j++)
+				set_bit(newmap->m_info[i].export_targets[j], targets);
+		}
  	}
 
Quoted 3 lines

fs/ceph/mds_client.c static void check_new_map(struct ceph_mds_client *mdsc, · line 4452

Quoted 1 line
fs/ceph/mds_client.c +0 -0
  	for (i = 0; i < oldmap->possible_max_rank && i < mdsc->max_sessions; i++) {

Looks sane. I'll plan to fold this into "ceph: reconnect to the export targets on new mdsmaps".

Wait, I have sent the V2 to fix:

- s/m_num_active_mds/possible_max_rank/

Thanks.

Quoted 2 lines

Thanks,

author
#3 lore raw
In reply to Jeff Layton
Quoted 33 lines · Jeff Layton
Quoted 32 lines · On Mon, 2021-08-30 at 20:33 +0800, [email protected] wrote:

From: Xiubo Li <[email protected]>

---
  fs/ceph/mds_client.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
fs/ceph/mds_client.c +5 -3
index 7ddc36c14b92..aa0ab069db40 100644
@@ -4434,7 +4434,7 @@ static void check_new_map(struct ceph_mds_client *mdsc,
  			  struct ceph_mdsmap *newmap,
  			  struct ceph_mdsmap *oldmap)
  {
-	int i, err;
+	int i, j, err;
  	int oldstate, newstate;
  	struct ceph_mds_session *s;
  	unsigned long targets[DIV_ROUND_UP(CEPH_MAX_MDS, sizeof(unsigned long))] = {0};
@@ -4443,8 +4443,10 @@ static void check_new_map(struct ceph_mds_client *mdsc,
  	     newmap->m_epoch, oldmap->m_epoch);
 
  	if (newmap->m_info) {
-		for (i = 0; i < newmap->m_info->num_export_targets; i++)
-			set_bit(newmap->m_info->export_targets[i], targets);
+		for (i = 0; i < newmap->m_num_active_mds; i++) {
+			for (j = 0; j < newmap->m_info[i].num_export_targets; j++)
+				set_bit(newmap->m_info[i].export_targets[j], targets);
+		}
  	}
 
Quoted 3 lines

fs/ceph/mds_client.c static void check_new_map(struct ceph_mds_client *mdsc, · line 4452

Quoted 1 line
fs/ceph/mds_client.c +0 -0
  	for (i = 0; i < oldmap->possible_max_rank && i < mdsc->max_sessions; i++) {

Looks sane. I'll plan to fold this into "ceph: reconnect to the export targets on new mdsmaps".

Why my previous test worked well, it should be there has only one active mds. And for the 'newmap->m_info->export_target' it will always equal to 'newmap->m_info[0].export_target', but I am not very sure why this could cause crash.

Quoted 1 line

Thanks,