From: Sagi Grimberg <sagig@mellanox.com>
To: "Nicholas A. Bellinger" <nab@daterainc.com>,
target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>, Hannes Reinecke <hare@suse.de>,
Or Gerlitz <ogerlitz@mellanox.com>,
Nicholas Bellinger <nab@linux-iscsi.org>,
oren Duer <oren@mellanox.com>
Subject: Re: [PATCH 03/14] target/sbc: Add sbc_check_prot + update sbc_parse_cdb for DIF
Date: Thu, 9 Jan 2014 16:58:09 +0200 [thread overview]
Message-ID: <52CEB901.6030504@mellanox.com> (raw)
In-Reply-To: <1389212157-14540-4-git-send-email-nab@daterainc.com>
On 1/8/2014 10:36 PM, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
>
> This patch adds sbc_check_prot() for performing various DIF
> related CDB sanity checks, along with setting SCF_PROT once
> sanity checks have passed.
>
> Also, add calls in sbc_parse_cdb() for READ_[10,12,16] +
> WRITE_[10,12,16] to perform DIF sanity checking.
>
> Cc: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: Sagi Grimberg <sagig@mellanox.com>
> Cc: Or Gerlitz <ogerlitz@mellanox.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
> drivers/target/target_core_sbc.c | 39 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
> index 52ae54e..600ffcb 100644
> --- a/drivers/target/target_core_sbc.c
> +++ b/drivers/target/target_core_sbc.c
> @@ -563,6 +563,27 @@ sbc_compare_and_write(struct se_cmd *cmd)
> return TCM_NO_SENSE;
> }
>
> +bool
> +sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb)
> +{
> + if (!dev->dev_attrib.pi_prot_type)
> + return true;
> +
> + if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE2_PROT &&
> + (cdb[1] & 0xe0))
> + return false;
> +
> + if (!(cdb[1] & 0xe0)) {
> + pr_warn("Target: Unprotected READ/WRITE to DIF device\n");
> + return true;
> + }
> + if (!cmd->t_prot_sg || !cmd->t_prot_nents)
> + return true;
> +
> + cmd->se_cmd_flags |= SCF_PROT;
Isn't this the place to fill the se_cmd DIF execution parameters?
prot_op, prot_type, guard_type, initial_reftag, apptag etc...
Next, all parties interested in DIF execution should look in se_cmd
(backstore, transport).
> + return true;
> +}
> +
> sense_reason_t
> sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
> {
> @@ -581,6 +602,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
> cmd->execute_cmd = sbc_execute_rw;
> break;
> case READ_10:
> + if (!sbc_check_prot(dev, cmd, cdb))
> + return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
> sectors = transport_get_sectors_10(cdb);
> cmd->t_task_lba = transport_lba_32(cdb);
> cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
> @@ -588,6 +612,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
> cmd->execute_cmd = sbc_execute_rw;
> break;
> case READ_12:
> + if (!sbc_check_prot(dev, cmd, cdb))
> + return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
> sectors = transport_get_sectors_12(cdb);
> cmd->t_task_lba = transport_lba_32(cdb);
> cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
> @@ -595,6 +622,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
> cmd->execute_cmd = sbc_execute_rw;
> break;
> case READ_16:
> + if (!sbc_check_prot(dev, cmd, cdb))
> + return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
> sectors = transport_get_sectors_16(cdb);
> cmd->t_task_lba = transport_lba_64(cdb);
> cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
> @@ -610,6 +640,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
> break;
> case WRITE_10:
> case WRITE_VERIFY:
> + if (!sbc_check_prot(dev, cmd, cdb))
> + return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
> sectors = transport_get_sectors_10(cdb);
> cmd->t_task_lba = transport_lba_32(cdb);
> if (cdb[1] & 0x8)
> @@ -619,6 +652,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
> cmd->execute_cmd = sbc_execute_rw;
> break;
> case WRITE_12:
> + if (!sbc_check_prot(dev, cmd, cdb))
> + return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
> sectors = transport_get_sectors_12(cdb);
> cmd->t_task_lba = transport_lba_32(cdb);
> if (cdb[1] & 0x8)
> @@ -628,6 +664,9 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
> cmd->execute_cmd = sbc_execute_rw;
> break;
> case WRITE_16:
> + if (!sbc_check_prot(dev, cmd, cdb))
> + return TCM_UNSUPPORTED_SCSI_OPCODE;
> +
> sectors = transport_get_sectors_16(cdb);
> cmd->t_task_lba = transport_lba_64(cdb);
> if (cdb[1] & 0x8)
next prev parent reply other threads:[~2014-01-09 14:58 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-08 20:15 [PATCH 00/14] target: Initial support for DIF Type1+Type3 emulation Nicholas A. Bellinger
2014-01-08 20:15 ` [PATCH 01/14] target: Add DIF related base definitions Nicholas A. Bellinger
2014-01-09 10:58 ` Sagi Grimberg
2014-01-08 20:15 ` [PATCH 02/14] target: Add DIF CHECK_CONDITION ASC/ASCQ exception cases Nicholas A. Bellinger
2014-01-09 10:43 ` Sagi Grimberg
2014-01-10 6:53 ` Nicholas A. Bellinger
2014-01-14 7:44 ` Sagi Grimberg
2014-01-14 8:53 ` Nicholas A. Bellinger
2014-01-14 10:56 ` Sagi Grimberg
2014-01-08 20:15 ` [PATCH 03/14] target/sbc: Add sbc_check_prot + update sbc_parse_cdb for DIF Nicholas A. Bellinger
2014-01-09 14:58 ` Sagi Grimberg [this message]
2014-01-10 7:04 ` Nicholas A. Bellinger
2014-01-12 11:59 ` Sagi Grimberg
2014-01-13 19:23 ` Nicholas A. Bellinger
2014-01-10 20:30 ` Martin K. Petersen
2014-01-08 20:15 ` [PATCH 04/14] target/sbc: Add DIF TYPE1+TYPE3 read/write verify emulation Nicholas A. Bellinger
2014-01-08 20:15 ` [PATCH 05/14] target/spc: Add protection bit to standard INQUIRY output Nicholas A. Bellinger
2014-01-10 20:34 ` Martin K. Petersen
2014-01-08 20:15 ` [PATCH 06/14] target/spc: Add protection related bits to INQUIRY EVPD=0x86 Nicholas A. Bellinger
2014-01-10 20:35 ` Martin K. Petersen
2014-01-08 20:15 ` [PATCH 07/14] target/sbc: Add P_TYPE + PROT_EN bits to READ_CAPACITY_16 Nicholas A. Bellinger
2014-01-09 10:24 ` Sagi Grimberg
2014-01-10 6:21 ` Nicholas A. Bellinger
2014-01-10 19:50 ` Andy Grover
2014-01-10 20:15 ` Nicholas A. Bellinger
2014-01-10 20:46 ` Martin K. Petersen
2014-01-12 11:49 ` Sagi Grimberg
2014-01-10 20:40 ` Martin K. Petersen
2014-01-10 20:39 ` Martin K. Petersen
2014-01-12 12:13 ` Sagi Grimberg
2014-01-12 12:33 ` Martin K. Petersen
2014-01-12 12:47 ` Sagi Grimberg
2014-01-12 12:53 ` Martin K. Petersen
2014-01-12 16:37 ` Douglas Gilbert
2014-01-12 17:21 ` Martin K. Petersen
2014-01-12 18:53 ` Douglas Gilbert
2014-01-13 16:33 ` Sagi Grimberg
2014-01-12 12:13 ` Sagi Grimberg
2014-01-10 20:37 ` Martin K. Petersen
2014-01-08 20:15 ` [PATCH 08/14] target/spc: Expose ATO bit in control mode page Nicholas A. Bellinger
2014-01-10 20:57 ` Martin K. Petersen
2014-01-08 20:15 ` [PATCH 09/14] target/configfs: Expose protection device attributes Nicholas A. Bellinger
2014-01-09 11:01 ` Sagi Grimberg
2014-01-10 7:00 ` Nicholas A. Bellinger
2014-01-12 11:56 ` Sagi Grimberg
2014-01-10 21:01 ` Martin K. Petersen
2014-01-12 12:18 ` Sagi Grimberg
2014-01-12 12:43 ` Martin K. Petersen
2014-01-12 12:52 ` Sagi Grimberg
2014-01-13 18:30 ` Nicholas A. Bellinger
2014-01-13 18:52 ` James Bottomley
2014-01-13 19:27 ` Nicholas A. Bellinger
2014-01-13 19:43 ` James Bottomley
2014-01-13 20:19 ` Martin K. Petersen
2014-01-13 20:24 ` James Bottomley
2014-01-13 20:30 ` Martin K. Petersen
2014-01-08 20:15 ` [PATCH 10/14] target: Add protection SGLs to target_submit_cmd_map_sgls Nicholas A. Bellinger
2014-01-08 20:15 ` [PATCH 11/14] target/rd: Refactor rd_build_device_space + rd_release_device_space Nicholas A. Bellinger
2014-01-08 20:15 ` [PATCH 12/14] target/rd: Add support for protection SGL setup + release Nicholas A. Bellinger
2014-01-08 20:15 ` [PATCH 13/14] target/rd: Add DIF protection into rd_execute_rw Nicholas A. Bellinger
2014-01-09 10:32 ` Sagi Grimberg
2014-01-10 6:52 ` Nicholas A. Bellinger
2014-01-12 11:53 ` Sagi Grimberg
2014-01-13 19:22 ` Nicholas A. Bellinger
2014-01-10 21:06 ` Martin K. Petersen
2014-01-12 12:23 ` Sagi Grimberg
2014-01-08 20:15 ` [PATCH 14/14] tcm_loop: Enable DIF/DIX modes in SCSI host LLD Nicholas A. Bellinger
2014-01-10 21:09 ` Martin K. Petersen
2014-01-13 18:45 ` Nicholas A. Bellinger
2014-01-13 20:08 ` Martin K. Petersen
2014-01-10 2:00 ` [PATCH 00/14] target: Initial support for DIF Type1+Type3 emulation Martin K. Petersen
2014-01-10 5:57 ` Nicholas A. Bellinger
2014-01-15 18:03 ` sagi grimberg
2014-01-15 21:55 ` Nicholas A. Bellinger
2014-01-16 1:42 ` Martin K. Petersen
2014-01-16 2:32 ` Nicholas A. Bellinger
2014-01-16 3:04 ` Martin K. Petersen
2014-01-16 7:45 ` sagi grimberg
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=52CEB901.6030504@mellanox.com \
--to=sagig@mellanox.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=nab@daterainc.com \
--cc=nab@linux-iscsi.org \
--cc=ogerlitz@mellanox.com \
--cc=oren@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
Powered by JetHome