]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Extend get_subvol_wrapper with another parameter which tells whether or not to align...
authorNathan Scott <nathans@sgi.com>
Mon, 6 Jun 2005 06:01:44 +0000 (06:01 +0000)
committerNathan Scott <nathans@sgi.com>
Mon, 6 Jun 2005 06:01:44 +0000 (06:01 +0000)
Merge of master-melb:xfs-cmds:22829a by kenmcd.

include/volume.h
libdisk/dm.c
libdisk/drivers.c
libdisk/drivers.h
libdisk/evms.c
libdisk/lvm.c
libdisk/md.c
libdisk/xvm.c
mkfs/xfs_mkfs.c

index ff66d7e99bd3fed4280c91378e08830fe5a2ddf9..12a63d6050ae407e10c448a6801fa1244773e327 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -60,7 +60,7 @@ typedef enum sv_type_e {
        SVTYPE_LAST             =255
 } sv_type_t;
 
-extern void get_subvol_stripe_wrapper (char *, sv_type_t, int *, int *);
+extern void get_subvol_stripe_wrapper (char *, sv_type_t, int *, int *, int *);
 extern int  get_driver_block_major (const char *, int);
 
 #endif /* __VOLUME_H__ */
index cec782ff8ef561650d3ab169e60b5cb1b7cd6df3..e9d2882f81a2f3520a7c4b7e488bdd415842bf1c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2004-2005 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -45,6 +45,7 @@ dm_get_subvol_stripe(
        sv_type_t       type,
        int             *sunit,
        int             *swidth,
+       int             *sectalign,
        struct stat64   *sb)
 {
        int             count, stripes = 0, stripesize = 0;
@@ -120,5 +121,6 @@ dm_get_subvol_stripe(
        /* Update sizes */
        *sunit = stripesize;
        *swidth = (stripes * stripesize);
+       *sectalign = 0;
        return 1;
 }
index 4cbb9344d773013822eae8b9ab9899ee805b38a5..64b4f074efaf2fe813a7e1b9a9c53929b4ed9570 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
 #include "drivers.h"
 
 void
-get_subvol_stripe_wrapper(char *dev, sv_type_t type, int *sunit, int *swidth)
+get_subvol_stripe_wrapper(
+       char            *dev,
+       sv_type_t       type,
+       int             *sunit,
+       int             *swidth,
+       int             *sectalign)
 {
-       struct stat64 sb;
+       struct stat64   sb;
 
        if (dev == NULL)
                return;
@@ -46,15 +51,15 @@ get_subvol_stripe_wrapper(char *dev, sv_type_t type, int *sunit, int *swidth)
                exit(1);
        }
 
-       if (  dm_get_subvol_stripe(dev, type, sunit, swidth, &sb))
+       if (  dm_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb))
                return;
-       if (  md_get_subvol_stripe(dev, type, sunit, swidth, &sb))
+       if (  md_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb))
                return;
-       if ( lvm_get_subvol_stripe(dev, type, sunit, swidth, &sb))
+       if ( lvm_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb))
                return;
-       if ( xvm_get_subvol_stripe(dev, type, sunit, swidth, &sb))
+       if ( xvm_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb))
                return;
-       if (evms_get_subvol_stripe(dev, type, sunit, swidth, &sb))
+       if (evms_get_subvol_stripe(dev, type, sunit, swidth, sectalign, &sb))
                return;
 
        /* ... add new device drivers here */
@@ -68,11 +73,13 @@ get_subvol_stripe_wrapper(char *dev, sv_type_t type, int *sunit, int *swidth)
  * being used in the running kernel.
  */
 int
