diff options
| author | Martin K. Petersen <martin.petersen@oracle.com> | 2017-09-27 21:38:59 -0400 |
|---|---|---|
| committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-10-02 22:16:25 -0400 |
| commit | 77082ca503bed061f7fbda7cfd7c93beda967a41 (patch) | |
| tree | dc722721e00d0a3f6ec06f379fd679a76684214b | |
| parent | 28a0bc4120d38a394499382ba21d6965a67a3703 (diff) | |
scsi: sd: Do not override max_sectors_kb sysfs setting
A user may lower the max_sectors_kb setting in sysfs to accommodate
certain workloads. Previously we would always set the max I/O size to
either the block layer default or the optional preferred I/O size
reported by the device.
Keep the current heuristics for the initial setting of max_sectors_kb.
For subsequent invocations, only update the current queue limit if it
exceeds the capabilities of the hardware.
Cc: <stable@vger.kernel.org>
Reported-by: Don Brace <don.brace@microsemi.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Tested-by: Don Brace <don.brace@microsemi.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
| -rw-r--r-- | drivers/scsi/sd.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3d26a729825c..d175c5c5ccf8 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
| @@ -3107,8 +3107,6 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
| 3107 | sd_read_security(sdkp, buffer); | 3107 | sd_read_security(sdkp, buffer); |
| 3108 | } | 3108 | } |
| 3109 | 3109 | ||
| 3110 | sdkp->first_scan = 0; | ||
| 3111 | |||
| 3112 | /* | 3110 | /* |
| 3113 | * We now have all cache related info, determine how we deal | 3111 | * We now have all cache related info, determine how we deal |
| 3114 | * with flush requests. | 3112 | * with flush requests. |
| @@ -3123,7 +3121,7 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
| 3123 | q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max); | 3121 | q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max); |
| 3124 | 3122 | ||
| 3125 | /* | 3123 | /* |
| 3126 | * Use the device's preferred I/O size for reads and writes | 3124 | * Determine the device's preferred I/O size for reads and writes |
| 3127 | * unless the reported value is unreasonably small, large, or | 3125 | * unless the reported value is unreasonably small, large, or |
| 3128 | * garbage. | 3126 | * garbage. |
| 3129 | */ | 3127 | */ |
| @@ -3137,8 +3135,19 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
| 3137 | rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), | 3135 | rw_max = min_not_zero(logical_to_sectors(sdp, dev_max), |
| 3138 | (sector_t)BLK_DEF_MAX_SECTORS); | 3136 | (sector_t)BLK_DEF_MAX_SECTORS); |
| 3139 | 3137 | ||
| 3140 | /* Combine with controller limits */ | 3138 | /* Do not exceed controller limit */ |
| 3141 | q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q)); | 3139 | rw_max = min(rw_max, queue_max_hw_sectors(q)); |
| 3140 | |||
| 3141 | /* | ||
| 3142 | * Only update max_sectors if previously unset or if the current value | ||
| 3143 | * exceeds the capabilities of the hardware. | ||
| 3144 | */ | ||
| 3145 | if (sdkp->first_scan || | ||
| 3146 | q->limits.max_sectors > q->limits.max_dev_sectors || | ||
| 3147 | q->limits.max_sectors > q->limits.max_hw_sectors) | ||
| 3148 | q->limits.max_sectors = rw_max; | ||
| 3149 | |||
| 3150 | sdkp->first_scan = 0; | ||
| 3142 | 3151 | ||
| 3143 | set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity)); | 3152 | set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity)); |
| 3144 | sd_config_write_same(sdkp); | 3153 | sd_config_write_same(sdkp); |
