]> err.no Git - linux-2.6/blobdiff - fs/nfs/file.c
Merge git://git.infradead.org/~dedekind/ubi-2.6
[linux-2.6] / fs / nfs / file.c
index d29f90d00aa24298882785747996bd5427193afe..5d2e9d9a4e28a390c15fd10a0c856baf2fe89058 100644 (file)
@@ -64,7 +64,11 @@ const struct file_operations nfs_file_operations = {
        .write          = do_sync_write,
        .aio_read       = nfs_file_read,
        .aio_write      = nfs_file_write,
+#ifdef CONFIG_MMU
        .mmap           = nfs_file_mmap,
+#else
+       .mmap           = generic_file_mmap,
+#endif
        .open           = nfs_file_open,
        .flush          = nfs_file_flush,
        .release        = nfs_file_release,
@@ -131,7 +135,7 @@ nfs_file_release(struct inode *inode, struct file *filp)
 {
        /* Ensure that dirty pages are flushed out with the right creds */
        if (filp->f_mode & FMODE_WRITE)
-               filemap_fdatawrite(filp->f_mapping);
+               nfs_wb_all(filp->f_path.dentry->d_inode);
        nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
        return NFS_PROTO(inode)->file_release(inode, filp);
 }
@@ -349,7 +353,9 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,
        unlock_page(page);
        page_cache_release(page);
 
-       return status < 0 ? status : copied;
+       if (status < 0)
+               return status;
+       return copied;
 }
 
 static void nfs_invalidate_page(struct page *page, unsigned long offset)
@@ -392,35 +398,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;
 }