]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: test that -l su is a multiple of block size
authorJan Tulak <jtulak@redhat.com>
Tue, 21 Jun 2016 02:54:30 +0000 (12:54 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 21 Jun 2016 02:54:30 +0000 (12:54 +1000)
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 <jtulak@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
mkfs/xfs_mkfs.c

index 47e2219e4fc4165187d5fe2aeabdd9b64ef35af1..82c9eaafad68627bd86dfd303c83c43e1ab9c2e6 100644 (file)
@@ -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) {