Skip to content

Commit 5ffc0cb

Browse files
kvaneeshericvh
authored andcommitted
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>
1 parent 62d810b commit 5ffc0cb

4 files changed

Lines changed: 124 additions & 70 deletions

File tree

‎fs/9p/acl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include <linux/posix_acl_xattr.h>
2222
#include "xattr.h"
2323
#include "acl.h"
24-
#include "v9fs_vfs.h"
2524
#include "v9fs.h"
25+
#include "v9fs_vfs.h"
2626

2727
static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name)
2828
{

‎fs/9p/v9fs_vfs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ void v9fs_destroy_inode(struct inode *inode);
5454
#endif
5555

5656
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);
5759
void v9fs_evict_inode(struct inode *inode);
5860
ino_t v9fs_qid2ino(struct p9_qid *qid);
5961
void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *);

‎fs/9p/vfs_inode.c‎

Lines changed: 75 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -243,26 +243,10 @@ void v9fs_destroy_inode(struct inode *inode)
243243
}
244244
#endif
245245

246-
/**
247-
* v9fs_get_inode - helper function to setup an inode
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)
246+
int v9fs_init_inode(struct v9fs_session_info *v9ses,
247+
struct inode *inode, int mode)
254248
{
255-
int err;
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-
}
249+
int err = 0;
266250

267251
inode_init_owner(inode, NULL, mode);
268252
inode->i_blocks = 0;
@@ -306,7 +290,6 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
306290
}
307291

308292
break;
309-
310293
case S_IFLNK:
311294
if (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)) {
312295
P9_DPRINTK(P9_DEBUG_ERROR, "extended modes used with "
@@ -342,12 +325,37 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
342325
err = -EINVAL;
343326
goto error;
344327
}
328+
error:
329+
return err;
345330

346-
return inode;
331+
}
347332

348-
error:
349-
iput(inode);
350-
return ERR_PTR(err);
333+
/**
334+
* v9fs_get_inode - helper function to setup an inode
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;
351359
}
352360

353361
/*
@@ -424,39 +432,60 @@ void v9fs_evict_inode(struct inode *inode)
424432
}
425433
}
426434

427-
struct inode *
428-
v9fs_inode(struct v9fs_session_info *v9ses, struct p9_fid *fid,
429-
struct super_block *sb)
435+
static struct inode *v9fs_qid_iget(struct super_block *sb,
436+
struct p9_qid *qid,
437+
struct p9_wstat *st)
430438
{
431-
int err, umode;
432-
struct inode *ret = NULL;
433-
struct p9_wstat *st;
434-
435-
st = p9_client_stat(fid);
436-
if (IS_ERR(st))
437-
return ERR_CAST(st);
439+
int retval, umode;
440+
unsigned long i_ino;
441+
struct inode *inode;
442+
struct v9fs_session_info *v9ses = sb->s_fs_info;
438443

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+
*/
439455
umode = p9mode2unixmode(v9ses, st->mode);
440-
ret = v9fs_get_inode(sb, umode);
441-
if (IS_ERR(ret)) {
442-
err = PTR_ERR(ret);
456+
retval = v9fs_init_inode(v9ses, inode, umode);
457+
if (retval)
443458
goto error;
444-
}
445-
446-
v9fs_stat2inode(st, ret, sb);
447-
ret->i_ino = v9fs_qid2ino(&st->qid);
448459

460+
v9fs_stat2inode(st, inode, sb);
449461
#ifdef CONFIG_9P_FSCACHE
450462
v9fs_vcookie_set_qid(ret, &st->qid);
451-
v9fs_cache_inode_get_cookie(ret);
463+
v9fs_cache_inode_get_cookie(inode);
452464
#endif
453-
p9stat_free(st);
454-
kfree(st);
455-
return ret;
465+
unlock_new_inode(inode);
466+
return inode;
456467
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);
457486
p9stat_free(st);
458487
kfree(st);
459-
return ERR_PTR(err);
488+
return inode;
460489
}
461490

462491
/**

‎fs/9p/vfs_inode_dotl.c‎

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,40 +86,63 @@ static struct dentry *v9fs_dentry_from_dir_inode(struct inode *inode)
8686
return dentry;
8787
}
8888

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+
89132
struct inode *
90133
v9fs_inode_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid,
91134
struct super_block *sb)
92135
{
93-
struct inode *ret = NULL;
94-
int err;
95136
struct p9_stat_dotl *st;
137+
struct inode *inode = NULL;
96138

97139
st = p9_client_getattr_dotl(fid, P9_STATS_BASIC);
98140
if (IS_ERR(st))
99141
return ERR_CAST(st);
100142

101-
ret = v9fs_get_inode(sb, st->st_mode);
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:
143+
inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st);
121144
kfree(st);
122-
return ERR_PTR(err);
145+
return inode;
123146
}
124147

125148
/**

0 commit comments

Comments
 (0)