]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: inode/block size error messages confusing
authorDave Chinner <dchinner@redhat.com>
Mon, 11 May 2015 00:09:22 +0000 (10:09 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 11 May 2015 00:09:22 +0000 (10:09 +1000)
As reported by Brain:

# ./mkfs/mkfs.xfs -f /dev/test/scratch -b size=512
illegal inode size 512
allowable inode size with 512 byte blocks is 256
# ./mkfs/mkfs.xfs -f /dev/test/scratch -b size=512 -i size=256
Minimum inode size for CRCs is 512 bytes
Usage: mkfs.xfs
...

Fix mkfs to catch the block size as being too small, rather than
leaving it for inode size detection to enforce.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
include/xfs_types.h
mkfs/xfs_mkfs.c

index 65c6e6650b1a5e86f586d7bbbc7b352758dd842b..accb95de7ec59393471e76a9e2ea9f49f0889e86 100644 (file)
@@ -100,11 +100,14 @@ typedef __uint64_t        xfs_filblks_t;  /* number of blocks in a file */
  * Minimum and maximum blocksize and sectorsize.
  * The blocksize upper limit is pretty much arbitrary.
  * The sectorsize upper limit is due to sizeof(sb_sectsize).
+ * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes
+ * cannot be used.
  */
 #define XFS_MIN_BLOCKSIZE_LOG  9       /* i.e. 512 bytes */
 #define XFS_MAX_BLOCKSIZE_LOG  16      /* i.e. 65536 bytes */
 #define XFS_MIN_BLOCKSIZE      (1 << XFS_MIN_BLOCKSIZE_LOG)
 #define XFS_MAX_BLOCKSIZE      (1 << XFS_MAX_BLOCKSIZE_LOG)
+#define XFS_MIN_CRC_BLOCKSIZE  (1 << (XFS_MIN_BLOCKSIZE_LOG + 1))
 #define XFS_MIN_SECTORSIZE_LOG 9       /* i.e. 512 bytes */
 #define XFS_MAX_SECTORSIZE_LOG 15      /* i.e. 32768 bytes */
 #define XFS_MIN_SECTORSIZE     (1 << XFS_MIN_SECTORSIZE_LOG)
index 0218491dd51ba0abc6d1d728febaea86998439b6..e2a052d40a781040021fdded6ad61c09d997c5d1 100644 (file)
@@ -1758,6 +1758,12 @@ _("cannot specify both crc and ftype\n"));
                fprintf(stderr, _("illegal block size %d\n"), blocksize);
                usage();
        }
+       if (crcs_enabled && blocksize < XFS_MIN_CRC_BLOCKSIZE) {
+               fprintf(stderr,
+_("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
+                       XFS_MIN_CRC_BLOCKSIZE);
+               usage();
+       }
 
        memset(&ft, 0, sizeof(ft));
        get_topology(&xi, &ft, force_overwrite);