]> www.infradead.org Git - users/hch/block.git/commitdiff
sd: also set max_user_sectors when setting max_sectors
authorChristoph Hellwig <hch@lst.de>
Thu, 23 May 2024 18:22:03 +0000 (20:22 +0200)
committerChristoph Hellwig <hch@lst.de>
Mon, 27 May 2024 06:30:25 +0000 (08:30 +0200)
sd can set a max_sectors value that is lower than the max_hw_sectors
limit based on the block limits VPD page.   While this is rather unusual,
it used to work until the max_user_sectors field was split out to cleanly
deal with conflicting hardware and user limits when the hardware limit
changes.  Also set max_user_sectors to ensure the limit can properly be
stacked.

Fixes: 4f563a64732d ("block: add a max_user_discard_sectors queue limit")
Reported-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Mike Snitzer <snitzer@kernel.org>
drivers/scsi/sd.c

index 332eb9dac22d91e66e1ee768f66d1f7e83713470..f6c822c9cbd2d3ef0cfdf584bc307cffa6ace353 100644 (file)
@@ -3700,8 +3700,10 @@ static int sd_revalidate_disk(struct gendisk *disk)
         */
        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 > q->limits.max_hw_sectors) {
                q->limits.max_sectors = rw_max;
+               q->limits.max_user_sectors = rw_max;
+       }
 
        sdkp->first_scan = 0;