From: mchristi@redhat.com
To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
socketpair@gmail.com
Cc: Mike Christie <mchristi@redhat.com>, stable@vger.kernel.org
Subject: [PATCH 2/2] target: fix max discard sectors calculation
Date: Mon, 16 May 2016 13:46:50 -0500 [thread overview]
Message-ID: <1463424410-17196-3-git-send-email-mchristi@redhat.com> (raw)
In-Reply-To: <1463424410-17196-1-git-send-email-mchristi@redhat.com>
From: Mike Christie <mchristi@redhat.com>
max_discard_sectors and block_size are 32 bits, so we can
overflow when trying to convert between the linux block
layer max discard sectors and the LIO value.
This fixes a regression caused by this 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
where you will get smaller and extra discards due to the max size
being shortened.
Signed-off-by: Mike Christie <mchristi@redhat.com>
Cc: stable@vger.kernel.org
---
drivers/target/target_core_device.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index a4046ca..3f9f304 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -826,8 +826,8 @@ bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
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 =
+ ((u64)q->limits.max_discard_sectors << 9) / block_size;
/*
* Currently hardcoded to 1 in Linux/SCSI code..
*/
--
2.7.2
next prev parent reply other threads:[~2016-05-16 18:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-16 18:46 [PATCH 0/2] fix max discard sectors calculation mchristi
2016-05-16 18:46 ` [PATCH 1/2] scsi: " mchristi
2016-05-16 22:44 ` Bart Van Assche
2016-05-17 3:46 ` Mike Christie
2016-05-16 18:46 ` mchristi [this message]
2016-05-16 18:57 ` [PATCH 2/2] target: " Bart Van Assche
2016-05-16 19:00 ` Mike Christie
2016-05-16 19:02 ` Martin K. Petersen
2016-05-17 18:16 ` Bart Van Assche
2016-05-17 21:49 ` Mike Christie
2016-05-18 16:56 ` Bart Van Assche
2016-05-18 17:17 ` Mike Christie
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=1463424410-17196-3-git-send-email-mchristi@redhat.com \
--to=mchristi@redhat.com \
--cc=linux-scsi@vger.kernel.org \
--cc=socketpair@gmail.com \
--cc=stable@vger.kernel.org \
--cc=target-devel@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).