diff options
author | Omar Sandoval <osandov@fb.com> | 2017-03-03 09:02:14 -0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-03-08 13:36:49 +0100 |
commit | 7fbb89d167ec2d8f3e7c0b46285778c1c481a742 (patch) | |
tree | 48ac1371e3860b2c70bfd09ace167f3e61030672 /volumes.c | |
parent | 839de9c033f3f6ecda2f61fcbcd1dfafc0e68125 (diff) |
btrfs-progs: report I/O errors when closing the filesystem
If the final fsync() on the Btrfs device fails, we just swallow the
error and don't alert the user in any way. This was uncovered by xfstest
generic/405, which checks that mkfs fails when it encounters EIO.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'volumes.c')
-rw-r--r-- | volumes.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -160,6 +160,7 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices) { struct btrfs_fs_devices *seed_devices; struct btrfs_device *device; + int ret = 0; again: if (!fs_devices) @@ -168,7 +169,11 @@ again: device = list_entry(fs_devices->devices.next, struct btrfs_device, dev_list); if (device->fd != -1) { - fsync(device->fd); + if (fsync(device->fd) == -1) { + warning("fsync on device %llu failed: %s", + device->devid, strerror(errno)); + ret = -errno; + } if (posix_fadvise(device->fd, 0, 0, POSIX_FADV_DONTNEED)) fprintf(stderr, "Warning, could not drop caches\n"); close(device->fd); @@ -197,7 +202,7 @@ again: free(fs_devices); } - return 0; + return ret; } void btrfs_close_all_devices(void) |