btrfs-progs: mkfs: return nozero value on thin provisioned device
authorSu Yue <suy.fnst@cn.fujitsu.com>
Tue, 3 Apr 2018 08:39:45 +0000 (16:39 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 11 Apr 2018 13:37:36 +0000 (15:37 +0200)
With mkfs.btrfs on a thin provisioned device with very small backing
size and big virtual size, all code works well in mkfs.btrfs until
close_ctree() is called.
close_ctree() fails to sync device due to small backing size while
closing devices.  However, mkfs returns 0 in such situation which causes
failure of fstests generic/405.

So, let mkfs returns nonzero value if previous steps succeeded but
close_ctree() failed. Then fstests generic/405 passes now.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
mkfs/main.c

index b65b18d..0337993 100644 (file)
@@ -1295,6 +1295,12 @@ out:
                }
        }
 
+       if (!ret && close_ret) {
+               ret = close_ret;
+               error("failed to close ctree, the filesystem may be inconsistent: %d",
+                     ret);
+       }
+
        btrfs_close_all_devices();
        free(label);