btrfs-progs: image: don't create unused threads
authorZhao Lei <zhaolei@cn.fujitsu.com>
Wed, 9 Sep 2015 13:32:22 +0000 (21:32 +0800)
committerDavid Sterba <dsterba@suse.com>
Fri, 11 Sep 2015 15:02:52 +0000 (17:02 +0200)
In case of creating an image without compression, we don't need to
create unused threads.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-image.c

index 6eddbd5d95c145713a8c7cb75587f5eb5e217cdd..551487fb03e25167ac0bedd3a486e6b71e4e99c4 100644 (file)
@@ -2786,11 +2786,14 @@ int main(int argc, char *argv[])
                }
        }
 
-       if ((compress_level > 0 || create == 0) &&
-           num_threads == 0) {
-               num_threads = sysconf(_SC_NPROCESSORS_ONLN);
-               if (num_threads <= 0)
-                       num_threads = 1;
+       if (compress_level > 0 || create == 0) {
+               if (num_threads == 0) {
+                       num_threads = sysconf(_SC_NPROCESSORS_ONLN);
+                       if (num_threads <= 0)
+                               num_threads = 1;
+               }
+       } else {
+               num_threads = 0;
        }
 
        if (create) {