diff --git a/pkg/storaged/client.js b/pkg/storaged/client.js index e94e3178150d..fb0c7ee94480 100644 --- a/pkg/storaged/client.js +++ b/pkg/storaged/client.js @@ -153,13 +153,42 @@ define([ */ function update_indices() { - var path, block, dev, mdraid, vgroup, pvol, lvol, part; + var path, block, dev, mdraid, vgroup, pvol, lvol, part, i; + client.drives_multipath_blocks = { }; client.drives_block = { }; + for (path in client.drives) { + client.drives_multipath_blocks[path] = [ ]; + } for (path in client.blocks) { block = client.blocks[path]; - if (block.Drive != "/") - client.drives_block[block.Drive] = block; + if (!client.blocks_part[path] && client.drives_multipath_blocks[block.Drive] !== undefined) + client.drives_multipath_blocks[block.Drive].push(block); + } + for (path in client.drives_multipath_blocks) { + var all_blocks = client.drives_multipath_blocks[path]; + var mpath_members = [ ]; + var non_mpath_members = [ ]; + + all_blocks.sort(function (a, b) { return a.DeviceNumber - b.DeviceNumber; }); + for (i = 0; i < all_blocks.length; i++) { + if (all_blocks[i].IdType == "mpath_member") + mpath_members.push(all_blocks[i]); + else + non_mpath_members.push(all_blocks[i]); + } + + /* A valid multipath drive has exactly one block device + * that is not a "mpath_member". + */ + + if (non_mpath_members.length === 1) { + client.drives_block[path] = non_mpath_members[0]; + client.drives_multipath_blocks[path] = mpath_members; + } else { + client.drives_block[path] = null; + client.drives_multipath_blocks[path] = all_blocks; + } } client.mdraids_block = { }; @@ -190,7 +219,7 @@ define([ block = client.blocks[path]; enter_slashdev(block, block.Device); enter_slashdev(block, block.PreferredDevice); - for (var i = 0; i < block.Symlinks.length; i++) + for (i = 0; i < block.Symlinks.length; i++) enter_slashdev(block, block.Symlinks[i]); } diff --git a/pkg/storaged/details.js b/pkg/storaged/details.js index c16fdadab572..27afeea93144 100644 --- a/pkg/storaged/details.js +++ b/pkg/storaged/details.js @@ -1302,21 +1302,38 @@ define([ } var drive_model = null; + var content_block = block; if (drive) { + var drive_block = client.drives_block[drive.path]; + var multipath_blocks = client.drives_multipath_blocks[drive.path]; + + var multipath_model = null; + if (multipath_blocks.length > 0) { + multipath_model = { + Devices: multipath_blocks.map(utils.block_name) + }; + } + drive_model = { dbus: drive, + block_dbus: drive_block, Size: drive.Size > 0 && utils.fmt_size_long(drive.Size), - Assessment: assessment + Assessment: assessment, + Device: drive_block && utils.block_name(drive_block), + Multipath: multipath_model }; + + content_block = drive_block; } return mustache.render(block_detail_tmpl, { Block: block_model, Drive: drive_model, - Content: mustache.render(content_tmpl, - { Title: _("Content"), - Entries: block_content_entries(block) - }) + Content: (content_block && + mustache.render(content_tmpl, + { Title: _("Content"), + Entries: block_content_entries(content_block) + })) }); } diff --git a/pkg/storaged/devices.html b/pkg/storaged/devices.html index 4d6e735d6183..8e4582274c00 100644 --- a/pkg/storaged/devices.html +++ b/pkg/storaged/devices.html @@ -343,12 +343,22 @@