Perform hardware cache flush on all disks during barrier operation. This makes it possible to enable hardware write cache for linear mappings. Signed-off-by: Mikulas Patocka --- drivers/md/dm-table.c | 16 ++++++++++++++++ drivers/md/dm.c | 9 ++++++++- drivers/md/dm.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) Index: linux-2.6.28-clean/drivers/md/dm-table.c =================================================================== --- linux-2.6.28-clean.orig/drivers/md/dm-table.c 2009-01-12 15:16:29.000000000 +0100 +++ linux-2.6.28-clean/drivers/md/dm-table.c 2009-01-12 15:19:46.000000000 +0100 @@ -979,6 +979,22 @@ void dm_table_unplug_all(struct dm_table } } +int dm_table_flush_all(struct dm_table *t) +{ + int error = 0; + struct dm_dev_internal *dd; + struct list_head *devices = dm_table_get_devices(t); + + list_for_each_entry(dd, devices, list) { + /* !!! TODO: concurrent flush */ + int r = blkdev_issue_flush(dd->dm_dev.bdev, NULL); + if (unlikely(r) && unlikely(r != -EOPNOTSUPP) && !error) + error = r; + } + + return error; +} + struct mapped_device *dm_table_get_md(struct dm_table *t) { dm_get(t->md); Index: linux-2.6.28-clean/drivers/md/dm.c =================================================================== --- linux-2.6.28-clean.orig/drivers/md/dm.c 2009-01-12 15:19:40.000000000 +0100 +++ linux-2.6.28-clean/drivers/md/dm.c 2009-01-12 15:19:46.000000000 +0100 @@ -1363,8 +1363,15 @@ static int dm_wait_for_completion(struct static int dm_flush(struct mapped_device *md) { + int error; + struct dm_table *map; dm_wait_for_completion(md, TASK_UNINTERRUPTIBLE); - return 0; + map = dm_get_table(md); + if (!map) + return 0; + error = dm_table_flush_all(map); + dm_table_put(map); + return error; } static void __merge_pushback_list(struct mapped_device *md) Index: linux-2.6.28-clean/drivers/md/dm.h =================================================================== --- linux-2.6.28-clean.orig/drivers/md/dm.h 2009-01-12 15:16:29.000000000 +0100 +++ linux-2.6.28-clean/drivers/md/dm.h 2009-01-12 15:19:46.000000000 +0100 @@ -46,6 +46,7 @@ void dm_table_presuspend_targets(struct void dm_table_postsuspend_targets(struct dm_table *t); int dm_table_resume_targets(struct dm_table *t); int dm_table_any_congested(struct dm_table *t, int bdi_bits); +int dm_table_flush_all(struct dm_table *t); /* * To check the return value from dm_table_find_target().