diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2009-04-28 10:56:37 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2009-04-28 10:56:37 -0400 |
commit | c7b7143c6342b8751d47b03a025ac5c0ac1ae809 (patch) | |
tree | 9bb528e90ba682b96f5a34ff5ee777ab3c260aef /fs/fuse/file.c | |
parent | 2106cb18930312af9325d3418e138569c5b903cc (diff) |
fuse: clean up args in fuse_finish_open() and fuse_release_fill()
Move setting ff->fh, ff->nodeid and file->private_data outside
fuse_finish_open(). Add ->open_flags member to struct fuse_file.
This simplifies the argument passing to fuse_finish_open() and
fuse_release_fill(), and paves the way for creating an open helper
that doesn't need an inode pointer.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs/fuse/file.c')
-rw-r--r-- | fs/fuse/file.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index aa4a3876ca37..d9458cace425 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -79,7 +79,7 @@ void fuse_file_free(struct fuse_file *ff) | |||
79 | kfree(ff); | 79 | kfree(ff); |
80 | } | 80 | } |
81 | 81 | ||
82 | static struct fuse_file *fuse_file_get(struct fuse_file *ff) | 82 | struct fuse_file *fuse_file_get(struct fuse_file *ff) |
83 | { | 83 | { |
84 | atomic_inc(&ff->count); | 84 | atomic_inc(&ff->count); |
85 | return ff; | 85 | return ff; |
@@ -102,18 +102,16 @@ static void fuse_file_put(struct fuse_file *ff) | |||
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | void fuse_finish_open(struct inode *inode, struct file *file, | 105 | void fuse_finish_open(struct inode *inode, struct file *file) |
106 | struct fuse_file *ff, struct fuse_open_out *outarg) | ||
107 | { | 106 | { |
108 | if (outarg->open_flags & FOPEN_DIRECT_IO) | 107 | struct fuse_file *ff = file->private_data; |
108 | |||
109 | if (ff->open_flags & FOPEN_DIRECT_IO) | ||
109 | file->f_op = &fuse_direct_io_file_operations; | 110 | file->f_op = &fuse_direct_io_file_operations; |
110 | if (!(outarg->open_flags & FOPEN_KEEP_CACHE)) | 111 | if (!(ff->open_flags & FOPEN_KEEP_CACHE)) |
111 | invalidate_inode_pages2(inode->i_mapping); | 112 | invalidate_inode_pages2(inode->i_mapping); |
112 | if (outarg->open_flags & FOPEN_NONSEEKABLE) | 113 | if (ff->open_flags & FOPEN_NONSEEKABLE) |
113 | nonseekable_open(inode, file); | 114 | nonseekable_open(inode, file); |
114 | ff->fh = outarg->fh; | ||
115 | ff->nodeid = get_node_id(inode); | ||
116 | file->private_data = fuse_file_get(ff); | ||
117 | } | 115 | } |
118 | 116 | ||
119 | int fuse_open_common(struct inode *inode, struct file *file, int isdir) | 117 | int fuse_open_common(struct inode *inode, struct file *file, int isdir) |
@@ -141,13 +139,17 @@ int fuse_open_common(struct inode *inode, struct file *file, int isdir) | |||
141 | else { | 139 | else { |
142 | if (isdir) | 140 | if (isdir) |
143 | outarg.open_flags &= ~FOPEN_DIRECT_IO; | 141 | outarg.open_flags &= ~FOPEN_DIRECT_IO; |
144 | fuse_finish_open(inode, file, ff, &outarg); | 142 | ff->fh = outarg.fh; |
143 | ff->nodeid = get_node_id(inode); | ||
144 | ff->open_flags = outarg.open_flags; | ||
145 | file->private_data = fuse_file_get(ff); | ||
146 | fuse_finish_open(inode, file); | ||
145 | } | 147 | } |
146 | 148 | ||
147 | return err; | 149 | return err; |
148 | } | 150 | } |
149 | 151 | ||
150 | void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode) | 152 | void fuse_release_fill(struct fuse_file *ff, int flags, int opcode) |
151 | { | 153 | { |
152 | struct fuse_req *req = ff->reserved_req; | 154 | struct fuse_req *req = ff->reserved_req; |
153 | struct fuse_release_in *inarg = &req->misc.release.in; | 155 | struct fuse_release_in *inarg = &req->misc.release.in; |
@@ -155,7 +157,7 @@ void fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags, int opcode) | |||
155 | inarg->fh = ff->fh; | 157 | inarg->fh = ff->fh; |
156 | inarg->flags = flags; | 158 | inarg->flags = flags; |
157 | req->in.h.opcode = opcode; | 159 | req->in.h.opcode = opcode; |
158 | req->in.h.nodeid = nodeid; | 160 | req->in.h.nodeid = ff->nodeid; |
159 | req->in.numargs = 1; | 161 | req->in.numargs = 1; |
160 | req->in.args[0].size = sizeof(struct fuse_release_in); | 162 | req->in.args[0].size = sizeof(struct fuse_release_in); |
161 | req->in.args[0].value = inarg; | 163 | req->in.args[0].value = inarg; |
@@ -174,7 +176,7 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir) | |||
174 | fc = get_fuse_conn(inode); | 176 | fc = get_fuse_conn(inode); |
175 | req = ff->reserved_req; | 177 | req = ff->reserved_req; |
176 | 178 | ||
177 | fuse_release_fill(ff, get_node_id(inode), file->f_flags, | 179 | fuse_release_fill(ff, file->f_flags, |
178 | isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); | 180 | isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); |
179 | 181 | ||
180 | /* Hold vfsmount and dentry until release is finished */ | 182 | /* Hold vfsmount and dentry until release is finished */ |