Skip to contentSkip to conversation

Add deleting state check for target messages

PATCH In review Mike Anderson 4 participants 8 messages Nov 13, 2009 – Nov 16, 2009 Device mapper

lore
Share & tools
lore
#0 lore raw

cover Add deleting state check for target messages

This patch adds a accessor function that allows determining if a mapped_device is in the deleting state and then adds this check to the target_message function. The result of this change would be that all targets would not be allowed to process messages post a mapped device entering the deleting state.

As previously described in the email at the archive url provided below the target_message ioctl can result in new work / activities being started post the mapped device entering states that new target work could cause issues.

http://permalink.gmane.org/gmane.linux.kernel.device-mapper.devel/10486

This patch depends on the previous patch that added dm_suspended_check due to proximity of changes in common files.

---

Mike Anderson (3):
dm: Add dm_deleting accesor function
dm: Add accessor dm_table_md_deleting
dm: Add deleting check to target_message

 drivers/md/dm-ioctl.c         |    6 ++++++
 drivers/md/dm-table.c         |    6 ++++++
 drivers/md/dm.c               |    5 +++++
 include/linux/device-mapper.h |    2 ++
 4 files changed, 19 insertions(+), 0 deletions(-)

--
-andmike

Michael Anderson <[email protected]>

#1 lore raw

PATCH 1/3 dm: Add dm_deleting accesor function

Add dm_deleting accesor function to allow checking of the DMF_DELETING bit.

---
 drivers/md/dm.c               |    5 +++++
 include/linux/device-mapper.h |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)
drivers/md/dm.c +5 -0
index 724efc6..96127cc 100644
@@ -2604,6 +2604,11 @@ int dm_suspended(struct mapped_device *md)
 	return test_bit(DMF_SUSPENDED, &md->flags);
 }
 
+int dm_deleting(struct mapped_device *md)
+{
+	return test_bit(DMF_DELETING, &md->flags);
+}
+
 int dm_noflush_suspending(struct dm_target *ti)
 {
 	struct mapped_device *md = dm_table_get_md(ti->table);
include/linux/device-mapper.h +1 -0
index 3440c54..16cd291 100644
@@ -236,6 +236,7 @@ const char *dm_device_name(struct mapped_device *md);
 int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid);
 struct gendisk *dm_disk(struct mapped_device *md);
 int dm_suspended(struct mapped_device *md);
+int dm_deleting(struct mapped_device *md);
 int dm_noflush_suspending(struct dm_target *ti);
 union map_info *dm_get_mapinfo(struct bio *bio);
 union map_info *dm_get_rq_mapinfo(struct request *rq);
#2 lore raw

PATCH 2/3 dm: Add accessor dm_table_md_deleting

In reply to Mike Anderson

Add a dm_table accessor function to check if md is being deleted.

---
 drivers/md/dm-table.c         |    6 ++++++
 include/linux/device-mapper.h |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)
drivers/md/dm-table.c +6 -0
index 6616598..fdf86fe 100644
@@ -1250,6 +1250,11 @@ int dm_table_md_suspended(struct dm_table *t)
 	return dm_suspended(t->md);
 }
 
+int dm_table_md_deleting(struct dm_table *t)
+{
+	return dm_deleting(t->md);
+}
+
 EXPORT_SYMBOL(dm_vcalloc);
 EXPORT_SYMBOL(dm_get_device);
 EXPORT_SYMBOL(dm_put_device);
@@ -1261,3 +1266,4 @@ EXPORT_SYMBOL(dm_table_put);
 EXPORT_SYMBOL(dm_table_get);
 EXPORT_SYMBOL(dm_table_unplug_all);
 EXPORT_SYMBOL(dm_table_md_suspended);
+EXPORT_SYMBOL(dm_table_md_deleting);
include/linux/device-mapper.h +1 -0
index 16cd291..5a0fb6c 100644
@@ -289,6 +289,7 @@ unsigned int dm_table_get_num_targets(struct dm_table *t);
 fmode_t dm_table_get_mode(struct dm_table *t);
 struct mapped_device *dm_table_get_md(struct dm_table *t);
 int dm_table_md_suspended(struct dm_table *t);
