Merge branch 'for-4.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[sfrench/cifs-2.6.git] / fs / btrfs / send.c
index 8f1d3d6e7087a94d0a88e89d62238f143dc32e75..8fd195cfe81b97b92412b95ac645188eb9a5a693 100644 (file)
@@ -539,33 +539,23 @@ static struct btrfs_path *alloc_path_for_send(void)
 static int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off)
 {
        int ret;
-       mm_segment_t old_fs;
        u32 pos = 0;
 
-       old_fs = get_fs();
-       set_fs(KERNEL_DS);
-
        while (pos < len) {
-               ret = vfs_write(filp, (__force const char __user *)buf + pos,
-                               len - pos, off);
+               ret = kernel_write(filp, buf + pos, len - pos, off);
                /* TODO handle that correctly */
                /*if (ret == -ERESTARTSYS) {
                        continue;
                }*/
                if (ret < 0)
-                       goto out;
+                       return ret;
                if (ret == 0) {
-                       ret = -EIO;
-                       goto out;
+                       return -EIO;
                }
                pos += ret;
        }
 
-       ret = 0;
-
-out:
-       set_fs(old_fs);
-       return ret;
+       return 0;
 }
 
 static int tlv_put(struct send_ctx *sctx, u16 attr, const void *data, int len)
@@ -2640,7 +2630,7 @@ static int send_create_inode(struct send_ctx *sctx, u64 ino)
        } else {
                btrfs_warn(sctx->send_root->fs_info, "unexpected inode type %o",
                                (int)(mode & S_IFMT));
-               ret = -ENOTSUPP;
+               ret = -EOPNOTSUPP;
                goto out;
        }