Btrfs-progs: btrfs-image: don't call pthread_join on IDs not present
commita185d8541a4f9a7a23863277358229b45f091981
authorRakesh Pandit <rakesh@tuxera.com>
Fri, 21 Mar 2014 01:06:23 +0000 (21 03:06 +0200)
committerDavid Sterba <dsterba@suse.cz>
Tue, 22 Apr 2014 12:33:31 +0000 (22 14:33 +0200)
treedfe4a8a1c850a3836890b4ed3b6a47c4ba5e9afd
parentfddeecb7d424d5bb1a93a19a5e537057a4a7f597
Btrfs-progs: btrfs-image: don't call pthread_join on IDs not present

If pthread_create fails in mdrestore_init, then number of threads
created could be less then num of threads option. Hence pass number of
successful pthread_create calls to mdrestore_destroy, so that we don't
call pthread_join on IDs not present when pthread_create fails.

metadump_init already had this fixed, but repeats code from
metadump_destroy. Reuse metadump_destroy by passing number of threads
created (successful pthread_create calls) and save repeated cleaup
code. Had to move metadump_destroy before metadump_init for obvious
reasons.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
btrfs-image.c