aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-ioctl.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2011-08-02 07:32:06 -0400
committerAlasdair G Kergon <agk@redhat.com>2011-08-02 07:32:06 -0400
commit0ddf9644cc26e74ed671525e61a17bdbebf18da6 (patch)
treefa10cf2fda8f52c0da7f2f1fcec54f2ce2d5bd1f /drivers/md/dm-ioctl.c
parenta3998799fb4df0b0af8271a7d50c4269032397aa (diff)
dm ioctl: fill in device parameters in more ioctls
Move parameter filling from find_device to __find_device_hash_cell. This patch causes ioctls using __find_device_hash_cell (DM_DEV_REMOVE_CMD, DM_DEV_SUSPEND_CMD - resume, DM_TABLE_CLEAR_CMD) to return device parameters, bringing them into line with the other ioctls. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-ioctl.c')
-rw-r--r--drivers/md/dm-ioctl.c63
1 files changed, 36 insertions, 27 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 1622a6bc0bf..99d38a6925a 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -719,24 +719,49 @@ static int dev_create(struct dm_ioctl *param, size_t param_size)
719static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param) 719static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
720{ 720{
721 struct mapped_device *md; 721 struct mapped_device *md;
722 void *mdptr = NULL; 722 struct hash_cell *hc = NULL;
723 723
724 if (*param->uuid) 724 if (*param->uuid) {
725 return __get_uuid_cell(param->uuid); 725 hc = __get_uuid_cell(param->uuid);
726 if (!hc)
727 return NULL;
728 goto fill_params;
729 }
726 730
727 if (*param->name) 731 if (*param->name) {
728 return __get_name_cell(param->name); 732 hc = __get_name_cell(param->name);
733 if (!hc)
734 return NULL;
735 goto fill_params;
736 }
729 737
730 md = dm_get_md(huge_decode_dev(param->dev)); 738 md = dm_get_md(huge_decode_dev(param->dev));
731 if (!md) 739 if (!md)
732 goto out; 740 return NULL;
733 741
734 mdptr = dm_get_mdptr(md); 742 hc = dm_get_mdptr(md);
735 if (!mdptr) 743 if (!hc) {
736 dm_put(md); 744 dm_put(md);
745 return NULL;
746 }
737 747
738out: 748fill_params:
739 return mdptr; 749 /*
750 * Sneakily write in both the name and the uuid
751 * while we have the cell.
752 */
753 strlcpy(param->name, hc->name, sizeof(param->name));
754 if (hc->uuid)
755 strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
756 else
757 param->uuid[0] = '\0';
758
759 if (hc->new_map)
760 param->flags |= DM_INACTIVE_PRESENT_FLAG;
761 else
762 param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
763
764 return hc;
740} 765}
741 766
742static struct mapped_device *find_device(struct dm_ioctl *param) 767static struct mapped_device *find_device(struct dm_ioctl *param)
@@ -746,24 +771,8 @@ static struct mapped_device *find_device(struct dm_ioctl *param)
746 771
747 down_read(&_hash_lock); 772 down_read(&_hash_lock);
748 hc = __find_device_hash_cell(param); 773 hc = __find_device_hash_cell(param);
749 if (hc) { 774 if (hc)
750 md = hc->md; 775 md = hc->md;
751
752 /*
753 * Sneakily write in both the name and the uuid
754 * while we have the cell.
755 */
756 strlcpy(param->name, hc->name, sizeof(param->name));
757 if (hc->uuid)
758 strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
759 else
760 param->uuid[0] = '\0';
761
762 if (hc->new_map)
763 param->flags |= DM_INACTIVE_PRESENT_FLAG;
764 else
765 param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
766 }
767 up_read(&_hash_lock); 776 up_read(&_hash_lock);
768 777
769 return md; 778 return md;