Commit af6aa1b9 authored by Richard Weinberger's avatar Richard Weinberger

hostfs: Use page_offset()

The kernel offers a helper function for that, use it.
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent b86b413a
...@@ -410,7 +410,7 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc) ...@@ -410,7 +410,7 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
struct address_space *mapping = page->mapping; struct address_space *mapping = page->mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
char *buffer; char *buffer;
unsigned long long base; loff_t base = page_offset(page);
int count = PAGE_CACHE_SIZE; int count = PAGE_CACHE_SIZE;
int end_index = inode->i_size >> PAGE_CACHE_SHIFT; int end_index = inode->i_size >> PAGE_CACHE_SHIFT;
int err; int err;
...@@ -419,7 +419,6 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc) ...@@ -419,7 +419,6 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
count = inode->i_size & (PAGE_CACHE_SIZE-1); count = inode->i_size & (PAGE_CACHE_SIZE-1);
buffer = kmap(page); buffer = kmap(page);
base = ((unsigned long long) page->index) << PAGE_CACHE_SHIFT;
err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count); err = write_file(HOSTFS_I(inode)->fd, &base, buffer, count);
if (err != count) { if (err != count) {
...@@ -444,10 +443,9 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc) ...@@ -444,10 +443,9 @@ static int hostfs_writepage(struct page *page, struct writeback_control *wbc)
static int hostfs_readpage(struct file *file, struct page *page) static int hostfs_readpage(struct file *file, struct page *page)
{ {
char *buffer; char *buffer;
long long start; loff_t start = page_offset(page);
int bytes_read, ret = 0; int bytes_read, ret = 0;
start = (long long) page->index << PAGE_CACHE_SHIFT;
buffer = kmap(page); buffer = kmap(page);
bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer, bytes_read = read_file(FILE_HOSTFS_I(file)->fd, &start, buffer,
PAGE_CACHE_SIZE); PAGE_CACHE_SIZE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment