Skip to contentSkip to conversation

block: fix an oops on BLKPREP_KILL

PATCH In review James Bottomley 2 participants 4 messages May 29, 2009 – May 31, 2009

Subsystems (3)
lore
Share & tools
lore

James Bottomley

author maintainer
#0 lore raw

PATCH 1/1 block: fix an oops on BLKPREP_KILL

Doing a bit of torture testing, I ran across a BUG in the block subsystem (at blk-core.c:2048): the test for if the request is queued.

It turns out the trigger was a BLKPREP_KILL coming out of the SCSI prep function. Currently for BLKPREP_KILL requests, we send them straight into __blk_end_request_all() with an error, but they've never been dequeued, so they trip the bug. Fix this by starting requests before killing them.

---

block/blk-core.c +1 -0
index 8b3b74e..9a0568c 100644
@@ -1789,6 +1789,7 @@ struct request *blk_peek_request(struct request_queue *q)
 			break;
 		} else if (ret == BLKPREP_KILL) {
 			rq->cmd_flags |= REQ_QUIET;
+			blk_start_request(rq);
 			__blk_end_request_all(rq, -EIO);
 		} else {
 			printk(KERN_ERR "%s: bad return=%d\n", __func__, ret);
#1 lore raw
Quoted 18 lines · James Bottomley

Doing a bit of torture testing, I ran across a BUG in the block subsystem (at blk-core.c:2048): the test for if the request is queued.

It turns out the trigger was a BLKPREP_KILL coming out of the SCSI prep function. Currently for BLKPREP_KILL requests, we send them straight into __blk_end_request_all() with an error, but they've never been dequeued, so they trip the bug. Fix this by starting requests before killing them.

---

block/blk-core.c +0 -0
index 8b3b74e..9a0568c 100644

block/blk-core.c struct request *blk_peek_request(struct request_queue *q) · line 1795

Quoted 7 lines
block/blk-core.c +1 -0
@@ -1789,6 +1789,7 @@ struct request *blk_peek_request(struct request_queue *q)
 			break;
 		} else if (ret == BLKPREP_KILL) {
 			rq->cmd_flags |= REQ_QUIET;
+			blk_start_request(rq);
 			__blk_end_request_all(rq, -EIO);
 		} else {
 			printk(KERN_ERR "%s: bad return=%d\n", __func__, ret);

Given how illogical that now looks, I think it could do with a comment. I'll add that while applying.

Signature · 1 line
Jens Axboe
author maintainer
#2 lore raw
Quoted 14 lines · Jens Axboe
Quoted 13 lines · James Bottomley

Doing a bit of torture testing, I ran across a BUG in the block subsystem (at blk-core.c:2048): the test for if the request is queued.

It turns out the trigger was a BLKPREP_KILL coming out of the SCSI prep function. Currently for BLKPREP_KILL requests, we send them straight into __blk_end_request_all() with an error, but they've never been dequeued, so they trip the bug. Fix this by starting requests before killing them.

---

Quoted 15 lines

block/blk-core.c struct request *blk_peek_request(struct request_queue *q) · line 1795

Quoted 12 lines
block/blk-core.c +1 -0
index 8b3b74e..9a0568c 100644
@@ -1789,6 +1789,7 @@ struct request *blk_peek_request(struct request_queue *q)
 			break;
 		} else if (ret == BLKPREP_KILL) {
 			rq->cmd_flags |= REQ_QUIET;
+			blk_start_request(rq);
 			__blk_end_request_all(rq, -EIO);
 		} else {
 			printk(KERN_ERR "%s: bad return=%d\n", __func__, ret);

Given how illogical that now looks, I think it could do with a comment. I'll add that while applying.

Um, if it looks illogical, then so is the new everything has to be dequeued before completion requirement ... I agree a comment reminding people why it has to work this way doesn't hurt, but if it looks illogical then there might be something wrong with the rules requiring this to happen ...

James

#3 lore raw
Quoted 31 lines · James Bottomley
Quoted 14 lines · Jens Axboe
Quoted 13 lines · James Bottomley

Doing a bit of torture testing, I ran across a BUG in the block subsystem (at blk-core.c:2048): the test for if the request is queued.

It turns out the trigger was a BLKPREP_KILL coming out of the SCSI prep function. Currently for BLKPREP_KILL requests, we send them straight into __blk_end_request_all() with an error, but they've never been dequeued, so they trip the bug. Fix this by starting requests before killing them.

---

Quoted 15 lines

block/blk-core.c struct request *blk_peek_request(struct request_queue *q) · line 1795

Quoted 12 lines
block/blk-core.c +1 -0
index 8b3b74e..9a0568c 100644
@@ -1789,6 +1789,7 @@ struct request *blk_peek_request(struct request_queue *q)
 			break;
 		} else if (ret == BLKPREP_KILL) {
 			rq->cmd_flags |= REQ_QUIET;
+			blk_start_request(rq);
 			__blk_end_request_all(rq, -EIO);
 		} else {
 			printk(KERN_ERR "%s: bad return=%d\n", __func__, ret);

Given how illogical that now looks, I think it could do with a comment. I'll add that while applying.

Quoted 5 lines

Um, if it looks illogical, then so is the new everything has to be dequeued before completion requirement ... I agree a comment reminding people why it has to work this way doesn't hurt, but if it looks illogical then there might be something wrong with the rules requiring this to happen ...

It's not a bad idea to be a little extra paranoid with such an API change, we can always relax this restriction later.

Signature · 1 line
Jens Axboe