From: Boaz Harrosh <bharrosh@panasas.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: James.Bottomley@hansenpartnership.com, dgilbert@interlog.com,
Ihab.Hamadi@emulex.com, James.Smart@emulex.com,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 4/5] sd: Support disks formatted with DIF Type 2
Date: Wed, 26 Aug 2009 15:26:27 +0300 [thread overview]
Message-ID: <4A9529F3.9070504@panasas.com> (raw)
In-Reply-To: <1251267481-24135-5-git-send-email-martin.petersen@oracle.com>
On 08/26/2009 09:18 AM, Martin K. Petersen wrote:
> Disks formatted with DIF Type 2 reject READ/WRITE 6/10/12/16 commands
> when protection is enabled. Only the 32-byte variants are supported.
>
> Implement support for issusing 32-byte READ/WRITE and enable support for
> Type 2 drives in the protection type detection logic.
>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> ---
> drivers/scsi/sd.c | 55 ++++++++++++++++++++++++++++++++++++++-------------
> include/scsi/scsi.h | 3 ++
> 2 files changed, 44 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 36e2333..a26371f 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -413,6 +413,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
> sector_t threshold;
> unsigned int this_count = blk_rq_sectors(rq);
> int ret, host_dif;
> + unsigned char protect;
>
> if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
> ret = scsi_setup_blk_pc_cmnd(sdp, rq);
> @@ -545,13 +546,41 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
> /* Set RDPROTECT/WRPROTECT if disk is formatted with DIF */
> host_dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type);
> if (host_dif)
> - SCpnt->cmnd[1] = 1 << 5;
> + protect = 1 << 5;
> else
> - SCpnt->cmnd[1] = 0;
> -
> - if (block > 0xffffffff) {
> + protect = 0;
> +
> + if (host_dif == SD_DIF_TYPE2_PROTECTION) {
> + BUG_ON(rq->cmd_len != SCSI_EXT_CDB_SIZE);
This is not nice you check on the rq->cmd_len but proceed to use
the SCpnt->cmnd. Better ask for SCpnt->cmd_len, just for consistency
> + SCpnt->cmnd[0] = VARIABLE_LENGTH_CMD;
> + SCpnt->cmnd[7] = 0x18;
> + SCpnt->cmnd[9] = (rq_data_dir(rq) == READ) ? READ_32 : WRITE_32;
> + SCpnt->cmnd[10] = protect | (blk_fua_rq(rq) ? 0x8 : 0);
> +
> + /* LBA */
> + SCpnt->cmnd[12] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0;
> + SCpnt->cmnd[13] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0;
> + SCpnt->cmnd[14] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0;
> + SCpnt->cmnd[15] = sizeof(block) > 4 ? (unsigned char) (block >> 32) & 0xff : 0;
> + SCpnt->cmnd[16] = (unsigned char) (block >> 24) & 0xff;
> + SCpnt->cmnd[17] = (unsigned char) (block >> 16) & 0xff;
> + SCpnt->cmnd[18] = (unsigned char) (block >> 8) & 0xff;
> + SCpnt->cmnd[19] = (unsigned char) block & 0xff;
> +
> + /* Expected Indirect LBA */
> + SCpnt->cmnd[20] = (unsigned char) (block >> 24) & 0xff;
> + SCpnt->cmnd[21] = (unsigned char) (block >> 16) & 0xff;
> + SCpnt->cmnd[22] = (unsigned char) (block >> 8) & 0xff;
> + SCpnt->cmnd[23] = (unsigned char) block & 0xff;
> +
> + /* Transfer length */
> + SCpnt->cmnd[28] = (unsigned char) (this_count >> 24) & 0xff;
> + SCpnt->cmnd[29] = (unsigned char) (this_count >> 16) & 0xff;
> + SCpnt->cmnd[30] = (unsigned char) (this_count >> 8) & 0xff;
> + SCpnt->cmnd[31] = (unsigned char) this_count & 0xff;
> + } else if (block > 0xffffffff) {
> SCpnt->cmnd[0] += READ_16 - READ_6;
> - SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0;
> + SCpnt->cmnd[1] = protect | (blk_fua_rq(rq) ? 0x8 : 0);
> SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0;
> SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0;
> SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0;
> @@ -572,7 +601,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
> this_count = 0xffff;
>
> SCpnt->cmnd[0] += READ_10 - READ_6;
> - SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0;
> + SCpnt->cmnd[1] = protect | (blk_fua_rq(rq) ? 0x8 : 0);
> SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff;
> SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff;
> SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff;
> @@ -1271,22 +1300,20 @@ void sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer)
>
> sdkp->protection_type = type;
>
> - switch (type) {
> - case SD_DIF_TYPE1_PROTECTION:
> - case SD_DIF_TYPE3_PROTECTION:
> - break;
> -
> - default:
> + if (type > SD_DIF_TYPE3_PROTECTION) {
> sd_printk(KERN_ERR, sdkp, "formatted with unsupported " \
> "protection type %u. Disabling disk!\n", type);
> sdkp->capacity = 0;
> return;
> }
>
> - if (scsi_host_dif_capable(sdp->host, type))
> + if (scsi_host_dif_capable(sdp->host, type)) {
> sd_printk(KERN_NOTICE, sdkp,
> "Enabling DIF Type %u protection\n", type);
> - else
> +
> + if (type == SD_DIF_TYPE2_PROTECTION)
> + sdp->use_32_for_rw = 1;
> + } else
> sd_printk(KERN_NOTICE, sdkp,
> "Disabling DIF Type %u protection\n", type);
> }
> diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
> index a7ae10a..847de86 100644
> --- a/include/scsi/scsi.h
> +++ b/include/scsi/scsi.h
> @@ -129,6 +129,9 @@ struct scsi_cmnd;
> #define MI_REPORT_TARGET_PGS 0x0a
> /* values for maintenance out */
> #define MO_SET_TARGET_PGS 0x0a
> +/* values for variable length command */
> +#define READ_32 0x09
> +#define WRITE_32 0x0b
>
> /* Values for T10/04-262r7 */
> #define ATA_16 0x85 /* 16-byte pass-thru */
Boaz
next prev parent reply other threads:[~2009-08-26 12:26 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-26 6:17 DIF/DIX updates for 2.6.32 Martin K. Petersen
2009-08-26 6:17 ` [PATCH 1/5] SCSI: Add support for 32-byte CDBs Martin K. Petersen
2009-08-26 12:16 ` Boaz Harrosh
2009-08-27 6:38 ` Martin K. Petersen
2009-08-26 6:17 ` [PATCH 2/5] SCSI: Deprecate SCSI_PROT_*_CONVERT operations Martin K. Petersen
2009-08-26 6:17 ` [PATCH 3/5] sd: Detach DIF from block integrity infrastructure Martin K. Petersen
2009-08-26 6:18 ` [PATCH 4/5] sd: Support disks formatted with DIF Type 2 Martin K. Petersen
2009-08-26 12:26 ` Boaz Harrosh [this message]
2009-08-27 6:41 ` Martin K. Petersen
2009-08-26 6:18 ` [PATCH 5/5] scsi_debug: Implement support for " Martin K. Petersen
2009-08-26 12:40 ` Boaz Harrosh
2009-08-27 6:58 ` Martin K. Petersen
2009-08-27 9:35 ` Boaz Harrosh
2009-08-27 13:41 ` James Bottomley
2009-08-27 14:20 ` Boaz Harrosh
2009-08-27 14:30 ` James Bottomley
2009-08-27 14:47 ` Boaz Harrosh
2009-08-27 14:54 ` James Bottomley
2009-08-27 15:17 ` Douglas Gilbert
2009-08-27 15:39 ` Boaz Harrosh
2009-08-26 11:54 ` DIF/DIX updates for 2.6.32 Boaz Harrosh
2009-08-27 6:34 ` Martin K. Petersen
2009-08-27 9:49 ` Boaz Harrosh
2009-08-27 13:46 ` James Bottomley
2009-08-27 14:40 ` Boaz Harrosh
2009-08-27 14:51 ` James Bottomley
2009-08-27 15:18 ` Boaz Harrosh
2009-08-27 15:22 ` James Bottomley
2009-08-27 20:02 ` Martin K. Petersen
2009-08-27 20:05 ` Chris Mason
-- strict thread matches above, loose matches on Subject: below --
2009-09-04 8:36 Martin K. Petersen
2009-09-04 8:36 ` [PATCH 4/5] sd: Support disks formatted with DIF Type 2 Martin K. Petersen
2009-09-11 19:20 DIF/DIX updates for 2.6.32 Martin K. Petersen
2009-09-11 19:20 ` [PATCH 4/5] sd: Support disks formatted with DIF Type 2 Martin K. Petersen
2009-09-13 9:37 ` Boaz Harrosh
2009-09-18 21:32 Final DIF/DIX patches for 2.6.32 Martin K. Petersen
2009-09-18 21:33 ` [PATCH 4/5] sd: Support disks formatted with DIF Type 2 Martin K. Petersen
2009-09-18 21:57 ` James Bottomley
2009-09-20 20:49 ` Martin K. Petersen
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=4A9529F3.9070504@panasas.com \
--to=bharrosh@panasas.com \
--cc=Ihab.Hamadi@emulex.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=James.Smart@emulex.com \
--cc=dgilbert@interlog.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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;
as well as URLs for NNTP newsgroup(s).