aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2008-09-19 18:47:19 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-10-13 09:28:57 -0400
commitbd623e79fb6bca7ab685bb1f7376476a81ce10bb (patch)
tree3992dbec095b5034725eb4b0397c4ea9249487b6 /drivers/scsi/sd.c
parentc82dc88ddaf17112841dd3a6b08352968555ee08 (diff)
[SCSI] sd: Issue correct protection operation
Use the same logic to prepare RD/WRPROTECT and the protection operation. Fixes a corner case where we could issue an unprotected CDB and yet tell the HBA to do DIF to the drive. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a7b53be6336..fec034557c3 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -384,7 +384,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
384 sector_t block = rq->sector; 384 sector_t block = rq->sector;
385 sector_t threshold; 385 sector_t threshold;
386 unsigned int this_count = rq->nr_sectors; 386 unsigned int this_count = rq->nr_sectors;
387 int ret; 387 int ret, host_dif;
388 388
389 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { 389 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
390 ret = scsi_setup_blk_pc_cmnd(sdp, rq); 390 ret = scsi_setup_blk_pc_cmnd(sdp, rq);
@@ -515,7 +515,8 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
515 rq->nr_sectors)); 515 rq->nr_sectors));
516 516
517 /* Set RDPROTECT/WRPROTECT if disk is formatted with DIF */ 517 /* Set RDPROTECT/WRPROTECT if disk is formatted with DIF */
518 if (scsi_host_dif_capable(sdp->host, sdkp->protection_type)) 518 host_dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type);
519 if (host_dif)
519 SCpnt->cmnd[1] = 1 << 5; 520 SCpnt->cmnd[1] = 1 << 5;
520 else 521 else
521 SCpnt->cmnd[1] = 0; 522 SCpnt->cmnd[1] = 0;
@@ -573,7 +574,7 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
573 SCpnt->sdb.length = this_count * sdp->sector_size; 574 SCpnt->sdb.length = this_count * sdp->sector_size;
574 575
575 /* If DIF or DIX is enabled, tell HBA how to handle request */ 576 /* If DIF or DIX is enabled, tell HBA how to handle request */
576 if (sdkp->protection_type || scsi_prot_sg_count(SCpnt)) 577 if (host_dif || scsi_prot_sg_count(SCpnt))
577 sd_dif_op(SCpnt, sdkp->protection_type, scsi_prot_sg_count(SCpnt)); 578 sd_dif_op(SCpnt, sdkp->protection_type, scsi_prot_sg_count(SCpnt));
578 579
579 /* 580 /*