diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2010-03-05 21:32:31 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2010-03-05 21:32:31 -0500 |
commit | 3abf85b5b5851b5f28d3d8a920ebb844edd08352 (patch) | |
tree | b59e5c9322cc116b0ce5dc183d3b8286080c6031 /drivers/md | |
parent | a97f925a32aad2a37971d7bfb657006acf04e42d (diff) |
dm ioctl: introduce flag indicating uevent was generated
Set a new DM_UEVENT_GENERATED_FLAG when returning from ioctls to
indicate that a uevent was actually generated. This tells the userspace
caller that it may need to wait for the event to be processed.
Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-ioctl.c | 19 | ||||
-rw-r--r-- | drivers/md/dm.c | 7 | ||||
-rw-r--r-- | drivers/md/dm.h | 4 |
3 files changed, 18 insertions, 12 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index e3cf5686d0aa..d7500e1c26f2 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -285,7 +285,8 @@ retry: | |||
285 | up_write(&_hash_lock); | 285 | up_write(&_hash_lock); |
286 | } | 286 | } |
287 | 287 | ||
288 | static int dm_hash_rename(uint32_t cookie, const char *old, const char *new) | 288 | static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old, |
289 | const char *new) | ||
289 | { | 290 | { |
290 | char *new_name, *old_name; | 291 | char *new_name, *old_name; |
291 | struct hash_cell *hc; | 292 | struct hash_cell *hc; |
@@ -344,7 +345,8 @@ static int dm_hash_rename(uint32_t cookie, const char *old, const char *new) | |||
344 | dm_table_put(table); | 345 | dm_table_put(table); |
345 | } | 346 | } |
346 | 347 | ||
347 | dm_kobject_uevent(hc->md, KOBJ_CHANGE, cookie); | 348 | if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, cookie)) |
349 | *flags |= DM_UEVENT_GENERATED_FLAG; | ||
348 | 350 | ||
349 | dm_put(hc->md); | 351 | dm_put(hc->md); |
350 | up_write(&_hash_lock); | 352 | up_write(&_hash_lock); |
@@ -736,10 +738,10 @@ static int dev_remove(struct dm_ioctl *param, size_t param_size) | |||
736 | __hash_remove(hc); | 738 | __hash_remove(hc); |
737 | up_write(&_hash_lock); | 739 | up_write(&_hash_lock); |
738 | 740 | ||
739 | dm_kobject_uevent(md, KOBJ_REMOVE, param->event_nr); | 741 | if (!dm_kobject_uevent(md, KOBJ_REMOVE, param->event_nr)) |
742 | param->flags |= DM_UEVENT_GENERATED_FLAG; | ||
740 | 743 | ||
741 | dm_put(md); | 744 | dm_put(md); |
742 | param->data_size = 0; | ||
743 | return 0; | 745 | return 0; |
744 | } | 746 | } |
745 | 747 | ||
@@ -773,7 +775,9 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size) | |||
773 | return r; | 775 | return r; |
774 | 776 | ||
775 | param->data_size = 0; | 777 | param->data_size = 0; |
776 | return dm_hash_rename(param->event_nr, param->name, new_name); | 778 | |
779 | return dm_hash_rename(param->event_nr, ¶m->flags, param->name, | ||
780 | new_name); | ||
777 | } | 781 | } |
778 | 782 | ||
779 | static int dev_set_geometry(struct dm_ioctl *param, size_t param_size) | 783 | static int dev_set_geometry(struct dm_ioctl *param, size_t param_size) |
@@ -899,8 +903,8 @@ static int do_resume(struct dm_ioctl *param) | |||
899 | 903 | ||
900 | if (dm_suspended_md(md)) { | 904 | if (dm_suspended_md(md)) { |
901 | r = dm_resume(md); | 905 | r = dm_resume(md); |
902 | if (!r) | 906 | if (!r && !dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr)) |
903 | dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr); | 907 | param->flags |= DM_UEVENT_GENERATED_FLAG; |
904 | } | 908 | } |
905 | 909 | ||
906 | if (old_map) | 910 | if (old_map) |
@@ -1477,6 +1481,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param) | |||
1477 | { | 1481 | { |
1478 | /* Always clear this flag */ | 1482 | /* Always clear this flag */ |
1479 | param->flags &= ~DM_BUFFER_FULL_FLAG; | 1483 | param->flags &= ~DM_BUFFER_FULL_FLAG; |
1484 | param->flags &= ~DM_UEVENT_GENERATED_FLAG; | ||
1480 | 1485 | ||
1481 | /* Ignores parameters */ | 1486 | /* Ignores parameters */ |
1482 | if (cmd == DM_REMOVE_ALL_CMD || | 1487 | if (cmd == DM_REMOVE_ALL_CMD || |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 7199846364e9..d21e1284604f 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -2618,18 +2618,19 @@ out: | |||
2618 | /*----------------------------------------------------------------- | 2618 | /*----------------------------------------------------------------- |
2619 | * Event notification. | 2619 | * Event notification. |
2620 | *---------------------------------------------------------------*/ | 2620 | *---------------------------------------------------------------*/ |
2621 | void dm_kobject_uevent(struct mapped_device *md, enum kobject_action action, | 2621 | int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action, |
2622 | unsigned cookie) | 2622 | unsigned cookie) |
2623 | { | 2623 | { |
2624 | char udev_cookie[DM_COOKIE_LENGTH]; | 2624 | char udev_cookie[DM_COOKIE_LENGTH]; |
2625 | char *envp[] = { udev_cookie, NULL }; | 2625 | char *envp[] = { udev_cookie, NULL }; |
2626 | 2626 | ||
2627 | if (!cookie) | 2627 | if (!cookie) |
2628 | kobject_uevent(&disk_to_dev(md->disk)->kobj, action); | 2628 | return kobject_uevent(&disk_to_dev(md->disk)->kobj, action); |
2629 | else { | 2629 | else { |
2630 | snprintf(udev_cookie, DM_COOKIE_LENGTH, "%s=%u", | 2630 | snprintf(udev_cookie, DM_COOKIE_LENGTH, "%s=%u", |
2631 | DM_COOKIE_ENV_VAR_NAME, cookie); | 2631 | DM_COOKIE_ENV_VAR_NAME, cookie); |
2632 | kobject_uevent_env(&disk_to_dev(md->disk)->kobj, action, envp); | 2632 | return kobject_uevent_env(&disk_to_dev(md->disk)->kobj, |
2633 | action, envp); | ||
2633 | } | 2634 | } |
2634 | } | 2635 | } |
2635 | 2636 | ||
diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 8dadaa5bc396..bad1724d4869 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h | |||
@@ -125,8 +125,8 @@ void dm_stripe_exit(void); | |||
125 | int dm_open_count(struct mapped_device *md); | 125 | int dm_open_count(struct mapped_device *md); |
126 | int dm_lock_for_deletion(struct mapped_device *md); | 126 | int dm_lock_for_deletion(struct mapped_device *md); |
127 | 127 | ||
128 | void dm_kobject_uevent(struct mapped_device *md, enum kobject_action action, | 128 | int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action, |
129 | unsigned cookie); | 129 | unsigned cookie); |
130 | 130 | ||
131 | int dm_io_init(void); | 131 | int dm_io_init(void); |
132 | void dm_io_exit(void); | 132 | void dm_io_exit(void); |