mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-kernel@vger.kernel.org
Cc: Dmitry Monakhov <dmonakhov@openvz.org>,
	Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	dm-devel@redhat.com
Subject: [PATCH 2/4] md: add flush_idx support for stacked devices
Date: Tue, 14 Oct 2014 14:03:53 +0400	[thread overview]
Message-ID: <1413281035-6483-3-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1413281035-6483-1-git-send-email-dmonakhov@openvz.org>

For single device mapping it is safe to introduce get_flush_idx conception.
This cover most common case linear mapping for a single dev.

CC: Alasdair Kergon <agk@redhat.com>
CC: Mike Snitzer <snitzer@redhat.com>
CC: dm-devel@redhat.com
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 drivers/md/dm.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 32b958d..042d172 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1843,6 +1843,36 @@ static int dm_any_congested(void *congested_data, int bdi_bits)
 	return r;
 }
 
+static int dm_iter_get_flush_idx(struct dm_target *ti,
+				struct dm_dev *dev, sector_t start,
+				sector_t len, void *data)
+{
+	struct block_device *bdev = dev->bdev;
+	struct request_queue *q = bdev_get_queue(bdev);
+
+	return blk_get_flush_idx(q,  *((bool *)data));
+}
+
+static unsigned dm_get_flush_idx(struct request_queue *q, bool queued)
+{
+	struct dm_target *ti;
+	struct mapped_device *md = q->queuedata;
+	struct dm_table *map = dm_get_live_table_fast(md);
+	unsigned fid = 0;
+
+	if (unlikely(!map || dm_table_get_num_targets(map) != 1))
+		goto out;
+
+	ti = dm_table_get_target(map, 0);
+	if (unlikely(!ti || !ti->type->iterate_devices))
+		goto out;
+
+	fid = ti->type->iterate_devices(ti, dm_iter_get_flush_idx, &queued);
+out:
+	dm_put_live_table_fast(md);
+	return fid;
+}
+
 /*-----------------------------------------------------------------
  * An IDR is used to keep track of allocated minor numbers.
  *---------------------------------------------------------------*/
@@ -1962,6 +1992,7 @@ static struct mapped_device *alloc_dev(int minor)
 		goto bad_queue;
 
 	dm_init_md_queue(md);
+	blk_queue_get_flush_idx(md->queue, dm_get_flush_idx);
 
 	md->disk = alloc_disk(1);
 	if (!md->disk)
-- 
1.7.1


  parent reply	other threads:[~2014-10-14 10:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-14 10:03 [PATCH 0/4] blkdev: flush optimization Dmitry Monakhov
2014-10-14 10:03 ` [PATCH 1/4] blkdev: add flush generation counter Dmitry Monakhov
2014-10-16 14:24   ` Ming Lei
2014-10-16 15:14     ` Dmitry Monakhov
2014-10-18  9:59       ` Ming Lei
2014-10-18 11:52         ` Dmitry Monakhov
2014-10-14 10:03 ` Dmitry Monakhov [this message]
2014-10-14 12:25   ` [PATCH 2/4] md: add flush_idx support for stacked devices Mike Snitzer
2014-10-14 10:03 ` [PATCH 3/4] ext4: cleanup data integrity sync fo nonjournal mode Dmitry Monakhov
2014-10-14 10:03 ` [PATCH 4/4] ext4: Add fdatasync scalability optimization Dmitry Monakhov
2014-10-14 10:57   ` Christoph Hellwig
2014-10-14 11:25     ` Dmitry Monakhov
2014-10-14 11:35       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413281035-6483-3-git-send-email-dmonakhov@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®