btrfs-progs: mkfs: Enhance minimal device size calculation to fix mkfs failure on...
[platform/upstream/btrfs-progs.git] / mkfs / main.c
index a69a699..90fab59 100644 (file)
@@ -1598,8 +1598,12 @@ int main(int argc, char **argv)
        while (dev_cnt-- > 0) {
                file = argv[optind++];
                if (is_block_device(file) == 1)
-                       if (test_dev_for_mkfs(file, force_overwrite))
-                               goto error;
+                       ret = test_dev_for_mkfs(file, force_overwrite);
+               else
+                       ret = test_status_for_mkfs(file, force_overwrite);
+
+               if (ret)
+                       goto error;
        }
 
        optind = saved_optind;
@@ -1664,7 +1668,8 @@ int main(int argc, char **argv)
                goto error;
        }
 
-       min_dev_size = btrfs_min_dev_size(nodesize);
+       min_dev_size = btrfs_min_dev_size(nodesize, mixed, metadata_profile,
+                                         data_profile);
        /* Check device/block_count after the nodesize is determined */
        if (block_count && block_count < min_dev_size) {
                error("size %llu is too small to make a usable filesystem",