From: Martin K. Petersen Date: Tue, 27 Mar 2001 04:24:31 +0000 (+0000) Subject: Automagic stripe unit/stripe width extraction for MD RAID devices X-Git-Tag: v1.2.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=156fafc9114677e95150b8def3171518343b4017;p=thirdparty%2Fxfsprogs-dev.git Automagic stripe unit/stripe width extraction for MD RAID devices --- diff --git a/VERSION b/VERSION index 6510a1b79..914aa3026 100644 --- a/VERSION +++ b/VERSION @@ -3,5 +3,5 @@ # PKG_MAJOR=1 PKG_MINOR=1 -PKG_REVISION=8 +PKG_REVISION=9 PKG_BUILD=0 diff --git a/doc/CHANGES b/doc/CHANGES index bef1f39ff..2c3acd211 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -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 diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index aa913a91a..fe095badb 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -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 */ + } }