Skip to contentSkip to conversation

tcm_fc: Generate TASK_SET_FULL for DataIN + response failures

PATCH In review Nicholas A. Bellinger 5 participants 12 messages Jun 5, 2014 – Jun 9, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover tcm_fc: Generate TASK_SET_FULL for DataIN + response failures

From: Nicholas Bellinger <[email protected]>

Hi Vasu,

This series generates SAM_STAT_TASK_SET_FULL status for lport->tt.seq_send() failures in DataIN + response status codepaths, which is done in order to get the initiator to reduce it's current queue_depth thus reducing the number of outstanding I/Os permitted in flight on the wire.

For the DataIN case, once a lport->tt.seq_send() failure occurs it will stop attempting to send subsequent DataIN payload data, and immediately attempt to send a response packet with SAM_STAT_TASK_SET_FULL status.

For the response case, once a lport->tt.seq_send() failure occurs it will set SAM_STAT_TASK_SET_FULL status and return -ENOMEM to the target, forcing the response to be requeued by target-core

Note this series has been compile tested only, so please review + test.

Thank you,

--nab

Nicholas Bellinger (2):
tcm_fc: Generate TASK_SET_FULL status for DataIN failures
tcm_fc: Generate TASK_SET_FULL status for response failures

 drivers/target/tcm_fc/tfc_cmd.c |   19 ++++++++++++++++---
 drivers/target/tcm_fc/tfc_io.c  |   14 +++++++++++++-
 2 files changed, 29 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/2 tcm_fc: Generate TASK_SET_FULL status for DataIN failures

From: Nicholas Bellinger <[email protected]>

This patch changes ft_queue_data_in() to set SAM_STAT_TASK_SET_FULL status upon a lport->tt.seq_send() failure, where it will now stop sending subsequent DataIN, and immediately attempt to send the response with exception status.

Sending a response with SAM_STAT_TASK_SET_FULL status is useful 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.

Also, add a check to skip sending DataIN if TASK_SET_FULL status has already been set due to a response lport->tt.seq_send() failure, that has asked target-core to requeue a response.

---
 drivers/target/tcm_fc/tfc_io.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/target/tcm_fc/tfc_io.c +13 -1
index e415af3..140659f 100644
@@ -82,6 +82,10 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
 
 	if (cmd->aborted)
 		return 0;
+
+	if (se_cmd->scsi_status == SAM_STAT_TASK_SET_FULL)
+		goto queue_status;
+
 	ep = fc_seq_exch(cmd->seq);
 	lport = ep->lp;
 	cmd->seq = lport->tt.seq_start_next(cmd->seq);
@@ -178,14 +182,22 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
 			       FC_TYPE_FCP, f_ctl, fh_off);
 		error = lport->tt.seq_send(lport, seq, fp);
 		if (error) {
-			/* XXX For now, initiator will retry */
 			pr_err_ratelimited("%s: Failed to send frame %p, "
 						"xid <0x%x>, remaining %zu, "
 						"lso_max <0x%x>\n",
 						__func__, fp, ep->xid,
 						remaining, lport->lso_max);
+			/*
+			 * Generate a TASK_SET_FULL status to notify the
+			 * initiator to reduce it's queue_depth, ignoring
+			 * the rest of the data-in and immediately attempt
+			 * to send the response.
+			 */
+			se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+			break;
 		}
 	}
+queue_status:
 	return ft_queue_status(se_cmd);
 }
 
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] tcm_fc: Generate TASK_SET_FULL status for DataIN failures

Quoted 45 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch changes ft_queue_data_in() to set SAM_STAT_TASK_SET_FULL status upon a lport->tt.seq_send() failure, where it will now stop sending subsequent DataIN, and immediately attempt to send the response with exception status.

Sending a response with SAM_STAT_TASK_SET_FULL status is useful 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.

Also, add a check to skip sending DataIN if TASK_SET_FULL status has already been set due to a response lport->tt.seq_send() failure, that has asked target-core to requeue a response.

---
 drivers/target/tcm_fc/tfc_io.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/target/tcm_fc/tfc_io.c +4 -1
index e415af3..140659f 100644
@@ -82,6 +82,10 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
 
 	if (cmd->aborted)
 		return 0;
