summaryrefslogtreecommitdiff
path: root/drivers/scsi/scsi_debug.c
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2013-09-18 21:27:25 +0900
committerJames Bottomley <JBottomley@Parallels.com>2013-10-25 09:58:11 +0100
commitbb8c063c6afcd930b8da944927144f2982609638 (patch)
tree2c056f02c74ac1965bd61b4d132c642782b4d7c5 /drivers/scsi/scsi_debug.c
parent14faa944b6fa4c77a6f386806c33ce2c3c77b3a4 (diff)
[SCSI] scsi_debug: factor out copying PI from dif_storep to prot_sglist
If data integrity support is enabled, prot_verify_read() is called in response to READ commands and it verifies protection info from dif_storep by comparing against fake_storep, and copies protection info to prot_sglist. This factors out the portion of copying protection info into a separate function. It will also be reused in the next change after supporting the opposite direction (copying prot_sglist to dif_storep). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/scsi_debug.c')
-rw-r--r--drivers/scsi/scsi_debug.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index f640b6b380bd..99e74d75cf08 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1789,37 +1789,16 @@ static int dif_verify(struct sd_dif_tuple *sdt, const void *data,
return 0;
}
-static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec,
- unsigned int sectors, u32 ei_lba)
+static void dif_copy_prot(struct scsi_cmnd *SCpnt, sector_t sector,
+ unsigned int sectors)
{
unsigned int i, resid;
struct scatterlist *psgl;
- struct sd_dif_tuple *sdt;
- sector_t sector;
void *paddr;
const void *dif_store_end = dif_storep + sdebug_store_sectors;
- for (i = 0; i < sectors; i++) {
- int ret;
-
- sector = start_sec + i;
- sdt = dif_store(sector);
-
- if (sdt->app_tag == 0xffff)
- continue;
-
- ret = dif_verify(sdt, fake_store(sector), sector, ei_lba);
- if (ret) {
- dif_errors++;
- return ret;
- }
-
- ei_lba++;
- }
-
/* Bytes of protection data to copy into sgl */
resid = sectors * sizeof(*dif_storep);
- sector = start_sec;
scsi_for_each_prot_sg(SCpnt, psgl, scsi_prot_sg_count(SCpnt), i) {
int len = min(psgl->length, resid);
@@ -1839,7 +1818,34 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec,
resid -= len;
kunmap_atomic(paddr);
}
+}
+
+static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec,
+ unsigned int sectors, u32 ei_lba)
+{
+ unsigned int i;
+ struct sd_dif_tuple *sdt;
+ sector_t sector;
+
+ for (i = 0; i < sectors; i++) {
+ int ret;
+
+ sector = start_sec + i;
+ sdt = dif_store(sector);
+
+ if (sdt->app_tag == 0xffff)
+ continue;
+
+ ret = dif_verify(sdt, fake_store(sector), sector, ei_lba);
+ if (ret) {
+ dif_errors++;
+ return ret;
+ }
+
+ ei_lba++;
+ }
+ dif_copy_prot(SCpnt, start_sec, sectors);
dix_reads++;
return 0;