patch-2.4.5 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
- Lines: 73
- Date:
Tue May 22 09:26:06 2001
- Orig file:
v2.4.4/linux/fs/nfs/file.c
- Orig date:
Fri Feb 9 11:29:44 2001
diff -u --recursive --new-file v2.4.4/linux/fs/nfs/file.c linux/fs/nfs/file.c
@@ -39,6 +39,7 @@
static ssize_t nfs_file_write(struct file *, const char *, size_t, loff_t *);
static int nfs_file_flush(struct file *);
static int nfs_fsync(struct file *, struct dentry *dentry, int datasync);
+static int nfs_file_release(struct inode *, struct file *);
struct file_operations nfs_file_operations = {
read: nfs_file_read,
@@ -46,7 +47,7 @@
mmap: nfs_file_mmap,
open: nfs_open,
flush: nfs_file_flush,
- release: nfs_release,
+ release: nfs_file_release,
fsync: nfs_fsync,
lock: nfs_lock,
};
@@ -87,6 +88,13 @@
return status;
}
+static int
+nfs_file_release(struct inode *inode, struct file *file)
+{
+ filemap_fdatasync(inode->i_mapping);
+ return nfs_release(inode,file);
+}
+
static ssize_t
nfs_file_read(struct file * file, char * buf, size_t count, loff_t *ppos)
{
@@ -283,16 +291,21 @@
* Flush all pending writes before doing anything
* with locks..
*/
- down(&filp->f_dentry->d_inode->i_sem);
+ filemap_fdatasync(inode->i_mapping);
+ down(&inode->i_sem);
status = nfs_wb_all(inode);
- up(&filp->f_dentry->d_inode->i_sem);
+ up(&inode->i_sem);
+ filemap_fdatawait(inode->i_mapping);
if (status < 0)
return status;
- if ((status = nlmclnt_proc(inode, cmd, fl)) < 0)
+ lock_kernel();
+ status = nlmclnt_proc(inode, cmd, fl);
+ unlock_kernel();
+ if (status < 0)
return status;
- else
- status = 0;
+
+ status = 0;
/*
* Make sure we clear the cache whenever we try to get the lock.
@@ -300,10 +313,12 @@
*/
out_ok:
if ((cmd == F_SETLK || cmd == F_SETLKW) && fl->fl_type != F_UNLCK) {
- down(&filp->f_dentry->d_inode->i_sem);
+ filemap_fdatasync(inode->i_mapping);
+ down(&inode->i_sem);
nfs_wb_all(inode); /* we may have slept */
+ up(&inode->i_sem);
+ filemap_fdatawait(inode->i_mapping);
nfs_zap_caches(inode);
- up(&filp->f_dentry->d_inode->i_sem);
}
return status;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)