Commit dbcc38f0 authored by zhenwei pi's avatar zhenwei pi Committed by Tomasz Zawadzki
Browse files

iscsi: cleanup backend on accessed exclusively



Multiple initiators share a target:

      +--+     +--+ +--+ +--+
      |Im| ... |Ix| |Iy| |Iz|
      +--+     +--+ +--+ +--+
       |        |    |    |
        \       |   /    /
      +---------------------+
      |       Target        |
      +---------------------+
                |
      +---------------------+
      |        Bdev         |
      +---------------------+

Once initiatorM(Im) gets disconnected, SPDK tries to cancel the
inflight IOs of Im by resetting backend bdev. Unfortunately, the
inflight IOs of Ix, Iy and Iz are canceled together,
'SENSE KEY:COMMAND ABORTED' error floods at that moment.

To avoid this issue, drain the inflight IOs of the exited connection
intead.

Change-Id: Ic7668d0be13052b6f4e3b0fd52c21db38f22ecf0
Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20469


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent a3ddc7dd
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -333,9 +333,16 @@ iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn)
	if (conn->sess->connections > 1) {
		/* connection specific cleanup */
	} else if (!g_iscsi.AllowDuplicateIsid) {
		/* clean up all tasks to all LUNs for session */
		/*
		 * a> a target is connected by a single initiator, cleanup backend cancels inflight
		 *    IOs and the resources (of this initiator) are reclaimed as soon as possible.
		 * b> a target is connected by multiple initiators, one of these initiators
		 *    disconnects with inflight IOs, resetting backend bdev leads all the inflight
		 *    IOs (of multiple initiators) aborted. In this scenario, drain inflight IOs of
		 *    the disconnected initiator instead.
		 */
		target = conn->sess->target;
		if (target != NULL) {
		if (target != NULL && iscsi_get_active_conns(target) == 1) {
			rc = iscsi_tgt_node_cleanup_luns(conn, target);
			if (rc < 0) {
				SPDK_ERRLOG("target abort failed\n");