]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
NFS: Optimise nfs_vm_page_mkwrite()
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 22 Jan 2008 22:13:06 +0000 (17:13 -0500)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 30 Jan 2008 07:05:23 +0000 (02:05 -0500)
The current model locks the page twice for no good reason. Optimise by
inlining the parts of nfs_write_begin()/nfs_write_end() that we care about.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/file.c

index b3bb89f7d5d2856719a705e37ddb320b7a285127..4560fc2ddb4afd29c33ed44b26ffd30811bb7f7d 100644 (file)
@@ -392,35 +392,27 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct page *page)
        struct file *filp = vma->vm_file;
        unsigned pagelen;
        int ret = -EINVAL;
-       void *fsdata;
        struct address_space *mapping;
-       loff_t offset;
 
        lock_page(page);
        mapping = page->mapping;
-       if (mapping != vma->vm_file->f_path.dentry->d_inode->i_mapping) {
-               unlock_page(page);
-               return -EINVAL;
-       }
+       if (mapping != vma->vm_file->f_path.dentry->d_inode->i_mapping)
+               goto out_unlock;
+
+       ret = 0;
        pagelen = nfs_page_length(page);
-       offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
-       unlock_page(page);
+       if (pagelen == 0)
+               goto out_unlock;
 
-       /*
-        * we can use mapping after releasing the page lock, because:
-        * we hold mmap_sem on the fault path, which should pin the vma
-        * which should pin the file, which pins the dentry which should
-        * hold a reference on inode.
-        */
+       ret = nfs_flush_incompatible(filp, page);
+       if (ret != 0)
+               goto out_unlock;
 
-       if (pagelen) {
-               struct page *page2 = NULL;
-               ret = nfs_write_begin(filp, mapping, offset, pagelen,
-                               0, &page2, &fsdata);
-               if (!ret)
-                       ret = nfs_write_end(filp, mapping, offset, pagelen,
-                                       pagelen, page2, fsdata);
-       }
+       ret = nfs_updatepage(filp, page, 0, pagelen);
+       if (ret == 0)
+               ret = pagelen;
+out_unlock:
+       unlock_page(page);
        return ret;
 }