From: Nathan Scott Date: Mon, 6 Jun 2005 06:01:44 +0000 (+0000) Subject: Extend get_subvol_wrapper with another parameter which tells whether or not to align... X-Git-Tag: v2.7.0~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c22b5fdfe43b2f93aa7b5f47cb81e80d25bec118;p=thirdparty%2Fxfsprogs-dev.git Extend get_subvol_wrapper with another parameter which tells whether or not to align sectors/blocks for this device. Use it in mkfs for RAID4/5/6. Merge of master-melb:xfs-cmds:22829a by kenmcd. --- diff --git a/include/volume.h b/include/volume.h index ff66d7e99..12a63d605 100644 --- a/include/volume.h +++ b/include/volume.h @@ -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__ */ diff --git a/libdisk/dm.c b/libdisk/dm.c index cec782ff8..e9d2882f8 100644 --- a/libdisk/dm.c +++ b/libdisk/dm.c @@ -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; } diff --git a/libdisk/drivers.c b/libdisk/drivers.c index 4cbb9344d..64b4f074e 100644 --- a/libdisk/drivers.c +++ b/libdisk/drivers.c @@ -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 @@ -33,9 +33,14 @@ #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; diff --git a/libdisk/drivers.h b/libdisk/drivers.h index c712064bc..41c5f6c81 100644 --- a/libdisk/drivers.h +++ b/libdisk/drivers.h @@ -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 @@ -39,16 +39,21 @@ */ #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 diff --git a/libdisk/evms.c b/libdisk/evms.c index a41e62a83..4c22ee190 100644 --- a/libdisk/evms.c +++ b/libdisk/evms.c @@ -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; diff --git a/libdisk/lvm.c b/libdisk/lvm.c index 327808fff..89dd6e2bc 100644 --- a/libdisk/lvm.c +++ b/libdisk/lvm.c @@ -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); diff --git a/libdisk/md.c b/libdisk/md.c index bbf773294..cbfd2cd17 100644 --- a/libdisk/md.c +++ b/libdisk/md.c @@ -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; } diff --git a/libdisk/xvm.c b/libdisk/xvm.c index 451cac6a7..a2265a256 100644 --- a/libdisk/xvm.c +++ b/libdisk/xvm.c @@ -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; } diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index d4f7c9508..1d018655b 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -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, §oralign); + 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,