stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable" has been added to the 4.9-stable tree
@ 2017-04-18 14:02 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2017-04-18 14:02 UTC (permalink / raw)
  To: famz, gregkh, martin.petersen; +Cc: stable, stable-commits


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.9-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.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 6780414519f91c2a84da9baa963a940ac916f803 Mon Sep 17 00:00:00 2001
From: Fam Zheng <famz@redhat.com>
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 <famz@redhat.com>

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")
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/sd.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2877,7 +2877,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 famz@redhat.com are

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-18 14:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-18 14:02 Patch "scsi: sd: Consider max_xfer_blocks if opt_xfer_blocks is unusable" has been added to the 4.9-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).