aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2015-02-24 21:58:21 -0500
committerMike Snitzer <snitzer@redhat.com>2015-04-15 12:10:14 -0400
commitde3ec86dff160d35c817bb70eeaeff6e392f44a4 (patch)
treeccb44d9f929f34bb8cae746252e3a40246c9f895
parentd548b34b062b60b4f4df295a0b4823dfda1f1fc4 (diff)
dm: don't start current request if it would've merged with the previous
Request-based DM's dm_request_fn() is so fast to pull requests off the queue that steps need to be taken to promote merging by avoiding request processing if it makes sense. If the current request would've merged with previous request let the current request stay on the queue longer. Suggested-by: Jens Axboe <axboe@fb.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 98eb02d32e6e..2ae78b31e4c0 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -21,6 +21,7 @@
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/wait.h> 22#include <linux/wait.h>
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/elevator.h> /* for rq_end_sector() */
24 25
25#include <trace/events/block.h> 26#include <trace/events/block.h>
26 27
@@ -216,6 +217,10 @@ struct mapped_device {
216 217
217 struct kthread_worker kworker; 218 struct kthread_worker kworker;
218 struct task_struct *kworker_task; 219 struct task_struct *kworker_task;
220
221 /* for request-based merge heuristic in dm_request_fn() */
222 sector_t last_rq_pos;
223 int last_rq_rw;
219}; 224};
220 225
221/* 226/*
@@ -1930,6 +1935,9 @@ static void dm_start_request(struct mapped_device *md, struct request *orig)
1930 blk_start_request(orig); 1935 blk_start_request(orig);
1931 atomic_inc(&md->pending[rq_data_dir(orig)]); 1936 atomic_inc(&md->pending[rq_data_dir(orig)]);
1932 1937
1938 md->last_rq_pos = rq_end_sector(orig);
1939 md->last_rq_rw = rq_data_dir(orig);
1940
1933 /* 1941 /*
1934 * Hold the md reference here for the in-flight I/O. 1942 * Hold the md reference here for the in-flight I/O.
1935 * We can't rely on the reference count by device opener, 1943 * We can't rely on the reference count by device opener,
@@ -1982,6 +1990,10 @@ static void dm_request_fn(struct request_queue *q)
1982 continue; 1990 continue;
1983 } 1991 }
1984 1992
1993 if (md_in_flight(md) && rq->bio && rq->bio->bi_vcnt == 1 &&
1994 md->last_rq_pos == pos && md->last_rq_rw == rq_data_dir(rq))
1995 goto delay_and_out;
1996
1985 if (ti->type->busy && ti->type->busy(ti)) 1997 if (ti->type->busy && ti->type->busy(ti))
1986 goto delay_and_out; 1998 goto delay_and_out;
1987 1999