[SCSI] scsi_debug: clear correct memory region when LBPRZ is enabled
authorAkinobu Mita <akinobu.mita@gmail.com>
Tue, 16 Apr 2013 13:11:57 +0000 (22:11 +0900)
committerJames Bottomley <JBottomley@Parallels.com>
Thu, 2 May 2013 22:40:41 +0000 (15:40 -0700)
The function unmap_region() clears memory region specified as the logical
block address and the number of logical blocks in ramdisk storage
(fake_storep) if lbpu and lbprz module parameters are enabled.

In the while loop of unmap_region(), it advances optimal unmap granularity
in logical blocks.  But it only clears one logical block at LBA 'block' per
loop iteration.  And furthermore, the 'block' is not pointing to a logical
block address which should be cleared, it is a index of probisioning map
(map_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>
drivers/scsi/scsi_debug.c

index 5c321409fff3d3fcb4294de56cafd11b33ed4396..4b5d3887ff4754655283d75809d0b39ddf8c36b2 100644 (file)
@@ -2059,8 +2059,9 @@ static void unmap_region(sector_t lba, unsigned int len)
                        clear_bit(block, map_storep);
                        if (scsi_debug_lbprz)
                                memset(fake_storep +
-                                      block * scsi_debug_sector_size, 0,
-                                      scsi_debug_sector_size);
+                                      lba * scsi_debug_sector_size, 0,
+                                      scsi_debug_sector_size *
+                                      scsi_debug_unmap_granularity);
                }
                lba += granularity - rem;
        }