From: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
To: pjk1939@linux.vnet.ibm.com
Cc: josh.h.morris@us.ibm.com, linux-kernel@vger.kernel.org,
axboe@kernel.dk,
Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>,
stable@vger.kernel.org
Subject: [PATCH] rsxx: fix discard with length smaller than hw blksize
Date: Mon, 30 Jun 2014 14:31:07 -0300 [thread overview]
Message-ID: <1404149467-17856-1-git-send-email-cascardo@linux.vnet.ibm.com> (raw)
When the discard length is not a multiple of RSXX_HW_BLK_SIZE, the
discard code will get into an infinite loop, even discarding data it is
not supposed to. This will also hang the system.
This can be reproduced by doing an ioctl BLKDISCARD to /dev/rsxx0 with
range from 0 to 1024.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org
---
drivers/block/rsxx/dma.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/drivers/block/rsxx/dma.c b/drivers/block/rsxx/dma.c
index cf8cd29..d105a4a 100644
--- a/drivers/block/rsxx/dma.c
+++ b/drivers/block/rsxx/dma.c
@@ -708,7 +708,9 @@ int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
if (bio->bi_rw & REQ_DISCARD) {
bv_len = bio->bi_iter.bi_size;
- while (bv_len > 0) {
+ if (bv_len < RSXX_HW_BLK_SIZE)
+ bio_endio(bio, 0);
+ while (bv_len >= RSXX_HW_BLK_SIZE) {
tgt = rsxx_get_dma_tgt(card, addr8);
laddr = rsxx_addr8_to_laddr(addr8, card);
--
1.7.1
next reply other threads:[~2014-06-30 17:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-30 17:31 Thadeu Lima de Souza Cascardo [this message]
2014-06-30 21:06 ` Jens Axboe
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=1404149467-17856-1-git-send-email-cascardo@linux.vnet.ibm.com \
--to=cascardo@linux.vnet.ibm.com \
--cc=axboe@kernel.dk \
--cc=josh.h.morris@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pjk1939@linux.vnet.ibm.com \
--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
Powered by JetHome