From: Sagi Grimberg <sagig@mellanox.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: "Nicholas A. Bellinger" <nab@daterainc.com>,
target-devel <target-devel@vger.kernel.org>,
linux-scsi <linux-scsi@vger.kernel.org>,
Quinn Tran <quinn.tran@qlogic.com>,
Christoph Hellwig <hch@lst.de>,
Doug Gilbert <dgilbert@interlog.com>
Subject: Re: [PATCH-v2 02/15] target: Add protected fabric + unprotected device support
Date: Mon, 13 Apr 2015 13:11:36 +0300 [thread overview]
Message-ID: <552B9658.7030502@mellanox.com> (raw)
In-Reply-To: <1428692341.20502.17.camel@haakon3.risingtidesystems.com>
On 4/10/2015 9:59 PM, Nicholas A. Bellinger wrote:
> On Thu, 2015-04-09 at 17:45 -0400, Martin K. Petersen wrote:
>>>>>>> "nab" == Nicholas A Bellinger <nab@linux-iscsi.org> writes:
>>
>>>> How do you handle RDPROTECT/WRPROTECT values of 3 if the PI is not
>>>> persistent?
>>
>> nab> AFAICT, this would result in cmd->prot_op = TARGET_PROT_*_PASS and
>> cmd-> prot_checks = 0 for RDPROTECT/WRPROTECT == 0x3 in
>> nab> sbc_set_prot_op_checks() code.
>>
>> nab> Do DOUT_STRIP + DIN_INSERT need to be called if a protection buffer
>> nab> is present when RDPROTECT/WRPROTECT == 0x3 if fabric_prot was
>> nab> cleared..? Or should the command be rejected when a protection
>> nab> buffer is present + RDPROTECT/WRPROTECT is non-zero if fabric_prot
>> nab> was cleared..?
>>
>> Depends how compliant you want to be.
>>
>> You can synthesize PI with RDPROTECT/WRPROTECT=1 as long as the
>> initiator doesn't rely on app tag escapes (we don't). Most non-HDD/SSD
>> targets work this way.
>>
>
> <nod>
>
>> I would suggest that you return invalid field in CDB for
>> RDPROTECT/WRPROTECT=3 unless the PI can be made persistent, however.
>>
>
> Ok, after thinking about this some more, here's what I've come up with..
>
> The following incremental patch saves the current sess_prot_type into
> se_node_acl, and will always reset sess_prot_type if a previous saved
> value exists. So the PI setting for the fabric's session with backend
> devices not supporting PI is persistent across session restart.
>
> I also noticed the internal DIF emulation was not honoring
> se_cmd->prot_checks for the WRPROTECT/RDPROTECT == 0x3 case, so
> sbc_dif_v1_verify() has been updated to follow which checks have been
> calculated based on WRPROTECT/RDPROTECT in sbc_set_prot_op_checks().
>
> Finally in sbc_check_prot(), if PROTECT is non-zero for a backend device
> with DIF disabled, and sess_prot_type is not set go ahead and return
> INVALID_CDB_FIELD.
>
> WDYT..?
>
> --nab
>
> diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
> index 315ff64..a75512f 100644
> --- a/drivers/target/target_core_sbc.c
> +++ b/drivers/target/target_core_sbc.c
> @@ -697,9 +697,13 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb,
> pi_prot_type = cmd->se_sess->sess_prot_type;
> break;
> }
> + if (!protect)
> + return TCM_NO_SENSE;
> /* Fallthrough */
> default:
> - return TCM_NO_SENSE;
> + pr_err("Unable to determine pi_prot_type for CDB: 0x%02x "
> + "PROTECT: 0x%02x\n", cdb[0], protect);
> + return TCM_INVALID_CDB_FIELD;
> }
>
> if (sbc_set_prot_op_checks(protect, fabric_prot, pi_prot_type, is_write, cmd))
> @@ -1221,6 +1227,9 @@ sbc_dif_v1_verify(struct se_cmd *cmd, struct se_dif_v1_tuple *sdt,
> int block_size = dev->dev_attrib.block_size;
> __be16 csum;
>
> + if (!(cmd->prot_checks & TARGET_DIF_CHECK_GUARD))
> + goto check_ref;
> +
> csum = cpu_to_be16(crc_t10dif(p, block_size));
>
> if (sdt->guard_tag != csum) {
> @@ -1230,6 +1239,10 @@ sbc_dif_v1_verify(struct se_cmd *cmd, struct se_dif_v1_tuple *sdt,
> return TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED;
> }
>
> +check_ref:
> + if (!(cmd->prot_checks & TARGET_DIF_CHECK_REFTAG))
> + return 0;
> +
> if (cmd->prot_type == TARGET_DIF_TYPE1_PROT &&
> be32_to_cpu(sdt->ref_tag) != (sector & 0xffffffff)) {
> pr_err("DIFv1 Type 1 reference failed on sector: %llu tag: 0x%08x"
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index f884198..3ff38b2 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -329,11 +329,17 @@ void __transport_register_session(
> se_sess->fabric_sess_ptr = fabric_sess_ptr;
> /*
> * Determine if fabric allows for T10-PI feature bits to be exposed
> - * to initiators for device backends with !dev->dev_attrib.pi_prot_type
> + * to initiators for device backends with !dev->dev_attrib.pi_prot_type.
> + *
> + * If so, then always save prot_type on a per se_node_acl node basis
> + * and re-instate the previous sess_prot_type to avoid disabling PI
> + * from below any previously initiator side registered LUNs.
> */
> - if (tfo->tpg_check_prot_fabric_only)
> - se_sess->sess_prot_type = tfo->tpg_check_prot_fabric_only(se_tpg);
> -
> + if (se_nacl->saved_prot_type)
> + se_sess->sess_prot_type = se_nacl->saved_prot_type;
> + else if (tfo->tpg_check_prot_fabric_only)
> + se_sess->sess_prot_type = se_nacl->saved_prot_type =
> + tfo->tpg_check_prot_fabric_only(se_tpg);
> /*
> * Used by struct se_node_acl's under ConfigFS to locate active se_session-t
> *
> diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
> index 383110d..51dcf2b 100644
> --- a/include/target/target_core_base.h
> +++ b/include/target/target_core_base.h
> @@ -590,6 +590,7 @@ struct se_node_acl {
> bool acl_stop:1;
> u32 queue_depth;
> u32 acl_index;
> + enum target_prot_type saved_prot_type;
> #define MAX_ACL_TAG_SIZE 64
> char acl_tag[MAX_ACL_TAG_SIZE];
> /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */
>
>
>
This looks fine to me.
Acked-by: Sagi Grimberg <sagig@mellanox.com>
next prev parent reply other threads:[~2015-04-13 10:11 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 3:28 [PATCH-v2 00/15] target: Add WRITE_STRIP + READ_INSERT support Nicholas A. Bellinger
2015-03-30 3:28 ` [PATCH-v2 01/15] target: Convert DIF emulation to use cmd->prot_type Nicholas A. Bellinger
2015-03-30 7:38 ` Sagi Grimberg
2015-04-07 23:22 ` Martin K. Petersen
2015-03-30 3:28 ` [PATCH-v2 02/15] target: Add protected fabric + unprotected device support Nicholas A. Bellinger
2015-03-30 7:51 ` Sagi Grimberg
2015-04-01 5:49 ` Nicholas A. Bellinger
2015-04-01 9:04 ` Sagi Grimberg
2015-04-02 4:40 ` Nicholas A. Bellinger
2015-04-07 23:27 ` Martin K. Petersen
2015-04-08 7:40 ` Nicholas A. Bellinger
2015-04-09 21:45 ` Martin K. Petersen
2015-04-10 18:59 ` Nicholas A. Bellinger
2015-04-13 10:11 ` Sagi Grimberg [this message]
2015-04-14 1:15 ` Martin K. Petersen
2015-03-30 3:28 ` [PATCH-v2 03/15] target: Update SPC/SBC emulation for sess_prot_type Nicholas A. Bellinger
2015-03-30 7:53 ` Sagi Grimberg
2015-04-07 23:28 ` Martin K. Petersen
2015-03-30 3:28 ` [PATCH-v2 04/15] target: Move cmd->prot_op check into target_check_write_prot Nicholas A. Bellinger
2015-03-30 7:57 ` Sagi Grimberg
2015-04-01 5:54 ` Nicholas A. Bellinger
2015-04-07 23:30 ` Martin K. Petersen
2015-03-30 3:28 ` [PATCH-v2 05/15] target: Add internal WRITE_STRIP support Nicholas A. Bellinger
2015-03-30 8:01 ` Sagi Grimberg
2015-04-01 5:59 ` Nicholas A. Bellinger
2015-04-07 23:32 ` Martin K. Petersen
2015-03-30 3:28 ` [PATCH-v2 06/15] target: Move cmd->prot_op check into target_check_read_prot Nicholas A. Bellinger
2015-03-30 8:02 ` Sagi Grimberg
2015-04-01 6:03 ` Nicholas A. Bellinger
2015-04-07 23:33 ` Martin K. Petersen
2015-03-30 3:28 ` [PATCH-v2 07/15] target: Add internal READ_INSERT support Nicholas A. Bellinger
2015-04-07 23:34 ` Martin K. Petersen
2015-03-30 3:28 ` [PATCH-v2 08/15] target/file: Add checks for backend DIF emulation Nicholas A. Bellinger
2015-03-30 8:05 ` Sagi Grimberg
2015-03-30 3:28 ` [PATCH-v2 09/15] target/iblock: " Nicholas A. Bellinger
2015-03-30 3:28 ` [PATCH-v2 10/15] target/rd: " Nicholas A. Bellinger
2015-03-30 3:28 ` [PATCH-v2 11/15] loopback: Add fabric_prot_type attribute support Nicholas A. Bellinger
2015-03-30 8:07 ` Sagi Grimberg
2015-04-01 6:22 ` Nicholas A. Bellinger
2015-03-30 3:28 ` [PATCH-v2 12/15] vhost/scsi: " Nicholas A. Bellinger
2015-03-30 3:28 ` [PATCH-v2 13/15] tcm_qla2xxx: Set TARGET_PROT_ALL for sup_prot_ops Nicholas A. Bellinger
2015-03-30 3:28 ` [PATCH-v2 14/15] tcm_qla2xxx: Add fabric_prot_type attribute support Nicholas A. Bellinger
2015-03-30 3:28 ` [PATCH-v2 15/15] iscsi/iser-target: " Nicholas A. Bellinger
2015-03-30 8:11 ` Sagi Grimberg
2015-04-01 6:27 ` Nicholas A. Bellinger
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=552B9658.7030502@mellanox.com \
--to=sagig@mellanox.com \
--cc=dgilbert@interlog.com \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=nab@daterainc.com \
--cc=nab@linux-iscsi.org \
--cc=quinn.tran@qlogic.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.