Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25601
b: refs/heads/master
c: 16c523d
h: refs/heads/master
i:
  25599: e77db04
v: v3
  • Loading branch information
Jens Axboe committed Apr 10, 2006
1 parent 1d0b667 commit 7bb8a08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 50 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: c0bd1f650bd06a43435808d44f1e9520ea806206
refs/heads/master: 16c523ddabcce5d3d817f4a2491d628f84dfaaa1
59 changes: 10 additions & 49 deletions trunk/fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ static int __generic_file_splice_read(struct file *in, struct inode *pipe,
{
struct address_space *mapping = in->f_mapping;
unsigned int offset, nr_pages;
struct page *pages[PIPE_BUFFERS], *shadow[PIPE_BUFFERS];
struct page *pages[PIPE_BUFFERS];
struct page *page;
pgoff_t index, pidx;
int i, j;
pgoff_t index;
int i;

index = in->f_pos >> PAGE_CACHE_SHIFT;
offset = in->f_pos & ~PAGE_CACHE_MASK;
Expand All @@ -237,74 +237,35 @@ static int __generic_file_splice_read(struct file *in, struct inode *pipe,
*/
do_page_cache_readahead(mapping, in, index, nr_pages);

/*
* Get as many pages from the page cache as possible..
* Start IO on the page cache entries we create (we
* can assume that any pre-existing ones we find have
* already had IO started on them).
*/
i = find_get_pages(mapping, index, nr_pages, pages);

/*
* common case - we found all pages and they are contiguous,
* kick them off
*/
if (i && (pages[i - 1]->index == index + i - 1))
goto splice_them;

/*
* fill shadow[] with pages at the right locations, so we only
* have to fill holes
*/
memset(shadow, 0, nr_pages * sizeof(struct page *));
for (j = 0; j < i; j++)
shadow[pages[j]->index - index] = pages[j];

/*
* now fill in the holes
*/
for (i = 0, pidx = index; i < nr_pages; pidx++, i++) {
int error;

if (shadow[i])
continue;

for (i = 0; i < nr_pages; i++, index++) {
/*
* no page there, look one up / create it
*/
page = find_or_create_page(mapping, pidx,
page = find_or_create_page(mapping, index,
mapping_gfp_mask(mapping));
if (!page)
break;

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

if (unlikely(error)) {
page_cache_release(page);
break;
}
}
shadow[i] = page;
}

if (!i) {
for (i = 0; i < nr_pages; i++) {
if (shadow[i])
page_cache_release(shadow[i]);
}
return 0;
pages[i] = page;
}

memcpy(pages, shadow, i * sizeof(struct page *));
if (i)
return move_to_pipe(pipe, pages, i, offset, len, flags);

/*
* Now we splice them into the pipe..
*/
splice_them:
return move_to_pipe(pipe, pages, i, offset, len, flags);
return 0;
}

/**
Expand Down

0 comments on commit 7bb8a08

Please sign in to comment.