diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2011-02-28 06:34:01 -0500 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2011-03-15 10:57:39 -0400 |
commit | 5ffc0cb308f69cea36058d308d911f26ee59316e (patch) | |
tree | 3419cbaeab2d8f20d96123ba20604d82b9129a80 | |
parent | 62d810b424e434a38ad6b17fb93cd5748692a026 (diff) |
fs/9p: Add inode hashing
We didn't add the inode to inode hash in 9p. We need to do that
to get sync to work, otherwise __mark_inode_dirty will not
add the inode to super block's dirty list.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
-rw-r--r-- | fs/9p/acl.c | 2 | ||||
-rw-r--r-- | fs/9p/v9fs_vfs.h | 2 | ||||
-rw-r--r-- | fs/9p/vfs_inode.c | 121 | ||||
-rw-r--r-- | fs/9p/vfs_inode_dotl.c | 69 |
4 files changed, 124 insertions, 70 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c index 1ee3434239c8..515455296378 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c | |||
@@ -21,8 +21,8 @@ | |||
21 | #include <linux/posix_acl_xattr.h> | 21 | #include <linux/posix_acl_xattr.h> |
22 | #include "xattr.h" | 22 | #include "xattr.h" |
23 | #include "acl.h" | 23 | #include "acl.h" |
24 | #include "v9fs_vfs.h" | ||
25 | #include "v9fs.h" | 24 | #include "v9fs.h" |
25 | #include "v9fs_vfs.h" | ||
26 | 26 | ||
27 | static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name) | 27 | static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name) |
28 | { | 28 | { |
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index c44aaa8bd2a3..ab72e66c2e0c 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h | |||
@@ -54,6 +54,8 @@ void v9fs_destroy_inode(struct inode *inode); | |||
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | struct inode *v9fs_get_inode(struct super_block *sb, int mode); | 56 | struct inode *v9fs_get_inode(struct super_block *sb, int mode); |
57 | int v9fs_init_inode(struct v9fs_session_info *v9ses, | ||
58 | struct inode *inode, int mode); | ||
57 | void v9fs_evict_inode(struct inode *inode); | 59 | void v9fs_evict_inode(struct inode *inode); |
58 | ino_t v9fs_qid2ino(struct p9_qid *qid); | 60 | ino_t v9fs_qid2ino(struct p9_qid *qid); |
59 | void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *); | 61 | void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *); |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index a0d65a398729..445dd283dc15 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -243,26 +243,10 @@ void v9fs_destroy_inode(struct inode *inode) | |||
243 | } | 243 | } |
244 | #endif | 244 | #endif |
245 | 245 | ||
246 | /** | 246 | int v9fs_init_inode(struct v9fs_session_info *v9ses, |
247 | * v9fs_get_inode - helper function to setup an inode | 247 | struct inode *inode, int mode) |
248 | * @sb: superblock | ||
249 | * @mode: mode to setup inode with | ||
250 | * | ||
251 | */ | ||
252 | |||
253 | struct inode *v9fs_get_inode(struct super_block *sb, int mode) | ||
254 | { | 248 | { |
255 | int err; | 249 | int err = 0; |
256 | struct inode *inode; | ||
257 | struct v9fs_session_info *v9ses = sb->s_fs_info; | ||
258 | |||
259 | P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); | ||
260 | |||
261 | inode = new_inode(sb); | ||
262 | if (!inode) { | ||
263 | P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n"); | ||
264 | return ERR_PTR(-ENOMEM); | ||
265 | } | ||
266 | 250 | ||
267 | inode_init_owner(inode, NULL, mode); | 251 | inode_init_owner(inode, NULL, mode); |
268 | inode->i_blocks = 0; | 252 | inode->i_blocks = 0; |
@@ -306,7 +290,6 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
306 | } | 290 | } |
307 | 291 | ||
308 | break; | 292 | break; |
309 | |||
310 | case S_IFLNK: | 293 | case S_IFLNK: |
311 | if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) { | 294 | if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) { |
312 | P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with " | 295 | P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with " |
@@ -342,12 +325,37 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) | |||
342 | err = -EINVAL; | 325 | err = -EINVAL; |
343 | goto error; | 326 | goto error; |
344 | } | 327 | } |
328 | error: | ||
329 | return err; | ||
345 | 330 | ||
346 | return inode; | 331 | } |
347 | 332 | ||
348 | error: | 333 | /** |
349 | iput(inode); | 334 | * v9fs_get_inode - helper function to setup an inode |
350 | return ERR_PTR(err); | 335 | * @sb: superblock |
336 | * @mode: mode to setup inode with | ||
337 | * | ||
338 | */ | ||
339 | |||
340 | struct inode *v9fs_get_inode(struct super_block *sb, int mode) | ||
341 | { | ||
342 | int err; | ||
343 | struct inode *inode; | ||
344 | struct v9fs_session_info *v9ses = sb->s_fs_info; | ||
345 | |||
346 | P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); | ||
347 | |||
348 | inode = new_inode(sb); | ||
349 | if (!inode) { | ||
350 | P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n"); | ||
351 | return ERR_PTR(-ENOMEM); | ||
352 | } | ||
353 | err = v9fs_init_inode(v9ses, inode, mode); | ||
354 | if (err) { | ||
355 | iput(inode); | ||
356 | return ERR_PTR(err); | ||
357 | } | ||
358 | return inode; | ||
351 | } | 359 | } |
352 | 360 | ||
353 | /* | 361 | /* |
@@ -424,39 +432,60 @@ void v9fs_evict_inode(struct inode *inode) | |||
424 | } | 432 | } |
425 | } | 433 | } |
426 | 434 | ||
427 | struct inode * | 435 | static struct inode *v9fs_qid_iget(struct super_block *sb, |
428 | v9fs_inode(struct v9fs_session_info *v9ses, struct p9_fid *fid, | 436 | struct p9_qid *qid, |
429 | struct super_block *sb) | 437 | struct p9_wstat *st) |
430 | { | 438 | { |
431 | int err, umode; | 439 | int retval, umode; |
432 | struct inode *ret = NULL; | 440 | unsigned long i_ino; |
433 | struct p9_wstat *st; | 441 | struct inode *inode; |
434 | 442 | struct v9fs_session_info *v9ses = sb->s_fs_info; | |
435 | st = p9_client_stat(fid); | ||
436 | if (IS_ERR(st)) | ||
437 | return ERR_CAST(st); | ||
438 | 443 | ||
444 | i_ino = v9fs_qid2ino(qid); | ||
445 | inode = iget_locked(sb, i_ino); | ||
446 | if (!inode) | ||
447 | return ERR_PTR(-ENOMEM); | ||
448 | if (!(inode->i_state & I_NEW)) | ||
449 | return inode; | ||
450 | /* | ||
451 | * initialize the inode with the stat info | ||
452 | * FIXME!! we may need support for stale inodes | ||
453 | * later. | ||
454 | */ | ||
439 | umode = p9mode2unixmode(v9ses, st->mode); | 455 | umode = p9mode2unixmode(v9ses, st->mode); |
440 | ret = v9fs_get_inode(sb, umode); | 456 | retval = v9fs_init_inode(v9ses, inode, umode); |
441 | if (IS_ERR(ret)) { | 457 | if (retval) |
442 | err = PTR_ERR(ret); | ||
443 | goto error; | 458 | goto error; |
444 | } | ||
445 | |||
446 | v9fs_stat2inode(st, ret, sb); | ||
447 | ret->i_ino = v9fs_qid2ino(&st->qid); | ||
448 | 459 | ||
460 | v9fs_stat2inode(st, inode, sb); | ||
449 | #ifdef CONFIG_9P_FSCACHE | 461 | #ifdef CONFIG_9P_FSCACHE |
450 | v9fs_vcookie_set_qid(ret, &st->qid); | 462 | v9fs_vcookie_set_qid(ret, &st->qid); |
451 | v9fs_cache_inode_get_cookie(ret); | 463 | v9fs_cache_inode_get_cookie(inode); |
452 | #endif | 464 | #endif |
453 | p9stat_free(st); | 465 | unlock_new_inode(inode); |
454 | kfree(st); | 466 | return inode; |
455 | return ret; | ||
456 | error: | 467 | error: |
468 | unlock_new_inode(inode); | ||
469 | iput(inode); | ||
470 | return ERR_PTR(retval); | ||
471 | |||
472 | } | ||
473 | |||
474 | struct inode * | ||
475 | v9fs_inode(struct v9fs_session_info *v9ses, struct p9_fid *fid, | ||
476 | struct super_block *sb) | ||
477 | { | ||
478 | struct p9_wstat *st; | ||
479 | struct inode *inode = NULL; | ||
480 | |||
481 | st = p9_client_stat(fid); | ||
482 | if (IS_ERR(st)) | ||
483 | return ERR_CAST(st); | ||
484 | |||
485 | inode = v9fs_qid_iget(sb, &st->qid, st); | ||
457 | p9stat_free(st); | 486 | p9stat_free(st); |
458 | kfree(st); | 487 | kfree(st); |
459 | return ERR_PTR(err); | 488 | return inode; |
460 | } | 489 | } |
461 | 490 | ||
462 | /** | 491 | /** |
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 1327464bb2bb..6f62320eda89 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c | |||
@@ -86,40 +86,63 @@ static struct dentry *v9fs_dentry_from_dir_inode(struct inode *inode) | |||
86 | return dentry; | 86 | return dentry; |
87 | } | 87 | } |
88 | 88 | ||
89 | static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, | ||
90 | struct p9_qid *qid, | ||
91 | struct p9_fid *fid, | ||
92 | struct p9_stat_dotl *st) | ||
93 | { | ||
94 | int retval; | ||
95 | unsigned long i_ino; | ||
96 | struct inode *inode; | ||
97 | struct v9fs_session_info *v9ses = sb->s_fs_info; | ||
98 | |||
99 | i_ino = v9fs_qid2ino(qid); | ||
100 | inode = iget_locked(sb, i_ino); | ||
101 | if (!inode) | ||
102 | return ERR_PTR(-ENOMEM); | ||
103 | if (!(inode->i_state & I_NEW)) | ||
104 | return inode; | ||
105 | /* | ||
106 | * initialize the inode with the stat info | ||
107 | * FIXME!! we may need support for stale inodes | ||
108 | * later. | ||
109 | */ | ||
110 | retval = v9fs_init_inode(v9ses, inode, st->st_mode); | ||
111 | if (retval) | ||
112 | goto error; | ||
113 | |||
114 | v9fs_stat2inode_dotl(st, inode); | ||
115 | #ifdef CONFIG_9P_FSCACHE | ||
116 | v9fs_vcookie_set_qid(inode, &st->qid); | ||
117 | v9fs_cache_inode_get_cookie(inode); | ||
118 | #endif | ||
119 | retval = v9fs_get_acl(inode, fid); | ||
120 | if (retval) | ||
121 | goto error; | ||
122 | |||
123 | unlock_new_inode(inode); | ||
124 | return inode; | ||
125 | error: | ||
126 | unlock_new_inode(inode); | ||
127 | iput(inode); | ||
128 | return ERR_PTR(retval); | ||
129 | |||
130 | } | ||
131 | |||
89 | struct inode * | 132 | struct inode * |
90 | v9fs_inode_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid, | 133 | v9fs_inode_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid, |
91 | struct super_block *sb) | 134 | struct super_block *sb) |
92 | { | 135 | { |
93 | struct inode *ret = NULL; | ||
94 | int err; | ||
95 | struct p9_stat_dotl *st; | 136 | struct p9_stat_dotl *st; |
137 | struct inode *inode = NULL; | ||
96 | 138 | ||
97 | st = p9_client_getattr_dotl(fid, P9_STATS_BASIC); | 139 | st = p9_client_getattr_dotl(fid, P9_STATS_BASIC); |
98 | if (IS_ERR(st)) | 140 | if (IS_ERR(st)) |
99 | return ERR_CAST(st); | 141 | return ERR_CAST(st); |
100 | 142 | ||
101 | ret = v9fs_get_inode(sb, st->st_mode); | 143 | inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st); |
102 | if (IS_ERR(ret)) { | ||
103 | err = PTR_ERR(ret); | ||
104 | goto error; | ||
105 | } | ||
106 | |||
107 | v9fs_stat2inode_dotl(st, ret); | ||
108 | ret->i_ino = v9fs_qid2ino(&st->qid); | ||
109 | #ifdef CONFIG_9P_FSCACHE | ||
110 | v9fs_vcookie_set_qid(ret, &st->qid); | ||
111 | v9fs_cache_inode_get_cookie(ret); | ||
112 | #endif | ||
113 | err = v9fs_get_acl(ret, fid); | ||
114 | if (err) { | ||
115 | iput(ret); | ||
116 | goto error; | ||
117 | } | ||
118 | kfree(st); | ||
119 | return ret; | ||
120 | error: | ||
121 | kfree(st); | 144 | kfree(st); |
122 | return ERR_PTR(err); | 145 | return inode; |
123 | } | 146 | } |
124 | 147 | ||
125 | /** | 148 | /** |