Skip to contentSkip to conversation

Patch "scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Apr 18, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
scsi-sd-consider-max_xfer_blocks-if-opt_xfer_blocks-is-unusable.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 6780414519f91c2a84da9baa963a940ac916f803 Mon Sep 17 00:00:00 2001

From: Fam Zheng <[email protected]>
Date: Tue, 28 Mar 2017 12:41:26 +0800
Subject: scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable

From: Fam Zheng <[email protected]>

commit 6780414519f91c2a84da9baa963a940ac916f803 upstream.

If device reports a small max_xfer_blocks and a zero opt_xfer_blocks, we end up using BLK_DEF_MAX_SECTORS, which is wrong and r/w of that size may get error.

[mkp: tweaked to avoid setting rw_max twice and added typecast]

Fixes ca369d51b3e ("block/sd: Fix device-imposed transfer length limits")
---
 drivers/scsi/sd.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/sd.c +2 -1
@@ -2888,7 +2888,8 @@ static int sd_revalidate_disk(struct gen
 		q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
 		rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
 	} else
-		rw_max = BLK_DEF_MAX_SECTORS;
+		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));

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/scsi-sd-consider-max_xfer_blocks-if-opt_xfer_blocks-is-unusable.patch