fs/splice: Pull buf->ops->confirm() from splice_from_pipe actors

This patch pulls calls to buf->ops->confirm() from all actors passed
(also indirectly) to splice_from_pipe_feed().

Is avoiding the call to buf->ops->confirm() while splice()ing to
/dev/null is an intentional optimization? No other user does that
and this will remove this special case.

Against current linux.git 6313e3c217.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
This commit is contained in:
Michał Mirosław 2010-12-17 08:56:44 +01:00 committed by Jens Axboe
parent e4ea0c16a8
commit a8adbe378b
3 changed files with 13 additions and 36 deletions

View file

@ -397,10 +397,6 @@ lo_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
sector_t IV; sector_t IV;
int size, ret; int size, ret;
ret = buf->ops->confirm(pipe, buf);
if (unlikely(ret))
return ret;
IV = ((sector_t) page->index << (PAGE_CACHE_SHIFT - 9)) + IV = ((sector_t) page->index << (PAGE_CACHE_SHIFT - 9)) +
(buf->offset >> 9); (buf->offset >> 9);
size = sd->len; size = sd->len;

View file

@ -847,10 +847,6 @@ nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
size_t size; size_t size;
int ret; int ret;
ret = buf->ops->confirm(pipe, buf);
if (unlikely(ret))
return ret;
size = sd->len; size = sd->len;
if (rqstp->rq_res.page_len == 0) { if (rqstp->rq_res.page_len == 0) {

View file

@ -682,19 +682,14 @@ static int pipe_to_sendpage(struct pipe_inode_info *pipe,
{ {
struct file *file = sd->u.file; struct file *file = sd->u.file;
loff_t pos = sd->pos; loff_t pos = sd->pos;
int ret, more; int more;
ret = buf->ops->confirm(pipe, buf); if (!likely(file->f_op && file->f_op->sendpage))
if (!ret) { return -EINVAL;
more = (sd->flags & SPLICE_F_MORE) || sd->len < sd->total_len;
if (file->f_op && file->f_op->sendpage)
ret = file->f_op->sendpage(file, buf->page, buf->offset,
sd->len, &pos, more);
else
ret = -EINVAL;
}
return ret; more = (sd->flags & SPLICE_F_MORE) || sd->len < sd->total_len;
return file->f_op->sendpage(file, buf->page, buf->offset,
sd->len, &pos, more);
} }
/* /*
@ -727,13 +722,6 @@ int pipe_to_file(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
void *fsdata; void *fsdata;
int ret; int ret;
/*
* make sure the data in this buffer is uptodate
*/
ret = buf->ops->confirm(pipe, buf);
if (unlikely(ret))
return ret;
offset = sd->pos & ~PAGE_CACHE_MASK; offset = sd->pos & ~PAGE_CACHE_MASK;
this_len = sd->len; this_len = sd->len;
@ -805,12 +793,17 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
if (sd->len > sd->total_len) if (sd->len > sd->total_len)
sd->len = sd->total_len; sd->len = sd->total_len;
ret = actor(pipe, buf, sd); ret = buf->ops->confirm(pipe, buf);
if (ret <= 0) { if (unlikely(ret)) {
if (ret == -ENODATA) if (ret == -ENODATA)
ret = 0; ret = 0;
return ret; return ret;
} }
ret = actor(pipe, buf, sd);
if (ret <= 0)
return ret;
buf->offset += ret; buf->offset += ret;
buf->len -= ret; buf->len -= ret;
@ -1044,10 +1037,6 @@ static int write_pipe_buf(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
int ret; int ret;
void *data; void *data;
ret = buf->ops->confirm(pipe, buf);
if (ret)
return ret;
data = buf->ops->map(pipe, buf, 0); data = buf->ops->map(pipe, buf, 0);
ret = kernel_write(sd->u.file, data + buf->offset, sd->len, sd->pos); ret = kernel_write(sd->u.file, data + buf->offset, sd->len, sd->pos);
buf->ops->unmap(pipe, buf, data); buf->ops->unmap(pipe, buf, data);
@ -1507,10 +1496,6 @@ static int pipe_to_user(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
char *src; char *src;
int ret; int ret;
ret = buf->ops->confirm(pipe, buf);
if (unlikely(ret))
return ret;
/* /*
* See if we can use the atomic maps, by prefaulting in the * See if we can use the atomic maps, by prefaulting in the
* pages and doing an atomic copy * pages and doing an atomic copy