From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Mike Christie <mchristi@redhat.com>,
Bart Van Assche <bart.vanassche@sandisk.com>,
Nicholas Bellinger <nab@linux-iscsi.org>
Subject: [PATCH 3.14 41/46] target: Fix max_unmap_lba_count calc overflow
Date: Thu, 18 Aug 2016 15:55:03 +0200 [thread overview]
Message-ID: <20160818135448.561240425@linuxfoundation.org> (raw)
In-Reply-To: <20160818135442.457400364@linuxfoundation.org>
3.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Christie <mchristi@redhat.com>
commit ea263c7fada4af8ec7fe5fcfd6e7d7705a89351b upstream.
max_discard_sectors only 32bits, and some non scsi backend
devices will set this to the max 0xffffffff, so we can end up
overflowing during the max_unmap_lba_count calculation.
This fixes a regression caused by my patch:
commit 8a9ebe717a133ba7bc90b06047f43cc6b8bcb8b3
Author: Mike Christie <mchristi@redhat.com>
Date: Mon Jan 18 14:09:27 2016 -0600
target: Fix WRITE_SAME/DISCARD conversion to linux 512b sectors
which can result in extra discards being sent to due the overflow
causing max_unmap_lba_count to be smaller than what the backing
device can actually support.
Signed-off-by: Mike Christie <mchristi@redhat.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/target/target_core_device.c | 8 +++++---
drivers/target/target_core_file.c | 3 +--
drivers/target/target_core_iblock.c | 3 +--
include/target/target_core_backend.h | 2 +-
4 files changed, 8 insertions(+), 8 deletions(-)
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1583,13 +1583,15 @@ struct se_device *target_alloc_device(st
* in ATA and we need to set TPE=1
*/
bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
- struct request_queue *q, int block_size)
+ struct request_queue *q)
{
+ int block_size = queue_logical_block_size(q);
+
if (!blk_queue_discard(q))
return false;
- attrib->max_unmap_lba_count = (q->limits.max_discard_sectors << 9) /
- block_size;
+ attrib->max_unmap_lba_count =
+ q->limits.max_discard_sectors >> (ilog2(block_size) - 9);
/*
* Currently hardcoded to 1 in Linux/SCSI code..
*/
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -165,8 +165,7 @@ static int fd_configure_device(struct se
dev_size, div_u64(dev_size, fd_dev->fd_block_size),
fd_dev->fd_block_size);
- if (target_configure_unmap_from_queue(&dev->dev_attrib, q,
- fd_dev->fd_block_size))
+ if (target_configure_unmap_from_queue(&dev->dev_attrib, q))
pr_debug("IFILE: BLOCK Discard support available,"
" disabled by default\n");
/*
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -126,8 +126,7 @@ static int iblock_configure_device(struc
dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q);
dev->dev_attrib.hw_queue_depth = q->nr_requests;
- if (target_configure_unmap_from_queue(&dev->dev_attrib, q,
- dev->dev_attrib.hw_block_size))
+ if (target_configure_unmap_from_queue(&dev->dev_attrib, q))
pr_debug("IBLOCK: BLOCK Discard support available,"
" disabled by default\n");
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -96,6 +96,6 @@ void array_free(void *array, int n);
sector_t target_to_linux_sector(struct se_device *dev, sector_t lb);
bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
- struct request_queue *q, int block_size);
+ struct request_queue *q);
#endif /* TARGET_CORE_BACKEND_H */
next prev parent reply other threads:[~2016-08-18 13:55 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20160818135526uscas1p209dc90415100838cf7c73a2d19ca32a3@uscas1p2.samsung.com>
2016-08-18 13:54 ` [PATCH 3.14 00/46] 3.14.77-stable review Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 01/46] tcp: make challenge acks faster Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 02/46] usb: renesas_usbhs: protect the CFIFOSEL setting in usbhsg_ep_enable() Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 11/46] cifs: Check for existing directory when opening file with O_CREAT Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 12/46] cifs: fix crash due to race in hmac(md5) handling Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 14/46] random: properly align get_random_int_hash Greg Kroah-Hartman
2016-08-19 3:14 ` Eric Biggers
2016-08-19 7:33 ` Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 15/46] random: print a warning for the first ten uninitialized random users Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 20/46] nfs: dont create zero-length requests Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 30/46] balloon: check the number of available pages in leak balloon Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 31/46] ftrace/recordmcount: Work around for addition of metag magic but not relocations Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 32/46] metag: Fix __cmpxchg_u32 asm constraint for CMP Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 33/46] IB/mlx5: Fix MODIFY_QP command input structure Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 34/46] IB/mlx5: Fix returned values of query QP Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 35/46] IB/mlx5: Fix post send fence logic Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 36/46] IB/IPoIB: Dont update neigh validity for unresolved entries Greg Kroah-Hartman
2016-08-18 13:54 ` [PATCH 3.14 37/46] IB/mlx4: Fix the SQ size of an RC QP Greg Kroah-Hartman
2016-08-18 13:55 ` [PATCH 3.14 38/46] ubi: Make volume resize power cut aware Greg Kroah-Hartman
2016-08-18 13:55 ` [PATCH 3.14 39/46] ubi: Fix race condition between ubi device creation and udev Greg Kroah-Hartman
2016-08-18 13:55 ` [PATCH 3.14 40/46] target: Fix race between iscsi-target connection shutdown + ABORT_TASK Greg Kroah-Hartman
2016-08-18 13:55 ` Greg Kroah-Hartman [this message]
2016-08-18 13:55 ` [PATCH 3.14 42/46] Input: i8042 - break load dependency between atkbd/psmouse and i8042 Greg Kroah-Hartman
2016-08-18 13:55 ` [PATCH 3.14 43/46] PCI: Mark Atheros AR9485 and QCA9882 to avoid bus reset Greg Kroah-Hartman
2016-08-18 13:55 ` [PATCH 3.14 44/46] dm flakey: error READ bios during the down_interval Greg Kroah-Hartman
2016-08-18 13:55 ` [PATCH 3.14 45/46] module: Invalidate signatures on force-loaded modules Greg Kroah-Hartman
2016-08-18 13:55 ` [PATCH 3.14 46/46] Documentation/module-signing.txt: Note need for version info if reusing a key Greg Kroah-Hartman
2016-08-18 20:05 ` [PATCH 3.14 00/46] 3.14.77-stable review Guenter Roeck
2016-08-19 7:38 ` Greg Kroah-Hartman
2016-08-18 21:34 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160818135448.561240425@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=bart.vanassche@sandisk.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchristi@redhat.com \
--cc=nab@linux-iscsi.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).