Skip to content

Commit

Permalink
exofs: Optimize read_4_write
Browse files Browse the repository at this point in the history
Don't attempt a read passed i_size, just zero the page and be
done with it.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
  • Loading branch information
Boaz Harrosh committed Mar 15, 2011
1 parent 0a93551 commit a8f1418
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions fs/exofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,10 @@ static int readpage_strip(void *data, struct page *page)

if (!pcol->read_4_write)
unlock_page(page);
EXOFS_DBGMSG("readpage_strip(0x%lx, 0x%lx) empty page,"
" splitting\n", inode->i_ino, page->index);
EXOFS_DBGMSG("readpage_strip(0x%lx) empty page len=%zx "
"read_4_write=%d index=0x%lx end_index=0x%lx "
"splitting\n", inode->i_ino, len,
pcol->read_4_write, page->index, end_index);

return read_exec(pcol);
}
Expand Down Expand Up @@ -722,11 +724,28 @@ int exofs_write_begin(struct file *file, struct address_space *mapping,

/* read modify write */
if (!PageUptodate(page) && (len != PAGE_CACHE_SIZE)) {
loff_t i_size = i_size_read(mapping->host);
pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
size_t rlen;

if (page->index < end_index)
rlen = PAGE_CACHE_SIZE;
else if (page->index == end_index)
rlen = i_size & ~PAGE_CACHE_MASK;
else
rlen = 0;

if (!rlen) {
clear_highpage(page);
SetPageUptodate(page);
goto out;
}

ret = _readpage(page, true);
if (ret) {
/*SetPageError was done by _readpage. Is it ok?*/
unlock_page(page);
EXOFS_DBGMSG("__readpage_filler failed\n");
EXOFS_DBGMSG("__readpage failed\n");
}
}
out:
Expand Down

0 comments on commit a8f1418

Please sign in to comment.