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>
free_fs_roots_tree(&fs_info->fs_root_tree);
btrfs_release_all_roots(fs_info);
free_fs_roots_tree(&fs_info->fs_root_tree);
btrfs_release_all_roots(fs_info);
- btrfs_close_devices(fs_info->fs_devices);
+ ret = btrfs_close_devices(fs_info->fs_devices);
btrfs_cleanup_all_caches(fs_info);
btrfs_free_fs_info(fs_info);
btrfs_cleanup_all_caches(fs_info);
btrfs_free_fs_info(fs_info);
}
int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
}
int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
{
struct btrfs_fs_devices *seed_devices;
struct btrfs_device *device;
{
struct btrfs_fs_devices *seed_devices;
struct btrfs_device *device;
device = list_entry(fs_devices->devices.next,
struct btrfs_device, dev_list);
if (device->fd != -1) {
device = list_entry(fs_devices->devices.next,
struct btrfs_device, dev_list);
if (device->fd != -1) {
+ 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);
if (posix_fadvise(device->fd, 0, 0, POSIX_FADV_DONTNEED))
fprintf(stderr, "Warning, could not drop caches\n");
close(device->fd);
}
void btrfs_close_all_devices(void)
}
void btrfs_close_all_devices(void)