Re: Patch to fix boot from RAID-1 partitioned arrays

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

 



Hello,

Apologies, just spotted a typo in my patch.  Updated patch below.
Regards,

Geoff.


diff -Naur linux-5.12.2.orig/drivers/md/md-autodetect.c linux-5.12.2/drivers/md/md-autodetect.c --- linux-5.12.2.orig/drivers/md/md-autodetect.c    2021-05-12 09:14:07.096442083 +0100 +++ linux-5.12.2/drivers/md/md-autodetect.c    2021-05-12 09:22:07.734653840 +0100
@@ -232,8 +232,24 @@
     mddev_unlock(mddev);
 out_blkdev_put:
     blkdev_put(bdev, FMODE_READ);
-}

+    /*
+     * Need to force read of partition table in order for partitioned
+     * arrays to be bootable.  Deliberately done after all cleanup,
+     * and only for successfully loaded arrays.
+     */
+    if (err == 0)
+    {
+        struct block_device *bd;
+
+        bd = blkdev_get_by_dev(mdev, FMODE_READ, NULL);
+        if (IS_ERR(bd))
+            pr_err("md: failed to get md device\n");
+        else
+            blkdev_put(bd, FMODE_READ);
+    }
+}
+
 static int __init raid_setup(char *str)
 {
     int len, pos;
diff -Naur linux-5.12.2.orig/drivers/md/md.c linux-5.12.2/drivers/md/md.c
--- linux-5.12.2.orig/drivers/md/md.c    2021-05-12 09:14:07.127441838 +0100
+++ linux-5.12.2/drivers/md/md.c    2021-05-12 09:34:26.960827487 +0100
@@ -6467,6 +6467,20 @@
         pr_warn("md: do_md_run() returned %d\n", err);
         do_md_stop(mddev, 0, NULL);
     }
+    else
+    {
+        /*
+         * Need to force read of partition table in order for partitioned
+         * arrays to be bootable.
+         */
+        struct block_device *bd;
+
+        bd = blkdev_get_by_dev(mddev->unit, FMODE_READ, NULL);
+        if (IS_ERR(bd))
+            pr_err("md: failed to get md device\n");
+        else
+            blkdev_put(bd, FMODE_READ);
+    }
 }

 /*



--

Geoff Back
What if we're all just characters in someone's nightmares?





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux