Skip to content

Conversation

@schabrolles
Copy link
Contributor

@schabrolles schabrolles commented May 29, 2016

20_partition_layout.shgets partition size from /sys/block filesystem for every hdX or sdX device.
But if the block device $blockd is a path of a multipath device, partition and size information does not exist anymore in /sys/block which stop the script with the following message:

"ERROR: BUG BUG BUG! Could not determine size of disk sdb/sdb2, please file a bug.
=== Issue report === Please report this unexpected issue at: https://github.com/rear/rear/issues Also include the relevant bits from /var/log/rear/rear-XXXXXXXX.log.lockless"

To avoid this situation, I propose to test if the sdX or hdX ($blockd) is part of a multipath device.
If yes, we ignore it because it will be handled by 28_multipath_layout script (real multipath device dm-X will be treated further by multipath scripts).

20_partition_layout.sh gets partition size from /sys/block filesystem for every hdX or sdX device. But if the block device is a path of a multipath device, partition and size information does not exist which stop the script with the following message:

"ERROR: BUG BUG BUG!  Could not determine size of disk sdb/sdb2, please file a bug.
=== Issue report === Please report this unexpected issue at: https://github.com/rear/rear/issues Also include the relevant bits from /var/log/rear/rear-XXXXXXXX.log.lockless"

To avoid this situation, we test if the sdX or hdX is part of a multipath device. If yes, we ignore it (real multipath device dm-X will be treated further by multipath scripts).

disktype=$(parted -s $devname print | grep -E "Partition Table|Disk label" | cut -d ":" -f "2" | tr -d " ")
#Check if blockd is a path of a multipath device.
if multipath -c /dev/${blockd} > /dev/null 2>&1 ; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies that multipath is a required binary for rear! In lots of set-ups multipath is not used. Is there no other way to make this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gdha if multipath is not installed and setup, then the result of multipath -c /dev/${blockd} will not be true; which is good in this case.
So the script will continue by trying to get partition size of /dev/${blockd} etc ..

To make it cleaner, we could test if multipath command is available before. but it will add extra non necessary if condition test.
Tell me what you prefer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about creating a function that abstracts that logic? Could be as simple as

function is_multipath_path {
    [ "$1" ] && type multipath &>/dev/null && multipath -c /dev/$1 &>/dev/null
}

@gdha gdha added the bug The code does not do what it is meant to do label May 30, 2016
@gdha gdha added this to the Rear v1.19 milestone May 30, 2016
@gdha gdha self-assigned this May 30, 2016
* Avoid to use multipath command if this one is not present
* Improve code readibility
@gdha gdha merged commit a5261ea into rear:master Jun 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug The code does not do what it is meant to do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants