Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 328886
b: refs/heads/master
c: 8c579ab
h: refs/heads/master
v: v3
  • Loading branch information
Martin K. Petersen authored and James Bottomley committed Sep 24, 2012
1 parent ca02b8a commit e8ed8e2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b656688a90175d4c424a2f02264863ede7e82d7b
refs/heads/master: 8c579ab69d50a416887390ba4b89598a7b2fa0b6
5 changes: 2 additions & 3 deletions trunk/drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,8 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
SCpnt->cmnd[0] = WRITE_6;
SCpnt->sc_data_direction = DMA_TO_DEVICE;

if (blk_integrity_rq(rq) &&
sd_dif_prepare(rq, block, sdp->sector_size) == -EIO)
goto out;
if (blk_integrity_rq(rq))
sd_dif_prepare(rq, block, sdp->sector_size);

} else if (rq_data_dir(rq) == READ) {
SCpnt->cmnd[0] = READ_6;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/scsi/sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct sd_dif_tuple {
#ifdef CONFIG_BLK_DEV_INTEGRITY

extern void sd_dif_config_host(struct scsi_disk *);
extern int sd_dif_prepare(struct request *rq, sector_t, unsigned int);
extern void sd_dif_prepare(struct request *rq, sector_t, unsigned int);
extern void sd_dif_complete(struct scsi_cmnd *, unsigned int);

#else /* CONFIG_BLK_DEV_INTEGRITY */
Expand Down
25 changes: 6 additions & 19 deletions trunk/drivers/scsi/sd_dif.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ void sd_dif_config_host(struct scsi_disk *sdkp)
*
* Type 3 does not have a reference tag so no remapping is required.
*/
int sd_dif_prepare(struct request *rq, sector_t hw_sector, unsigned int sector_sz)
void sd_dif_prepare(struct request *rq, sector_t hw_sector,
unsigned int sector_sz)
{
const int tuple_sz = sizeof(struct sd_dif_tuple);
struct bio *bio;
Expand All @@ -378,7 +379,7 @@ int sd_dif_prepare(struct request *rq, sector_t hw_sector, unsigned int sector_s
sdkp = rq->bio->bi_bdev->bd_disk->private_data;

if (sdkp->protection_type == SD_DIF_TYPE3_PROTECTION)
return 0;
return;

phys = hw_sector & 0xffffffff;

Expand All @@ -397,10 +398,9 @@ int sd_dif_prepare(struct request *rq, sector_t hw_sector, unsigned int sector_s

for (j = 0 ; j < iv->bv_len ; j += tuple_sz, sdt++) {

if (be32_to_cpu(sdt->ref_tag) != virt)
goto error;
if (be32_to_cpu(sdt->ref_tag) == virt)
sdt->ref_tag = cpu_to_be32(phys);

sdt->ref_tag = cpu_to_be32(phys);
virt++;
phys++;
}
Expand All @@ -410,16 +410,6 @@ int sd_dif_prepare(struct request *rq, sector_t hw_sector, unsigned int sector_s

bio->bi_flags |= (1 << BIO_MAPPED_INTEGRITY);
}

return 0;

error:
kunmap_atomic(sdt);
sd_printk(KERN_ERR, sdkp, "%s: virt %u, phys %u, ref %u, app %4x\n",
__func__, virt, phys, be32_to_cpu(sdt->ref_tag),
be16_to_cpu(sdt->app_tag));

return -EILSEQ;
}

/*
Expand Down Expand Up @@ -463,10 +453,7 @@ void sd_dif_complete(struct scsi_cmnd *scmd, unsigned int good_bytes)
return;
}

if (be32_to_cpu(sdt->ref_tag) != phys &&
sdt->app_tag != 0xffff)
sdt->ref_tag = 0xffffffff; /* Bad ref */
else
if (be32_to_cpu(sdt->ref_tag) == phys)
sdt->ref_tag = cpu_to_be32(virt);

virt++;
Expand Down

0 comments on commit e8ed8e2

Please sign in to comment.