[14/37] Use page_cache_xxx in fs/splice.c

From: clameter
Date: Wed Jun 20 2007 - 14:33:33 EST


Signed-off-by: Christoph Lameter <clameter@xxxxxxx>

---
fs/splice.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)

Index: vps/fs/splice.c
===================================================================
--- vps.orig/fs/splice.c 2007-06-09 22:18:02.000000000 -0700
+++ vps/fs/splice.c 2007-06-09 22:22:08.000000000 -0700
@@ -282,9 +282,9 @@ __generic_file_splice_read(struct file *
.ops = &page_cache_pipe_buf_ops,
};

- index = *ppos >> PAGE_CACHE_SHIFT;
- loff = *ppos & ~PAGE_CACHE_MASK;
- nr_pages = (len + loff + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
+ index = page_cache_index(mapping, *ppos);
+ loff = page_cache_offset(mapping, *ppos);
+ nr_pages = page_cache_next(mapping, len + loff);

if (nr_pages > PIPE_BUFFERS)
nr_pages = PIPE_BUFFERS;
@@ -345,7 +345,7 @@ __generic_file_splice_read(struct file *
* Now loop over the map and see if we need to start IO on any
* pages, fill in the partial map, etc.
*/
- index = *ppos >> PAGE_CACHE_SHIFT;
+ index = page_cache_index(mapping, *ppos);
nr_pages = spd.nr_pages;
spd.nr_pages = 0;
for (page_nr = 0; page_nr < nr_pages; page_nr++) {
@@ -357,7 +357,8 @@ __generic_file_splice_read(struct file *
/*
* this_len is the max we'll use from this page
*/
- this_len = min_t(unsigned long, len, PAGE_CACHE_SIZE - loff);
+ this_len = min_t(unsigned long, len,
+ page_cache_size(mapping) - loff);
page = pages[page_nr];

if (PageReadahead(page))
@@ -416,7 +417,7 @@ __generic_file_splice_read(struct file *
* i_size must be checked after ->readpage().
*/
isize = i_size_read(mapping->host);
- end_index = (isize - 1) >> PAGE_CACHE_SHIFT;
+ end_index = page_cache_index(mapping, isize - 1);
if (unlikely(!isize || index > end_index))
break;

@@ -425,7 +426,8 @@ __generic_file_splice_read(struct file *
* the length and stop
*/
if (end_index == index) {
- loff = PAGE_CACHE_SIZE - (isize & ~PAGE_CACHE_MASK);
+ loff = page_cache_size(mapping)
+ - page_cache_offset(mapping, isize);
if (total_len + loff > isize)
break;
/*
@@ -557,6 +559,7 @@ static int pipe_to_file(struct pipe_inod
struct page *page;
void *fsdata;
int ret;
+ int pagesize = page_cache_size(mapping);

/*
* make sure the data in this buffer is uptodate
@@ -565,11 +568,11 @@ static int pipe_to_file(struct pipe_inod
if (unlikely(ret))
return ret;

- offset = sd->pos & ~PAGE_CACHE_MASK;
+ offset = page_cache_offset(mapping, sd->pos);

this_len = sd->len;
- if (this_len + offset > PAGE_CACHE_SIZE)
- this_len = PAGE_CACHE_SIZE - offset;
+ if (this_len + offset > pagesize)
+ this_len = pagesize - offset;

ret = pagecache_write_begin(file, mapping, sd->pos, sd->len,
AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata);

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/