From: Mike Anderson <[email-masked]>

Once we begin deleting a device, prevent any further messages being sent 
to targets of its table (to avoid races).

Signed-off-by: Mike Anderson <[email-masked]>
Signed-off-by: Alasdair G Kergon <[email-masked]>
---
 drivers/md/dm-ioctl.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: linux-2.6.32/drivers/md/dm-ioctl.c
===================================================================
--- linux-2.6.32.orig/drivers/md/dm-ioctl.c
+++ linux-2.6.32/drivers/md/dm-ioctl.c
@@ -1303,6 +1303,11 @@ static int target_message(struct dm_ioct
 	if (!table)
 		goto out_argv;
 
+	if (dm_deleting_md(md)) {
+		r = -ENXIO;
+		goto out_table;
+	}
+
 	ti = dm_table_find_target(table, tmsg->sector);
 	if (!dm_target_is_valid(ti)) {
 		DMWARN("Target message sector outside device.");
@@ -1314,6 +1319,7 @@ static int target_message(struct dm_ioct
 		r = -EINVAL;
 	}
 
+ out_table:
 	dm_table_put(table);
  out_argv:
 	kfree(argv);