btrfs-progs: mkfs: Cleanup temporary chunks before filling rootdir
authorQu Wenruo <wqu@suse.com>
Wed, 29 Nov 2017 06:31:39 +0000 (14:31 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jan 2018 17:11:38 +0000 (18:11 +0100)
Cleanup of temporary chunks should be done as soon as possible, and it
should be especially before doing large tree operations, like filling
the filesystem when using --rootdir.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
mkfs/main.c

index 5b5193d..ec6b2f8 100644 (file)
@@ -1223,6 +1223,13 @@ raid_groups:
                goto out;
        }
 
+       ret = cleanup_temp_chunks(fs_info, &allocation, data_profile,
+                                 metadata_profile, metadata_profile);
+       if (ret < 0) {
+               error("failed to cleanup temporary chunks: %d", ret);
+               goto out;
+       }
+
        if (source_dir_set) {
                trans = btrfs_start_transaction(root, 1);
                BUG_ON(IS_ERR(trans));
@@ -1245,12 +1252,6 @@ raid_groups:
                        goto out;
                }
        }
-       ret = cleanup_temp_chunks(fs_info, &allocation, data_profile,
-                                 metadata_profile, metadata_profile);
-       if (ret < 0) {
-               error("failed to cleanup temporary chunks: %d", ret);
-               goto out;
-       }
 
        if (verbose) {
                char features_buf[64];