+int dm_table_md_deleting(struct dm_table *t);
 
 /*
  * Trigger an event.
#3 lore raw

PATCH 3/3 dm: Add deleting check to target_message

In reply to Mike Anderson

Add dm_table_md_deleting check to target_message

---
 drivers/md/dm-ioctl.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/md/dm-ioctl.c +6 -0
index a679429..04e252c 100644
@@ -1292,6 +1292,11 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
 	if (!table)
 		goto out_argv;
 
+	if (dm_table_md_deleting(table)) {
+		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.");
@@ -1303,6 +1308,7 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
 		r = -EINVAL;
 	}
 
+ out_table:
 	dm_table_put(table);
  out_argv:
 	kfree(argv);
#4 lore raw

Re: [PATCH 3/3] dm: Add deleting check to target_message

Quoted 12 lines · Mike Anderson [[email protected]] wrote:

Add dm_table_md_deleting check to target_message

---
 drivers/md/dm-ioctl.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/md/dm-ioctl.c +0 -0
index a679429..04e252c 100644

drivers/md/dm-ioctl.c static int target_message(struct dm_ioctl *param, size_t param_size) · line 1298

Quoted 7 lines
drivers/md/dm-ioctl.c +4 -0
@@ -1292,6 +1292,11 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
 	if (!table)
 		goto out_argv;
 
+	if (dm_table_md_deleting(table)) {
+		r = -ENXIO;
+		goto out_table;
+	}

Is there some reason that DELETING bit won't be set while executing the rest of the following code. If not, what is the point of checking the bit above?

Quoted 17 lines
drivers/md/dm-ioctl.c +1 -1
 	ti = dm_table_find_target(table, tmsg->sector);
 	if (!dm_target_is_valid(ti)) {
 		DMWARN("Target message sector outside device.");
@@ -1303,6 +1308,7 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
 		r = -EINVAL;
 	}
 
+ out_table:
 	dm_table_put(table);
  out_argv:
 	kfree(argv);
 
--

dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#5 lore raw
In reply to Mike Anderson

Hi Mike,

Quoted 6 lines · Mike Anderson

This patch adds a accessor function that allows determining if a mapped_device is in the deleting state and then adds this check to the target_message function. The result of this change would be that all targets would not be allowed to process messages post a mapped device entering the deleting state.

Quoted 6 lines

As previously described in the email at the archive url provided below the target_message ioctl can result in new work / activities being started post the mapped device entering states that new target work could cause issues.

http://permalink.gmane.org/gmane.linux.kernel.device-mapper.devel/10486

Thank you for the patch-set.
Although I'm not sure this patch-set is really needed after the fix of message ioctl during suspend will have been done, I understand why you want this patch-set (since issuing message ioctl to a deleting device is a bit pointless).

But there is a small window in this patch-set as Malahal described. Also, I have some comments below:
o Please use drivers/md/dm.h instead of include/linux/device-mapper.h and don't export symbols, because all accessors you are adding are used in only dm-core, no target uses them.

o target_message() can use dm_deleting(), because target_message() has a reference to the md.
We don't need the table function, dm_table_md_deleting(), at all.

Thanks,
Kiyoshi Ueda

#6 lore raw
Quoted 14 lines · Kiyoshi Ueda

Hi Mike,

Quoted 11 lines · Mike Anderson

This patch adds a accessor function that allows determining if a mapped_device is in the deleting state and then adds this check to the target_message function. The result of this change would be that all targets would not be allowed to process messages post a mapped device entering the deleting state.

As previously described in the email at the archive url provided below the target_message ioctl can result in new work / activities being started post the mapped device entering states that new target work could cause issues.

Quoted 8 lines
Quoted 1 line

http://permalink.gmane.org/gmane.linux.kernel.device-mapper.devel/10486

Thank you for the patch-set.
Although I'm not sure this patch-set is really needed after the fix of message ioctl during suspend will have been done, I understand why you want this patch-set (since issuing message ioctl to a deleting device is a bit pointless).

Yes this patch set should not be needed post the fix to the message ioctl. The reduction was aimed at future callers using dm_get_md prior to DMF_FREEING being set as the dm_table_destroy holders wait would not proceed until current message operations had completed, but the reduction of this case is not that important with the other message ioctl changes in place.

This patch set can be dropped.

Quoted 10 lines

But there is a small window in this patch-set as Malahal described. Also, I have some comments below:
o Please use drivers/md/dm.h instead of include/linux/device-mapper.h and don't export symbols, because all accessors you are adding are used in only dm-core, no target uses them.

o target_message() can use dm_deleting(), because target_message() has a reference to the md.
We don't need the table function, dm_table_md_deleting(), at all.

Thanks for the review tip.

-andmike
--
Michael Anderson
[email protected]

#7 lore raw
Quoted 6 lines · Mike Anderson

Yes this patch set should not be needed post the fix to the message ioctl. The reduction was aimed at future callers using dm_get_md prior to DMF_FREEING being set as the dm_table_destroy holders wait would not proceed until current message operations had completed, but the reduction of this case is not that important with the other message ioctl changes in place.

I've left it in my tree for now (with the suggested simplifications - private to dm.h), to enforce the situation that the dm core will not forward messages to table targets after they begin to be deleted.

Alasdair