|
|
@@ -3107,8 +3107,6 @@ static int sd_revalidate_disk(struct gendisk *disk)
|
|
|
sd_read_security(sdkp, buffer);
|
|
|
}
|
|
|
|
|
|
- sdkp->first_scan = 0;
|
|
|
-
|
|
|
/*
|
|
|
* We now have all cache related info, determine how we deal
|
|
|
* with flush requests.
|
|
|
@@ -3123,7 +3121,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
|
|
|
q->limits.max_dev_sectors = logical_to_sectors(sdp, dev_max);
|
|
|
|
|
|
/*
|
|
|
- * Use the device's preferred I/O size for reads and writes
|
|
|
+ * Determine the device's preferred I/O size for reads and writes
|
|
|
* unless the reported value is unreasonably small, large, or
|
|
|
* garbage.
|
|
|
*/
|
|
|
@@ -3137,8 +3135,19 @@ static int sd_revalidate_disk(struct gendisk *disk)
|
|
|
rw_max = min_not_zero(logical_to_sectors(sdp, dev_max),
|
|
|
(sector_t)BLK_DEF_MAX_SECTORS);
|
|
|
|
|
|
- /* Combine with controller limits */
|
|
|
- q->limits.max_sectors = min(rw_max, queue_max_hw_sectors(q));
|
|
|
+ /* Do not exceed controller limit */
|
|
|
+ rw_max = min(rw_max, queue_max_hw_sectors(q));
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Only update max_sectors if previously unset or if the current value
|
|
|
+ * exceeds the capabilities of the hardware.
|
|
|
+ */
|
|
|
+ if (sdkp->first_scan ||
|
|
|
+ q->limits.max_sectors > q->limits.max_dev_sectors ||
|
|
|
+ q->limits.max_sectors > q->limits.max_hw_sectors)
|
|
|
+ q->limits.max_sectors = rw_max;
|
|
|
+
|
|
|
+ sdkp->first_scan = 0;
|
|
|
|
|
|
set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity));
|
|
|
sd_config_write_same(sdkp);
|