From: NeilBrown <[email-masked]>

Add .iterate_devices function which should be implemented for all DM
targets.

Add an .io_hints function too because the provided topology information
is particularly important for a raid device.

Cc: [email-masked]
Signed-off-by: NeilBrown <[email-masked]>
Signed-off-by: Jonathan Brassow <[email-masked]>
Signed-off-by: Mike Snitzer <[email-masked]>

---
drivers/md/dm-raid.c |   33 +++++++++++++++++++++++++++++++++
 drivers/md/dm-raid.c |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Index: linux-2.6.37/drivers/md/dm-raid.c
===================================================================
--- linux-2.6.37.orig/drivers/md/dm-raid.c
+++ linux-2.6.37/drivers/md/dm-raid.c
@@ -575,6 +575,37 @@ static int raid_status(struct dm_target 
 	return 0;
 }
 
+static int raid_iterate_devices(struct dm_target *ti,
+				iterate_devices_callout_fn fn,
+				void *data)
+{
+	struct raid_set *rs = ti->private;
+	int ret = 0;
+	unsigned i = 0;
+
+	for (i = 0; !ret && i < rs->md.raid_disks; i++)
+		if (rs->dev[i].data_dev)
+			ret = fn(ti,
+				 rs->dev[i].data_dev,
+				 0, /* No offset on data devs */
+				 rs->md.dev_sectors,
+				 data);
+
+	return ret;
+}
+
+static void raid_io_hints(struct dm_target *ti,
+			  struct queue_limits *limits)
+{
+	struct raid_set *rs = ti->private;
+	unsigned chunk_size = rs->md.chunk_sectors << 9;
+	raid5_conf_t *conf = rs->md.private;
+
+	blk_limits_io_min(limits, chunk_size);
+	blk_limits_io_opt(limits, chunk_size *
+			  (conf->raid_disks - conf->max_degraded));
+}
+
 static struct target_type raid_target = {
 	.name = "raid",
 	.version = {1, 0, 0},
@@ -583,6 +614,8 @@ static struct target_type raid_target = 
 	.dtr = raid_dtr,
 	.map = raid_map,
 	.status = raid_status,
+	.iterate_devices = raid_iterate_devices,
+	.io_hints = raid_io_hints,
 };
 
 static int __init dm_raid_init(void)