diff options
Diffstat (limited to 'fs/coda/file.c')
| -rw-r--r-- | fs/coda/file.c | 31 | 
1 files changed, 19 insertions, 12 deletions
diff --git a/fs/coda/file.c b/fs/coda/file.c index c8b50ba4366..9e83b779021 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c @@ -21,10 +21,9 @@  #include <asm/uaccess.h>  #include <linux/coda.h> -#include <linux/coda_linux.h> -#include <linux/coda_fs_i.h>  #include <linux/coda_psdev.h> +#include "coda_linux.h"  #include "coda_int.h"  static ssize_t @@ -37,7 +36,7 @@ coda_file_read(struct file *coda_file, char __user *buf, size_t count, loff_t *p  	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);  	host_file = cfi->cfi_container; -	if (!host_file->f_op || !host_file->f_op->read) +	if (!host_file->f_op->read)  		return -EINVAL;  	return host_file->f_op->read(host_file, buf, count, ppos); @@ -67,7 +66,7 @@ coda_file_splice_read(struct file *coda_file, loff_t *ppos,  static ssize_t  coda_file_write(struct file *coda_file, const char __user *buf, size_t count, loff_t *ppos)  { -	struct inode *host_inode, *coda_inode = coda_file->f_path.dentry->d_inode; +	struct inode *host_inode, *coda_inode = file_inode(coda_file);  	struct coda_file_info *cfi;  	struct file *host_file;  	ssize_t ret; @@ -76,10 +75,11 @@ coda_file_write(struct file *coda_file, const char __user *buf, size_t count, lo  	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);  	host_file = cfi->cfi_container; -	if (!host_file->f_op || !host_file->f_op->write) +	if (!host_file->f_op->write)  		return -EINVAL; -	host_inode = host_file->f_path.dentry->d_inode; +	host_inode = file_inode(host_file); +	file_start_write(host_file);  	mutex_lock(&coda_inode->i_mutex);  	ret = host_file->f_op->write(host_file, buf, count, ppos); @@ -88,6 +88,7 @@ coda_file_write(struct file *coda_file, const char __user *buf, size_t count, lo  	coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9;  	coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC;  	mutex_unlock(&coda_inode->i_mutex); +	file_end_write(host_file);  	return ret;  } @@ -104,11 +105,11 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma)  	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);  	host_file = cfi->cfi_container; -	if (!host_file->f_op || !host_file->f_op->mmap) +	if (!host_file->f_op->mmap)  		return -ENODEV; -	coda_inode = coda_file->f_path.dentry->d_inode; -	host_inode = host_file->f_path.dentry->d_inode; +	coda_inode = file_inode(coda_file); +	host_inode = file_inode(host_file);  	cii = ITOC(coda_inode);  	spin_lock(&cii->c_lock); @@ -179,7 +180,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)  	err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),  			  coda_flags, coda_file->f_cred->fsuid); -	host_inode = cfi->cfi_container->f_path.dentry->d_inode; +	host_inode = file_inode(cfi->cfi_container);  	cii = ITOC(coda_inode);  	/* did we mmap this file? */ @@ -200,10 +201,10 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)  	return 0;  } -int coda_fsync(struct file *coda_file, int datasync) +int coda_fsync(struct file *coda_file, loff_t start, loff_t end, int datasync)  {  	struct file *host_file; -	struct inode *coda_inode = coda_file->f_path.dentry->d_inode; +	struct inode *coda_inode = file_inode(coda_file);  	struct coda_file_info *cfi;  	int err; @@ -211,6 +212,11 @@ int coda_fsync(struct file *coda_file, int datasync)  	      S_ISLNK(coda_inode->i_mode)))  		return -EINVAL; +	err = filemap_write_and_wait_range(coda_inode->i_mapping, start, end); +	if (err) +		return err; +	mutex_lock(&coda_inode->i_mutex); +  	cfi = CODA_FTOC(coda_file);  	BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);  	host_file = cfi->cfi_container; @@ -218,6 +224,7 @@ int coda_fsync(struct file *coda_file, int datasync)  	err = vfs_fsync(host_file, datasync);  	if (!err && !datasync)  		err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); +	mutex_unlock(&coda_inode->i_mutex);  	return err;  }  | 
