Skip to content

Commit 1cac8e8

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
* 'for-linus' of git://git.kernel.dk/linux-block: block: fix blk_queue_end_tag() block: re-use existing 'reading' variable instead of checking direction again block, cfq: fix empty queue crash caused by request merge
2 parents b0365c8 + f2b20d4 commit 1cac8e8

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

block/blk-map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
311311
if (IS_ERR(bio))
312312
return PTR_ERR(bio);
313313

314-
if (rq_data_dir(rq) == WRITE)
314+
if (!reading)
315315
bio->bi_rw |= REQ_WRITE;
316316

317317
if (do_copy)

block/blk-tag.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,18 +282,9 @@ EXPORT_SYMBOL(blk_queue_resize_tags);
282282
void blk_queue_end_tag(struct request_queue *q, struct request *rq)
283283
{
284284
struct blk_queue_tag *bqt = q->queue_tags;
285-
int tag = rq->tag;
285+
unsigned tag = rq->tag; /* negative tags invalid */
286286

287-
BUG_ON(tag == -1);
288-
289-
if (unlikely(tag >= bqt->max_depth)) {
290-
/*
291-
* This can happen after tag depth has been reduced.
292-
* But tag shouldn't be larger than real_max_depth.
293-
*/
294-
WARN_ON(tag >= bqt->real_max_depth);
295-
return;
296-
}
287+
BUG_ON(tag >= bqt->real_max_depth);
297288

298289
list_del_init(&rq->queuelist);
299290
rq->cmd_flags &= ~REQ_QUEUED;

block/cfq-iosched.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,8 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,
16551655
struct request *next)
16561656
{
16571657
struct cfq_queue *cfqq = RQ_CFQQ(rq);
1658+
struct cfq_data *cfqd = q->elevator->elevator_data;
1659+
16581660
/*
16591661
* reposition in fifo if next is older than rq
16601662
*/
@@ -1669,6 +1671,16 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,
16691671
cfq_remove_request(next);
16701672
cfq_blkiocg_update_io_merged_stats(&(RQ_CFQG(rq))->blkg,
16711673
rq_data_dir(next), rq_is_sync(next));
1674+
1675+
cfqq = RQ_CFQQ(next);
1676+
/*
1677+
* all requests of this queue are merged to other queues, delete it
1678+
* from the service tree. If it's the active_queue,
1679+
* cfq_dispatch_requests() will choose to expire it or do idle
1680+
*/
1681+
if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY_ROOT(&cfqq->sort_list) &&
1682+
cfqq != cfqd->active_queue)
1683+
cfq_del_cfqq_rr(cfqd, cfqq);
16721684
}
16731685

16741686
static int cfq_allow_merge(struct request_queue *q, struct request *rq,

0 commit comments

Comments
 (0)