From: Mikulas Patocka <[email-masked]>

Introduce a callback pointer from the log to dm-raid1 layer.

Before some region is set as "in-sync", we need to flush hardware cache on
all the disks. But the log module doesn't have access to the mirror_set
structure. So it will use this callback.

So far the callback is unused, it will be used in further patches.

Signed-off-by: Mikulas Patocka <[email-masked]>

---
 drivers/md/dm-log.c            |    4 ++--
 drivers/md/dm-raid1.c          |    6 +++---
 drivers/md/dm-region-hash.c    |    8 ++++----
 include/linux/dm-dirty-log.h   |    4 ++--
 include/linux/dm-region-hash.h |    4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)

Index: linux-2.6.30/drivers/md/dm-log.c
===================================================================
--- linux-2.6.30.orig/drivers/md/dm-log.c
+++ linux-2.6.30/drivers/md/dm-log.c
@@ -664,13 +664,13 @@ static int core_in_sync(struct dm_dirty_
 	return log_test_bit(lc->sync_bits, region);
 }
 
-static int core_flush(struct dm_dirty_log *log)
+static int core_flush(struct dm_dirty_log *log, int (*flush)(void *), void *cookie)
 {
 	/* no op */
 	return 0;
 }
 
-static int disk_flush(struct dm_dirty_log *log)
+static int disk_flush(struct dm_dirty_log *log, int (*flush)(void *), void *cookie)
 {
 	int r;
 	struct log_c *lc = (struct log_c *) log->context;
Index: linux-2.6.30/drivers/md/dm-raid1.c
===================================================================
--- linux-2.6.30.orig/drivers/md/dm-raid1.c
+++ linux-2.6.30/drivers/md/dm-raid1.c
@@ -654,7 +654,7 @@ static void do_writes(struct mirror_set 
 	 */
 	dm_rh_inc_pending(ms->rh, &sync);
 	dm_rh_inc_pending(ms->rh, &nosync);
-	ms->log_failure = dm_rh_flush(ms->rh) ? 1 : 0;
+	ms->log_failure = dm_rh_flush(ms->rh, NULL, NULL) ? 1 : 0;
 
 	/*
 	 * Dispatch io.
@@ -755,7 +755,7 @@ static void do_mirror(struct work_struct
 	bio_list_init(&ms->failures);
 	spin_unlock_irqrestore(&ms->lock, flags);
 
-	dm_rh_update_states(ms->rh, errors_handled(ms));
+	dm_rh_update_states(ms->rh, errors_handled(ms), NULL, NULL);
 	do_recovery(ms);
 	do_reads(ms, &reads);
 	do_writes(ms, &writes);
@@ -1211,7 +1211,7 @@ static void mirror_postsuspend(struct dm
 	struct mirror_set *ms = ti->private;
 	struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh);
 
-	if (log->type->postsuspend && log->type->postsuspend(log))
+	if (log->type->postsuspend && log->type->postsuspend(log, NULL, NULL))
 		/* FIXME: need better error handling */
 		DMWARN("log postsuspend failed");
 }
Index: linux-2.6.30/drivers/md/dm-region-hash.c
===================================================================
--- linux-2.6.30.orig/drivers/md/dm-region-hash.c
+++ linux-2.6.30/drivers/md/dm-region-hash.c
@@ -436,7 +436,7 @@ void dm_rh_mark_nosync(struct dm_region_
 }
 EXPORT_SYMBOL_GPL(dm_rh_mark_nosync);
 
-void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled)
+void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled, int (*flush)(void *), void *cookie)
 {
 	struct dm_region *reg, *next;
 
@@ -495,7 +495,7 @@ void dm_rh_update_states(struct dm_regio
 		mempool_free(reg, rh->region_pool);
 	}
 
-	rh->log->type->flush(rh->log);
+	rh->log->type->flush(rh->log, flush, cookie);
 }
 EXPORT_SYMBOL_GPL(dm_rh_update_states);
 
@@ -681,9 +681,9 @@ int dm_rh_recovery_in_flight(struct dm_r
 }
 EXPORT_SYMBOL_GPL(dm_rh_recovery_in_flight);
 
-int dm_rh_flush(struct dm_region_hash *rh)
+int dm_rh_flush(struct dm_region_hash *rh, int (*flush)(void *), void *cookie)
 {
-	return rh->log->type->flush(rh->log);
+	return rh->log->type->flush(rh->log, flush, cookie);
 }
 EXPORT_SYMBOL_GPL(dm_rh_flush);
 
Index: linux-2.6.30/include/linux/dm-dirty-log.h
===================================================================
--- linux-2.6.30.orig/include/linux/dm-dirty-log.h
+++ linux-2.6.30/include/linux/dm-dirty-log.h
@@ -40,7 +40,7 @@ struct dm_dirty_log_type {
 	 * the disk.
 	 */
 	int (*presuspend)(struct dm_dirty_log *log);
-	int (*postsuspend)(struct dm_dirty_log *log);
+	int (*postsuspend)(struct dm_dirty_log *log, int (*flush)(void *), void *cookie);
 	int (*resume)(struct dm_dirty_log *log);
 
 	/*
@@ -73,7 +73,7 @@ struct dm_dirty_log_type {
 	 * Flush the current log state (eg, to disk).  This
 	 * function may block.
 	 */
-	int (*flush)(struct dm_dirty_log *log);
+	int (*flush)(struct dm_dirty_log *log, int (*flush)(void *), void *cookie);
 
 	/*
 	 * Mark an area as clean or dirty.  These functions may
Index: linux-2.6.30/include/linux/dm-region-hash.h
===================================================================
--- linux-2.6.30.orig/include/linux/dm-region-hash.h
+++ linux-2.6.30/include/linux/dm-region-hash.h
@@ -66,10 +66,10 @@ void dm_rh_set_state(struct dm_region_ha
 		     enum dm_rh_region_states state, int may_block);
 
 /* Non-zero errors_handled leaves the state of the region NOSYNC */
-void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled);
+void dm_rh_update_states(struct dm_region_hash *rh, int errors_handled, int (*flush)(void *), void *cookie);
 
 /* Flush the region hash and dirty log. */
-int dm_rh_flush(struct dm_region_hash *rh);
+int dm_rh_flush(struct dm_region_hash *rh, int (*flush)(void *), void *cookie);
 
 /* Inc/dec pending count on regions. */
 void dm_rh_inc_pending(struct dm_region_hash *rh, struct bio_list *bios);