From 50120c37b31758cc9aeeca420ca1bb363501cb2d Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 24 Feb 2012 02:24:06 +0000 Subject: [PATCH] scst_cmd_aborted() is a bad and ambiguous name. Rename it to scst_cmd_aborted_on_xmit() and create a new version, which truly reflects its semantic. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4143 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- fcst/ft_cmd.c | 2 +- ibmvstgt/src/ibmvstgt.c | 2 +- iscsi-scst/kernel/iscsi.c | 2 +- mvsas_tgt/mv_tgt.c | 2 +- qla2x00t/qla2x00-target/qla2x00t.c | 2 +- qla_isp/linux/isp_scst.c | 2 +- scst/include/scst.h | 25 +++++++++++++++++++++---- scst_local/scst_local.c | 2 +- srpt/src/ib_srpt.c | 2 +- 9 files changed, 29 insertions(+), 12 deletions(-) diff --git a/fcst/ft_cmd.c b/fcst/ft_cmd.c index a03439613..55832d8a1 100644 --- a/fcst/ft_cmd.c +++ b/fcst/ft_cmd.c @@ -223,7 +223,7 @@ int ft_send_response(struct scst_cmd *cmd) ep = fc_seq_exch(fcmd->seq); lport = ep->lp; - if (scst_cmd_aborted(cmd)) { + if (scst_cmd_aborted_on_xmit(cmd)) { FT_IO_DBG("cmd aborted did %x oxid %x\n", ep->did, ep->oxid); scst_set_delivery_status(cmd, SCST_CMD_DELIVERY_ABORTED); goto done; diff --git a/ibmvstgt/src/ibmvstgt.c b/ibmvstgt/src/ibmvstgt.c index e5aa2a607..1d0604d35 100644 --- a/ibmvstgt/src/ibmvstgt.c +++ b/ibmvstgt/src/ibmvstgt.c @@ -439,7 +439,7 @@ static int ibmvstgt_xmit_response(struct scst_cmd *sc) int ret; enum dma_data_direction dir; - if (unlikely(scst_cmd_aborted(sc))) { + if (unlikely(scst_cmd_aborted_on_xmit(sc))) { scst_set_delivery_status(sc, SCST_CMD_DELIVERY_ABORTED); atomic_inc(&vport->req_lim_delta); srp_iu_put(iue); diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index a3ca290d8..ec75b1d1b 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -3268,7 +3268,7 @@ static int iscsi_xmit_response(struct scst_cmd *scst_cmd) EXTRACHECKS_BUG_ON(req->scst_state != ISCSI_CMD_STATE_RESTARTED); - if (unlikely(scst_cmd_aborted(scst_cmd))) + if (unlikely(scst_cmd_aborted_on_xmit(scst_cmd))) set_bit(ISCSI_CMD_ABORTED, &req->prelim_compl_flags); if (unlikely(req->prelim_compl_flags != 0)) { diff --git a/mvsas_tgt/mv_tgt.c b/mvsas_tgt/mv_tgt.c index c7eb06ce2..051c2a368 100644 --- a/mvsas_tgt/mv_tgt.c +++ b/mvsas_tgt/mv_tgt.c @@ -778,7 +778,7 @@ static int mvst_xmit_response(struct scst_cmd *scst_cmd) sess = (struct mvst_sess *) scst_sess_get_tgt_priv(scst_cmd_get_session(scst_cmd)); - if (unlikely(scst_cmd_aborted(scst_cmd))) { + if (unlikely(scst_cmd_aborted_on_xmit(scst_cmd))) { TRACE_MGMT_DBG("mvst tgt: terminating exchange " "for aborted scst_cmd=%p (tag=%lld)", scst_cmd, scst_cmd_get_tag(scst_cmd)); diff --git a/qla2x00t/qla2x00-target/qla2x00t.c b/qla2x00t/qla2x00-target/qla2x00t.c index c715a93ca..1a6c44280 100644 --- a/qla2x00t/qla2x00-target/qla2x00t.c +++ b/qla2x00t/qla2x00-target/qla2x00t.c @@ -2768,7 +2768,7 @@ static int q2x_xmit_response(struct scst_cmd *scst_cmd) cmd->data_direction = scst_cmd_get_data_direction(scst_cmd); cmd->dma_data_direction = scst_to_tgt_dma_dir(cmd->data_direction); cmd->offset = scst_cmd_get_ppl_offset(scst_cmd); - cmd->aborted = scst_cmd_aborted(scst_cmd); + cmd->aborted = scst_cmd_aborted_on_xmit(scst_cmd); q2t_check_srr_debug(cmd, &xmit_type); diff --git a/qla_isp/linux/isp_scst.c b/qla_isp/linux/isp_scst.c index b5da2e5b8..1d683a0b3 100644 --- a/qla_isp/linux/isp_scst.c +++ b/qla_isp/linux/isp_scst.c @@ -1188,7 +1188,7 @@ isp_xmit_response(struct scst_cmd *scst_cmd) bus_t *bp = tmd->cd_bus; tmd_xact_t *xact = &tmd->cd_xact; - if (unlikely(scst_cmd_aborted(scst_cmd))) { + if (unlikely(scst_cmd_aborted_on_xmit(scst_cmd))) { scst_set_delivery_status(scst_cmd, SCST_CMD_DELIVERY_ABORTED); scst_tgt_cmd_done(scst_cmd, SCST_CONTEXT_SAME); return (SCST_TGT_RES_SUCCESS); diff --git a/scst/include/scst.h b/scst/include/scst.h index 2b7588b08..5c3102912 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -3395,11 +3395,28 @@ static inline void scst_cmd_set_noio_mem_alloc(struct scst_cmd *cmd) } /* - * Returns 1 if the cmd was aborted, so its status is invalid and no - * reply shall be sent to the remote initiator. A target driver should - * only clear internal resources, associated with cmd. + * Returns true if the cmd was aborted, so the caller should complete it as + * soon as possible. + * + * !! Xmit_response() callback must use scst_cmd_aborted_on_xmit() instead !! + * !! to allow status of completed commands aborted by other initiators be !! + * !! delivered to their initiators !! */ -static inline int scst_cmd_aborted(struct scst_cmd *cmd) +static inline bool scst_cmd_aborted(struct scst_cmd *cmd) +{ + return test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags); +} + +/* + * Returns true if the cmd was aborted by its initiator or aborted by another + * initiator and not completed, so its status is invalid and no reply shall + * be sent to the remote initiator. A target driver should only clear + * internal resources, associated with cmd. + * + * This functions shall be called by all target drivers in the beginning of + * xmit_response() callback. + */ +static inline bool scst_cmd_aborted_on_xmit(struct scst_cmd *cmd) { return test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags) && !test_bit(SCST_CMD_ABORTED_OTHER, &cmd->cmd_flags); diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index f73b94530..18fc0f1bb 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -1289,7 +1289,7 @@ static int scst_local_targ_xmit_response(struct scst_cmd *scst_cmd) TRACE_ENTRY(); - if (unlikely(scst_cmd_aborted(scst_cmd))) { + if (unlikely(scst_cmd_aborted_on_xmit(scst_cmd))) { scst_set_delivery_status(scst_cmd, SCST_CMD_DELIVERY_ABORTED); scst_tgt_cmd_done(scst_cmd, SCST_CONTEXT_SAME); return SCST_TGT_RES_SUCCESS; diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 5d4ad0278..d5e3bca58 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3214,7 +3214,7 @@ static int srpt_xmit_response(struct scst_cmd *scmnd) } spin_unlock(&ioctx->spinlock); - if (unlikely(scst_cmd_aborted(scmnd))) { + if (unlikely(scst_cmd_aborted_on_xmit(scmnd))) { srpt_adjust_req_lim(ch, 0, 1); srpt_abort_cmd(ioctx, SCST_CONTEXT_SAME); goto out;