+
+	if (se_cmd->scsi_status == SAM_STAT_TASK_SET_FULL)
+		goto queue_status;
+
 	ep = fc_seq_exch(cmd->seq);
 	lport = ep->lp;
 	cmd->seq = lport->tt.seq_start_next(cmd->seq);
@@ -178,14 +182,22 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
 			       FC_TYPE_FCP, f_ctl, fh_off);
 		error = lport->tt.seq_send(lport, seq, fp);
 		if (error) {
-			/* XXX For now, initiator will retry */
 			pr_err_ratelimited("%s: Failed to send frame %p, "

drivers/target/tcm_fc/tfc_io.c int ft_queue_data_in(struct se_cmd *se_cmd) · line 195

Quoted 10 lines
drivers/target/tcm_fc/tfc_io.c +6 -0
 						"xid <0x%x>, remaining %zu, "
 						"lso_max <0x%x>\n",
 						__func__, fp, ep->xid,
 						remaining, lport->lso_max);
+			/*
+			 * Generate a TASK_SET_FULL status to notify the
+			 * initiator to reduce it's queue_depth, ignoring
+			 * the rest of the data-in and immediately attempt
+			 * to send the response.
+			 */

I see above added check will drop rest of the frames but cannot find notifying to initiator with the TASK_SET_FULL status as in comments above, may be just the comment needs update otherwise code changes are fine.

drivers/target/tcm_fc/tfc_io.c int ft_queue_data_in(struct se_cmd *se_cmd) · line 203

Quoted 8 lines
drivers/target/tcm_fc/tfc_io.c +3 -0
+			se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+			break;
 		}
 	}
+queue_status:
 	return ft_queue_status(se_cmd);
 }
 
#3 lore raw

Re: [PATCH 1/2] tcm_fc: Generate TASK_SET_FULL status for DataIN failures

Quoted 53 lines · Vasu Dev
Quoted 52 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

This patch changes ft_queue_data_in() to set SAM_STAT_TASK_SET_FULL status upon a lport->tt.seq_send() failure, where it will now stop sending subsequent DataIN, and immediately attempt to send the response with exception status.

Sending a response with SAM_STAT_TASK_SET_FULL status is useful 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.

Also, add a check to skip sending DataIN if TASK_SET_FULL status has already been set due to a response lport->tt.seq_send() failure, that has asked target-core to requeue a response.

Cc Vasu Dev <vasu.dev-VuQAYsv1563Yd54FQh9/[email protected]>
Cc Jun Wu <jwu-kEM2MQtWpIJWk0Htik3J/[email protected]>
---
 drivers/target/tcm_fc/tfc_io.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/target/tcm_fc/tfc_io.c +7 -1
index e415af3..140659f 100644
@@ -82,6 +82,10 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
 
 	if (cmd->aborted)
 		return 0;
+
+	if (se_cmd->scsi_status == SAM_STAT_TASK_SET_FULL)
+		goto queue_status;
+
 	ep = fc_seq_exch(cmd->seq);
 	lport = ep->lp;
 	cmd->seq = lport->tt.seq_start_next(cmd->seq);
@@ -178,14 +182,22 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
 			       FC_TYPE_FCP, f_ctl, fh_off);
 		error = lport->tt.seq_send(lport, seq, fp);
 		if (error) {
-			/* XXX For now, initiator will retry */
 			pr_err_ratelimited("%s: Failed to send frame %p, "
 						"xid <0x%x>, remaining %zu, "
 						"lso_max <0x%x>\n",
 						__func__, fp, ep->xid,
 						remaining, lport->lso_max);
+			/*
+			 * Generate a TASK_SET_FULL status to notify the
+			 * initiator to reduce it's queue_depth, ignoring
Quoted 9 lines

drivers/target/tcm_fc/tfc_io.c int ft_queue_data_in(struct se_cmd *se_cmd) · line 195

Quoted 3 lines
drivers/target/tcm_fc/tfc_io.c +3 -0
+			 * the rest of the data-in and immediately attempt
+			 * to send the response.
+			 */

I see above added check will drop rest of the frames but cannot find notifying to initiator with the TASK_SET_FULL status as in comments above, may be just the comment needs update otherwise code changes are fine.

The break aborts the DataIN send loop and invokes ft_queue_status() below in an attempt to send TASK_SET_FULL status.

If the ft_queue_status() -> lport->tt.seq_send() also fails, then -ENOMEM will be returned to the target and a delayed re-queue attempt will be made.

In any event, updating the comment above to be more precise..

Quoted 11 lines

drivers/target/tcm_fc/tfc_io.c int ft_queue_data_in(struct se_cmd *se_cmd) · line 203

Quoted 8 lines
drivers/target/tcm_fc/tfc_io.c +3 -0
+			se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+			break;
 		}
 	}
