提交 c8e7f449 编写于 作者: J Jan Blunck 提交者: Al Viro

[patch 1/4] vfs: path_{get,put}() cleanups

Here are some more places where path_{get,put}() can be used instead of
dput()/mntput() pair.
Signed-off-by: NJan Blunck <jblunck@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 c70f8441
...@@ -581,15 +581,13 @@ static __always_inline int link_path_walk(const char *name, struct nameidata *nd ...@@ -581,15 +581,13 @@ static __always_inline int link_path_walk(const char *name, struct nameidata *nd
int result; int result;
/* make sure the stuff we saved doesn't go away */ /* make sure the stuff we saved doesn't go away */
dget(save.dentry); path_get(&save);
mntget(save.mnt);
result = __link_path_walk(name, nd); result = __link_path_walk(name, nd);
if (result == -ESTALE) { if (result == -ESTALE) {
/* nd->path had been dropped */ /* nd->path had been dropped */
nd->path = save; nd->path = save;
dget(nd->path.dentry); path_get(&nd->path);
mntget(nd->path.mnt);
nd->flags |= LOOKUP_REVAL; nd->flags |= LOOKUP_REVAL;
result = __link_path_walk(name, nd); result = __link_path_walk(name, nd);
} }
...@@ -1216,8 +1214,9 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, ...@@ -1216,8 +1214,9 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
nd->flags = flags; nd->flags = flags;
nd->depth = 0; nd->depth = 0;
nd->path.mnt = mntget(mnt); nd->path.dentry = dentry;
nd->path.dentry = dget(dentry); nd->path.mnt = mnt;
path_get(&nd->path);
retval = path_walk(name, nd); retval = path_walk(name, nd);
if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry && if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry &&
......
...@@ -1003,8 +1003,7 @@ struct file *create_write_pipe(void) ...@@ -1003,8 +1003,7 @@ struct file *create_write_pipe(void)
void free_write_pipe(struct file *f) void free_write_pipe(struct file *f)
{ {
free_pipe_info(f->f_dentry->d_inode); free_pipe_info(f->f_dentry->d_inode);
dput(f->f_path.dentry); path_put(&f->f_path);
mntput(f->f_path.mnt);
put_filp(f); put_filp(f);
} }
...@@ -1015,8 +1014,8 @@ struct file *create_read_pipe(struct file *wrf) ...@@ -1015,8 +1014,8 @@ struct file *create_read_pipe(struct file *wrf)
return ERR_PTR(-ENFILE); return ERR_PTR(-ENFILE);
/* Grab pipe from the writer */ /* Grab pipe from the writer */
f->f_path.mnt = mntget(wrf->f_path.mnt); f->f_path = wrf->f_path;
f->f_path.dentry = dget(wrf->f_path.dentry); path_get(&wrf->f_path);
f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping; f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping;
f->f_pos = 0; f->f_pos = 0;
...@@ -1068,8 +1067,7 @@ int do_pipe(int *fd) ...@@ -1068,8 +1067,7 @@ int do_pipe(int *fd)
err_fdr: err_fdr:
put_unused_fd(fdr); put_unused_fd(fdr);
err_read_pipe: err_read_pipe:
dput(fr->f_dentry); path_put(&fr->f_path);
mntput(fr->f_vfsmnt);
put_filp(fr); put_filp(fr);
err_write_pipe: err_write_pipe:
free_write_pipe(fw); free_write_pipe(fw);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册