Skip to content

Commit 9546ac7

Browse files
committed
9p: Fix initialisation of netfs_inode for 9p
The 9p filesystem is calling netfs_inode_init() in v9fs_init_inode() - before the struct inode fields have been initialised from the obtained file stats (ie. after v9fs_stat2inode*() has been called), but netfslib wants to set a couple of its fields from i_size. Reported-by: Marc Dionne <[email protected]> Signed-off-by: David Howells <[email protected]> Tested-by: Marc Dionne <[email protected]> Tested-by: Dominique Martinet <[email protected]> Acked-by: Dominique Martinet <[email protected]> cc: Eric Van Hensbergen <[email protected]> cc: Latchesar Ionkov <[email protected]> cc: Dominique Martinet <[email protected]> cc: Christian Schoenebeck <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected]
1 parent 7097c96 commit 9546ac7

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

fs/9p/v9fs_vfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb);
4242
void v9fs_free_inode(struct inode *inode);
4343
struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode,
4444
dev_t rdev);
45+
void v9fs_set_netfs_context(struct inode *inode);
4546
int v9fs_init_inode(struct v9fs_session_info *v9ses,
4647
struct inode *inode, umode_t mode, dev_t rdev);
4748
void v9fs_evict_inode(struct inode *inode);

fs/9p/vfs_inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void v9fs_free_inode(struct inode *inode)
246246
/*
247247
* Set parameters for the netfs library
248248
*/
249-
static void v9fs_set_netfs_context(struct inode *inode)
249+
void v9fs_set_netfs_context(struct inode *inode)
250250
{
251251
struct v9fs_inode *v9inode = V9FS_I(inode);
252252
netfs_inode_init(&v9inode->netfs, &v9fs_req_ops, true);
@@ -326,8 +326,6 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses,
326326
err = -EINVAL;
327327
goto error;
328328
}
329-
330-
v9fs_set_netfs_context(inode);
331329
error:
332330
return err;
333331

@@ -359,6 +357,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev)
359357
iput(inode);
360358
return ERR_PTR(err);
361359
}
360+
v9fs_set_netfs_context(inode);
362361
return inode;
363362
}
364363

@@ -461,6 +460,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb,
461460
goto error;
462461

463462
v9fs_stat2inode(st, inode, sb, 0);
463+
v9fs_set_netfs_context(inode);
464464
v9fs_cache_inode_get_cookie(inode);
465465
unlock_new_inode(inode);
466466
return inode;

fs/9p/vfs_inode_dotl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb,
128128
goto error;
129129

130130
v9fs_stat2inode_dotl(st, inode, 0);
131+
v9fs_set_netfs_context(inode);
131132
v9fs_cache_inode_get_cookie(inode);
132133
retval = v9fs_get_acl(inode, fid);
133134
if (retval)

0 commit comments

Comments
 (0)