Skip to content

Commit 856a6f1

Browse files
prajnohakergon
authored andcommitted
dm ioctl: return uevent flag after rename
All the dm ioctls that generate uevents set the DM_UEVENT_GENERATED flag so that userspace knows whether or not to wait for a uevent to be processed before continuing, The dm rename ioctl sets this flag but was not structured to return it to userspace. This patch restructures the rename ioctl processing to behave like the other ioctls that return data and so fix this. Signed-off-by: Peter Rajnoha <prajnoha@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
1 parent 094ea9a commit 856a6f1

1 file changed

Lines changed: 24 additions & 17 deletions

File tree

‎drivers/md/dm-ioctl.c‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -285,19 +285,20 @@ 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, uint32_t *flags, const char *old,
289-
const char *new)
288+
static struct mapped_device *dm_hash_rename(struct dm_ioctl *param,
289+
const char *new)
290290
{
291291
char *new_name, *old_name;
292292
struct hash_cell *hc;
293293
struct dm_table *table;
294+
struct mapped_device *md;
294295

295296
/*
296297
* duplicate new.
297298
*/
298299
new_name = kstrdup(new, GFP_KERNEL);
299300
if (!new_name)
300-
return -ENOMEM;
301+
return ERR_PTR(-ENOMEM);
301302

302303
down_write(&_hash_lock);
303304

@@ -306,24 +307,24 @@ static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
306307
*/
307308
hc = __get_name_cell(new);
308309
if (hc) {
309-
DMWARN("asked to rename to an already existing name %s -> %s",
310-
old, new);
310+
DMWARN("asked to rename to an already-existing name %s -> %s",
311+
param->name, new);
311312
dm_put(hc->md);
312313
up_write(&_hash_lock);
313314
kfree(new_name);
314-
return -EBUSY;
315+
return ERR_PTR(-EBUSY);
315316
}
316317

317318
/*
318319
* Is there such a device as 'old' ?
319320
*/
320-
hc = __get_name_cell(old);
321+
hc = __get_name_cell(param->name);
321322
if (!hc) {
322-
DMWARN("asked to rename a non existent device %s -> %s",
323-
old, new);
323+
DMWARN("asked to rename a non-existent device %s -> %s",
324+
param->name, new);
324325
up_write(&_hash_lock);
325326
kfree(new_name);
326-
return -ENXIO;
327+
return ERR_PTR(-ENXIO);
327328
}
328329

329330
/*
@@ -345,13 +346,14 @@ static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
345346
dm_table_put(table);
346347
}
347348

348-
if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, cookie))
349-
*flags |= DM_UEVENT_GENERATED_FLAG;
349+
if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr))
350+
param->flags |= DM_UEVENT_GENERATED_FLAG;
350351

351-
dm_put(hc->md);
352+
md = hc->md;
352353
up_write(&_hash_lock);
353354
kfree(old_name);
354-
return 0;
355+
356+
return md;
355357
}
356358

357359
/*-----------------------------------------------------------------
@@ -760,6 +762,7 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
760762
{
761763
int r;
762764
char *new_name = (char *) param + param->data_start;
765+
struct mapped_device *md;
763766

764767
if (new_name < param->data ||
765768
invalid_str(new_name, (void *) param + param_size) ||
@@ -772,10 +775,14 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
772775
if (r)
773776
return r;
774777

775-
param->data_size = 0;
778+
md = dm_hash_rename(param, new_name);
779+
if (IS_ERR(md))
780+
return PTR_ERR(md);
776781

777-
return dm_hash_rename(param->event_nr, &param->flags, param->name,
778-
new_name);
782+
__dev_status(md, param);
783+
dm_put(md);
784+
785+
return 0;
779786
}
780787

781788
static int dev_set_geometry(struct dm_ioctl *param, size_t param_size)

0 commit comments

Comments
 (0)