
From: Jens Axboe <axboe@suse.de>

dm bits


---

 25-akpm/drivers/md/dm-table.c |   23 +++++++++++++++++++++++
 25-akpm/drivers/md/dm.c       |   16 ++++++++++++++++
 25-akpm/drivers/md/dm.h       |    1 +
 3 files changed, 40 insertions(+)

diff -puN drivers/md/dm.c~disk-barrier-dm drivers/md/dm.c
--- 25/drivers/md/dm.c~disk-barrier-dm	2004-05-21 02:36:29.166280040 -0700
+++ 25-akpm/drivers/md/dm.c	2004-05-21 02:36:29.173278976 -0700
@@ -585,6 +585,21 @@ static int dm_request(request_queue_t *q
 	return 0;
 }
 
+static int dm_flush_all(request_queue_t *q, struct gendisk *disk,
+			sector_t *error_sector)
+{
+	struct mapped_device *md = q->queuedata;
+	struct dm_table *map = dm_get_table(md);
+	int ret = -ENXIO;
+
+	if (map) {
+		ret = dm_table_flush_all(md->map);
+		dm_table_put(map);
+	}
+
+	return ret;
+}
+
 static void dm_unplug_all(request_queue_t *q)
 {
 	struct mapped_device *md = q->queuedata;
@@ -694,6 +709,7 @@ static struct mapped_device *alloc_dev(u
 	md->queue->backing_dev_info.congested_data = md;
 	blk_queue_make_request(md->queue, dm_request);
 	md->queue->unplug_fn = dm_unplug_all;
+	md->queue->issue_flush_fn = dm_flush_all;
 
 	md->io_pool = mempool_create(MIN_IOS, mempool_alloc_slab,
 				     mempool_free_slab, _io_cache);
diff -puN drivers/md/dm.h~disk-barrier-dm drivers/md/dm.h
--- 25/drivers/md/dm.h~disk-barrier-dm	2004-05-21 02:36:29.168279736 -0700
+++ 25-akpm/drivers/md/dm.h	2004-05-21 02:36:29.174278824 -0700
@@ -117,6 +117,7 @@ void dm_table_suspend_targets(struct dm_
 void dm_table_resume_targets(struct dm_table *t);
 int dm_table_any_congested(struct dm_table *t, int bdi_bits);
 void dm_table_unplug_all(struct dm_table *t);
+int dm_table_flush_all(struct dm_table *t);
 
 /*-----------------------------------------------------------------
  * A registry of target types.
diff -puN drivers/md/dm-table.c~disk-barrier-dm drivers/md/dm-table.c
--- 25/drivers/md/dm-table.c~disk-barrier-dm	2004-05-21 02:36:29.169279584 -0700
+++ 25-akpm/drivers/md/dm-table.c	2004-05-21 02:36:29.174278824 -0700
@@ -900,6 +900,28 @@ void dm_table_unplug_all(struct dm_table
 	}
 }
 
+int dm_table_flush_all(struct dm_table *t)
+{
+	struct list_head *d, *devices = dm_table_get_devices(t);
+	int ret = 0;
+
+	for (d = devices->next; d != devices; d = d->next) {
+		struct dm_dev *dd = list_entry(d, struct dm_dev, list);
+		request_queue_t *q = bdev_get_queue(dd->bdev);
+		int err;
+
+		if (!q->issue_flush_fn)
+			err = -EOPNOTSUPP;
+		else
+			err = q->issue_flush_fn(q, dd->bdev->bd_disk, NULL);
+
+		if (!ret)
+			ret = err;
+	}
+
+	return ret;
+}
+
 EXPORT_SYMBOL(dm_vcalloc);
 EXPORT_SYMBOL(dm_get_device);
 EXPORT_SYMBOL(dm_put_device);
@@ -908,3 +930,4 @@ EXPORT_SYMBOL(dm_table_get_mode);
 EXPORT_SYMBOL(dm_table_put);
 EXPORT_SYMBOL(dm_table_get);
 EXPORT_SYMBOL(dm_table_unplug_all);
+EXPORT_SYMBOL(dm_table_flush_all);

_
