Skip to contentSkip to conversation

libceph: fix protocol feature mismatch failure path

PATCH In review Sage Weil 2 participants 3 messages Dec 27, 2012 – Dec 28, 2012 Ceph common code (libceph)

lore
Share & tools
lore

Sage Weil

author
#0 lore raw

PATCH 1/1 libceph: fix protocol feature mismatch failure path

We should not set con->state to CLOSED here; that happens in ceph_fault() in the caller, where it first asserts that the state is not yet CLOSED. Avoids a BUG when the features don't match.

---
 net/ceph/messenger.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ceph/messenger.c +1 -1
index 4d111fd..24a5c86 100644
@@ -1508,9 +1508,9 @@ static int process_banner(struct ceph_connection *con)
 
 static void fail_protocol(struct ceph_connection *con)
 {
+	dout("fail_protocol %p\n", con);
 	reset_connection(con);
 	BUG_ON(con->state != CON_STATE_NEGOTIATING);
-	con->state = CON_STATE_CLOSED;
 }
 
 static int process_connect(struct ceph_connection *con)
Signature · 1 line
1.7.9
#1 lore raw
Quoted 2 lines · Sage Weil

We should not set con->state to CLOSED here; that happens in ceph_fault() in the caller, where it first asserts that the state is not yet CLOSED.

I'm not seeing the code path you're talking about. Do you mean in the LOSSYTX case?

(I don't doubt you're right, I'm just trying to follow along at home.)

Quoted 1 line

Avoids a BUG when the features don't match.

Is this related to the crashes reported here?

    http://tracker.newdream.net/issues/3657
Quoted 10 lines
---
 net/ceph/messenger.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ceph/messenger.c +0 -0
index 4d111fd..24a5c86 100644

net/ceph/messenger.c static int process_banner(struct ceph_connection *con) · line 1513

Quoted 6 lines
net/ceph/messenger.c +1 -0
@@ -1508,9 +1508,9 @@ static int process_banner(struct ceph_connection *con)
 
 static void fail_protocol(struct ceph_connection *con)
 {
+	dout("fail_protocol %p\n", con);
 	reset_connection(con);
 	BUG_ON(con->state != CON_STATE_NEGOTIATING);

Since fail_protocol becomes essentially a trivial wrapper for reset_connection(), I think it should just go away and call reset_connection() directly. The assertion that it's in NEGOTIATING state is not very useful at the moment; fail_protocol() is only called from process_connect(), and that's only called from try_read when the state is NEGOTIATING.

-Alex

Quoted 5 lines
net/ceph/messenger.c +0 -1
-	con->state = CON_STATE_CLOSED;
 }
 
 static int process_connect(struct ceph_connection *con)
author
#2 lore raw
Quoted 6 lines · Alex Elder
Quoted 2 lines · Sage Weil

We should not set con->state to CLOSED here; that happens in ceph_fault() in the caller, where it first asserts that the state is not yet CLOSED.

I'm not seeing the code path you're talking about. Do you mean in the LOSSYTX case?

It's when the feature bits don't match. It calls this, sets CLOSED< and then returns -1 and con_work() calls ceph_fault().

Quoted 20 lines

(I don't doubt you're right, I'm just trying to follow along at home.)

Quoted 1 line

Avoids a BUG when the features don't match.

Is this related to the crashes reported here?

    http://tracker.newdream.net/issues/3657
Quoted 11 lines
---
 net/ceph/messenger.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ceph/messenger.c +0 -0
index 4d111fd..24a5c86 100644
@@ -1508,9 +1508,9 @@ static int process_banner(struct ceph_connection *con)
 
Quoted 13 lines

net/ceph/messenger.c static int process_banner(struct ceph_connection *con) · line 1513

Quoted 5 lines
net/ceph/messenger.c +1 -0
 static void fail_protocol(struct ceph_connection *con)
 {
+	dout("fail_protocol %p\n", con);
 	reset_connection(con);
 	BUG_ON(con->state != CON_STATE_NEGOTIATING);

Since fail_protocol becomes essentially a trivial wrapper for reset_connection(), I think it should just go away and call reset_connection() directly. The assertion that it's in NEGOTIATING state is not very useful at the moment; fail_protocol() is only called from process_connect(), and that's only called from try_read when the state is NEGOTIATING.

Good point. I'll clean that up!

Quoted 10 lines

-Alex

Quoted 5 lines
net/ceph/messenger.c +0 -1
-	con->state = CON_STATE_CLOSED;
 }
 
 static int process_connect(struct ceph_connection *con)