diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2013-04-16 09:11:55 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2013-05-02 18:39:04 -0400 |
commit | 9ed8d3dc5b46f86ab9117937bd24427ac10e8de5 (patch) | |
tree | 0a09ac5278743d2e3054822770818ed3f93ede73 | |
parent | 025a1f5029497c12a800a10d4540bf2313413b59 (diff) |
[SCSI] scsi_debug: call map_region() and unmap_region() only when needed
If the logical block provisioning is not enabled, map_region() and
unmap_region() have no effect and they don't need to be called.
So this makes map_region() and unmap_region() to be called only
when scsi_debug_lbp() returns true, i.e. logical block provisioning is
enabled.
While I'm at it, this also removes meaningless non-zero check for
scsi_debug_unmap_granularity.
Because scsi_debug_unmap_granularity cannot be zero with usual setting:
scsi_debug_unmap_granularity is 1 by default, and it can be changed to
zero with explicit module parameter setting only when the logical block
provisioning is disabled. But it is only meaningful module parameter
when the logical block provisioning is enabled.
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>
-rw-r--r-- | drivers/scsi/scsi_debug.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 5cda11c07c68..05abf4e153a3 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -2089,7 +2089,7 @@ static int resp_write(struct scsi_cmnd *SCpnt, unsigned long long lba, | |||
2089 | 2089 | ||
2090 | write_lock_irqsave(&atomic_rw, iflags); | 2090 | write_lock_irqsave(&atomic_rw, iflags); |
2091 | ret = do_device_access(SCpnt, devip, lba, num, 1); | 2091 | ret = do_device_access(SCpnt, devip, lba, num, 1); |
2092 | if (scsi_debug_unmap_granularity) | 2092 | if (scsi_debug_lbp()) |
2093 | map_region(lba, num); | 2093 | map_region(lba, num); |
2094 | write_unlock_irqrestore(&atomic_rw, iflags); | 2094 | write_unlock_irqrestore(&atomic_rw, iflags); |
2095 | if (-1 == ret) | 2095 | if (-1 == ret) |
@@ -2122,7 +2122,7 @@ static int resp_write_same(struct scsi_cmnd *scmd, unsigned long long lba, | |||
2122 | 2122 | ||
2123 | write_lock_irqsave(&atomic_rw, iflags); | 2123 | write_lock_irqsave(&atomic_rw, iflags); |
2124 | 2124 | ||
2125 | if (unmap && scsi_debug_unmap_granularity) { | 2125 | if (unmap && scsi_debug_lbp()) { |
2126 | unmap_region(lba, num); | 2126 | unmap_region(lba, num); |
2127 | goto out; | 2127 | goto out; |
2128 | } | 2128 | } |
@@ -2146,7 +2146,7 @@ static int resp_write_same(struct scsi_cmnd *scmd, unsigned long long lba, | |||
2146 | fake_storep + (lba * scsi_debug_sector_size), | 2146 | fake_storep + (lba * scsi_debug_sector_size), |
2147 | scsi_debug_sector_size); | 2147 | scsi_debug_sector_size); |
2148 | 2148 | ||
2149 | if (scsi_debug_unmap_granularity) | 2149 | if (scsi_debug_lbp()) |
2150 | map_region(lba, num); | 2150 | map_region(lba, num); |
2151 | out: | 2151 | out: |
2152 | write_unlock_irqrestore(&atomic_rw, iflags); | 2152 | write_unlock_irqrestore(&atomic_rw, iflags); |