Skip to content

Commit 3abf85b

Browse files
prajnohakergon
authored andcommitted
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>
1 parent a97f925 commit 3abf85b

4 files changed

Lines changed: 25 additions & 14 deletions

File tree

‎drivers/md/dm-ioctl.c‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ static void dm_hash_remove_all(int keep_open_devices)
285285
up_write(&_hash_lock);
286286
}
287287

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)
289290
{
290291
char *new_name, *old_name;
291292
struct hash_cell *hc;
@@ -344,7 +345,8 @@ static int dm_hash_rename(uint32_t cookie, const char *old, const char *new)
344345
dm_table_put(table);
345346
}
346347

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;
348350

349351
dm_put(hc->md);
350352
up_write(&_hash_lock);
@@ -736,10 +738,10 @@ static int dev_remove(struct dm_ioctl *param, size_t param_size)
736738
__hash_remove(hc);
737739
up_write(&_hash_lock);
738740

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;
740743

741744
dm_put(md);
742-
param->data_size = 0;
743745
return 0;
744746
}
745747

@@ -773,7 +775,9 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
773775
return r;
774776

775777
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, &param->flags, param->name,
780+
new_name);
777781
}
778782

779783
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)
899903

900904
if (dm_suspended_md(md)) {
901905
r = dm_resume(md);
902-
if (!r)
903-
dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr);
906+
if (!r && !dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr))
907+
param->flags |= DM_UEVENT_GENERATED_FLAG;
904908
}
905909

906910
if (old_map)
@@ -1477,6 +1481,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
14771481
{
14781482
/* Always clear this flag */
14791483
param->flags &= ~DM_BUFFER_FULL_FLAG;
1484+
param->flags &= ~DM_UEVENT_GENERATED_FLAG;
14801485

14811486
/* Ignores parameters */
14821487
if (cmd == DM_REMOVE_ALL_CMD ||

‎drivers/md/dm.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2618,18 +2618,19 @@ int dm_resume(struct mapped_device *md)
26182618
/*-----------------------------------------------------------------
26192619
* Event notification.
26202620
*---------------------------------------------------------------*/
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,
26222622
unsigned cookie)
26232623
{
26242624
char udev_cookie[DM_COOKIE_LENGTH];
26252625
char *envp[] = { udev_cookie, NULL };
26262626

26272627
if (!cookie)
2628-
kobject_uevent(&disk_to_dev(md->disk)->kobj, action);
2628+
return kobject_uevent(&disk_to_dev(md->disk)->kobj, action);
26292629
else {
26302630
snprintf(udev_cookie, DM_COOKIE_LENGTH, "%s=%u",
26312631
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);
26332634
}
26342635
}
26352636

‎drivers/md/dm.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ void dm_stripe_exit(void);
125125
int dm_open_count(struct mapped_device *md);
126126
int dm_lock_for_deletion(struct mapped_device *md);
127127

128-
void dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
129-
unsigned cookie);
128+
int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
129+
unsigned cookie);
130130

131131
int dm_io_init(void);
132132
void dm_io_exit(void);

‎include/linux/dm-ioctl.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ enum {
266266
#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
267267

268268
#define DM_VERSION_MAJOR 4
269-
#define DM_VERSION_MINOR 16
269+
#define DM_VERSION_MINOR 17
270270
#define DM_VERSION_PATCHLEVEL 0
271-
#define DM_VERSION_EXTRA "-ioctl (2009-11-05)"
271+
#define DM_VERSION_EXTRA "-ioctl (2010-03-05)"
272272

273273
/* Status bits */
274274
#define DM_READONLY_FLAG (1 << 0) /* In/Out */
@@ -316,4 +316,9 @@ enum {
316316
*/
317317
#define DM_QUERY_INACTIVE_TABLE_FLAG (1 << 12) /* In */
318318

319+
/*
320+
* If set, a uevent was generated for which the caller may need to wait.
321+
*/
322+
#define DM_UEVENT_GENERATED_FLAG (1 << 13) /* Out */
323+
319324
#endif /* _LINUX_DM_IOCTL_H */

0 commit comments

Comments
 (0)