[gparted/ataraid: 5/17] Recognise ATARAID members (#75)



commit aea6200d5fda00bb0722d473764842d1b022bbd4
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Nov 2 17:07:12 2019 +0000

    Recognise ATARAID members (#75)
    
    PATCHSET OVERVIEW
    
    A user had a Firmware / BIOS / ATARAID array of 2 devices configured as
    a RAID 0 (stripe) set.  On top of that was a GPT with the OS partitions.
    GParted displays the following errors on initial load and subsequent
    refresh:
    
            Libparted Error
        (-) Invalid argument during seek for read on /dev/sda
                              [ Retry ] [ Cancel ] [ Ignore ]
    
            Libparted Error
        (-) The backup GPT table is corrupt, but the
            primary appears OK, so that will be used.
                                  [  Ok  ] [ Cancel ]
    
    This is an Intel Software RAID array which stores metadata at the end of
    each member device, and so the first 128 KiB stripe of the set is stored
    in the first 128 KiB of the first member device /dev/sda which includes
    the GPT for the whole RAID 0 device.  Hence when libparted reads member
    device /dev/sda it finds a GPT describing a block device twice it's
    size and in results the above errors when trying to read the backup GPT.
    
    A more dangerous scenario occurs when using 2 devices configured in an
    Intel Software RAID 1 (mirrored) set with GPT on top.  On refresh
    GParted display this error for both members, /dev/sda and /dev/sdb:
    
            Libparted Warning
        /!\ Not all of the space available to /dev/sda appears to be used,
            you can fix the GPT to use all of the space (an extra 9554
            blocks) or continue with the current setting?
                                                      [  Fix  ] [ Ignore ]
    
    Selecting [Fix] gets libparted to re-write the backup GPT to the end of
    the member device, overwriting the ISW metadata!  Do that twice and both
    copies of the metadata are gone!
    
    Worked example of this more dangerous mirrored set case.  Initial setup:
    
        # dmraid -s
        *** Group superset isw_caffbiaegi
        --> Subset
        name   : isw_caffbiaegi_MyMirror
        size   : 16768000
        stride : 128
        type   : mirror
        status : ok
        subsets: 0
        devs   : 2
        spares : 0
    
        # dmraid -r
        /dev/sda: isw, "isw_caffbiaegi", GROUP, ok, 16777214 sectors, data@ 0
        /dev/sdb: isw, "isw_caffbiaegi", GROUP, ok, 16777214 sectors, data@ 0
    
        # wipefs /dev/sda
        offset               type
        ---------------------------------------------
        0x200                gpt   [partition table]
        0x1fffffc00          isw_raid_member   [raid]
    
    Run GParted and click [Fix] on /dev/sda.  Now the first member has gone:
    
        # dmraid -s
        *** Group superset isw_caffbiaegi
        --> *Inconsistent* Subset
        name   : isw_caffbiaegi_MyMirror
        size   : 16768000
        stride : 128
        type   : mirror
        status : inconsistent
        subsets: 0
        devs   : 1
        spares : 0
    
        # dmraid -r
        /dev/sdb: isw, "isw_caffbiaegi", GROUP, ok, 16777214 sectors, data@ 0
    
        # wipefs /dev/sda
        offset               type
        ---------------------------------------------
        0x200                gpt   [partition table]
    
    Click [Fix] on /dev/sdb.  Now all members of the array are gone:
    
        # dmraid -s
        no raid disks
    
        # dmraid -r
        no raid disks
    
        # wipefs /dev/sdb
        offset               type
        ---------------------------------------------
        0x200                gpt   [partition table]
    
    So GParted must not run libparted partition table scanning on the member
    devices in ATARAID arrays.  Only on the array device itself.
    
    In terms of the UI GParted must show disks which are ATARAID members as
    whole disk devices with ATARAID member content and detect array busy
    status to avoid allowing active members from being overwritten while in
    use.
    
    THIS COMMIT
    
    Recognise ATARAID member devices and display in GParted as whole device
    "ataraid" file systems.  Because they are recognised as whole device
    content ("ataraid" file systems) this alone stops GParted running the
    libparted partition table scanning and avoids the above errors.
    
    The list of dmraid supported formats is matched by the signatures
    recognised by blkid:
    
        $ dmraid -l
        asr     : Adaptec HostRAID ASR (0,1,10)
        ddf1    : SNIA DDF1 (0,1,4,5,linear)
        hpt37x  : Highpoint HPT37X (S,0,1,10,01)
        hpt45x  : Highpoint HPT45X (S,0,1,10)
        isw     : Intel Software RAID (0,1,5,01)
        jmicron : JMicron ATARAID (S,0,1)
        lsi     : LSI Logic MegaRAID (0,1,10)
        nvidia  : NVidia RAID (S,0,1,10,5)
        pdc     : Promise FastTrack (S,0,1,10)
        sil     : Silicon Image(tm) Medley(tm) (0,1,10)
        via     : VIA Software RAID (S,0,1,10)
        dos     : DOS partitions on SW RAIDs
    
        $ fgrep -h _raid_member util-linux/libblkid/src/superblocks/*.c
                .name           = "adaptec_raid_member",
                .name           = "ddf_raid_member",
                .name           = "hpt45x_raid_member",
                .name           = "hpt37x_raid_member",
                .name           = "isw_raid_member",
                .name           = "jmicron_raid_member",
                .name           = "linux_raid_member",
                .name           = "lsi_mega_raid_member",
                .name           = "nvidia_raid_member",
                .name           = "promise_fasttrack_raid_member",
                .name           = "silicon_medley_raid_member",
                .name           = "via_raid_member",
    
    As they are all types of Firmware / BIOS / ATARAID arrays, report all
    members as a single "ataraid" file system type.  (Except for
    "linux_raid_member" in the above blkid source listing which is Linux
    Software RAID).
    
    Closes #75 - Errors with GPT on RAID 0 ATARAID array

 include/Utils.h     | 21 +++++++++++----------
 src/GParted_Core.cc | 12 ++++++++++++
 src/Utils.cc        |  2 ++
 3 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/include/Utils.h b/include/Utils.h
index ab0d7b3d..569f3f79 100644
--- a/include/Utils.h
+++ b/include/Utils.h
@@ -95,18 +95,19 @@ enum FSType
 
        // Other recognised file system types
        FS_APFS            = 28,
-       FS_BITLOCKER       = 29,
-       FS_GRUB2_CORE_IMG  = 30,
-       FS_ISO9660         = 31,
-       FS_LINUX_SWRAID    = 32,
-       FS_LINUX_SWSUSPEND = 33,
-       FS_REFS            = 34,
-       FS_UFS             = 35,
-       FS_ZFS             = 36,
+       FS_ATARAID         = 29,
+       FS_BITLOCKER       = 30,
+       FS_GRUB2_CORE_IMG  = 31,
+       FS_ISO9660         = 32,
+       FS_LINUX_SWRAID    = 33,
+       FS_LINUX_SWSUSPEND = 34,
+       FS_REFS            = 35,
+       FS_UFS             = 36,
+       FS_ZFS             = 37,
 
        // Partition space usage colours
-       FS_USED            = 37,
-       FS_UNUSED          = 38
+       FS_USED            = 38,
+       FS_UNUSED          = 39
 } ;
 
 enum SIZE_UNIT
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 286f96ab..449cc328 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1284,6 +1284,18 @@ FSType GParted_Core::detect_filesystem( PedDevice * lp_device, PedPartition * lp
                        return FS_REFS;
                else if ( fsname == "zfs_member" )
                        return FS_ZFS;
+               else if (fsname == "adaptec_raid_member"           ||
+                        fsname == "ddf_raid_member"               ||
+                        fsname == "hpt45x_raid_member"            ||
+                        fsname == "hpt37x_raid_member"            ||
+                        fsname == "isw_raid_member"               ||
+                        fsname == "jmicron_raid_member"           ||
+                        fsname == "lsi_mega_raid_member"          ||
+                        fsname == "nvidia_raid_member"            ||
+                        fsname == "promise_fasttrack_raid_member" ||
+                        fsname == "silicon_medley_raid_member"    ||
+                        fsname == "via_raid_member"                 )
+                       return FS_ATARAID;
        }
 
        // (Q4) Fallback to GParted simple internal file system detection
diff --git a/src/Utils.cc b/src/Utils.cc
index c816ff17..5389cc89 100644
--- a/src/Utils.cc
+++ b/src/Utils.cc
@@ -178,6 +178,7 @@ Glib::ustring Utils::get_color( FSType filesystem )
                case FS_UDF:             return "#105210";  // Accent Green Shadow [+]
                case FS_XFS:             return "#EED680";  // Accent Yellow
                case FS_APFS:            return "#874986";  // Magenta Dark [*]
+               case FS_ATARAID:         return "#5A4733";  // Dark brown [*]
                case FS_BITLOCKER:       return "#494066";  // Purple Shadow
                case FS_GRUB2_CORE_IMG:  return "#666666";  // Dark Gray [*]
                case FS_ISO9660:         return "#D3D3D3";  // Light Gray [*]
@@ -366,6 +367,7 @@ Glib::ustring Utils::get_filesystem_string( FSType filesystem )
                case FS_UDF:             return "udf";
                case FS_XFS:             return "xfs";
                case FS_APFS:            return "apfs";
+               case FS_ATARAID:         return "ataraid";
                case FS_BITLOCKER:       return "bitlocker";
                case FS_GRUB2_CORE_IMG:  return "grub2 core.img";
                case FS_ISO9660:         return "iso9660";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]