From c50abeb38026ea721a812cf8a9b2fac5d3b7684b Mon Sep 17 00:00:00 2001 From: Mike Anderson Date: Thu, 10 Dec 2009 23:52:20 +0000 Subject: [RHEL5.7 PATCH] dm ioctl: forbid messages to devices being deleted Upstream commit c50abeb38026ea721a812cf8a9b2fac5d3b7684b Author: Mike Anderson Date: Thu Dec 10 23:52:20 2009 +0000 dm ioctl: forbid messages to devices being deleted 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 Signed-off-by: Alasdair G Kergon --- drivers/md/dm-ioctl.c | 6 ++++++ 1 file changed, 6 insertions(+) Index: linux-rhel5/drivers/md/dm-ioctl.c =================================================================== --- linux-rhel5.orig/drivers/md/dm-ioctl.c +++ linux-rhel5/drivers/md/dm-ioctl.c @@ -1263,6 +1263,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."); @@ -1274,6 +1279,7 @@ static int target_message(struct dm_ioct r = -EINVAL; } + out_table: dm_table_put(table); out_argv: kfree(argv);