Re: [PATCH] dm-ioctl: Return data to userspace after rename ioctl is processed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



An updated version based on Alasdair's comments: __dev_status call added.

Allow data to be returned to userspace after a rename ioctl is processed.
It carries important information for userspace code to react properly,
now checking new DM_UEVENT_GENERATED_FLAG that has been added recently.

Signed-off-by: Peter Rajnoha <prajnoha@xxxxxxxxxx>
---
 drivers/md/dm-ioctl.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index d7500e1..f67ec28 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -49,6 +49,7 @@ struct vers_iter {
 static struct list_head _name_buckets[NUM_BUCKETS];
 static struct list_head _uuid_buckets[NUM_BUCKETS];
 
+static int __dev_status(struct mapped_device *md, struct dm_ioctl *param);
 static void dm_hash_remove_all(int keep_open_devices);
 
 /*
@@ -285,12 +286,12 @@ retry:
 	up_write(&_hash_lock);
 }
 
-static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
-			  const char *new)
+static int dm_hash_rename(struct dm_ioctl *param, const char *new)
 {
 	char *new_name, *old_name;
 	struct hash_cell *hc;
 	struct dm_table *table;
+	int r;
 
 	/*
 	 * duplicate new.
@@ -307,7 +308,7 @@ static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
 	hc = __get_name_cell(new);
 	if (hc) {
 		DMWARN("asked to rename to an already existing name %s -> %s",
-		       old, new);
+		       param->name, new);
 		dm_put(hc->md);
 		up_write(&_hash_lock);
 		kfree(new_name);
@@ -317,10 +318,10 @@ static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
 	/*
 	 * Is there such a device as 'old' ?
 	 */
-	hc = __get_name_cell(old);
+	hc = __get_name_cell(param->name);
 	if (!hc) {
 		DMWARN("asked to rename a non existent device %s -> %s",
-		       old, new);
+		       param->name, new);
 		up_write(&_hash_lock);
 		kfree(new_name);
 		return -ENXIO;
@@ -345,13 +346,15 @@ static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
 		dm_table_put(table);
 	}
 
-	if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, cookie))
-		*flags |= DM_UEVENT_GENERATED_FLAG;
+	if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, param->event_nr))
+		param->flags |= DM_UEVENT_GENERATED_FLAG;
+
+	r = __dev_status(hc->md, param);
 
 	dm_put(hc->md);
 	up_write(&_hash_lock);
 	kfree(old_name);
-	return 0;
+	return r;
 }
 
 /*-----------------------------------------------------------------
@@ -774,10 +777,7 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
 	if (r)
 		return r;
 
-	param->data_size = 0;
-
-	return dm_hash_rename(param->event_nr, &param->flags, param->name,
-			      new_name);
+	return dm_hash_rename(param, new_name);
 }
 
 static int dev_set_geometry(struct dm_ioctl *param, size_t param_size)

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux