iscsi: Simplify the check of return value of spdk_iscsi_reject()

The possible cause of failure in spdk_iscsi_reject() is only -ENOMEM,
and SPDK_SUCCESS is 0 and SPDK_ISCSI_CONNECTION_FATAL is -1.

Hence just calling spdk_iscsi_reject() as return value will be
enough.

Besides, one redundant return path was found and fixed in this
patch too.

Change-Id: I37647a9ef6d0173d68d1017443d5a1d5604c1e64
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/436644
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-12-10 08:41:57 +09:00 committed by Jim Harris
parent 72caa1d06b
commit 943561fae1

View File

@ -1702,13 +1702,8 @@ spdk_iscsi_op_login_phase_none(struct spdk_iscsi_conn *conn,
} }
} }
rc = spdk_iscsi_op_login_set_target_info(conn, rsp_pdu, session_type, return spdk_iscsi_op_login_set_target_info(conn, rsp_pdu, session_type,
alloc_len, target); alloc_len, target);
if (rc < 0) {
return rc;
}
return rc;
} }
/* /*
@ -2910,23 +2905,14 @@ spdk_iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
SPDK_ERRLOG("data segment len(=%d) > task transfer len(=%d)\n", SPDK_ERRLOG("data segment len(=%d) > task transfer len(=%d)\n",
(int)pdu->data_segment_len, transfer_len); (int)pdu->data_segment_len, transfer_len);
spdk_iscsi_task_put(task); spdk_iscsi_task_put(task);
rc = spdk_iscsi_reject(conn, pdu, return spdk_iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
ISCSI_REASON_PROTOCOL_ERROR);
if (rc < 0) {
SPDK_ERRLOG("iscsi_reject() failed\n");
}
return rc;
} }
/* check the ImmediateData and also pdu->data_segment_len */ /* check the ImmediateData and also pdu->data_segment_len */
if ((!conn->sess->ImmediateData && (pdu->data_segment_len > 0)) || if ((!conn->sess->ImmediateData && (pdu->data_segment_len > 0)) ||
(pdu->data_segment_len > conn->sess->FirstBurstLength)) { (pdu->data_segment_len > conn->sess->FirstBurstLength)) {
spdk_iscsi_task_put(task); spdk_iscsi_task_put(task);
rc = spdk_iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR); return spdk_iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
if (rc < 0) {
SPDK_ERRLOG("iscsi_reject() failed\n");
}
return rc;
} }
if (F_bit && pdu->data_segment_len < transfer_len) { if (F_bit && pdu->data_segment_len < transfer_len) {
@ -3887,7 +3873,6 @@ spdk_iscsi_handle_data_ack(struct spdk_iscsi_conn *conn,
uint32_t run_length; uint32_t run_length;
struct spdk_iscsi_pdu *old_pdu; struct spdk_iscsi_pdu *old_pdu;
uint32_t old_datasn; uint32_t old_datasn;
int rc;
struct iscsi_bhs_snack_req *reqh; struct iscsi_bhs_snack_req *reqh;
struct spdk_iscsi_task *task; struct spdk_iscsi_task *task;
struct iscsi_bhs_data_in *datain_header; struct iscsi_bhs_data_in *datain_header;
@ -3944,13 +3929,7 @@ spdk_iscsi_handle_data_ack(struct spdk_iscsi_conn *conn,
return 0; return 0;
reject_return: reject_return:
rc = spdk_iscsi_reject(conn, pdu, ISCSI_REASON_INVALID_SNACK); return spdk_iscsi_reject(conn, pdu, ISCSI_REASON_INVALID_SNACK);
if (rc < 0) {
SPDK_ERRLOG("iscsi_reject() failed\n");
return -1;
}
return 0;
} }
/* This function is used to remove the r2t pdu from snack_pdu_list by < task, r2t_sn> info */ /* This function is used to remove the r2t pdu from snack_pdu_list by < task, r2t_sn> info */
@ -4048,12 +4027,7 @@ spdk_iscsi_op_snack(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
reqh = (struct iscsi_bhs_snack_req *)&pdu->bhs; reqh = (struct iscsi_bhs_snack_req *)&pdu->bhs;
if (!conn->sess->ErrorRecoveryLevel) { if (!conn->sess->ErrorRecoveryLevel) {
SPDK_ERRLOG("Got a SNACK request in ErrorRecoveryLevel=0\n"); SPDK_ERRLOG("Got a SNACK request in ErrorRecoveryLevel=0\n");
rc = spdk_iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR); return spdk_iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
if (rc < 0) {
SPDK_ERRLOG("iscsi_reject() failed\n");
return -1;
}
return rc;
} }
type = reqh->flags & ISCSI_FLAG_SNACK_TYPE_MASK; type = reqh->flags & ISCSI_FLAG_SNACK_TYPE_MASK;
@ -4246,13 +4220,7 @@ send_r2t_recovery_return:
} }
reject_return: reject_return:
rc = spdk_iscsi_reject(conn, pdu, reject_reason); return spdk_iscsi_reject(conn, pdu, reject_reason);
if (rc < 0) {
SPDK_ERRLOG("iscsi_reject() failed\n");
return SPDK_ISCSI_CONNECTION_FATAL;
}
return SPDK_SUCCESS;
} }
static int static int
@ -4522,12 +4490,7 @@ spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
default: default:
SPDK_ERRLOG("unsupported opcode %x\n", opcode); SPDK_ERRLOG("unsupported opcode %x\n", opcode);
rc = spdk_iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR); return spdk_iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
if (rc < 0) {
SPDK_ERRLOG("spdk_iscsi_reject() failed\n");
return rc;
}
break;
} }
return 0; return 0;