From: Jan Tulak Date: Tue, 21 Jun 2016 02:54:30 +0000 (+1000) Subject: mkfs: test that -l su is a multiple of block size X-Git-Tag: v4.7.0-rc1~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=587636b1418df1a3dd1e1bbd3f6f35a56eec332c;p=thirdparty%2Fxfsprogs-dev.git mkfs: test that -l su is a multiple of block size lsunit was already tested, but lsu was not. So a thing like -l su=4097 was possible. This commit adds a check to catch this, and moves the entire lsu/lsunit block size testing to calc_stripe_factors(), where already is some logic w.r.t. lsu/lsunit. Signed-off-by: Jan Tulak Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 47e2219e4..82c9eaafa 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -716,6 +716,9 @@ struct opt_params mopts = { */ #define WHACK_SIZE (128 * 1024) +/* + * Convert lsu to lsunit for 512 bytes blocks and check validity of the values. + */ static void calc_stripe_factors( int dsu, @@ -765,6 +768,20 @@ calc_stripe_factors( if (lsu) *lsunit = (int)BTOBBT(lsu); + + /* verify if lsu/lsunit is a multiple block size */ + if (lsu % blocksize != 0) { + fprintf(stderr, +_("log stripe unit (%d) must be a multiple of the block size (%d)\n"), + lsu, blocksize); + exit(1); + } + if ((BBTOB(*lsunit) % blocksize != 0)) { + fprintf(stderr, +_("log stripe unit (%d) must be a multiple of the block size (%d)\n"), + BBTOB(*lsunit), blocksize); + exit(1); + } } static void @@ -2537,12 +2554,6 @@ an AG size that is one stripe unit smaller, for example %llu.\n"), */ if (lsunit) { - if ((BBTOB(lsunit) % blocksize != 0)) { - fprintf(stderr, - _("log stripe unit (%d) must be a multiple of the block size (%d)\n"), - BBTOB(lsunit), blocksize); - exit(1); - } /* convert from 512 byte blocks to fs blocks */ lsunit = DTOBT(lsunit); } else if (sb_feat.log_version == 2 && loginternal && dsunit) {