libceph: set CLOSED state bit in con_init
Once a connection is fully initialized, it is really in a CLOSED state, so make that explicit by setting the bit in its state field. It is possible for a connection in NEGOTIATING state to get a failure, leading to ceph_fault() and ultimately ceph_con_close(). Clear that bits if it is set in that case, to reflect that the connection truly is closed and is no longer participating in a connect sequence. Issue a warning if ceph_con_open() is called on a connection that is not in CLOSED state. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
e10006f807
commit
a5988c490e
@ -454,11 +454,14 @@ void ceph_con_close(struct ceph_connection *con)
|
|||||||
{
|
{
|
||||||
dout("con_close %p peer %s\n", con,
|
dout("con_close %p peer %s\n", con,
|
||||||
ceph_pr_addr(&con->peer_addr.in_addr));
|
ceph_pr_addr(&con->peer_addr.in_addr));
|
||||||
set_bit(CLOSED, &con->state); /* in case there's queued work */
|
clear_bit(NEGOTIATING, &con->state);
|
||||||
clear_bit(STANDBY, &con->state); /* avoid connect_seq bump */
|
clear_bit(STANDBY, &con->state); /* avoid connect_seq bump */
|
||||||
|
set_bit(CLOSED, &con->state);
|
||||||
|
|
||||||
clear_bit(LOSSYTX, &con->flags); /* so we retry next connect */
|
clear_bit(LOSSYTX, &con->flags); /* so we retry next connect */
|
||||||
clear_bit(KEEPALIVE_PENDING, &con->flags);
|
clear_bit(KEEPALIVE_PENDING, &con->flags);
|
||||||
clear_bit(WRITE_PENDING, &con->flags);
|
clear_bit(WRITE_PENDING, &con->flags);
|
||||||
|
|
||||||
mutex_lock(&con->mutex);
|
mutex_lock(&con->mutex);
|
||||||
reset_connection(con);
|
reset_connection(con);
|
||||||
con->peer_global_seq = 0;
|
con->peer_global_seq = 0;
|
||||||
@ -475,7 +478,8 @@ void ceph_con_open(struct ceph_connection *con, struct ceph_entity_addr *addr)
|
|||||||
{
|
{
|
||||||
dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr));
|
dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr));
|
||||||
set_bit(OPENING, &con->state);
|
set_bit(OPENING, &con->state);
|
||||||
clear_bit(CLOSED, &con->state);
|
WARN_ON(!test_and_clear_bit(CLOSED, &con->state));
|
||||||
|
|
||||||
memcpy(&con->peer_addr, addr, sizeof(*addr));
|
memcpy(&con->peer_addr, addr, sizeof(*addr));
|
||||||
con->delay = 0; /* reset backoff memory */
|
con->delay = 0; /* reset backoff memory */
|
||||||
queue_con(con);
|
queue_con(con);
|
||||||
@ -530,6 +534,8 @@ void ceph_con_init(struct ceph_messenger *msgr, struct ceph_connection *con)
|
|||||||
INIT_LIST_HEAD(&con->out_queue);
|
INIT_LIST_HEAD(&con->out_queue);
|
||||||
INIT_LIST_HEAD(&con->out_sent);
|
INIT_LIST_HEAD(&con->out_sent);
|
||||||
INIT_DELAYED_WORK(&con->work, con_work);
|
INIT_DELAYED_WORK(&con->work, con_work);
|
||||||
|
|
||||||
|
set_bit(CLOSED, &con->state);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ceph_con_init);
|
EXPORT_SYMBOL(ceph_con_init);
|
||||||
|
|
||||||
@ -1933,14 +1939,15 @@ more:
|
|||||||
|
|
||||||
/* open the socket first? */
|
/* open the socket first? */
|
||||||
if (con->sock == NULL) {
|
if (con->sock == NULL) {
|
||||||
|
clear_bit(NEGOTIATING, &con->state);
|
||||||
|
set_bit(CONNECTING, &con->state);
|
||||||
|
|
||||||
con_out_kvec_reset(con);
|
con_out_kvec_reset(con);
|
||||||
prepare_write_banner(con);
|
prepare_write_banner(con);
|
||||||
ret = prepare_write_connect(con);
|
ret = prepare_write_connect(con);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
prepare_read_banner(con);
|
prepare_read_banner(con);
|
||||||
set_bit(CONNECTING, &con->state);
|
|
||||||
clear_bit(NEGOTIATING, &con->state);
|
|
||||||
|
|
||||||
BUG_ON(con->in_msg);
|
BUG_ON(con->in_msg);
|
||||||
con->in_tag = CEPH_MSGR_TAG_READY;
|
con->in_tag = CEPH_MSGR_TAG_READY;
|
||||||
|
Loading…
Reference in New Issue
Block a user