patch-2.3.99-pre6 linux/fs/nfs/file.c

Next file: linux/fs/nfs/flushd.c
Previous file: linux/fs/nfs/dir.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.99-pre5/linux/fs/nfs/file.c linux/fs/nfs/file.c
@@ -74,6 +74,11 @@
 
 	dfprintk(VFS, "nfs: flush(%x/%ld)\n", inode->i_dev, inode->i_ino);
 
+	/* Make sure all async reads have been sent off. We don't bother
+	 * waiting on them though... */
+	if (file->f_mode & FMODE_READ)
+		nfs_pagein_inode(inode, 0, 0);
+
 	status = nfs_wb_file(inode, file);
 	if (!status) {
 		status = file->f_error;
@@ -166,8 +171,36 @@
 	return status;
 }
 
+/*
+ * The following is used by wait_on_page(), generic_file_readahead()
+ * to initiate the completion of any page readahead operations.
+ */
+static int nfs_sync_page(struct page *page)
+{
+	struct inode	*inode = (struct inode *)page->mapping->host;
+	unsigned long	index = page_index(page);
+	unsigned int	rpages, wpages;
+	int		result;
+
+	if (!inode)
+		return 0;
+
+	rpages = NFS_SERVER(inode)->rpages;
+	result = nfs_pagein_inode(inode, index, rpages);
+	if (result < 0)
+		goto out_bad;
+	wpages = NFS_SERVER(inode)->wpages;
+	result = nfs_sync_file(inode, NULL, index, wpages, FLUSH_STABLE);
+	if (result < 0)
+		goto out_bad;
+	return 0;
+ out_bad:
+	return result;
+}
+
 struct address_space_operations nfs_file_aops = {
 	readpage: nfs_readpage,
+	sync_page: nfs_sync_page,
 	writepage: nfs_writepage,
 	prepare_write: nfs_prepare_write,
 	commit_write: nfs_commit_write

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)