Commit ab0a3dbe authored by Trond Myklebust's avatar Trond Myklebust

[PATCH] NFS: Write optimization for short files and small O_SYNC writes.

 Use stable writes if we can see that we are only going to put a single
 write on the wire.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent fe51beec
...@@ -750,7 +750,7 @@ int nfs_updatepage(struct file *file, struct page *page, ...@@ -750,7 +750,7 @@ int nfs_updatepage(struct file *file, struct page *page,
* is entirely in cache, it may be more efficient to avoid * is entirely in cache, it may be more efficient to avoid
* fragmenting write requests. * fragmenting write requests.
*/ */
if (PageUptodate(page) && inode->i_flock == NULL) { if (PageUptodate(page) && inode->i_flock == NULL && !(file->f_mode & O_SYNC)) {
loff_t end_offs = i_size_read(inode) - 1; loff_t end_offs = i_size_read(inode) - 1;
unsigned long end_index = end_offs >> PAGE_CACHE_SHIFT; unsigned long end_index = end_offs >> PAGE_CACHE_SHIFT;
...@@ -1342,8 +1342,16 @@ static int nfs_flush_inode(struct inode *inode, unsigned long idx_start, ...@@ -1342,8 +1342,16 @@ static int nfs_flush_inode(struct inode *inode, unsigned long idx_start,
spin_lock(&nfsi->req_lock); spin_lock(&nfsi->req_lock);
res = nfs_scan_dirty(inode, &head, idx_start, npages); res = nfs_scan_dirty(inode, &head, idx_start, npages);
spin_unlock(&nfsi->req_lock); spin_unlock(&nfsi->req_lock);
if (res) if (res) {
error = nfs_flush_list(&head, NFS_SERVER(inode)->wpages, how); struct nfs_server *server = NFS_SERVER(inode);
/* For single writes, FLUSH_STABLE is more efficient */
if (res == nfsi->npages && nfsi->npages <= server->wpages) {
if (res > 1 || nfs_list_entry(head.next)->wb_bytes <= server->wsize)
how |= FLUSH_STABLE;
}
error = nfs_flush_list(&head, server->wpages, how);
}
if (error < 0) if (error < 0)
return error; return error;
return res; return res;
......
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