Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25607
b: refs/heads/master
c: 7480a90
h: refs/heads/master
i:
  25605: 925b500
  25603: addd2ea
  25599: e77db04
v: v3
  • Loading branch information
Jens Axboe committed Apr 11, 2006
1 parent 0dbf63e commit ed64183
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 12 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: b92ce55893745e011edae70830b8bc863be881f9
refs/heads/master: 7480a90435673b4c717b6caf1350ec577d5f1adf
74 changes: 63 additions & 11 deletions trunk/fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ __generic_file_splice_read(struct file *in, struct pipe_inode_info *pipe,
struct page *pages[PIPE_BUFFERS];
struct page *page;
pgoff_t index;
int i;
int i, error;

index = in->f_pos >> PAGE_CACHE_SHIFT;
offset = in->f_pos & ~PAGE_CACHE_MASK;
Expand All @@ -260,32 +260,84 @@ __generic_file_splice_read(struct file *in, struct pipe_inode_info *pipe,
/*
* now fill in the holes
*/
error = 0;
for (i = 0; i < nr_pages; i++, index++) {
find_page:
/*
* no page there, look one up / create it
* lookup the page for this index
*/
page = find_or_create_page(mapping, index,
mapping_gfp_mask(mapping));
if (!page)
break;
page = find_get_page(mapping, index);
if (!page) {
/*
* If in nonblock mode then dont block on
* readpage (we've kicked readahead so there
* will be asynchronous progress):
*/
if (flags & SPLICE_F_NONBLOCK)
break;

/*
* page didn't exist, allocate one
*/
page = page_cache_alloc_cold(mapping);
if (!page)
break;

error = add_to_page_cache_lru(page, mapping, index,
mapping_gfp_mask(mapping));
if (unlikely(error)) {
page_cache_release(page);
break;
}

if (PageUptodate(page))
unlock_page(page);
else {
int error = mapping->a_ops->readpage(in, page);
goto readpage;
}

/*
* If the page isn't uptodate, we may need to start io on it
*/
if (!PageUptodate(page)) {
lock_page(page);

/*
* page was truncated, stop here. if this isn't the
* first page, we'll just complete what we already
* added
*/
if (!page->mapping) {
unlock_page(page);
page_cache_release(page);
break;
}
/*
* page was already under io and is now done, great
*/
if (PageUptodate(page)) {
unlock_page(page);
goto fill_it;
}

readpage:
/*
* need to read in the page
*/
error = mapping->a_ops->readpage(in, page);

if (unlikely(error)) {
page_cache_release(page);
if (error == AOP_TRUNCATED_PAGE)
goto find_page;
break;
}
}
fill_it:
pages[i] = page;
}

if (i)
return move_to_pipe(pipe, pages, i, offset, len, flags);

return 0;
return error;
}

/**
Expand Down

0 comments on commit ed64183

Please sign in to comment.