From: Alan D. Brunelle Fix unplug/insert trace inversion problem. Signed-off-by: Alan D. Brunelle --- block/ll_rw_blk.c | 8 ++++---- include/linux/blkdev.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 46d29f7..3bec97f 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -2981,6 +2981,7 @@ out_unlock: if (bio_data_dir(bio) == WRITE && ioc->qrcu_idx == -1) ioc->qrcu_idx = qrcu_read_lock(&q->qrcu); list_add_tail(&req->queuelist, &ioc->plugged_list); + ioc->plugged_list_len++; } out: @@ -3720,7 +3721,6 @@ void blk_unplug_current(void) struct io_context *ioc = current->io_context; struct request *req; request_queue_t *q; - int nr_unplug; if (!ioc) return; @@ -3735,19 +3735,19 @@ void blk_unplug_current(void) if (list_empty(&ioc->plugged_list)) goto out; - nr_unplug = 0; + blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL, ioc->plugged_list_len); + spin_lock_irq(q->queue_lock); do { req = list_entry_rq(ioc->plugged_list.next); list_del_init(&req->queuelist); add_request(q, req); - nr_unplug++; } while (!list_empty(&ioc->plugged_list)); + ioc->plugged_list_len = 0; spin_unlock_irq(q->queue_lock); queue_delayed_work(kblockd_workqueue, &q->delay_work, 0); - blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL, nr_unplug); out: /* diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f8cdd44..848564c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -113,6 +113,7 @@ struct io_context { */ int plugged; int qrcu_idx; + int plugged_list_len; struct list_head plugged_list; struct request_queue *plugged_queue;