]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: fix reflink/rmap logic w.r.t. realtime devices and crc=0 support
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 30 Sep 2020 14:59:15 +0000 (10:59 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 30 Sep 2020 14:59:15 +0000 (10:59 -0400)
mkfs has some logic to deal with situations where reflink or rmapbt are
turned on and the administrator has configured a realtime device or a V4
filesystem; such configurations are not allowed.

The logic ought to disable reflink and/or rmapbt if they're enabled due
to being the defaults, and it ought to complain and abort if they're
enabled because the admin explicitly turned them on.

Unfortunately, the logic here doesn't do that and makes no sense at all
since usage() exits the program.  Fix it to follow what everything else
does.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
mkfs/xfs_mkfs.c

index 4f8f75803d31bd656caa676a5402339f7551458b..0b9cbdbe1c33abed0f66ec1f37bf3a78d5aa8c29 100644 (file)
@@ -1973,7 +1973,7 @@ _("sparse inodes not supported without CRC support\n"));
                }
                cli->sb_feat.spinodes = false;
 
-               if (cli->sb_feat.rmapbt) {
+               if (cli->sb_feat.rmapbt && cli_opt_set(&mopts, M_RMAPBT)) {
                        fprintf(stderr,
 _("rmapbt not supported without CRC support\n"));
                        usage();
@@ -1995,17 +1995,19 @@ _("cowextsize not supported without reflink support\n"));
                usage();
        }
 
-       if (cli->sb_feat.reflink && cli->xi->rtname) {
-               fprintf(stderr,
+       if (cli->xi->rtname) {
+               if (cli->sb_feat.reflink && cli_opt_set(&mopts, M_REFLINK)) {
+                       fprintf(stderr,
 _("reflink not supported with realtime devices\n"));
-               usage();
+                       usage();
+               }
                cli->sb_feat.reflink = false;
-       }
 
-       if (cli->sb_feat.rmapbt && cli->xi->rtname) {
-               fprintf(stderr,
+               if (cli->sb_feat.rmapbt && cli_opt_set(&mopts, M_RMAPBT)) {
+                       fprintf(stderr,
 _("rmapbt not supported with realtime devices\n"));
-               usage();
+                       usage();
+               }
                cli->sb_feat.rmapbt = false;
        }