+queue_status:
 	return ft_queue_status(se_cmd);
 }
 

Thanks Vasu!

--nab

#4 lore raw

Re: [PATCH 1/2] tcm_fc: Generate TASK_SET_FULL status for DataIN failures

Quoted 6 lines · Nicholas A. Bellinger

The break aborts the DataIN send loop and invokes ft_queue_status() below in an attempt to send TASK_SET_FULL status.

If the ft_queue_status() -> lport->tt.seq_send() also fails, then -ENOMEM will be returned to the target and a delayed re-queue attempt will be made.

I see.

Quoted 1 line

In any event, updating the comment above to be more precise

I'm ok with leaving comment as is for now, just to avoid patch re-spin for this after above clarification. Thanks for detailed clarification

//Vasu

#5 lore raw

PATCH 2/2 tcm_fc: Generate TASK_SET_FULL status for response failures

In reply to Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

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.

---
 drivers/target/tcm_fc/tfc_cmd.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/target/tcm_fc/tfc_cmd.c +16 -3
index f5fd515..5585038 100644
@@ -128,6 +128,7 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	struct fc_lport *lport;
 	struct fc_exch *ep;
 	size_t len;
+	int rc;
 
 	if (cmd->aborted)
 		return 0;
@@ -137,9 +138,10 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	len = sizeof(*fcp) + se_cmd->scsi_sense_length;
 	fp = fc_frame_alloc(lport, len);
 	if (!fp) {
-		/* XXX shouldn't just drop it - requeue and retry? */
-		return 0;
+		se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+		return -ENOMEM;
 	}
+
 	fcp = fc_frame_payload_get(fp, len);
 	memset(fcp, 0, len);
 	fcp->resp.fr_status = se_cmd->scsi_status;
@@ -170,7 +172,18 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	fc_fill_fc_hdr(fp, FC_RCTL_DD_CMD_STATUS, ep->did, ep->sid, FC_TYPE_FCP,
 		       FC_FC_EX_CTX | FC_FC_LAST_SEQ | FC_FC_END_SEQ, 0);
 
-	lport->tt.seq_send(lport, cmd->seq, fp);
+	rc = lport->tt.seq_send(lport, cmd->seq, fp);
+	if (rc) {
+		pr_err_ratelimited("%s: Failed to send response frame %p, "
+				   "xid <0x%x>\n", __func__, fp, ep->xid);
+		/*
+		 * Generate a TASK_SET_FULL status to notify the initiator
+		 * to reduce it's queue_depth after the se_cmd response has
+		 * been re-queued by target-core.
+		 */
+		se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+		return -ENOMEM;
+	}
 	lport->tt.exch_done(cmd->seq);
 	return 0;
 }
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 1402011002-20771-3-git-send-email-nab-PEzghdH756F8UrSeD/[email protected]

Reviewed-by
#7 lore raw

Re: [PATCH 2/2] tcm_fc: Generate TASK_SET_FULL status for response failures

Quoted 44 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

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.

Cc Vasu Dev <vasu.dev-VuQAYsv1563Yd54FQh9/[email protected]>
Cc Jun Wu <jwu-kEM2MQtWpIJWk0Htik3J/[email protected]>
---
 drivers/target/tcm_fc/tfc_cmd.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/target/tcm_fc/tfc_cmd.c +4 -2
index f5fd515..5585038 100644
@@ -128,6 +128,7 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	struct fc_lport *lport;
 	struct fc_exch *ep;
 	size_t len;
+	int rc;
 
 	if (cmd->aborted)
 		return 0;
