aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r--drivers/md/dm-ioctl.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 4bc4c4fca90d..79ee5ba217f2 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -285,19 +285,20 @@ retry:
285 up_write(&_hash_lock); 285 up_write(&_hash_lock);
286} 286}
287 287
288static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old, 288static struct mapped_device *dm_hash_rename(struct dm_ioctl *param,
289 const char *new) 289 const char *new)
290{ 290{
291 char *new_name, *old_name; 291 char *new_name, *old_name;
292 struct hash_cell *hc; 292 struct hash_cell *hc;
293 struct dm_table *table; 293 struct dm_table *table;
294 struct mapped_device *md;
294 295
295 /* 296 /*
296 * duplicate new. 297 * duplicate new.
297 */ 298 */
298 new_name = kstrdup(new, GFP_KERNEL); 299 new_name = kstrdup(new, GFP_KERNEL);
299 if (!new_name) 300 if (!new_name)
300 return -ENOMEM; 301 return ERR_PTR(-ENOMEM);
301 302
302 down_write(&_hash_lock); 303 down_write(&_hash_lock);
303 304
@@ -306,24 +307,24 @@ static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
306 */ 307 */
307 hc = __get_name_cell(new); 308 hc = __get_name_cell(new);
308 if (hc) { 309 if (hc) {
309 DMWARN("asked to rename to an already existing name %s -> %s", 310 DMWARN("asked to rename to an already-existing name %s -> %s",
310 old, new); 311 param->name, new);
311 dm_put(hc->md); 312 dm_put(hc->md);
312 up_write(&_hash_lock); 313 up_write(&_hash_lock);
313 kfree(new_name); 314 kfree(new_name);
314 return -EBUSY; 315 return ERR_PTR(-EBUSY);
315 } 316 }
316 317
317 /* 318 /*
318 * Is there such a device as 'old' ? 319 * Is there such a device as 'old' ?
319 */ 320 */
320 hc = __get_name_cell(old); 321 hc = __get_name_cell(param->name);
321 if (!hc) { 322 if (!hc) {
322 DMWARN("asked to rename a non existent device %s -> %s", 323 DMWARN("asked to rename a non-existent device %s -> %s",
323 old, new); 324 param->name, new);
324 up_write(&_hash_lock); 325 up_write(&_hash_lock);
325 kfree(new_name); 326 kfree(new_name);
326 return -ENXIO; 327 return ERR_PTR(-ENXIO);
327 } 328 }
328 329
329 /* 330 /*
@@ -345,13 +346,14 @@ static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
345 dm_table_put(table); 346 dm_table_put(table);
346 } 347 }
347 348
348 if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, cookie)) 349 if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr))
349 *flags |= DM_UEVENT_GENERATED_FLAG; 350 param->flags |= DM_UEVENT_GENERATED_FLAG;
350 351
351 dm_put(hc->md); 352 md = hc->md;
352 up_write(&_hash_lock); 353 up_write(&_hash_lock);
353 kfree(old_name); 354 kfree(old_name);
354 return 0; 355
356 return md;
355} 357}
356 358
357/*----------------------------------------------------------------- 359/*-----------------------------------------------------------------
@@ -760,6 +762,7 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
760{ 762{
761 int r; 763 int r;
762 char *new_name = (char *) param + param->data_start; 764 char *new_name = (char *) param + param->data_start;
765 struct mapped_device *md;
763 766
764 if (new_name < param->data || 767 if (new_name < param->data ||
765 invalid_str(new_name, (void *) param + param_size) || 768 invalid_str(new_name, (void *) param + param_size) ||
@@ -772,10 +775,14 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
772 if (r) 775 if (r)
773 return r; 776 return r;
774 777
775 param->data_size = 0; 778 md = dm_hash_rename(param, new_name);
779 if (IS_ERR(md))
780 return PTR_ERR(md);
776 781
777 return dm_hash_rename(param->event_nr, &param->flags, param->name, 782 __dev_status(md, param);
778 new_name); 783 dm_put(md);
784
785 return 0;
779} 786}
780 787
781static int dev_set_geometry(struct dm_ioctl *param, size_t param_size) 788static int dev_set_geometry(struct dm_ioctl *param, size_t param_size)