All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagi Grimberg <sagig@dev.mellanox.co.il>
To: "Nicholas A. Bellinger" <nab@daterainc.com>,
	target-devel <target-devel@vger.kernel.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Sagi Grimberg <sagig@mellanox.com>,
	Quinn Tran <quinn.tran@qlogic.com>,
	Nicholas Bellinger <nab@linux-iscsi.org>,
	Christoph Hellwig <hch@lst.de>,
	Doug Gilbert <dgilbert@interlog.com>
Subject: Re: [PATCH-v2 03/15] target: Update SPC/SBC emulation for sess_prot_type
Date: Mon, 30 Mar 2015 10:53:24 +0300	[thread overview]
Message-ID: <551900F4.2040203@dev.mellanox.co.il> (raw)
In-Reply-To: <1427686104-14231-4-git-send-email-nab@daterainc.com>

On 3/30/2015 6:28 AM, Nicholas A. Bellinger wrote:
> From: Nicholas Bellinger <nab@linux-iscsi.org>
>
> This patch updates standard INQUIRY, INQUIRY EVPD=0x86, READ_CAPACITY_16
> and control mode pages to use se_sess->sess_prot_type when determing which
> type of T10-PI related feature bits can be exposed.
>
> This is required for fabric sessions supporting T10-PI metadata to
> backend devices that don't have protection enabled.
>
> Cc: Martin Petersen <martin.petersen@oracle.com>
> Cc: Sagi Grimberg <sagig@mellanox.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Doug Gilbert <dgilbert@interlog.com>
> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
> ---
>   drivers/target/target_core_sbc.c | 13 +++++++++++--
>   drivers/target/target_core_spc.c | 14 +++++++++-----
>   2 files changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
> index 5b3564a..68373c9 100644
> --- a/drivers/target/target_core_sbc.c
> +++ b/drivers/target/target_core_sbc.c
> @@ -93,6 +93,8 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd)
>   {
>   	struct se_device *dev = cmd->se_dev;
>   	struct se_session *sess = cmd->se_sess;
> +	int pi_prot_type = dev->dev_attrib.pi_prot_type;
> +
>   	unsigned char *rbuf;
>   	unsigned char buf[32];
>   	unsigned long long blocks = dev->transport->get_blocks(dev);
> @@ -114,8 +116,15 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd)
>   	 * Set P_TYPE and PROT_EN bits for DIF support
>   	 */
>   	if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
> -		if (dev->dev_attrib.pi_prot_type)
> -			buf[12] = (dev->dev_attrib.pi_prot_type - 1) << 1 | 0x1;
> +		/*
> +		 * Only override a device's pi_prot_type if no T10-PI is
> +		 * available, and sess_prot_type has been explicitly enabled.
> +		 */
> +		if (!pi_prot_type)
> +			pi_prot_type = sess->sess_prot_type;
> +
> +		if (pi_prot_type)
> +			buf[12] = (pi_prot_type - 1) << 1 | 0x1;
>   	}
>
>   	if (dev->transport->get_lbppbe)
> diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
> index f310aac..9ec6459 100644
> --- a/drivers/target/target_core_spc.c
> +++ b/drivers/target/target_core_spc.c
> @@ -103,10 +103,12 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
>   		buf[5] |= 0x8;
>   	/*
>   	 * Set Protection (PROTECT) bit when DIF has been enabled on the
> -	 * device, and the transport supports VERIFY + PASS.
> +	 * device, and the fabric supports VERIFY + PASS.  Also report
> +	 * PROTECT=1 if sess_prot_type has been configured to allow T10-PI
> +	 * to unprotected devices.
>   	 */
>   	if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
> -		if (dev->dev_attrib.pi_prot_type)
> +		if (dev->dev_attrib.pi_prot_type || cmd->se_sess->sess_prot_type)
>   			buf[5] |= 0x1;
>   	}
>
> @@ -480,9 +482,11 @@ spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
>   	 * only for TYPE3 protection.
>   	 */
>   	if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
> -		if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT)
> +		if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE1_PROT ||
> +		    cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE1_PROT)
>   			buf[4] = 0x5;
> -		else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT)
> +		else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT ||
> +			cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE3_PROT)
>   			buf[4] = 0x4;
>   	}
>
> @@ -874,7 +878,7 @@ static int spc_modesense_control(struct se_cmd *cmd, u8 pc, u8 *p)
>   	 * TAG field.
>   	 */
>   	if (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) {
> -		if (dev->dev_attrib.pi_prot_type)
> +		if (dev->dev_attrib.pi_prot_type || sess->sess_prot_type)
>   			p[5] |= 0x80;
>   	}
>
>

Reviewed-by: Sagi Grimberg <sagig@mellanox.com>

  reply	other threads:[~2015-03-30  7:53 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
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 [this message]
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=551900F4.2040203@dev.mellanox.co.il \
    --to=sagig@dev.mellanox.co.il \
    --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=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 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.