Some more path_{get,put}() cleanups
Subsystems (4)
cover Some more path_{get,put}() cleanups
Here are some patches where path_{get,put}() can be used instead of dput()/mntput() pairs. The patches are against 2.6.25-mm1.
Cheers,
Jan
PATCH 1/3 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 Jan Blunck <[email protected]>
--- fs/namei.c | 11 +++++------ fs/pipe.c | 10 ++++------ 2 files changed, 9 insertions(+), 12 deletions(-)
fs/namei.c +5 -6
@@ -582,15 +582,13 @@ static __always_inline int link_path_walint result;/* make sure the stuff we saved doesn't go away */ -dget (save.dentry); -mntget (save.mnt); +path_get (&save); result =__link_path_walk (name, nd);if (result == -ESTALE ) {/* nd->path had been dropped */ nd->path = save; -dget (nd->path.dentry); -mntget (nd->path.mnt); +path_get (&nd->path); nd->flags |=LOOKUP_REVAL ; result =__link_path_walk (name, nd); }
@@ -1217,8 +1215,9 @@ int vfs_path_lookup(struct dentry *dentr nd->flags = flags; nd->depth =0 ; - nd->path.mnt =mntget (mnt); - nd->path.dentry =dget (dentry); + nd->path.dentry = dentry; + nd->path.mnt = mnt; +path_get (&nd->path); retval =path_walk (name, nd); if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry &&
fs/pipe.c +4 -6
@@ -999,8 +999,7 @@ struct file *create_write_pipe(void)void free_write_pipe (struct file *f) {free_pipe_info (f->f_dentry->d_inode); -dput (f->f_path.dentry); -mntput (f->f_path.mnt); +path_put (&f->f_path);put_filp (f); }
@@ -1011,8 +1010,8 @@ struct file *create_read_pipe(struct filreturn ERR_PTR (-ENFILE );/* Grab pipe from the writer */ - f->f_path.mnt =mntget (wrf->f_path.mnt); - f->f_path.dentry =dget (wrf->f_path.dentry); + f->f_path = wrf->f_path; +path_get (&wrf->f_path); f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping; f->f_pos =0 ;
@@ -1064,8 +1063,7 @@ int do_pipe(int *fd) err_fdr:put_unused_fd (fdr); err_read_pipe: -dput (fr->f_dentry); -mntput (fr->f_vfsmnt); +path_put (&fr->f_path);put_filp (fr); err_write_pipe:free_write_pipe (fw);
PATCH 2/3 NFS: path_{get,put}() cleanups
In reply to Jan BlunckHere are some more places where path_{get,put}() can be used instead of dput()/mntput() pair.
Signed-off-by Jan Blunck <[email protected]>
--- fs/nfs/inode.c | 3 +-- fs/nfs/namespace.c | 3 +-- fs/nfs/nfs4proc.c | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-)
fs/nfs/inode.c +1 -2
@@ -541,8 +541,7 @@ static void __put_nfs_open_context(struc }if (ctx->cred !=NULL )put_rpccred (ctx->cred); -dput (ctx->path.dentry); -mntput (ctx->path.mnt); +path_put (&ctx->path);kfree (ctx); }
fs/nfs/namespace.c +1 -2
@@ -137,8 +137,7 @@ static void * nfs_follow_mountpoint(stru goto out_follow; goto out_err; } -mntput (nd->path.mnt); -dput (nd->path.dentry); +path_put (&nd->path); nd->path.mnt = mnt; nd->path.dentry =dget (mnt->mnt_root);schedule_delayed_work (&nfs_automount_task, nfs_mountpoint_expiry_timeout);
fs/nfs/nfs4proc.c +2 -4
@@ -304,8 +304,7 @@ static void nfs4_opendata_free(struct krnfs4_put_open_state (p->state);nfs4_put_state_owner (p->owner);dput (p->dir); -dput (p->path.dentry); -mntput (p->path.mnt); +path_put (&p->path);kfree (p); }
@@ -1213,8 +1212,7 @@ static void nfs4_free_closedata(void *danfs4_put_open_state (calldata->state);nfs_free_seqid (calldata->arg.seqid);nfs4_put_state_owner (sp); -dput (calldata->path.dentry); -mntput (calldata->path.mnt); +path_put (&calldata->path);kfree (calldata); }
PATCH 3/3 AutoFS: path_{get,put}() cleanups
In reply to Jan BlunckHere are some more places where path_{get,put}() can be used instead of dput()/mntput() pair. Besides that it fixes a bug in autofs4_mount_busy() where mntput() was called before dput().
Signed-off-by Jan Blunck <[email protected]>
--- fs/autofs4/expire.c | 2 +- fs/autofs4/root.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
fs/autofs4/expire.c +1 -1
@@ -73,8 +73,8 @@ static int autofs4_mount_busy(struct vfs status =0 ; done:DPRINTK ("returning = %d" , status); -mntput (mnt);dput (dentry); +mntput (mnt);return status; }
fs/autofs4/root.c +6 -6
@@ -146,17 +146,17 @@ static int autofs4_dir_open(struct inodeif (d_mountpoint (dentry)) {struct file *fp =NULL ; -struct vfsmount *fp_mnt =mntget (mnt); -struct dentry *fp_dentry =dget (dentry); +struct path fp_path = { .dentry = dentry, .mnt = mnt }; -if (!autofs4_follow_mount (&fp_mnt, &fp_dentry)) { -dput (fp_dentry); -mntput (fp_mnt); +path_get (&fp_path); + +if (!autofs4_follow_mount (&fp_path.mnt, &fp_path.dentry)) { +path_put (&fp_path);dcache_dir_close (inode, file); goto out; } - fp =dentry_open (fp_dentry, fp_mnt, file->f_flags); + fp =dentry_open (fp_path.dentry, fp_path.mnt, file->f_flags); status =PTR_ERR (fp);if (IS_ERR (fp)) {dcache_dir_close (inode, file);