fuse: prepare fuse_direct_io() for CUSE

Move code operating on the inode out from fuse_direct_io().

This prepares this function for use by CUSE, where the inode is not
owned by a fuse filesystem.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
This commit is contained in:
Miklos Szeredi 2009-04-28 16:56:36 +02:00
parent 2d698b0703
commit d09cb9d7f6

View File

@ -993,9 +993,6 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
ssize_t res = 0; ssize_t res = 0;
struct fuse_req *req; struct fuse_req *req;
if (is_bad_inode(inode))
return -EIO;
req = fuse_get_req(fc); req = fuse_get_req(fc);
if (IS_ERR(req)) if (IS_ERR(req))
return PTR_ERR(req); return PTR_ERR(req);
@ -1038,12 +1035,8 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
} }
} }
fuse_put_request(fc, req); fuse_put_request(fc, req);
if (res > 0) { if (res > 0)
if (write)
fuse_write_update_size(inode, pos);
*ppos = pos; *ppos = pos;
}
fuse_invalidate_attr(inode);
return res; return res;
} }
@ -1051,7 +1044,17 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
static ssize_t fuse_direct_read(struct file *file, char __user *buf, static ssize_t fuse_direct_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
return fuse_direct_io(file, buf, count, ppos, 0); ssize_t res;
struct inode *inode = file->f_path.dentry->d_inode;
if (is_bad_inode(inode))
return -EIO;
res = fuse_direct_io(file, buf, count, ppos, 0);
fuse_invalidate_attr(inode);
return res;
} }
static ssize_t fuse_direct_write(struct file *file, const char __user *buf, static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
@ -1059,12 +1062,22 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
ssize_t res; ssize_t res;
if (is_bad_inode(inode))
return -EIO;
/* Don't allow parallel writes to the same file */ /* Don't allow parallel writes to the same file */
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
res = generic_write_checks(file, ppos, &count, 0); res = generic_write_checks(file, ppos, &count, 0);
if (!res) if (!res) {
res = fuse_direct_io(file, buf, count, ppos, 1); res = fuse_direct_io(file, buf, count, ppos, 1);
if (res > 0)
fuse_write_update_size(inode, *ppos);
}
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
fuse_invalidate_attr(inode);
return res; return res;
} }