Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.24.4 /fs/nfs/write.c

Filename:/fs/nfs/write.c
Lines Added:17
Lines Deleted:3
Also changed in: (Previous) 2.6.24.3  2.6.24.3-rc1  2.6.24-git22  2.6.24-git21  2.6.24-git20  2.6.24-git19 
(Following) 2.6.24.5  2.6.24.6  2.6.24.7  2.6.25-rc6-git8  2.6.25-rc7  2.6.25-rc8 

Location
[  2.6.24.4
  [  fs
    [  nfs
       o  write.c

Patch

diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 51cc1bd..855b6d5 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -701,6 +701,17 @@ int nfs_flush_incompatible(struct file *file, struct page *page)
 }
 
 /*
+ * If the page cache is marked as unsafe or invalid, then we can't rely on
+ * the PageUptodate() flag. In this case, we will need to turn off
+ * write optimisations that depend on the page contents being correct.
+ */
+static int nfs_write_pageuptodate(struct page *page, struct inode *inode)
+{
+   return PageUptodate(page) &&
+      !(NFS_I(inode)->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA));
+}
+
+/*
  * Update and possibly write a cached page of an NFS file.
  *
  * XXX: Keep an eye on generic_file_read to make sure it doesn't do bad
@@ -721,10 +732,13 @@ int nfs_updatepage(struct file *file, struct page *page,
       (long long)(page_offset(page) +offset));
 
    /* If we're not using byte range locks, and we know the page
-    * is entirely in cache, it may be more efficient to avoid
-    * fragmenting write requests.
+    * is up to date, it may be more efficient to extend the write
+    * to cover the entire page in order to avoid fragmentation
+    * inefficiencies.
     */
-   if (PageUptodate(page) && inode->i_flock == NULL && !(file->f_mode & O_SYNC)) {
+   if (nfs_write_pageuptodate(page, inode) &&
+         inode->i_flock == NULL &&
+         !(file->f_mode & O_SYNC)) {
       count = max(count + offset, nfs_page_length(page));
       offset = 0;
    }


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.