btrfs-progs: image: don't create unused threads

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>
This commit is contained in:
Zhao Lei 2015-09-09 21:32:22 +08:00 committed by David Sterba
parent 50ef0322b4
commit de554435e8
1 changed files with 8 additions and 5 deletions

View File

@ -2786,12 +2786,15 @@ int main(int argc, char *argv[])
} }
} }
if ((compress_level > 0 || create == 0) && if (compress_level > 0 || create == 0) {
num_threads == 0) { if (num_threads == 0) {
num_threads = sysconf(_SC_NPROCESSORS_ONLN); num_threads = sysconf(_SC_NPROCESSORS_ONLN);
if (num_threads <= 0) if (num_threads <= 0)
num_threads = 1; num_threads = 1;
} }
} else {
num_threads = 0;
}
if (create) { if (create) {
ret = check_mounted(source); ret = check_mounted(source);