Commit 41e9d344 authored by Jens Axboe's avatar Jens Axboe Committed by Linus Torvalds

IDE: fix termination of non-fs requests

ide-disk calls

        ide_end_request(drive, 0, 0);

to finish an unknown request, but this doesn't work so well for non-fs
requests, since ide_end_request() internally looks at ->hard_cur_sectors
to see how much data to end. Only file system requests store a transfer
value in there, pc requests fill out ->data_len as a byte based transfer
value instead.

Since we ask to end 0 bytes of that request, it will never be terminated
and ide-disk gets stuck in a loop "handling" that same request over and
over.

Switch __ide_end_request() to take a byte based transfer count, and
adjust ide_end_request() to look at the right field to determine how
much IO to end when it's being passed in 0.
Acked-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tested-By: default avatarGiacomo Catenazzi <cate@debian.org>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 275afcac
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#include <asm/bitops.h> #include <asm/bitops.h>
static int __ide_end_request(ide_drive_t *drive, struct request *rq, static int __ide_end_request(ide_drive_t *drive, struct request *rq,
int uptodate, int nr_sectors) int uptodate, unsigned int nr_bytes)
{ {
int ret = 1; int ret = 1;
...@@ -64,7 +64,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq, ...@@ -64,7 +64,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
* complete the whole request right now * complete the whole request right now
*/ */
if (blk_noretry_request(rq) && end_io_error(uptodate)) if (blk_noretry_request(rq) && end_io_error(uptodate))
nr_sectors = rq->hard_nr_sectors; nr_bytes = rq->hard_nr_sectors << 9;
if (!blk_fs_request(rq) && end_io_error(uptodate) && !rq->errors) if (!blk_fs_request(rq) && end_io_error(uptodate) && !rq->errors)
rq->errors = -EIO; rq->errors = -EIO;
...@@ -78,7 +78,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq, ...@@ -78,7 +78,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
HWGROUP(drive)->hwif->ide_dma_on(drive); HWGROUP(drive)->hwif->ide_dma_on(drive);
} }
if (!end_that_request_first(rq, uptodate, nr_sectors)) { if (!end_that_request_chunk(rq, uptodate, nr_bytes)) {
add_disk_randomness(rq->rq_disk); add_disk_randomness(rq->rq_disk);
if (!list_empty(&rq->queuelist)) if (!list_empty(&rq->queuelist))
blkdev_dequeue_request(rq); blkdev_dequeue_request(rq);
...@@ -103,6 +103,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq, ...@@ -103,6 +103,7 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors) int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
{ {
unsigned int nr_bytes = nr_sectors << 9;
struct request *rq; struct request *rq;
unsigned long flags; unsigned long flags;
int ret = 1; int ret = 1;
...@@ -114,10 +115,14 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors) ...@@ -114,10 +115,14 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags);
rq = HWGROUP(drive)->rq; rq = HWGROUP(drive)->rq;
if (!nr_sectors) if (!nr_bytes) {
nr_sectors = rq->hard_cur_sectors; if (blk_pc_request(rq))
nr_bytes = rq->data_len;
else
nr_bytes = rq->hard_cur_sectors << 9;
}
ret = __ide_end_request(drive, rq, uptodate, nr_sectors); ret = __ide_end_request(drive, rq, uptodate, nr_bytes);
spin_unlock_irqrestore(&ide_lock, flags); spin_unlock_irqrestore(&ide_lock, flags);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment