[Kimchi-devel] [PATCH v2] Logical Storage Pool: Detect and Enumerate Multipath Block Devices

Mark Wu wudxw at linux.vnet.ibm.com
Wed Mar 26 04:36:49 UTC 2014


On 03/26/2014 11:52 AM, zhshzhou at linux.vnet.ibm.com wrote:
> From: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
>
> When creating a logical storage pool Kimci ignores multipath block
> devices. This is on purpose because at the time the kimchi.disks was
> implemented, there was not enough time to test every kind of devices.
>
> This patch adds the missing support for multipath block devices. After
> this patch, the kimchi.disks will include multipath devices in the
> available partition list. The front-end code is also changed
> accordingly.
>
> v2
> Use the major device number to determine if a deivce is a multipath one.
> Use indexOf of the array object to determine if an element is in array.
>
> Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
> ---
>   src/kimchi/disks.py                      | 13 ++++++++++++-
>   ui/js/src/kimchi.storagepool_add_main.js |  3 ++-
>   2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/disks.py b/src/kimchi/disks.py
> index ce0c5bb..5f004b3 100644
> --- a/src/kimchi/disks.py
> +++ b/src/kimchi/disks.py
> @@ -27,8 +27,19 @@ from kimchi.exception import OperationFailed
>   from kimchi.utils import kimchi_log
>
>
> +def _get_friendly_dm_path(maj_min):
> +    """ Returns user friendly dm path given the device number 'major:min' """
> +    dm_name = "/sys/dev/block/%s/dm/name" % maj_min
> +    with open(dm_name) as dm_f:
> +        content = dm_f.read().rstrip('\n')
> +    return "/dev/mapper/" + content
> +
> +
>   def _get_dev_node_path(maj_min):
>       """ Returns device node path given the device number 'major:min' """
> +    if maj_min.startswith('253:'):
> +        return _get_friendly_dm_path(maj_min)
> +
>       uevent = "/sys/dev/block/%s/uevent" % maj_min
>       with open(uevent) as ueventf:
>           content = ueventf.read()
> @@ -137,7 +148,7 @@ def get_partitions_names():
>           # leaf means a partition, a disk has no partition, or a disk not held
>           # by any multipath device. Physical volume belongs to no volume group
>           # is also listed. Extended partitions should not be listed.
> -        if not (dev['type'] in ['part', 'disk'] and
> +        if not (dev['type'] in ['part', 'disk', 'mpath'] and
>                   dev['fstype'] in ['', 'LVM2_member'] and
>                   dev['mountpoint'] == "" and
>                   _get_vgname(devNodePath) == "" and
> diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js
> index 10833be..a3b60f7 100644
> --- a/ui/js/src/kimchi.storagepool_add_main.js
> +++ b/ui/js/src/kimchi.storagepool_add_main.js
> @@ -27,8 +27,9 @@ kimchi.initStorageAddPage = function() {
>           if (data.length > 0) {
>               var deviceHtml = $('#partitionTmpl').html();
>               var listHtml = '';
> +            valid_types = ['part', 'disk', 'mpath'];
>               $.each(data, function(index, value) {
> -                if (value.type === 'part' || value.type === 'disk') {
> +                if (valid_types.indexOf(value.type) != -1) {
>                       listHtml += kimchi.template(deviceHtml, value);
>                   }
>               });
Reviewed-by: Mark Wu<wudxw at linux.vnet.ibm.com>




More information about the Kimchi-devel mailing list