patch-2.1.118 linux/fs/nfs/file.c

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

diff -u --recursive --new-file v2.1.117/linux/fs/nfs/file.c linux/fs/nfs/file.c
@@ -35,6 +35,7 @@
 static int  nfs_file_mmap(struct file *, struct vm_area_struct *);
 static ssize_t nfs_file_read(struct file *, char *, size_t, loff_t *);
 static ssize_t nfs_file_write(struct file *, const char *, size_t, loff_t *);
+static int  nfs_file_flush(struct file *);
 static int  nfs_file_close(struct inode *, struct file *);
 static int  nfs_fsync(struct file *, struct dentry *dentry);
 
@@ -47,6 +48,7 @@
 	NULL,			/* ioctl - default */
 	nfs_file_mmap,		/* mmap */
 	NULL,			/* no special open is needed */
+	nfs_file_flush,		/* flush */
 	nfs_file_close,		/* release */
 	nfs_fsync,		/* fsync */
 	NULL,			/* fasync */
@@ -84,13 +86,7 @@
 #endif
 
 /*
- * Flush all dirty pages, and check for write errors.
- *
- * Note that since the file close operation is called only by the
- * _last_ process to close the file, we need to flush _all_ dirty 
- * pages. This also means that there is little sense in checking
- * for errors for this specific process -- we should probably just
- * clear all errors.
+ * Sync the file..
  */
 static int
 nfs_file_close(struct inode *inode, struct file *file)
@@ -104,6 +100,22 @@
 	if (!status)
 		status = error;
 	return status;
+}
+
+/*
+ * Flush all dirty pages, and check for write errors.
+ *
+ * We should probably do this better - this does get called at every
+ * close, so we should probably just flush the changes that "this"
+ * file has done and report on only those.
+ *
+ * Right now we use the "flush everything" approach. Overkill, but
+ * works.
+ */
+static int
+nfs_file_flush(struct file *file)
+{
+	return nfs_file_close(file->f_dentry->d_inode, file);
 }
 
 static ssize_t

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov