]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Automagic stripe unit/stripe width extraction for MD RAID devices
authorMartin K. Petersen <mkp@linuxcare.com>
Tue, 27 Mar 2001 04:24:31 +0000 (04:24 +0000)
committerMartin K. Petersen <mkp@linuxcare.com>
Tue, 27 Mar 2001 04:24:31 +0000 (04:24 +0000)
VERSION
doc/CHANGES
mkfs/xfs_mkfs.c

diff --git a/VERSION b/VERSION
index 6510a1b7954e30758ad2cb936729b8c958e1507c..914aa3026e8acc5e8617b6057f08baa13b610bd1 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -3,5 +3,5 @@
 #
 PKG_MAJOR=1
 PKG_MINOR=1
-PKG_REVISION=8
+PKG_REVISION=9
 PKG_BUILD=0
index bef1f39fff5113d4106944e5f1283d31769719b6..2c3acd2110c444233b30ab844a4a6253e6aa038c 100644 (file)
@@ -1,3 +1,6 @@
+xfsprogs-1.1.9 (26 March 2001)
+       - Added automagic stripe unit/stripe width extraction for MD devices
+
 xfsprogs-1.1.8 (23 March 2001)
        - mkfs heuristics to make a qualified guess of internal logsize
 
index aa913a91aa3f526f187c16f3b2e99486f56a5c33..fe095badb6b9ead664f74579754c9cf793e8382d 100644 (file)
@@ -46,6 +46,8 @@
   int opt_d;           /* Same thing */
 #endif
 
+#include "md-int.h"
+
 /*
  * Prototypes for internal functions.
  */
@@ -261,6 +263,7 @@ static void
 get_subvol_stripe_wrapper(char *dfile, int type, int *sunit, int *swidth)
 {
        struct stat64 sb;
+       struct md_array_info_s md;
 #if HAVE_LIBLVM
         lv_t *lv;
        char *vgname;
@@ -274,40 +277,79 @@ get_subvol_stripe_wrapper(char *dfile, int type, int *sunit, int *swidth)
                usage();
         }
 
-#if HAVE_LIBLVM
-       /* If this is not an LVM volume, just bail out */
-        if (sb.st_rdev >> 8 != LVM_BLK_MAJOR) 
-               return;
+       /* MD volume */
+       if (sb.st_rdev >> 8 == MD_MAJOR) {
+               int fd;
 
-       /* Find volume group */
-        if (! (vgname = vg_name_of_lv (dfile))) {
-                fprintf (stderr, "Can't find volume group for %s\n", dfile);
-               usage();
-        }
+               /* Open device */
+               fd = open (dfile, O_RDONLY);
+               if (fd == -1)
+                       return;
+               
+               /* Is this thing on... */
+               if (ioctl (fd, GET_ARRAY_INFO, &md)) {
+                       fprintf (stderr, "Error getting array info from %s\n",
+                                dfile);
+                       usage();
+               }
 
-       /* Logical volume */
-        if (! lvm_tab_lv_check_exist (dfile)) {
-                fprintf (stderr, "Logical volume %s doesn't exist!\n", dfile);
-               usage();
-        }
+               /* Check state */
+               if (md.state) {
+                       fprintf (stderr, "MD array %s not in clean state\n",
+                                dfile);
+                       usage();
+               }
 
-       /* Get status */
-        if (lv_status_byname (vgname, dfile, &lv) < 0 || lv == NULL) {
-                fprintf (stderr, "Could not get status info from %s\n", dfile);
-               usage();
-        }
+               /* Deduct a disk from stripe width on RAID5 */
+               if (md.level == 5)
+                       md.nr_disks--;
+                       
+               /* Update sizes */
+               *sunit = md.chunk_size >> 9;
+               *swidth = *sunit * md.nr_disks;
 
-       /* Check that data is consistent */
-        if (lv_check_consistency (lv) < 0) {
-                fprintf (stderr, "Logical volume %s is inconsistent\n", dfile);
-               usage();
-        }
-        
-       /* Update sizes */
-        *sunit = lv->lv_stripesize;
-        *swidth = lv->lv_stripes * lv->lv_stripesize;
+               return;
+       }
+
+#if HAVE_LIBLVM
+       /* LVM volume */
+       if (sb.st_rdev >> 8 == LVM_BLK_MAJOR) {
 
+               /* Find volume group */
+               if (! (vgname = vg_name_of_lv (dfile))) {
+                       fprintf (stderr, "Can't find volume group for %s\n", 
+                                dfile);
+                       usage();
+               }
+               
+               /* Logical volume */
+               if (! lvm_tab_lv_check_exist (dfile)) {
+                       fprintf (stderr, "Logical volume %s doesn't exist!\n",
+                                dfile);
+                       usage();
+               }
+               
+               /* Get status */
+               if (lv_status_byname (vgname, dfile, &lv) < 0 || lv == NULL) {
+                       fprintf (stderr, "Could not get status info from %s\n",
+                                dfile);
+                       usage();
+               }
+               
+               /* Check that data is consistent */
+               if (lv_check_consistency (lv) < 0) {
+                       fprintf (stderr, "Logical volume %s is inconsistent\n",
+                                dfile);
+                       usage();
+               }
+               
+               /* Update sizes */
+               *sunit = lv->lv_stripesize;
+               *swidth = lv->lv_stripes * lv->lv_stripesize;
+               
+               return;
 #endif /* HAVE_LIBLVM */
+       }
 }