Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25610
b: refs/heads/master
c: 6f767b0
h: refs/heads/master
v: v3
  • Loading branch information
Jens Axboe committed Apr 11, 2006
1 parent cce0201 commit c8cbc7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 923f4f23940d2361e8d5c4245982163a8e9d1c91
refs/heads/master: 6f767b0425f5902e4817648632230b512e81c963
33 changes: 13 additions & 20 deletions trunk/fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,15 @@ static ssize_t move_to_pipe(struct pipe_inode_info *pipe, struct page **pages,
mutex_lock(&pipe->inode->i_mutex);

for (;;) {
int bufs;

if (!pipe->readers) {
send_sig(SIGPIPE, current, 0);
if (!ret)
ret = -EPIPE;
break;
}

bufs = pipe->nrbufs;
if (bufs < PIPE_BUFFERS) {
int newbuf = (pipe->curbuf + bufs) & (PIPE_BUFFERS - 1);
if (pipe->nrbufs < PIPE_BUFFERS) {
int newbuf = (pipe->curbuf + pipe->nrbufs) & (PIPE_BUFFERS - 1);
struct pipe_buffer *buf = pipe->bufs + newbuf;
struct page *page = pages[i++];
unsigned long this_len;
Expand All @@ -174,8 +171,9 @@ static ssize_t move_to_pipe(struct pipe_inode_info *pipe, struct page **pages,
buf->offset = offset;
buf->len = this_len;
buf->ops = &page_cache_pipe_buf_ops;
pipe->nrbufs = ++bufs;
do_wakeup = 1;
pipe->nrbufs++;
if (pipe->inode)
do_wakeup = 1;

ret += this_len;
len -= this_len;
Expand All @@ -184,7 +182,7 @@ static ssize_t move_to_pipe(struct pipe_inode_info *pipe, struct page **pages,
break;
if (!len)
break;
if (bufs < PIPE_BUFFERS)
if (pipe->nrbufs < PIPE_BUFFERS)
continue;

break;
Expand Down Expand Up @@ -581,11 +579,8 @@ static ssize_t move_from_pipe(struct pipe_inode_info *pipe, struct file *out,
mutex_lock(&pipe->inode->i_mutex);

for (;;) {
int bufs = pipe->nrbufs;

if (bufs) {
int curbuf = pipe->curbuf;
struct pipe_buffer *buf = pipe->bufs + curbuf;
if (pipe->nrbufs) {
struct pipe_buffer *buf = pipe->bufs + pipe->curbuf;
struct pipe_buf_operations *ops = buf->ops;

sd.len = buf->len;
Expand All @@ -606,10 +601,10 @@ static ssize_t move_from_pipe(struct pipe_inode_info *pipe, struct file *out,
if (!buf->len) {
buf->ops = NULL;
ops->release(pipe, buf);
curbuf = (curbuf + 1) & (PIPE_BUFFERS - 1);
pipe->curbuf = curbuf;
pipe->nrbufs = --bufs;
do_wakeup = 1;
pipe->curbuf = (pipe->curbuf + 1) & (PIPE_BUFFERS - 1);
pipe->nrbufs--;
if (pipe->inode)
do_wakeup = 1;
}

sd.pos += sd.len;
Expand All @@ -618,7 +613,7 @@ static ssize_t move_from_pipe(struct pipe_inode_info *pipe, struct file *out,
break;
}

if (bufs)
if (pipe->nrbufs)
continue;
if (!pipe->writers)
break;
Expand Down Expand Up @@ -660,9 +655,7 @@ static ssize_t move_from_pipe(struct pipe_inode_info *pipe, struct file *out,
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
}

mutex_lock(&out->f_mapping->host->i_mutex);
out->f_pos = sd.pos;
mutex_unlock(&out->f_mapping->host->i_mutex);
return ret;

}
Expand Down

0 comments on commit c8cbc7a

Please sign in to comment.