stgt.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anton Kovalenko <Anton.Kovalenko@acronis.com>
To: "stgt@vger.kernel.org" <stgt@vger.kernel.org>
Subject: [PATCH] Disable NOP-IN and adjust state for closed conn
Date: Tue, 30 Aug 2016 17:09:21 +0000	[thread overview]
Message-ID: <1472576961463.91961@acronis.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]

I'm attaching the patch fixing one more problem noticed with non-zero nop_interval:

There is a couple of problems when a connection is closed by
iscsi_tcp_nop_work_handler, and there are uncompleted scsi commands for
that connection:

1) usr/iscsi/iscsid.c:iscsi_scsi_cmd_done assumes that a closed connection
has .state == STATE_CLOSE. The assumption fails if the connection is
closed not as a reaction to STATE_CLOSE, but by a raw conn_close call
outside of rx/tx handlers (like it happens for unanswered NOP-INs).
This commit takes care to set .state = STATE_CLOSE in ep_close callback,
so incomplete scsi commands will be freed on completion.

2) the connection doesn't go away from iscsi_tcp_conn_list until its
refcount reaches zero (see iscsi_tcp_release). It makes
iscsi_tcp_nop_work_handler call conn_close for the same connection
repeatedly, as long as it has incomplete scsi commands (hence non-zero
refcount). This commit zeroes out nop_interval for closed connections,
so next iscsi_tcp_nop_work_handler calls won't try to close the
connection any more.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Disable-NOP-IN-and-adjust-state-for-closed-conn.patch --]
[-- Type: text/x-patch; name="0001-Disable-NOP-IN-and-adjust-state-for-closed-conn.patch", Size: 1682 bytes --]

From ac1b732b612fe2c188dcc2441e5dd247d3452836 Mon Sep 17 00:00:00 2001
From: Anton Kovalenko <anton.kovalenko@acronis.com>
Date: Tue, 30 Aug 2016 19:02:51 +0300
Subject: [PATCH] Disable NOP-IN and adjust state for closed conn

There is a couple of problems when a connection is closed by
iscsi_tcp_nop_work_handler, and there are uncompleted scsi commands for
that connection:

1) usr/iscsi/iscsid.c:iscsi_scsi_cmd_done assumes that a closed connection
has .state == STATE_CLOSE. The assumption fails if the connection is
closed not as a reaction to STATE_CLOSE, but by a raw conn_close call
outside of rx/tx handlers (like it happens for unanswered NOP-INs).
This commit takes care to set .state = STATE_CLOSE in ep_close callback,
so incomplete scsi commands will be freed on completion.

2) the connection doesn't go away from iscsi_tcp_conn_list until its
refcount reaches zero (see iscsi_tcp_release). It makes
iscsi_tcp_nop_work_handler call conn_close for the same connection
repeatedly, as long as it has incomplete scsi commands (hence non-zero
refcount). This commit zeroes out nop_interval for closed connections,
so next iscsi_tcp_nop_work_handler calls won't try to close the
connection any more.
---
 usr/iscsi/iscsi_tcp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c
index 4cc2cf4..536f22e 100644
--- a/usr/iscsi/iscsi_tcp.c
+++ b/usr/iscsi/iscsi_tcp.c
@@ -508,6 +508,8 @@ static size_t iscsi_tcp_close(struct iscsi_connection *conn)
 	struct iscsi_tcp_connection *tcp_conn = TCP_CONN(conn);
 
 	tgt_event_del(tcp_conn->fd);
+	conn->state = STATE_CLOSE;
+	tcp_conn->nop_interval = 0;
 	return 0;
 }
 
-- 
2.9.3


             reply	other threads:[~2016-08-30 17:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-30 17:09 Anton Kovalenko [this message]
2016-09-01  2:16 ` [PATCH] Disable NOP-IN and adjust state for closed conn FUJITA Tomonori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472576961463.91961@acronis.com \
    --to=anton.kovalenko@acronis.com \
    --cc=stgt@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).