Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcm_fc: Generate TASK_SET_FULL status for response failures

This patch changes ft_queue_status() to set SAM_STAT_TASK_SET_FULL
status upon lport->tt.seq_send( failure, and return -EAGAIN to notify
target-core to attempt to requeue the response.

It also does the same for a fc_frame_alloc() failures, in order to
signal the initiator that it should try to reduce it's current
queue_depth, to lower the number of outstanding I/Os on the wire.

Reported-by: Vasu Dev <vasu.dev@linux.intel.com>
Reviewed-by: Vasu Dev <vasu.dev@linux.intel.com>
Cc: Jun Wu <jwu@stormojo.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

+16 -3
+16 -3
drivers/target/tcm_fc/tfc_cmd.c
··· 128 128 struct fc_lport *lport; 129 129 struct fc_exch *ep; 130 130 size_t len; 131 + int rc; 131 132 132 133 if (cmd->aborted) 133 134 return 0; ··· 138 137 len = sizeof(*fcp) + se_cmd->scsi_sense_length; 139 138 fp = fc_frame_alloc(lport, len); 140 139 if (!fp) { 141 - /* XXX shouldn't just drop it - requeue and retry? */ 142 - return 0; 140 + se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL; 141 + return -ENOMEM; 143 142 } 143 + 144 144 fcp = fc_frame_payload_get(fp, len); 145 145 memset(fcp, 0, len); 146 146 fcp->resp.fr_status = se_cmd->scsi_status; ··· 172 170 fc_fill_fc_hdr(fp, FC_RCTL_DD_CMD_STATUS, ep->did, ep->sid, FC_TYPE_FCP, 173 171 FC_FC_EX_CTX | FC_FC_LAST_SEQ | FC_FC_END_SEQ, 0); 174 172 175 - lport->tt.seq_send(lport, cmd->seq, fp); 173 + rc = lport->tt.seq_send(lport, cmd->seq, fp); 174 + if (rc) { 175 + pr_info_ratelimited("%s: Failed to send response frame %p, " 176 + "xid <0x%x>\n", __func__, fp, ep->xid); 177 + /* 178 + * Generate a TASK_SET_FULL status to notify the initiator 179 + * to reduce it's queue_depth after the se_cmd response has 180 + * been re-queued by target-core. 181 + */ 182 + se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL; 183 + return -ENOMEM; 184 + } 176 185 lport->tt.exch_done(cmd->seq); 177 186 return 0; 178 187 }