diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2011-08-02 07:32:06 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2011-08-02 07:32:06 -0400 |
commit | ba2e19b0f4ccd6920fe175a86521ff18ede260cb (patch) | |
tree | 25a9533cfbd1946da36483c3172914b9ea1f51cb /drivers/md | |
parent | 0ddf9644cc26e74ed671525e61a17bdbebf18da6 (diff) |
dm ioctl: introduce __get_dev_cell
Move logic to find device based on major/minor number to a separate
function __get_dev_cell (similar to __get_uuid_cell and __get_name_cell).
This makes the function __find_device_hash_cell more straightforward.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-ioctl.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 99d38a6925a4..4c350914f4a0 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -128,6 +128,24 @@ static struct hash_cell *__get_uuid_cell(const char *str) | |||
128 | return NULL; | 128 | return NULL; |
129 | } | 129 | } |
130 | 130 | ||
131 | static struct hash_cell *__get_dev_cell(uint64_t dev) | ||
132 | { | ||
133 | struct mapped_device *md; | ||
134 | struct hash_cell *hc; | ||
135 | |||
136 | md = dm_get_md(huge_decode_dev(dev)); | ||
137 | if (!md) | ||
138 | return NULL; | ||
139 | |||
140 | hc = dm_get_mdptr(md); | ||
141 | if (!hc) { | ||
142 | dm_put(md); | ||
143 | return NULL; | ||
144 | } | ||
145 | |||
146 | return hc; | ||
147 | } | ||
148 | |||
131 | /*----------------------------------------------------------------- | 149 | /*----------------------------------------------------------------- |
132 | * Inserting, removing and renaming a device. | 150 | * Inserting, removing and renaming a device. |
133 | *---------------------------------------------------------------*/ | 151 | *---------------------------------------------------------------*/ |
@@ -718,34 +736,23 @@ static int dev_create(struct dm_ioctl *param, size_t param_size) | |||
718 | */ | 736 | */ |
719 | static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param) | 737 | static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param) |
720 | { | 738 | { |
721 | struct mapped_device *md; | ||
722 | struct hash_cell *hc = NULL; | 739 | struct hash_cell *hc = NULL; |
723 | 740 | ||
724 | if (*param->uuid) { | 741 | if (*param->uuid) { |
725 | hc = __get_uuid_cell(param->uuid); | 742 | hc = __get_uuid_cell(param->uuid); |
726 | if (!hc) | 743 | if (!hc) |
727 | return NULL; | 744 | return NULL; |
728 | goto fill_params; | 745 | } else if (*param->name) { |
729 | } | ||
730 | |||
731 | if (*param->name) { | ||
732 | hc = __get_name_cell(param->name); | 746 | hc = __get_name_cell(param->name); |
733 | if (!hc) | 747 | if (!hc) |
734 | return NULL; | 748 | return NULL; |
735 | goto fill_params; | 749 | } else if (param->dev) { |
736 | } | 750 | hc = __get_dev_cell(param->dev); |
737 | 751 | if (!hc) | |
738 | md = dm_get_md(huge_decode_dev(param->dev)); | 752 | return NULL; |
739 | if (!md) | 753 | } else |
740 | return NULL; | ||
741 | |||
742 | hc = dm_get_mdptr(md); | ||
743 | if (!hc) { | ||
744 | dm_put(md); | ||
745 | return NULL; | 754 | return NULL; |
746 | } | ||
747 | 755 | ||
748 | fill_params: | ||
749 | /* | 756 | /* |
750 | * Sneakily write in both the name and the uuid | 757 | * Sneakily write in both the name and the uuid |
751 | * while we have the cell. | 758 | * while we have the cell. |