linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Some more path_{get,put}() cleanups
@ 2008-04-28 16:37 Jan Blunck
  2008-04-28 16:37 ` [PATCH 1/3] VFS: " Jan Blunck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jan Blunck @ 2008-04-28 16:37 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Andrew Morton,
	Linux-fsdevel Mailinglist


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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] VFS: path_{get,put}() cleanups
  2008-04-28 16:37 [PATCH 0/3] Some more path_{get,put}() cleanups Jan Blunck
@ 2008-04-28 16:37 ` Jan Blunck
  2008-04-28 16:37 ` [PATCH 2/3] NFS: " Jan Blunck
  2008-04-28 16:37 ` [PATCH 3/3] AutoFS: " Jan Blunck
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Blunck @ 2008-04-28 16:37 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Andrew Morton,
	Linux-fsdevel Mailinglist; +Cc: viro

[-- Attachment #1: vfs/path_get_put-cleanups.diff --]
[-- Type: text/plain, Size: 2107 bytes --]

Here are some more places where path_{get,put}() can be used instead of
dput()/mntput() pair.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 fs/namei.c |   11 +++++------
 fs/pipe.c  |   10 ++++------
 2 files changed, 9 insertions(+), 12 deletions(-)

Index: b/fs/namei.c
===================================================================
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -582,15 +582,13 @@ static __always_inline int link_path_wal
 	int 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 &&
Index: b/fs/pipe.c
===================================================================
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -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 fil
 		return 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);



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] NFS: path_{get,put}() cleanups
  2008-04-28 16:37 [PATCH 0/3] Some more path_{get,put}() cleanups Jan Blunck
  2008-04-28 16:37 ` [PATCH 1/3] VFS: " Jan Blunck
@ 2008-04-28 16:37 ` Jan Blunck
  2008-04-28 16:37 ` [PATCH 3/3] AutoFS: " Jan Blunck
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Blunck @ 2008-04-28 16:37 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Andrew Morton,
	Linux-fsdevel Mailinglist
  Cc: Trond.Myklebust, linux-nfs

[-- Attachment #1: vfs/path_get_put-cleanups-nfs.diff --]
[-- Type: text/plain, Size: 1756 bytes --]

Here are some more places where path_{get,put}() can be used instead of
dput()/mntput() pair.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 fs/nfs/inode.c     |    3 +--
 fs/nfs/namespace.c |    3 +--
 fs/nfs/nfs4proc.c  |    6 ++----
 3 files changed, 4 insertions(+), 8 deletions(-)

Index: b/fs/nfs/inode.c
===================================================================
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -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);
 }
 
Index: b/fs/nfs/namespace.c
===================================================================
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -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);
Index: b/fs/nfs/nfs4proc.c
===================================================================
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -304,8 +304,7 @@ static void nfs4_opendata_free(struct kr
 		nfs4_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 *da
 	nfs4_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);
 }
 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] AutoFS: path_{get,put}() cleanups
  2008-04-28 16:37 [PATCH 0/3] Some more path_{get,put}() cleanups Jan Blunck
  2008-04-28 16:37 ` [PATCH 1/3] VFS: " Jan Blunck
  2008-04-28 16:37 ` [PATCH 2/3] NFS: " Jan Blunck
@ 2008-04-28 16:37 ` Jan Blunck
  2 siblings, 0 replies; 4+ messages in thread
From: Jan Blunck @ 2008-04-28 16:37 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Andrew Morton,
	Linux-fsdevel Mailinglist
  Cc: raven, autofs

[-- Attachment #1: vfs/path_get_put-cleanups-autofs.diff --]
[-- Type: text/plain, Size: 1570 bytes --]

Here 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 <jblunck@suse.de>
---
 fs/autofs4/expire.c |    2 +-
 fs/autofs4/root.c   |   12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

Index: b/fs/autofs4/expire.c
===================================================================
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -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;
 }
 
Index: b/fs/autofs4/root.c
===================================================================
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -146,17 +146,17 @@ static int autofs4_dir_open(struct inode
 
 	if (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);



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-28 14:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-28 16:37 [PATCH 0/3] Some more path_{get,put}() cleanups Jan Blunck
2008-04-28 16:37 ` [PATCH 1/3] VFS: " Jan Blunck
2008-04-28 16:37 ` [PATCH 2/3] NFS: " Jan Blunck
2008-04-28 16:37 ` [PATCH 3/3] AutoFS: " Jan Blunck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).