All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sd: preserve sysfs updates to max_sectors_kb
@ 2017-08-18 21:00 Don Brace
  2017-08-18 21:05 ` Bart Van Assche
  2017-09-28  1:38 ` [PATCH] scsi: sd: Do not override max_sectors_kb sysfs setting Martin K. Petersen
  0 siblings, 2 replies; 21+ messages in thread
From: Don Brace @ 2017-08-18 21:00 UTC (permalink / raw)
  To: joseph.szczypek, gerry.morong, john.hall, jejb, Kevin.Barnett,
	Mahesh.Rajashekhara, bader.alisaleh, hch, scott.teel, Viswas.G,
	Justin.Lindley, scott.benesh, POSWALD
  Cc: linux-scsi

prevent systemd-udevd from changing a device's sysfs entry
max_sectors_kb back to the default value.
 - max_sectors_kb can be tweaked for better performance.
 - udev can be triggered by sg_logs -t or scsi_temperature, ...
 - sd_revalidate_disk is called from udev by ioctl BLKRRPART

Reviewed-by: Scott Teel <scott.teel@microsemi.com>
Signed-off-by: Don Brace <don.brace@microsemi.com>
---
 drivers/scsi/sd.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index bea36ad..457dc7c 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3055,6 +3055,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
 	sector_t old_capacity = sdkp->capacity;
 	unsigned char *buffer;
 	unsigned int dev_max, rw_max;
+	unsigned int max_sectors;
 
 	SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
 				      "sd_revalidate_disk\n"));
@@ -3128,9 +3129,14 @@ 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));
+	/* Check for max_sectors_kb update through sysfs */
+	if (q->limits.max_sectors < min(rw_max, queue_max_hw_sectors(q)))
+		max_sectors = q->limits.max_sectors;
+	else
+		max_sectors = min(rw_max, queue_max_hw_sectors(q));
 
+	/* Combine with controller limits */
+	q->limits.max_sectors = max_sectors;
 	set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity));
 	sd_config_write_same(sdkp);
 	kfree(buffer);

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-09-29 13:46 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 21:00 [PATCH] sd: preserve sysfs updates to max_sectors_kb Don Brace
2017-08-18 21:05 ` Bart Van Assche
2017-08-18 21:29   ` Don Brace
2017-08-18 21:46     ` Bart Van Assche
2017-08-21 19:12       ` Don Brace
2017-08-21 19:53         ` Bart Van Assche
2017-08-21 20:14           ` Don Brace
2017-08-29 17:41             ` Don Brace
2017-08-29 17:42             ` Don Brace
2017-08-29 18:13               ` Bart Van Assche
2017-08-29 18:36                 ` Don Brace
2017-08-29 19:41                   ` Don Brace
2017-08-29 22:25                     ` Bart Van Assche
2017-08-29 22:32                       ` Don Brace
2017-08-29 23:00                         ` Bart Van Assche
2017-08-30  1:24                           ` Martin K. Petersen
2017-09-09 10:32                             ` Martin Wilck
2017-09-28  1:37                               ` Martin K. Petersen
2017-09-28  1:38 ` [PATCH] scsi: sd: Do not override max_sectors_kb sysfs setting Martin K. Petersen
2017-09-29 12:26   ` Martin Wilck
2017-09-29 13:46   ` Don Brace

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.