dmraid-activate uses flawed logic to detect degraded condition

Bug #737159 reported by Phillip Susi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dmraid (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: dmraid

The dmraid-activate script attempts to detect if an array is degraded and only activate it if the degraded boot parameter has been set. The problem is the logic it uses to detect the degraded condition is flawed. Rather than check the number of devices that are MISSING, it checks the number of devices that are present. For a stripe, it checks that the device count is >= 2, but a 3+ disk stripe is still broken with only 2 disks present. For a mirror, it also checks for >= 2 disks, but you can have a 3 disk mirror with one disk missing, and this check would consider it to not be degraded. Finally for a raid5, it considers it to be degraded if there are less than 3 disks present, 3 out of 4 disks is also degraded. The relevant code is:

        Raid_Type=$(dmraid -i -si -ct "$1")
        Raid_Nodevs=$(dmraid -i -si -cd "$1")

        case "$Raid_Type" in
                stripe)
                        if [ "$Raid_Nodevs" -lt 2 ]; then
                                if [ -n "$Degraded" ]; then
                                        log_error "Cannot bring up a RAID0 array in degraded \
mode, not all devices present."
                                fi
                                return 2
                        fi
                        ;;
                mirror)
                        if [ "$Raid_Nodevs" -lt 2 ]; then
                                if [ -z "$Degraded" ]; then
                                        log_error "Raid set $Raid_Name is degraded. Not activ\
ating"
                                        return 2
                                else
                                        log_warning "Activating $Raid_Name in degraded mode"
                                        Return_Val=3
                                fi
                        fi
                        ;;
                raid5_*)
                        modprobe -q dm_raid45
                        if [ "$Raid_Nodevs" -lt 3 ]; then
                                if [ -z "$Degraded" ]; then
                                        log_error "Raid set $Raid_Name is degraded. Not activ\
ating"
                                        return 2
                                else
                                        log_warning "Activating $Raid_Name in degraded mode"
                                        Return_Val=3
                                fi
                        fi

Revision history for this message
D3m0n1q_733rz (cryo-rebirth) wrote :

I believe the problem we're going to have with fixing this is determining how many disks were in the array to begin with. It requires reading specific data from the arrays descriptors and matching it to the drives listed. I would also recommend getting sector specific on the fix so that drives sharing multiple arrays won't bug when an already counted drive is counted again for another array.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.