@@ -137,9 +138,10 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	len = sizeof(*fcp) + se_cmd->scsi_sense_length;
 	fp = fc_frame_alloc(lport, len);
 	if (!fp) {
-		/* XXX shouldn't just drop it - requeue and retry? */
-		return 0;
+		se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+		return -ENOMEM;
 	}
+
 	fcp = fc_frame_payload_get(fp, len);
 	memset(fcp, 0, len);
 	fcp->resp.fr_status = se_cmd->scsi_status;

drivers/target/tcm_fc/tfc_cmd.c int ft_queue_status(struct se_cmd *se_cmd) · line 178

Quoted 8 lines
drivers/target/tcm_fc/tfc_cmd.c +4 -1
@@ -170,7 +172,18 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	fc_fill_fc_hdr(fp, FC_RCTL_DD_CMD_STATUS, ep->did, ep->sid, FC_TYPE_FCP,
 		       FC_FC_EX_CTX | FC_FC_LAST_SEQ | FC_FC_END_SEQ, 0);
 
-	lport->tt.seq_send(lport, cmd->seq, fp);
+	rc = lport->tt.seq_send(lport, cmd->seq, fp);
+	if (rc) {
+		pr_err_ratelimited("%s: Failed to send response frame %p, "
+				   "xid <0x%x>\n", __func__, fp, ep->xid);

May be should be pr_info_ratelimited since this is not really error and IO could get aborted due to timeouts in any setups or stressed workloads.

drivers/target/tcm_fc/tfc_cmd.c int ft_queue_status(struct se_cmd *se_cmd) · line 189

Quoted 11 lines
drivers/target/tcm_fc/tfc_cmd.c +8 -0
+		/*
+		 * Generate a TASK_SET_FULL status to notify the initiator
+		 * to reduce it's queue_depth after the se_cmd response has
+		 * been re-queued by target-core.
+		 */
+		se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+		return -ENOMEM;
+	}
 	lport->tt.exch_done(cmd->seq);
 	return 0;
 }
#8 lore raw

Re: [PATCH 2/2] tcm_fc: Generate TASK_SET_FULL status for response failures

Quoted 48 lines · Vasu Dev
Quoted 47 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

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.

---
 drivers/target/tcm_fc/tfc_cmd.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/target/tcm_fc/tfc_cmd.c +4 -2
index f5fd515..5585038 100644
@@ -128,6 +128,7 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	struct fc_lport *lport;
 	struct fc_exch *ep;
 	size_t len;
+	int rc;
 
 	if (cmd->aborted)
 		return 0;
@@ -137,9 +138,10 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	len = sizeof(*fcp) + se_cmd->scsi_sense_length;
 	fp = fc_frame_alloc(lport, len);
 	if (!fp) {
-		/* XXX shouldn't just drop it - requeue and retry? */
-		return 0;
+		se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+		return -ENOMEM;
 	}
+
 	fcp = fc_frame_payload_get(fp, len);
 	memset(fcp, 0, len);
 	fcp->resp.fr_status = se_cmd->scsi_status;
@@ -170,7 +172,18 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	fc_fill_fc_hdr(fp, FC_RCTL_DD_CMD_STATUS, ep->did, ep->sid, FC_TYPE_FCP,
 		       FC_FC_EX_CTX | FC_FC_LAST_SEQ | FC_FC_END_SEQ, 0);
 
Quoted 9 lines

drivers/target/tcm_fc/tfc_cmd.c int ft_queue_status(struct se_cmd *se_cmd) · line 178

Quoted 5 lines
drivers/target/tcm_fc/tfc_cmd.c +4 -1
-	lport->tt.seq_send(lport, cmd->seq, fp);
+	rc = lport->tt.seq_send(lport, cmd->seq, fp);
+	if (rc) {
+		pr_err_ratelimited("%s: Failed to send response frame %p, "
+				   "xid <0x%x>\n", __func__, fp, ep->xid);

May be should be pr_info_ratelimited since this is not really error and IO could get aborted due to timeouts in any setups or stressed workloads.

<nod>, changing this to pr_info_ratelimited and doing the same in ft_queue_data_in() well.

Quoted 15 lines

drivers/target/tcm_fc/tfc_cmd.c int ft_queue_status(struct se_cmd *se_cmd) · line 189

Quoted 12 lines
drivers/target/tcm_fc/tfc_cmd.c +8 -0
+		/*
+		 * Generate a TASK_SET_FULL status to notify the initiator
+		 * to reduce it's queue_depth after the se_cmd response has
+		 * been re-queued by target-core.
+		 */
+		se_cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
+		return -ENOMEM;
+	}
 	lport->tt.exch_done(cmd->seq);
 	return 0;
 }

