Add deleting state check for target messages
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]>
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
@@ -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
@@ -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);
PATCH 2/3 dm: Add accessor dm_table_md_deleting
In reply to Mike AndersonAdd 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
@@ -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
@@ -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.
PATCH 3/3 dm: Add deleting check to target_message
In reply to Mike AndersonAdd 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
@@ -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);
Re: [PATCH 3/3] dm: Add deleting check to target_message
Quoted 12 lines · Mike Anderson [[email protected]] wrote:
Add
dm_table_md_deletingcheck totarget_messageSigned-off-by Mike Anderson <[email protected]>--- drivers/md/dm-ioctl.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)drivers/md/dm-ioctl.c +0
-0
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
-1ti =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
Hi Mike,
Quoted 6 lines · Mike Anderson
This patch adds a accessor function that allows determining if a
mapped_deviceis in the deleting state and then adds this check to thetarget_messagefunction. 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_messageioctl 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
Quoted 14 lines · Kiyoshi Ueda
Hi Mike,
Quoted 11 lines · Mike Anderson
This patch adds a accessor function that allows determining if a
mapped_deviceis in the deleting state and then adds this check to thetarget_messagefunction. 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_messageioctl can result in new work / activities being started post the mapped device entering states that new target work could cause issues.
Quoted 8 lines
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 usedrivers/md/dm.hinstead ofinclude/linux/device-mapper.hand don't export symbols, because all accessors you are adding are used in only dm-core, no target uses them.o
target_message()can usedm_deleting(), becausetarget_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]
Alasdair G Kergon
maintainerQuoted 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_mdprior toDMF_FREEINGbeing set as thedm_table_destroyholders 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