public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagig@dev.mellanox.co.il>
To: Akinobu Mita <akinobu.mita@gmail.com>, target-devel@vger.kernel.org
Cc: Nicholas Bellinger <nab@linux-iscsi.org>,
	Sagi Grimberg <sagig@mellanox.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Christoph Hellwig <hch@lst.de>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 5/5] target/file: enable WRITE SAME when protection info is enabled
Date: Sun, 26 Apr 2015 12:58:23 +0300	[thread overview]
Message-ID: <553CB6BF.8090601@dev.mellanox.co.il> (raw)
In-Reply-To: <1429972410-7146-6-git-send-email-akinobu.mita@gmail.com>

On 4/25/2015 5:33 PM, Akinobu Mita wrote:
> Now we can generate correct PI for WRITE SAME command, so it is
> unnecessary to disallow WRITE SAME when protection info is enabled.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Nicholas Bellinger <nab@linux-iscsi.org>
> Cc: Sagi Grimberg <sagig@mellanox.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: target-devel@vger.kernel.org
> Cc: linux-scsi@vger.kernel.org
> ---
> * No change from v2
>
>   drivers/target/target_core_file.c | 18 +++++++++++++-----
>   1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
> index 829817a..fe98f58 100644
> --- a/drivers/target/target_core_file.c
> +++ b/drivers/target/target_core_file.c
> @@ -376,16 +376,12 @@ fd_execute_write_same(struct se_cmd *cmd)
>   	struct bio_vec *bvec;
>   	unsigned int len = 0, i;
>   	ssize_t ret;
> +	sense_reason_t rc;
>
>   	if (!nolb) {
>   		target_complete_cmd(cmd, SAM_STAT_GOOD);
>   		return 0;
>   	}
> -	if (cmd->prot_op) {
> -		pr_err("WRITE_SAME: Protection information with FILEIO"
> -		       " backends not supported\n");
> -		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
> -	}
>
>   	if (cmd->t_data_nents > 1 ||
>   	    cmd->t_data_sg[0].length != cmd->se_dev->dev_attrib.block_size) {
> @@ -397,6 +393,10 @@ fd_execute_write_same(struct se_cmd *cmd)
>   		return TCM_INVALID_CDB_FIELD;
>   	}
>
> +	rc = sbc_dif_verify(cmd, cmd->t_task_lba, nolb, 0, cmd->t_prot_sg, 0);
> +	if (rc)
> +		return rc;
> +
>   	bvec = kcalloc(nolb, sizeof(struct bio_vec), GFP_KERNEL);
>   	if (!bvec)
>   		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
> @@ -418,6 +418,14 @@ fd_execute_write_same(struct se_cmd *cmd)
>   		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
>   	}
>
> +	if (cmd->prot_op) {
> +		ret = fd_do_rw(cmd, fd_dev->fd_prot_file, se_dev->prot_length,
> +				cmd->t_prot_sg, cmd->t_prot_nents,
> +				cmd->prot_length, 1);
> +		if (ret < 0)
> +			return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
> +	}
> +
>   	target_complete_cmd(cmd, SAM_STAT_GOOD);
>   	return 0;
>   }
>

This looks good,

iblock is needed too though. I think you just need a missing call to
iblock_alloc_bip() and you're good to go (you can use scsi_debug with
dif/dix to test it). I think it belongs in the same patch.

Sagi.

  reply	other threads:[~2015-04-26  9:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1429972410-7146-1-git-send-email-akinobu.mita@gmail.com>
2015-04-25 14:33 ` [PATCH v3 1/5] target: ensure se_cmd->t_prot_sg is allocated when required Akinobu Mita
2015-04-26  9:26   ` Sagi Grimberg
2015-04-26  9:44     ` Sagi Grimberg
2015-04-27 12:57       ` Akinobu Mita
2015-04-27 15:08         ` Sagi Grimberg
2015-04-25 14:33 ` [PATCH v3 3/5] target: handle odd SG mapping for data transfer memory Akinobu Mita
2015-04-26 10:07   ` Sagi Grimberg
2015-04-27 13:03     ` Akinobu Mita
2015-04-25 14:33 ` [PATCH v3 4/5] target: Fix sbc_dif_generate() and sbc_dif_verify() for WRITE SAME Akinobu Mita
2015-04-26  9:53   ` Sagi Grimberg
2015-04-27 12:58     ` Akinobu Mita
2015-04-25 14:33 ` [PATCH v3 5/5] target/file: enable WRITE SAME when protection info is enabled Akinobu Mita
2015-04-26  9:58   ` Sagi Grimberg [this message]
2015-04-27 13:02     ` Akinobu Mita

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=553CB6BF.8090601@dev.mellanox.co.il \
    --to=sagig@dev.mellanox.co.il \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akinobu.mita@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nab@linux-iscsi.org \
    --cc=sagig@mellanox.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox