Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25602
b: refs/heads/master
c: 49d0b21
h: refs/heads/master
v: v3
  • Loading branch information
Jens Axboe committed Apr 10, 2006
1 parent 7bb8a08 commit 9bdb8f2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 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: 16c523ddabcce5d3d817f4a2491d628f84dfaaa1
refs/heads/master: 49d0b21be21efc07526d637e0ae935019667e532
40 changes: 30 additions & 10 deletions trunk/fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,43 @@ static void *page_cache_pipe_buf_map(struct file *file,
struct pipe_buffer *buf)
{
struct page *page = buf->page;

lock_page(page);
int err;

if (!PageUptodate(page)) {
unlock_page(page);
return ERR_PTR(-EIO);
}
lock_page(page);

/*
* Page got truncated/unhashed. This will cause a 0-byte
* splice, if this is the first page
*/
if (!page->mapping) {
err = -ENODATA;
goto error;
}

/*
* uh oh, read-error from disk
*/
if (!PageUptodate(page)) {
err = -EIO;
goto error;
}

if (!page->mapping) {
/*
* page is ok afterall, fall through to mapping
*/
unlock_page(page);
return ERR_PTR(-ENODATA);
}

return kmap(buf->page);
return kmap(page);
error:
unlock_page(page);
return ERR_PTR(err);
}

static void page_cache_pipe_buf_unmap(struct pipe_inode_info *info,
struct pipe_buffer *buf)
{
unlock_page(buf->page);
kunmap(buf->page);
}

Expand Down Expand Up @@ -379,7 +396,7 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
int ret;

/*
* after this, page will be locked and unmapped
* make sure the data in this buffer is uptodate
*/
src = buf->ops->map(file, info, buf);
if (IS_ERR(src))
Expand All @@ -399,6 +416,9 @@ static int pipe_to_file(struct pipe_inode_info *info, struct pipe_buffer *buf,
if (buf->ops->steal(info, buf))
goto find_page;

/*
* this will also set the page locked
*/
page = buf->page;
if (add_to_page_cache(page, mapping, index, gfp_mask))
goto find_page;
Expand Down

0 comments on commit 9bdb8f2

Please sign in to comment.