diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-16 11:58:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-16 11:58:09 -0400 |
commit | 26a992dbc24e34cbdd03621d1c97ce571ad74e65 (patch) | |
tree | cbb3171eb715b7c1ed28ed3ca29f1f03165e2faa /fs/9p/fid.c | |
parent | abab012a52237693ae48a655ece30cacb2ce4cf7 (diff) | |
parent | 7c9e592e1f6a994d2903c9b055e488ec90f58159 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs: (46 commits)
fs/9p: Make the writeback_fid owned by root
fs/9p: Writeback dirty data before setattr
fs/9p: call vmtruncate before setattr 9p opeation
fs/9p: Properly update inode attributes on link
fs/9p: Prevent multiple inclusion of same header
fs/9p: Workaround vfs rename rehash bug
fs/9p: Mark directory inode invalid for many directory inode operations
fs/9p: Add . and .. dentry revalidation flag
fs/9p: mark inode attribute invalid on rename, unlink and setattr
fs/9p: Add support for marking inode attribute invalid
fs/9p: Initialize root inode number for dotl
fs/9p: Update link count correctly on different file system operations
fs/9p: Add drop_inode 9p callback
fs/9p: Add direct IO support in cached mode
fs/9p: Fix inode i_size update in file_write
fs/9p: set default readahead pages in cached mode
fs/9p: Move writeback fid to v9fs_inode
fs/9p: Add v9fs_inode
fs/9p: Don't set stat.st_blocks based on nrpages
fs/9p: Add inode hashing
...
Diffstat (limited to 'fs/9p/fid.c')
-rw-r--r-- | fs/9p/fid.c | 114 |
1 files changed, 80 insertions, 34 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index b00223c99d70..cd63e002d826 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
@@ -125,46 +125,17 @@ err_out: | |||
125 | return -ENOMEM; | 125 | return -ENOMEM; |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, |
129 | * v9fs_fid_lookup - lookup for a fid, try to walk if not found | 129 | uid_t uid, int any) |
130 | * @dentry: dentry to look for fid in | ||
131 | * | ||
132 | * Look for a fid in the specified dentry for the current user. | ||
133 | * If no fid is found, try to create one walking from a fid from the parent | ||
134 | * dentry (if it has one), or the root dentry. If the user haven't accessed | ||
135 | * the fs yet, attach now and walk from the root. | ||
136 | */ | ||
137 | |||
138 | struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | ||
139 | { | 130 | { |
140 | int i, n, l, clone, any, access; | ||
141 | u32 uid; | ||
142 | struct p9_fid *fid, *old_fid = NULL; | ||
143 | struct dentry *ds; | 131 | struct dentry *ds; |
144 | struct v9fs_session_info *v9ses; | ||
145 | char **wnames, *uname; | 132 | char **wnames, *uname; |
133 | int i, n, l, clone, access; | ||
134 | struct v9fs_session_info *v9ses; | ||
135 | struct p9_fid *fid, *old_fid = NULL; | ||
146 | 136 | ||
147 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 137 | v9ses = v9fs_inode2v9ses(dentry->d_inode); |
148 | access = v9ses->flags & V9FS_ACCESS_MASK; | 138 | access = v9ses->flags & V9FS_ACCESS_MASK; |
149 | switch (access) { | ||
150 | case V9FS_ACCESS_SINGLE: | ||
151 | case V9FS_ACCESS_USER: | ||
152 | case V9FS_ACCESS_CLIENT: | ||
153 | uid = current_fsuid(); | ||
154 | any = 0; | ||
155 | break; | ||
156 | |||
157 | case V9FS_ACCESS_ANY: | ||
158 | uid = v9ses->uid; | ||
159 | any = 1; | ||
160 | break; | ||
161 | |||
162 | default: | ||
163 | uid = ~0; | ||
164 | any = 0; | ||
165 | break; | ||
166 | } | ||
167 | |||
168 | fid = v9fs_fid_find(dentry, uid, any); | 139 | fid = v9fs_fid_find(dentry, uid, any); |
169 | if (fid) | 140 | if (fid) |
170 | return fid; | 141 | return fid; |
@@ -250,6 +221,45 @@ err_out: | |||
250 | return fid; | 221 | return fid; |
251 | } | 222 | } |
252 | 223 | ||
224 | /** | ||
225 | * v9fs_fid_lookup - lookup for a fid, try to walk if not found | ||
226 | * @dentry: dentry to look for fid in | ||
227 | * | ||
228 | * Look for a fid in the specified dentry for the current user. | ||
229 | * If no fid is found, try to create one walking from a fid from the parent | ||
230 | * dentry (if it has one), or the root dentry. If the user haven't accessed | ||
231 | * the fs yet, attach now and walk from the root. | ||
232 | */ | ||
233 | |||
234 | struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | ||
235 | { | ||
236 | uid_t uid; | ||
237 | int any, access; | ||
238 | struct v9fs_session_info *v9ses; | ||
239 | |||
240 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | ||
241 | access = v9ses->flags & V9FS_ACCESS_MASK; | ||
242 | switch (access) { | ||
243 | case V9FS_ACCESS_SINGLE: | ||
244 | case V9FS_ACCESS_USER: | ||
245 | case V9FS_ACCESS_CLIENT: | ||
246 | uid = current_fsuid(); | ||
247 | any = 0; | ||
248 | break; | ||
249 | |||
250 | case V9FS_ACCESS_ANY: | ||
251 | uid = v9ses->uid; | ||
252 | any = 1; | ||
253 | break; | ||
254 | |||
255 | default: | ||
256 | uid = ~0; | ||
257 | any = 0; | ||
258 | break; | ||
259 | } | ||
260 | return v9fs_fid_lookup_with_uid(dentry, uid, any); | ||
261 | } | ||
262 | |||
253 | struct p9_fid *v9fs_fid_clone(struct dentry *dentry) | 263 | struct p9_fid *v9fs_fid_clone(struct dentry *dentry) |
254 | { | 264 | { |
255 | struct p9_fid *fid, *ret; | 265 | struct p9_fid *fid, *ret; |
@@ -261,3 +271,39 @@ struct p9_fid *v9fs_fid_clone(struct dentry *dentry) | |||
261 | ret = p9_client_walk(fid, 0, NULL, 1); | 271 | ret = p9_client_walk(fid, 0, NULL, 1); |
262 | return ret; | 272 | return ret; |
263 | } | 273 | } |
274 | |||
275 | static struct p9_fid *v9fs_fid_clone_with_uid(struct dentry *dentry, uid_t uid) | ||
276 | { | ||
277 | struct p9_fid *fid, *ret; | ||
278 | |||
279 | fid = v9fs_fid_lookup_with_uid(dentry, uid, 0); | ||
280 | if (IS_ERR(fid)) | ||
281 | return fid; | ||
282 | |||
283 | ret = p9_client_walk(fid, 0, NULL, 1); | ||
284 | return ret; | ||
285 | } | ||
286 | |||
287 | struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) | ||
288 | { | ||
289 | int err; | ||
290 | struct p9_fid *fid; | ||
291 | |||
292 | fid = v9fs_fid_clone_with_uid(dentry, 0); | ||
293 | if (IS_ERR(fid)) | ||
294 | goto error_out; | ||
295 | /* | ||
296 | * writeback fid will only be used to write back the | ||
297 | * dirty pages. We always request for the open fid in read-write | ||
298 | * mode so that a partial page write which result in page | ||
299 | * read can work. | ||
300 | */ | ||
301 | err = p9_client_open(fid, O_RDWR); | ||
302 | if (err < 0) { | ||
303 | p9_client_clunk(fid); | ||
304 | fid = ERR_PTR(err); | ||
305 | goto error_out; | ||
306 | } | ||
307 | error_out: | ||
308 | return fid; | ||
309 | } | ||