Thanks Vasu!

--nab

#9 lore raw

Re: [PATCH 2/2] tcm_fc: Generate TASK_SET_FULL status for response failures

Quoted 2 lines · Nicholas A. Bellinger

<nod>, changing this to pr_info_ratelimited and doing the same in ft_queue_data_in() well.

Since doing more places and therefore can be done in separate patch.

//Vasu

#10 lore raw
In reply to Nicholas A. Bellinger
Quoted 9 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

Hi Vasu,

This series generates SAM_STAT_TASK_SET_FULL status for lport->tt.seq_send() failures in DataIN + response status codepaths, which is done in order to get the initiator to reduce it's current queue_depth thus reducing the number of outstanding I/Os permitted in flight on the wire.

Quoted 8 lines

For the DataIN case, once a lport->tt.seq_send() failure occurs it will stop attempting to send subsequent DataIN payload data, and immediately attempt to send a response packet with SAM_STAT_TASK_SET_FULL status.

For the response case, once a lport->tt.seq_send() failure occurs it will set SAM_STAT_TASK_SET_FULL status and return -ENOMEM to the target, forcing the response to be requeued by target-core

Good change and it was missing in tcm_fc.

Quoted 1 line

Note this series has been compile tested only, so please review + test.

Just did review and basic test but should be stressed to really ensure it does work & fixes issues resulting these patches.

Thanks,
Vasu

Quoted 12 lines

Thank you,

--nab

Nicholas Bellinger (2):
tcm_fc: Generate TASK_SET_FULL status for DataIN failures
tcm_fc: Generate TASK_SET_FULL status for response failures

 drivers/target/tcm_fc/tfc_cmd.c |   19 ++++++++++++++++---
 drivers/target/tcm_fc/tfc_io.c  |   14 +++++++++++++-
 2 files changed, 29 insertions(+), 4 deletions(-)
#11 lore raw
Quoted 19 lines · Vasu Dev
Quoted 9 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

Hi Vasu,

This series generates SAM_STAT_TASK_SET_FULL status for lport->tt.seq_send() failures in DataIN + response status codepaths, which is done in order to get the initiator to reduce it's current queue_depth thus reducing the number of outstanding I/Os permitted in flight on the wire.

Quoted 8 lines

For the DataIN case, once a lport->tt.seq_send() failure occurs it will stop attempting to send subsequent DataIN payload data, and immediately attempt to send a response packet with SAM_STAT_TASK_SET_FULL status.

For the response case, once a lport->tt.seq_send() failure occurs it will set SAM_STAT_TASK_SET_FULL status and return -ENOMEM to the target, forcing the response to be requeued by target-core

Quoted 6 lines

Good change and it was missing in tcm_fc.

Quoted 1 line

Note this series has been compile tested only, so please review + test.

Just did review and basic test but should be stressed to really ensure it does work & fixes issues resulting these patches.

So if you don't mind I'll go ahead and queue these up for now in target-pending/for-next, given they are pretty straight-forward fixes.

If they end up being problematic, they can be dropped before the v3.16 PULL request goes out next week.

Jun can you please test both cases..? Eg: the first with an explicitly reduced fcoe initiator queue_depth setting mentioned earlier, and the second with these two patches to return TASK_SET_FULL when the sequence failures start occurring.

Thanks,

--nab

#12 lore raw
Quoted 6 lines · Nicholas A. Bellinger

So if you don't mind I'll go ahead and queue these up for now in target-pending/for-next, given they are pretty straight-forward fixes.

If they end up being problematic, they can be dropped before the v3.16 PULL request goes out next week.

All make sense, so go head with the push and I already added reviewed by to both patches.

//Vasu