diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-20 13:19:30 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-21 13:11:11 -0400 |
commit | 06ae43f34bcc07a0b6be8bf78a1c895bcd12c839 (patch) | |
tree | b74fe0c7e9370dfed956a1607dd10282c9ba1096 | |
parent | f6161aa153581da4a3867a2d1a7caf4be19b6ec9 (diff) |
Don't bother with redoing rw_verify_area() from default_file_splice_from()
default_file_splice_from() ends up calling vfs_write() (via very convoluted
callchain). It's an overkill, since we already have done rw_verify_area()
in the caller by the time we call vfs_write() we are under set_fs(KERNEL_DS),
so access_ok() is also pointless. Add a new helper (__kernel_write()),
use it instead of kernel_write() in there.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/internal.h | 5 | ||||
-rw-r--r-- | fs/read_write.c | 25 | ||||
-rw-r--r-- | fs/splice.c | 4 |
3 files changed, 33 insertions, 1 deletions
diff --git a/fs/internal.h b/fs/internal.h index 507141fceb99..4be78237d896 100644 --- a/fs/internal.h +++ b/fs/internal.h | |||
@@ -125,3 +125,8 @@ extern int invalidate_inodes(struct super_block *, bool); | |||
125 | * dcache.c | 125 | * dcache.c |
126 | */ | 126 | */ |
127 | extern struct dentry *__d_alloc(struct super_block *, const struct qstr *); | 127 | extern struct dentry *__d_alloc(struct super_block *, const struct qstr *); |
128 | |||
129 | /* | ||
130 | * read_write.c | ||
131 | */ | ||
132 | extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *); | ||
diff --git a/fs/read_write.c b/fs/read_write.c index a698eff457fb..f7b5a23b804b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/splice.h> | 17 | #include <linux/splice.h> |
18 | #include <linux/compat.h> | 18 | #include <linux/compat.h> |
19 | #include "read_write.h" | 19 | #include "read_write.h" |
20 | #include "internal.h" | ||
20 | 21 | ||
21 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
22 | #include <asm/unistd.h> | 23 | #include <asm/unistd.h> |
@@ -417,6 +418,30 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof | |||
417 | 418 | ||
418 | EXPORT_SYMBOL(do_sync_write); | 419 | EXPORT_SYMBOL(do_sync_write); |
419 | 420 | ||
421 | ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos) | ||
422 | { | ||
423 | mm_segment_t old_fs; | ||
424 | const char __user *p; | ||
425 | ssize_t ret; | ||
426 | |||
427 | old_fs = get_fs(); | ||
428 | set_fs(get_ds()); | ||
429 | p = (__force const char __user *)buf; | ||
430 | if (count > MAX_RW_COUNT) | ||
431 | count = MAX_RW_COUNT; | ||
432 | if (file->f_op->write) | ||
433 | ret = file->f_op->write(file, p, count, pos); | ||
434 | else | ||
435 | ret = do_sync_write(file, p, count, pos); | ||
436 | set_fs(old_fs); | ||
437 | if (ret > 0) { | ||
438 | fsnotify_modify(file); | ||
439 | add_wchar(current, ret); | ||
440 | } | ||
441 | inc_syscw(current); | ||
442 | return ret; | ||
443 | } | ||
444 | |||
420 | ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) | 445 | ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) |
421 | { | 446 | { |
422 | ssize_t ret; | 447 | ssize_t ret; |
diff --git a/fs/splice.c b/fs/splice.c index 718bd0056384..29e394e49ddd 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/security.h> | 31 | #include <linux/security.h> |
32 | #include <linux/gfp.h> | 32 | #include <linux/gfp.h> |
33 | #include <linux/socket.h> | 33 | #include <linux/socket.h> |
34 | #include "internal.h" | ||
34 | 35 | ||
35 | /* | 36 | /* |
36 | * Attempt to steal a page from a pipe buffer. This should perhaps go into | 37 | * Attempt to steal a page from a pipe buffer. This should perhaps go into |
@@ -1048,9 +1049,10 @@ static int write_pipe_buf(struct pipe_inode_info *pipe, struct pipe_buffer *buf, | |||
1048 | { | 1049 | { |
1049 | int ret; | 1050 | int ret; |
1050 | void *data; | 1051 | void *data; |
1052 | loff_t tmp = sd->pos; | ||
1051 | 1053 | ||
1052 | data = buf->ops->map(pipe, buf, 0); | 1054 | data = buf->ops->map(pipe, buf, 0); |
1053 | ret = kernel_write(sd->u.file, data + buf->offset, sd->len, sd->pos); | 1055 | ret = __kernel_write(sd->u.file, data + buf->offset, sd->len, &tmp); |
1054 | buf->ops->unmap(pipe, buf, data); | 1056 | buf->ops->unmap(pipe, buf, data); |
1055 | 1057 | ||
1056 | return ret; | 1058 | return ret; |