Commit de05a0cc authored by Trond Myklebust's avatar Trond Myklebust

NFS: Minor read optimisation...

Since PG_uptodate may now end up getting set during the call to
nfs_wb_page(), we can avoid putting a read request on the wire in those
situations.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 44dd151d
...@@ -483,17 +483,19 @@ int nfs_readpage(struct file *file, struct page *page) ...@@ -483,17 +483,19 @@ int nfs_readpage(struct file *file, struct page *page)
*/ */
error = nfs_wb_page(inode, page); error = nfs_wb_page(inode, page);
if (error) if (error)
goto out_error; goto out_unlock;
if (PageUptodate(page))
goto out_unlock;
error = -ESTALE; error = -ESTALE;
if (NFS_STALE(inode)) if (NFS_STALE(inode))
goto out_error; goto out_unlock;
if (file == NULL) { if (file == NULL) {
error = -EBADF; error = -EBADF;
ctx = nfs_find_open_context(inode, NULL, FMODE_READ); ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
if (ctx == NULL) if (ctx == NULL)
goto out_error; goto out_unlock;
} else } else
ctx = get_nfs_open_context((struct nfs_open_context *) ctx = get_nfs_open_context((struct nfs_open_context *)
file->private_data); file->private_data);
...@@ -502,8 +504,7 @@ int nfs_readpage(struct file *file, struct page *page) ...@@ -502,8 +504,7 @@ int nfs_readpage(struct file *file, struct page *page)
put_nfs_open_context(ctx); put_nfs_open_context(ctx);
return error; return error;
out_unlock:
out_error:
unlock_page(page); unlock_page(page);
return error; return error;
} }
...@@ -520,21 +521,32 @@ readpage_async_filler(void *data, struct page *page) ...@@ -520,21 +521,32 @@ readpage_async_filler(void *data, struct page *page)
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
struct nfs_page *new; struct nfs_page *new;
unsigned int len; unsigned int len;
int error;
error = nfs_wb_page(inode, page);
if (error)
goto out_unlock;
if (PageUptodate(page))
goto out_unlock;
nfs_wb_page(inode, page);
len = nfs_page_length(page); len = nfs_page_length(page);
if (len == 0) if (len == 0)
return nfs_return_empty_page(page); return nfs_return_empty_page(page);
new = nfs_create_request(desc->ctx, inode, page, 0, len); new = nfs_create_request(desc->ctx, inode, page, 0, len);
if (IS_ERR(new)) { if (IS_ERR(new))
SetPageError(page); goto out_error;
unlock_page(page);
return PTR_ERR(new);
}
if (len < PAGE_CACHE_SIZE) if (len < PAGE_CACHE_SIZE)
zero_user_page(page, len, PAGE_CACHE_SIZE - len, KM_USER0); zero_user_page(page, len, PAGE_CACHE_SIZE - len, KM_USER0);
nfs_pageio_add_request(desc->pgio, new); nfs_pageio_add_request(desc->pgio, new);
return 0; return 0;
out_error:
error = PTR_ERR(new);
SetPageError(page);
out_unlock:
unlock_page(page);
return error;
} }
int nfs_readpages(struct file *filp, struct address_space *mapping, int nfs_readpages(struct file *filp, struct address_space *mapping,
......
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