-get_driver_block_major(const char *driver, int major)
+get_driver_block_major(
+       const char      *driver,
+       int             major)
 {
-       FILE    *f;
-       char    buf[64], puf[64];
-       int     dmajor, match = 0;
+       FILE            *f;
+       char            buf[64], puf[64];
+       int             dmajor, match = 0;
 
        if ((f = fopen(DEVICES, "r")) == NULL)
                return match;
index c712064bcf4984de0f19444a4b09216f5219a256..41c5f6c811b07b7da593c68d6b5d8c5865293eae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
  */
 
 #ifdef __linux__
-extern int   dm_get_subvol_stripe(char*, sv_type_t, int*, int*, struct stat64*);
-extern int   md_get_subvol_stripe(char*, sv_type_t, int*, int*, struct stat64*);
-extern int  lvm_get_subvol_stripe(char*, sv_type_t, int*, int*, struct stat64*);
-extern int  xvm_get_subvol_stripe(char*, sv_type_t, int*, int*, struct stat64*);
-extern int evms_get_subvol_stripe(char*, sv_type_t, int*, int*, struct stat64*);
+extern int   dm_get_subvol_stripe(char*, sv_type_t, int*, int*, int*,
+                                       struct stat64*);
+extern int   md_get_subvol_stripe(char*, sv_type_t, int*, int*, int*,
+                                       struct stat64*);
+extern int  lvm_get_subvol_stripe(char*, sv_type_t, int*, int*, int*,
+                                       struct stat64*);
+extern int  xvm_get_subvol_stripe(char*, sv_type_t, int*, int*, int*,
+                                       struct stat64*);
+extern int evms_get_subvol_stripe(char*, sv_type_t, int*, int*, int*,
+                                       struct stat64*);
 #else
 #define stat64 stat
-#define   dm_get_subvol_stripe(dev, type, a, b, stat)  (-1)
-#define   md_get_subvol_stripe(dev, type, a, b, stat)  (-1)
-#define  lvm_get_subvol_stripe(dev, type, a, b, stat)  (-1)
-#define  xvm_get_subvol_stripe(dev, type, a, b, stat)  (-1)
-#define evms_get_subvol_stripe(dev, type, a, b, stat)  (-1)
+#define   dm_get_subvol_stripe(dev, type, a, b, c, stat)  (-1)
+#define   md_get_subvol_stripe(dev, type, a, b, c, stat)  (-1)
+#define  lvm_get_subvol_stripe(dev, type, a, b, c, stat)  (-1)
+#define  xvm_get_subvol_stripe(dev, type, a, b, c, stat)  (-1)
+#define evms_get_subvol_stripe(dev, type, a, b, c, stat)  (-1)
 #endif
index a41e62a83e3843b1f15221c7a125d8ab93f3a08d..4c22ee190e002612161f921ac7195a94bc3320fc 100644 (file)
@@ -40,6 +40,7 @@ evms_get_subvol_stripe(
        sv_type_t       type,
        int             *sunit,
        int             *swidth,
+       int             *sectalign,
        struct stat64   *sb)
 {
        if (mnt_is_evms_subvol(sb->st_rdev)) {
@@ -58,6 +59,7 @@ evms_get_subvol_stripe(
                /* Update sizes */
                *sunit = info.size;
                *swidth = *sunit * info.width;
+               *sectalign = 0;
 
                close(fd);
                return 1;
index 327808fff92ab7b3f1baa01803f3f96ed44f759a..89dd6e2bc258a9a2d04b9069979a904240b1967e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -51,6 +51,7 @@ lvm_get_subvol_stripe(
        sv_type_t       type,
        int             *sunit,
        int             *swidth,
+       int             *sectalign,
        struct stat64   *sb)
 {
        int             lvpipe[2], stripes = 0, stripesize = 0;
@@ -122,6 +123,7 @@ lvm_get_subvol_stripe(
        /* Update sizes */
        *sunit = stripesize << 1;
        *swidth = (stripes * stripesize) << 1;
+       *sectalign = 0;
 
        fclose(stream);
 
index bbf77329425cc5c352bf9e7d766b29446ba6022d..cbfd2cd17810c6057015336910ce7b017bb9398e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -48,6 +48,7 @@ md_get_subvol_stripe(
        sv_type_t       type,
        int             *sunit,
        int             *swidth,
+       int             *sectalign,
        struct stat64   *sb)
 {
        if (mnt_is_md_subvol(sb->st_rdev)) {
@@ -91,6 +92,7 @@ md_get_subvol_stripe(
                /* Update sizes */
                *sunit = md.chunk_size >> 9;
                *swidth = *sunit * md.nr_disks;
+               *sectalign = (md.level == 4 || md.level == 5 || md.level == 6);
 
                return 1;
        }
index 451cac6a75c78c8dbc64ee0e4f3835efa01a4b6a..a2265a256cd2f48397a1e0339c3097ffd271b942 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of version 2 of the GNU General Public License as
@@ -61,6 +61,7 @@ xvm_get_subvol_stripe(
        sv_type_t       type,
        int             *sunit,
        int             *swidth,
+       int             *sectalign,
        struct stat64   *sb)
 {
        int fd;
@@ -100,6 +101,7 @@ xvm_get_subvol_stripe(
 
        *sunit = subvol_stripe.unit_size;
        *swidth = *sunit * subvol_stripe.width_size;
+       *sectalign = 0;
        close(fd);
        return 1;
 }
index d4f7c95083e740f6380efbf65e4c4b15fc850110..1d018655be4e6f3ac9bd17ab7033bfa10df88102 100644 (file)
@@ -587,6 +587,7 @@ main(
        char                    *rtfile;
        char                    *rtsize;
        xfs_sb_t                *sbp;
+       int                     sectoralign;
        int                     sectorlog;
        unsigned int            sectorsize;
        int                     slflag;
@@ -1270,6 +1271,8 @@ main(
 
        /*
         * Blocksize and sectorsize first, other things depend on them
+        * For RAID4/5/6 we want to align sector size and block size,
+        * so we need to start with the device geometry extraction too.
         */
        if (!blflag && !bsflag) {
                blocklog = XFS_DFL_BLOCKSIZE_LOG;
@@ -1279,6 +1282,20 @@ main(
                fprintf(stderr, _("illegal block size %d\n"), blocksize);
                usage();
        }
+
+       sectoralign = 0;
+       xlv_dsunit = xlv_dswidth = 0;
+       if (!nodsflag && !xi.disfile)
+               get_subvol_stripe_wrapper(dfile, SVTYPE_DATA,
+                               &xlv_dsunit, &xlv_dswidth, &sectoralign);
+       if (sectoralign) {
+               sectorsize = blocksize;
+               sectorlog = libxfs_highbit32(sectorsize);
+               if (loginternal) {
+                       lsectorsize = sectorsize;
+                       lsectorlog = sectorlog;
+               }
+       }
        if (sectorsize < XFS_MIN_SECTORSIZE ||
            sectorsize > XFS_MAX_SECTORSIZE || sectorsize > blocksize) {
                fprintf(stderr, _("illegal sector size %d\n"), sectorsize);
@@ -1443,8 +1460,8 @@ main(
                dummy1 = rswidth = 0;
 
                if (!norsflag && !xi.risfile && !(!rtsize && xi.disfile))
-                       get_subvol_stripe_wrapper(dfile, SVTYPE_RT, &dummy1, 
-                                                 &rswidth);
+                       get_subvol_stripe_wrapper(dfile, SVTYPE_RT, &dummy1,
+                                                 &rswidth, &dummy1);
 
                /* check that rswidth is a multiple of fs blocksize */
                if (!norsflag && rswidth && !(BBTOB(rswidth) % blocksize)) {
@@ -1687,10 +1704,6 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
 
        validate_ag_geometry(blocklog, dblocks, agsize, agcount);
 
-       xlv_dsunit = xlv_dswidth = 0;
-       if (!nodsflag && !xi.disfile)
-               get_subvol_stripe_wrapper(dfile, SVTYPE_DATA,
-                                               &xlv_dsunit, &xlv_dswidth);
        if (!nodsflag && dsunit) {
                if (xlv_dsunit && xlv_dsunit != dsunit) {
                        fprintf(stderr,