diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2009-04-28 10:56:36 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2009-04-28 10:56:36 -0400 |
commit | d09cb9d7f6e4cb1dd0cf12ee0d352440291c74cf (patch) | |
tree | 34955b4d20f9a9cc3b238a9d8117f9a15074afda | |
parent | 2d698b070382442f817813b9dd0103034e5bca81 (diff) |
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>
-rw-r--r-- | fs/fuse/file.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 823f84a69733..b83d7d86b527 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -993,9 +993,6 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf, | |||
993 | ssize_t res = 0; | 993 | ssize_t res = 0; |
994 | struct fuse_req *req; | 994 | struct fuse_req *req; |
995 | 995 | ||
996 | if (is_bad_inode(inode)) | ||
997 | return -EIO; | ||
998 | |||
999 | req = fuse_get_req(fc); | 996 | req = fuse_get_req(fc); |
1000 | if (IS_ERR(req)) | 997 | if (IS_ERR(req)) |
1001 | return PTR_ERR(req); | 998 | return PTR_ERR(req); |
@@ -1038,12 +1035,8 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf, | |||
1038 | } | 1035 | } |
1039 | } | 1036 | } |
1040 | fuse_put_request(fc, req); | 1037 | fuse_put_request(fc, req); |
1041 | if (res > 0) { | 1038 | if (res > 0) |
1042 | if (write) | ||
1043 | fuse_write_update_size(inode, pos); | ||
1044 | *ppos = pos; | 1039 | *ppos = pos; |
1045 | } | ||
1046 | fuse_invalidate_attr(inode); | ||
1047 | 1040 | ||
1048 | return res; | 1041 | return res; |
1049 | } | 1042 | } |
@@ -1051,7 +1044,17 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf, | |||
1051 | static ssize_t fuse_direct_read(struct file *file, char __user *buf, | 1044 | static ssize_t fuse_direct_read(struct file *file, char __user *buf, |
1052 | size_t count, loff_t *ppos) | 1045 | size_t count, loff_t *ppos) |
1053 | { | 1046 | { |
1054 | return fuse_direct_io(file, buf, count, ppos, 0); | 1047 | ssize_t res; |
1048 | struct inode *inode = file->f_path.dentry->d_inode; | ||
1049 | |||
1050 | if (is_bad_inode(inode)) | ||
1051 | return -EIO; | ||
1052 | |||
1053 | res = fuse_direct_io(file, buf, count, ppos, 0); | ||
1054 | |||
1055 | fuse_invalidate_attr(inode); | ||
1056 | |||
1057 | return res; | ||
1055 | } | 1058 | } |
1056 | 1059 | ||
1057 | static ssize_t fuse_direct_write(struct file *file, const char __user *buf, | 1060 | 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, | |||
1059 | { | 1062 | { |
1060 | struct inode *inode = file->f_path.dentry->d_inode; | 1063 | struct inode *inode = file->f_path.dentry->d_inode; |
1061 | ssize_t res; | 1064 | ssize_t res; |
1065 | |||
1066 | if (is_bad_inode(inode)) | ||
1067 | return -EIO; | ||
1068 | |||
1062 | /* Don't allow parallel writes to the same file */ | 1069 | /* Don't allow parallel writes to the same file */ |
1063 | mutex_lock(&inode->i_mutex); | 1070 | mutex_lock(&inode->i_mutex); |
1064 | res = generic_write_checks(file, ppos, &count, 0); | 1071 | res = generic_write_checks(file, ppos, &count, 0); |
1065 | if (!res) | 1072 | if (!res) { |
1066 | res = fuse_direct_io(file, buf, count, ppos, 1); | 1073 | res = fuse_direct_io(file, buf, count, ppos, 1); |
1074 | if (res > 0) | ||
1075 | fuse_write_update_size(inode, *ppos); | ||
1076 | } | ||
1067 | mutex_unlock(&inode->i_mutex); | 1077 | mutex_unlock(&inode->i_mutex); |
1078 | |||
1079 | fuse_invalidate_attr(inode); | ||
1080 | |||
1068 | return res; | 1081 | return res; |
1069 | } | 1082 | } |
1070 | 1083 | ||