Commit fc3fc352 authored by Akinobu Mita's avatar Akinobu Mita Committed by James Bottomley

[SCSI] scsi_debug: fix incorrectly nested kmap_atomic()

In the function prot_verify_write(), kmap_atomic()/kunmap_atomic() for
data page and kmap_atomic()/kunmap_atomic() for protection information
page are not nested each other.

It worked perfectly before commit 3e4d3af5
("mm: stack based kmap_atomic()").  Because the kmap_atomic slot KM_IRQ0
was used for data page and the slot KM_IRQ1 was used for protection page.

But KM_types are gone and kmap_atomic() is using stack based implementation.
So two different kmap_atomic() usages must be strictly nested now.

This change ensures kmap_atomic() usage is strictly nested.
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
Acked-by: default avatar"Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 518d9df8
...@@ -1891,12 +1891,12 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, ...@@ -1891,12 +1891,12 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec,
BUG_ON(scsi_sg_count(SCpnt) == 0); BUG_ON(scsi_sg_count(SCpnt) == 0);
BUG_ON(scsi_prot_sg_count(SCpnt) == 0); BUG_ON(scsi_prot_sg_count(SCpnt) == 0);
paddr = kmap_atomic(sg_page(psgl)) + psgl->offset;
ppage_offset = 0; ppage_offset = 0;
/* For each data page */ /* For each data page */
scsi_for_each_sg(SCpnt, dsgl, scsi_sg_count(SCpnt), i) { scsi_for_each_sg(SCpnt, dsgl, scsi_sg_count(SCpnt), i) {
daddr = kmap_atomic(sg_page(dsgl)) + dsgl->offset; daddr = kmap_atomic(sg_page(dsgl)) + dsgl->offset;
paddr = kmap_atomic(sg_page(psgl)) + psgl->offset;
/* For each sector-sized chunk in data page */ /* For each sector-sized chunk in data page */
for (j = 0; j < dsgl->length; j += scsi_debug_sector_size) { for (j = 0; j < dsgl->length; j += scsi_debug_sector_size) {
...@@ -1980,19 +1980,18 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec, ...@@ -1980,19 +1980,18 @@ static int prot_verify_write(struct scsi_cmnd *SCpnt, sector_t start_sec,
ppage_offset += sizeof(struct sd_dif_tuple); ppage_offset += sizeof(struct sd_dif_tuple);
} }
kunmap_atomic(paddr);
kunmap_atomic(daddr); kunmap_atomic(daddr);
} }
kunmap_atomic(paddr);
dix_writes++; dix_writes++;
return 0; return 0;
out: out:
dif_errors++; dif_errors++;
kunmap_atomic(daddr);
kunmap_atomic(paddr); kunmap_atomic(paddr);
kunmap_atomic(daddr);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment