--- linux-2.6.30.i686/fs/nfs/file.c.org +++ linux-2.6.30.i686/fs/nfs/file.c @@ -337,15 +337,15 @@ static int nfs_write_begin(struct file * struct page **pagep, void **fsdata) { int ret; - pgoff_t index; + pgoff_t index = pos >> PAGE_CACHE_SHIFT; struct page *page; - index = pos >> PAGE_CACHE_SHIFT; dfprintk(PAGECACHE, "NFS: write_begin(%s/%s(%ld), %u@%lld)\n", file->f_path.dentry->d_parent->d_name.name, file->f_path.dentry->d_name.name, mapping->host->i_ino, len, (long long) pos); +start: /* * Prevent starvation issues if someone is doing a consistency * sync-to-disk @@ -364,6 +364,12 @@ static int nfs_write_begin(struct file * if (ret) { unlock_page(page); page_cache_release(page); + } else if ((file->f_mode & FMODE_READ) && !PageUptodate(page) && + ((pos & (PAGE_CACHE_SIZE - 1)) || len != PAGE_CACHE_SIZE)) { + ret = nfs_readpage(file, page); + page_cache_release(page); + if (!ret) + goto start; } return ret; }