diff mbox

[PATCH-v2,06/15] target: Move cmd->prot_op check into target_check_read_prot

Message ID 1427686104-14231-7-git-send-email-nab@daterainc.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nicholas A. Bellinger March 30, 2015, 3:28 a.m. UTC
From: Nicholas Bellinger <nab@linux-iscsi.org>

This patch moves the existing target_complete_ok_work() check for
cmd->prot_op into it's own function, so it's easier to add future
support for READ INSERT.

Cc: Martin Petersen <martin.petersen@oracle.com>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
---
 drivers/target/target_core_transport.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

Comments

Sagi Grimberg March 30, 2015, 8:02 a.m. UTC | #1
On 3/30/2015 6:28 AM, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
>
> This patch moves the existing target_complete_ok_work() check for
> cmd->prot_op into it's own function, so it's easier to add future
> support for READ INSERT.
>
> Cc: Martin Petersen <martin.petersen@oracle.com>
> Cc: Sagi Grimberg <sagig@mellanox.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
>   drivers/target/target_core_transport.c | 21 +++++++++++++--------
>   1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index 51b62bd..e603e34 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -1980,16 +1980,22 @@ static void transport_handle_queue_full(
>   	schedule_work(&cmd->se_dev->qf_work_queue);
>   }
>
> -static bool target_check_read_strip(struct se_cmd *cmd)
> +static bool target_check_read_prot(struct se_cmd *cmd)

Same comment on naming.

>   {
>   	sense_reason_t rc;
>
> -	if (!(cmd->se_sess->sup_prot_ops & TARGET_PROT_DIN_STRIP)) {
> -		rc = sbc_dif_read_strip(cmd);
> -		if (rc) {
> -			cmd->pi_err = rc;
> -			return true;
> +	switch (cmd->prot_op) {
> +	case TARGET_PROT_DIN_STRIP:
> +		if (!(cmd->se_sess->sup_prot_ops & TARGET_PROT_DIN_STRIP)) {
> +			rc = sbc_dif_read_strip(cmd);
> +			if (rc) {
> +				cmd->pi_err = rc;
> +				return true;
> +			}
>   		}
> +		break;
> +	default:
> +		break;
>   	}
>
>   	return false;
> @@ -2064,8 +2070,7 @@ static void target_complete_ok_work(struct work_struct *work)
>   		 * backend had PI enabled, if the transport will not be
>   		 * performing hardware READ_STRIP offload.
>   		 */
> -		if (cmd->prot_op == TARGET_PROT_DIN_STRIP &&
> -		    target_check_read_strip(cmd)) {
> +		if (target_check_read_prot(cmd)) {
>   			ret = transport_send_check_condition_and_sense(cmd,
>   						cmd->pi_err, 0);
>   			if (ret == -EAGAIN || ret == -ENOMEM)
>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicholas A. Bellinger April 1, 2015, 6:03 a.m. UTC | #2
On Mon, 2015-03-30 at 11:02 +0300, Sagi Grimberg wrote:
> On 3/30/2015 6:28 AM, Nicholas A. Bellinger wrote:
> > From: Nicholas Bellinger <nab@linux-iscsi.org>
> >
> > This patch moves the existing target_complete_ok_work() check for
> > cmd->prot_op into it's own function, so it's easier to add future
> > support for READ INSERT.
> >
> > Cc: Martin Petersen <martin.petersen@oracle.com>
> > Cc: Sagi Grimberg <sagig@mellanox.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> > ---
> >   drivers/target/target_core_transport.c | 21 +++++++++++++--------
> >   1 file changed, 13 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> > index 51b62bd..e603e34 100644
> > --- a/drivers/target/target_core_transport.c
> > +++ b/drivers/target/target_core_transport.c
> > @@ -1980,16 +1980,22 @@ static void transport_handle_queue_full(
> >   	schedule_work(&cmd->se_dev->qf_work_queue);
> >   }
> >
> > -static bool target_check_read_strip(struct se_cmd *cmd)
> > +static bool target_check_read_prot(struct se_cmd *cmd)
> 
> Same comment on naming.

Fixed.

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin K. Petersen April 7, 2015, 11:33 p.m. UTC | #3
>>>>> "nab" == Nicholas A Bellinger <nab@daterainc.com> writes:

nab> This patch moves the existing target_complete_ok_work() check for
nab> cmd-> prot_op into it's own function, so it's easier to add future
nab> support for READ INSERT.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
diff mbox

Patch

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 51b62bd..e603e34 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1980,16 +1980,22 @@  static void transport_handle_queue_full(
 	schedule_work(&cmd->se_dev->qf_work_queue);
 }
 
-static bool target_check_read_strip(struct se_cmd *cmd)
+static bool target_check_read_prot(struct se_cmd *cmd)
 {
 	sense_reason_t rc;
 
-	if (!(cmd->se_sess->sup_prot_ops & TARGET_PROT_DIN_STRIP)) {
-		rc = sbc_dif_read_strip(cmd);
-		if (rc) {
-			cmd->pi_err = rc;
-			return true;
+	switch (cmd->prot_op) {
+	case TARGET_PROT_DIN_STRIP:
+		if (!(cmd->se_sess->sup_prot_ops & TARGET_PROT_DIN_STRIP)) {
+			rc = sbc_dif_read_strip(cmd);
+			if (rc) {
+				cmd->pi_err = rc;
+				return true;
+			}
 		}
+		break;
+	default:
+		break;
 	}
 
 	return false;
@@ -2064,8 +2070,7 @@  static void target_complete_ok_work(struct work_struct *work)
 		 * backend had PI enabled, if the transport will not be
 		 * performing hardware READ_STRIP offload.
 		 */
-		if (cmd->prot_op == TARGET_PROT_DIN_STRIP &&
-		    target_check_read_strip(cmd)) {
+		if (target_check_read_prot(cmd)) {
 			ret = transport_send_check_condition_and_sense(cmd,
 						cmd->pi_err, 0);
 			if (ret == -EAGAIN || ret == -ENOMEM)