Btrfs: fix file loss on log replay after renaming a file and fsync
[cascardo/linux.git] / fs / btrfs / ioctl.c
index 6110d8c..0af5ecb 100644 (file)
@@ -59,6 +59,7 @@
 #include "props.h"
 #include "sysfs.h"
 #include "qgroup.h"
+#include "tree-log.h"
 
 #ifdef CONFIG_64BIT
 /* If we have a 32-bit userspace and 64-bit kernel, then the UAPI
@@ -2093,8 +2094,6 @@ static noinline int search_ioctl(struct inode *inode,
                key.offset = (u64)-1;
                root = btrfs_read_fs_root_no_name(info, &key);
                if (IS_ERR(root)) {
-                       btrfs_err(info, "could not find root %llu",
-                              sk->tree_id);
                        btrfs_free_path(path);
                        return -ENOENT;
                }
@@ -2472,6 +2471,8 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
        trans->block_rsv = &block_rsv;
        trans->bytes_reserved = block_rsv.size;
 
+       btrfs_record_snapshot_destroy(trans, dir);
+
        ret = btrfs_unlink_subvol(trans, root, dir,
                                dest->root_key.objectid,
                                dentry->d_name.name,
@@ -5259,8 +5260,7 @@ out_unlock:
          .compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_##suffix, \
          .incompat_flags = BTRFS_FEATURE_INCOMPAT_##suffix }
 
-static int btrfs_ioctl_get_supported_features(struct file *file,
-                                             void __user *arg)
+int btrfs_ioctl_get_supported_features(void __user *arg)
 {
        static const struct btrfs_ioctl_feature_flags features[3] = {
                INIT_FEATURE_FLAGS(SUPP),
@@ -5539,7 +5539,7 @@ long btrfs_ioctl(struct file *file, unsigned int
        case BTRFS_IOC_SET_FSLABEL:
                return btrfs_ioctl_set_fslabel(file, argp);
        case BTRFS_IOC_GET_SUPPORTED_FEATURES:
-               return btrfs_ioctl_get_supported_features(file, argp);
+               return btrfs_ioctl_get_supported_features(argp);
        case BTRFS_IOC_GET_FEATURES:
                return btrfs_ioctl_get_features(file, argp);
        case BTRFS_IOC_SET_FEATURES: