Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2227026

Summary: [RAID 1] mdraid configured with hot spare disk does not start rebuild automatically when one of the leg got removed
Product: Red Hat Enterprise Linux 9 Reporter: pratapsingh <pmahale>
Component: mdadmAssignee: Nigel Croxon <ncroxon>
Status: CLOSED NOTABUG QA Contact: Storage QE <storage-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.2CC: heinzm, jpittman, ncroxon, xni
Target Milestone: rcKeywords: Reproducer, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-08-28 19:36:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description pratapsingh 2023-07-27 13:15:15 UTC
Description of problem: [RAID 1] mdraid configured with hot spare disk does not start rebuilding automatically when one of the legs got removed if md raid is not mounted


Version-Release number of selected component (if applicable):
5.14.0-284.11.1.el9_2.x86_64
mdadm-4.2-8.el9.x86_64
Red Hat Enterprise Linux release 9.2 (Plow)

How reproducible:
Always

Steps to Reproduce:

1. Create a RAID1 with a spare leg

#mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sda /dev/sdb --spare-device=1 /dev/sdc

2. Once it's created remove one of the active legs

# echo 1 > /sys/block/sdb/device/delete 

3. Auto rebuilding has not started


Actual results:

1. As mentioned in step 2 above I removed the disk after that disk got removed successfully.

2. The disk was marked as "removed" however auto rebuilding doesn't happen automatically with the spare leg even after I waited for a few mins.

[root@~]# mdadm -D /dev/md1 
/dev/md1:
           Version : 1.2
     Creation Time : Thu Jul 27 07:36:07 2023
        Raid Level : raid1
        Array Size : 5237760 (5.00 GiB 5.36 GB)
     Used Dev Size : 5237760 (5.00 GiB 5.36 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

       Update Time : Thu Jul 27 07:53:40 2023
             State : clean, degraded 
    Active Devices : 1
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 1

Consistency Policy : resync

              Name : 1
              UUID : 1094d9ed:3d47bc39:49fd5afc:2f352617
            Events : 37

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       -       0        0        1      removed

       2       8       32        -      spare   /dev/sdc

3. If adding any new disk rebuilding started automatically.

#  mdadm --manage /dev/md1 --add /dev/sdd
mdadm: added /dev/sdd

Consistency Policy : resync

    Rebuild Status : 13% complete

              Name : 1
              UUID : 1094d9ed:3d47bc39:49fd5afc:2f352617
            Events : 42

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       3       8       48        1      spare rebuilding   /dev/sdd

       2       8       32        -      spare   /dev/sdc



Expected results:

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       0       0        0        1      removed     
       2       8       32        -     spare rebuilding /dev/sdc

Additional info:

1. If /dev/md1 is mounted then auto rebuilding happens automatically if any leg got removed.
2. The status of the disk showing as removed in case /dev/md1 is not mounted. 
3. The status of the disk showing as missing if /dev/md1 is mounted.
4. I am not sure if it's expected behavior or a kind of bug because the issue is the same on all kernels RHEL7,8 and 9 and customer expectation is to rebuild or resync automatically if one leg got removed.

Comment 1 Nigel Croxon 2023-07-27 18:46:55 UTC
Expected behavior.  Not a bug.

Human intervention is required, as you have done to add the disk back into the array.

You also do not have a bitmap, which would make the resync faster when the disk is re-added.

Comment 2 pratapsingh 2023-07-28 05:51:12 UTC
(In reply to Nigel Croxon from comment #1)
> Expected behavior.  Not a bug.
> 
> Human intervention is required, as you have done to add the disk back into
> the array.
> 
> You also do not have a bitmap, which would make the resync faster when the
> disk is re-added.

Hello Nigel,

If /dev/md1 is mounted then auto rebuilding happens automatically if any leg got removed. And the status of the disk also shows as missing instead of removed.


[root@~]# mount /dev/md1 /test-raid
[root@~]# df -h /test-raid/
Filesystem      Size  Used Avail Use% Mounted on
/dev/md1        5.0G   68M  5.0G   2% /test-raid
[root@~]# mdadm -D /dev/md1 
/dev/md1:
           Version : 1.2
     Creation Time : Thu Jul 27 07:36:07 2023
        Raid Level : raid1
        Array Size : 5237760 (5.00 GiB 5.36 GB)
     Used Dev Size : 5237760 (5.00 GiB 5.36 GB)
      Raid Devices : 2
     Total Devices : 3
       Persistence : Superblock is persistent

       Update Time : Thu Jul 27 08:00:07 2023
             State : clean 
    Active Devices : 2
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 1

Consistency Policy : resync

              Name : 1
              UUID : 1094d9ed:3d47bc39:49fd5afc:2f352617
            Events : 57

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       3       8       48        1      active sync   /dev/sdd

       2       8       32        -      spare   /dev/sdc

--> I removed the active device

[root@~]# echo 1 > /sys/block/sdd/device/delete 

--> It will show as missing and after a few seconds md1 start auto-resync with the spare leg. 

[root@~]# mdadm -D /dev/md1 
/dev/md1:
           Version : 1.2
     Creation Time : Thu Jul 27 07:36:07 2023
        Raid Level : raid1
        Array Size : 5237760 (5.00 GiB 5.36 GB)
     Used Dev Size : 5237760 (5.00 GiB 5.36 GB)
      Raid Devices : 2
     Total Devices : 3
       Persistence : Superblock is persistent

       Update Time : Thu Jul 27 08:00:07 2023
             State : clean, degraded 
    Active Devices : 2
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 1

Consistency Policy : resync

              Name : 1
              UUID : 1094d9ed:3d47bc39:49fd5afc:2f352617
            Events : 57

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       3       8       48        1      active sync   missing

       2       8       32        -      spare   /dev/sdc
[root@~]# mdadm -D /dev/md1 
/dev/md1:
           Version : 1.2
     Creation Time : Thu Jul 27 07:36:07 2023
        Raid Level : raid1
        Array Size : 5237760 (5.00 GiB 5.36 GB)
     Used Dev Size : 5237760 (5.00 GiB 5.36 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

       Update Time : Thu Jul 27 08:00:41 2023
             State : clean, degraded, recovering 
    Active Devices : 1
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 1

Consistency Policy : resync

    Rebuild Status : 3% complete

              Name : 1
              UUID : 1094d9ed:3d47bc39:49fd5afc:2f352617
            Events : 60

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       2       8       32        1      spare rebuilding   /dev/sdc

Why md1 does not start auto-rebuilding with the spare leg as with the mounted disk?

Regards,
Pratapsingh