Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[sfrench/cifs-2.6.git] / fs / splice.c
index fc71e9733f7a6d3cc148d1613603754c49ec81e4..3ee7e82df48f2b14d09ddd3b4877879e90f8c418 100644 (file)
@@ -353,7 +353,7 @@ static ssize_t kernel_readv(struct file *file, const struct kvec *vec,
        ssize_t res;
 
        old_fs = get_fs();
-       set_fs(get_ds());
+       set_fs(KERNEL_DS);
        /* The cast to a user pointer is valid due to the set_fs() */
        res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos, 0);
        set_fs(old_fs);
@@ -1119,6 +1119,9 @@ static long do_splice(struct file *in, loff_t __user *off_in,
                if (ipipe == opipe)
                        return -EINVAL;
 
+               if ((in->f_flags | out->f_flags) & O_NONBLOCK)
+                       flags |= SPLICE_F_NONBLOCK;
+
                return splice_pipe_to_pipe(ipipe, opipe, len, flags);
        }
 
@@ -1144,6 +1147,9 @@ static long do_splice(struct file *in, loff_t __user *off_in,
                if (unlikely(ret < 0))
                        return ret;
 
+               if (in->f_flags & O_NONBLOCK)
+                       flags |= SPLICE_F_NONBLOCK;
+
                file_start_write(out);
                ret = do_splice_from(ipipe, out, &offset, len, flags);
                file_end_write(out);
@@ -1168,6 +1174,9 @@ static long do_splice(struct file *in, loff_t __user *off_in,
                        offset = in->f_pos;
                }
 
+               if (out->f_flags & O_NONBLOCK)
+                       flags |= SPLICE_F_NONBLOCK;
+
                pipe_lock(opipe);
                ret = wait_for_space(opipe, flags);
                if (!ret)
@@ -1717,6 +1726,9 @@ static long do_tee(struct file *in, struct file *out, size_t len,
         * copying the data.
         */
        if (ipipe && opipe && ipipe != opipe) {
+               if ((in->f_flags | out->f_flags) & O_NONBLOCK)
+                       flags |= SPLICE_F_NONBLOCK;
+
                /*
                 * Keep going, unless we encounter an error. The ipipe/opipe
                 * ordering doesn't really matter.