Skip to contentSkip to conversation

ceph: clear `s_cap_reconnect` when ceph_pagelist_encode_32() fails

PATCH In review Max Kellermann 2 participants 4 messages Mar 30 – Apr 2 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: clear `s_cap_reconnect` when ceph_pagelist_encode_32() fails

This MDS reconnect error path leaves s_cap_reconnect set. send_mds_reconnect() sets the bit at the beginning of the reconnect, but the first failing operation after that, ceph_pagelist_encode_32(), can jump to fail: without clearing it.

__ceph_remove_cap() consults that flag to decide whether cap releases should be queued. A reconnect-preparation failure therefore leaves the session in reconnect mode from the cap-release path's point of view and can strand release work until some later state transition repairs it.

---
 fs/ceph/mds_client.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +5 -1
index b1746273f186..4fa471d9b3b2 100644
@@ -4956,7 +4956,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
 	/* placeholder for nr_caps */
 	err = ceph_pagelist_encode_32(recon_state.pagelist, 0);
 	if (err)
-		goto fail;
+		goto fail_clear_cap_reconnect;
 
 	if (test_bit(CEPHFS_FEATURE_MULTI_RECONNECT, &session->s_features)) {
 		recon_state.msg_version = 3;
@@ -5046,6 +5046,10 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
 	ceph_pagelist_release(recon_state.pagelist);
 	return;
 
+fail_clear_cap_reconnect:
+	spin_lock(&session->s_cap_lock);
+	session->s_cap_reconnect = 0;
+	spin_unlock(&session->s_cap_lock);
 fail:
 	ceph_msg_put(reply);
 	up_read(&mdsc->snap_rwsem);
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Max Kellermann

This MDS reconnect error path leaves s_cap_reconnect set. send_mds_reconnect() sets the bit at the beginning of the reconnect, but the first failing operation after that, ceph_pagelist_encode_32(), can jump to fail: without clearing it.

__ceph_remove_cap() consults that flag to decide whether cap releases should be queued. A reconnect-preparation failure therefore leaves the session in reconnect mode from the cap-release path's point of view and can strand release work until some later state transition repairs it.

---
 fs/ceph/mds_client.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +1 -1
index b1746273f186..4fa471d9b3b2 100644
@@ -4956,7 +4956,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
 	/* placeholder for nr_caps */
 	err = ceph_pagelist_encode_32(recon_state.pagelist, 0);
 	if (err)
-		goto fail;
+		goto fail_clear_cap_reconnect;
 
 	if (test_bit(CEPHFS_FEATURE_MULTI_RECONNECT, &session->s_features)) {
 		recon_state.msg_version = 3;

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

Quoted 10 lines
fs/ceph/mds_client.c +4 -0
@@ -5046,6 +5046,10 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
 	ceph_pagelist_release(recon_state.pagelist);
 	return;
 
+fail_clear_cap_reconnect:
+	spin_lock(&session->s_cap_lock);
+	session->s_cap_reconnect = 0;
+	spin_unlock(&session->s_cap_lock);
 fail:
 	ceph_msg_put(reply);
 	up_read(&mdsc->snap_rwsem);

Makes sense. Nice fix. But, maybe, we need to consider refactoring of this function because of such issue.

Thanks,
Slava.

#2 lore raw
Quoted 45 lines · Viacheslav Dubeyko
Quoted 30 lines · Max Kellermann

This MDS reconnect error path leaves s_cap_reconnect set. send_mds_reconnect() sets the bit at the beginning of the reconnect, but the first failing operation after that, ceph_pagelist_encode_32(), can jump to fail: without clearing it.

__ceph_remove_cap() consults that flag to decide whether cap releases should be queued. A reconnect-preparation failure therefore leaves the session in reconnect mode from the cap-release path's point of view and can strand release work until some later state transition repairs it.

---
 fs/ceph/mds_client.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +1 -1
index b1746273f186..4fa471d9b3b2 100644
@@ -4956,7 +4956,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
 	/* placeholder for nr_caps */
 	err = ceph_pagelist_encode_32(recon_state.pagelist, 0);
 	if (err)
-		goto fail;
+		goto fail_clear_cap_reconnect;
 
 	if (test_bit(CEPHFS_FEATURE_MULTI_RECONNECT, &session->s_features)) {
 		recon_state.msg_version = 3;

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

Quoted 10 lines
fs/ceph/mds_client.c +4 -0
@@ -5046,6 +5046,10 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
 	ceph_pagelist_release(recon_state.pagelist);
 	return;
 
+fail_clear_cap_reconnect:
+	spin_lock(&session->s_cap_lock);
+	session->s_cap_reconnect = 0;
+	spin_unlock(&session->s_cap_lock);
 fail:
 	ceph_msg_put(reply);
 	up_read(&mdsc->snap_rwsem);

Makes sense. Nice fix. But, maybe, we need to consider refactoring of this function because of such issue.

Quoted 3 lines

The xfstests run on 7.0-rc6 didn't reveal any new issues related to the patch.

Thanks,
Slava.

#3 lore raw
Quoted 46 lines · Viacheslav Dubeyko
Quoted 45 lines · Viacheslav Dubeyko
Quoted 30 lines · Max Kellermann

This MDS reconnect error path leaves s_cap_reconnect set. send_mds_reconnect() sets the bit at the beginning of the reconnect, but the first failing operation after that, ceph_pagelist_encode_32(), can jump to fail: without clearing it.

__ceph_remove_cap() consults that flag to decide whether cap releases should be queued. A reconnect-preparation failure therefore leaves the session in reconnect mode from the cap-release path's point of view and can strand release work until some later state transition repairs it.

---
 fs/ceph/mds_client.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ceph/mds_client.c +1 -1
index b1746273f186..4fa471d9b3b2 100644
@@ -4956,7 +4956,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
 	/* placeholder for nr_caps */
 	err = ceph_pagelist_encode_32(recon_state.pagelist, 0);
 	if (err)
-		goto fail;
+		goto fail_clear_cap_reconnect;
 
 	if (test_bit(CEPHFS_FEATURE_MULTI_RECONNECT, &session->s_features)) {
 		recon_state.msg_version = 3;

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

Quoted 10 lines
fs/ceph/mds_client.c +4 -0
@@ -5046,6 +5046,10 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
 	ceph_pagelist_release(recon_state.pagelist);
 	return;
 
+fail_clear_cap_reconnect:
+	spin_lock(&session->s_cap_lock);
+	session->s_cap_reconnect = 0;
+	spin_unlock(&session->s_cap_lock);
 fail:
 	ceph_msg_put(reply);
 	up_read(&mdsc->snap_rwsem);

Makes sense. Nice fix. But, maybe, we need to consider refactoring of this function because of such issue.

Quoted 8 lines
Quoted 3 lines

The xfstests run on 7.0-rc6 didn't reveal any new issues related to the patch.

Applied on testing branch of CephFS kernel client.

Thanks,
Slava.