aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm.c
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2009-04-08 19:27:14 -0400
committerAlasdair G Kergon <agk@redhat.com>2009-04-08 19:27:14 -0400
commit54d9a1b4513b96cbd835ca6866c6a604d194b2ae (patch)
tree42813374e137f5ac6d9d7aedfae02a089b6443a6 /drivers/md/dm.c
parent1eb787ec183d1267cac95aae632e92dee05ed50a (diff)
dm: simplify dm_request loop
Refactor the code in dm_request(). Require the new DMF_BLOCK_FOR_SUSPEND flag on readahead bios we will discard so we don't drop such bios while processing a barrier. Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm.c')
-rw-r--r--drivers/md/dm.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 7cac7220937f..bb97ec8d6644 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -929,7 +929,6 @@ out:
929 */ 929 */
930static int dm_request(struct request_queue *q, struct bio *bio) 930static int dm_request(struct request_queue *q, struct bio *bio)
931{ 931{
932 int r = -EIO;
933 int rw = bio_data_dir(bio); 932 int rw = bio_data_dir(bio);
934 struct mapped_device *md = q->queuedata; 933 struct mapped_device *md = q->queuedata;
935 int cpu; 934 int cpu;
@@ -957,11 +956,14 @@ static int dm_request(struct request_queue *q, struct bio *bio)
957 while (test_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags)) { 956 while (test_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags)) {
958 up_read(&md->io_lock); 957 up_read(&md->io_lock);
959 958
960 if (bio_rw(bio) != READA) 959 if (unlikely(test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) &&
961 r = queue_io(md, bio); 960 bio_rw(bio) == READA) {
961 bio_io_error(bio);
962 return 0;
963 }
962 964
963 if (r <= 0) 965 if (!queue_io(md, bio))
964 goto out_req; 966 return 0;
965 967
966 /* 968 /*
967 * We're in a while loop, because someone could suspend 969 * We're in a while loop, because someone could suspend
@@ -973,12 +975,6 @@ static int dm_request(struct request_queue *q, struct bio *bio)
973 __split_and_process_bio(md, bio); 975 __split_and_process_bio(md, bio);
974 up_read(&md->io_lock); 976 up_read(&md->io_lock);
975 return 0; 977 return 0;
976
977out_req:
978 if (r < 0)
979 bio_io_error(bio);
980
981 return 0;
982} 978}
983 979
984static void dm_unplug_all(struct request_queue *q) 980static void dm_unplug_all(struct request_queue *q)