linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ftp.linux.org.uk>
To: torvalds@osdl.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linuxram@us.ibm.com
Subject: [PATCH 6/18] sanitize the interface of graft_tree().
Date: Tue, 08 Nov 2005 02:01:31 +0000	[thread overview]
Message-ID: <E1EZInj-0001En-AM@ZenIV.linux.org.uk> (raw)

From: Ram Pai <linuxram@us.ibm.com>
Date: 1131401789 -0500

Old semanitcs: graft_tree() grabs a reference on the vfsmount before
returning success.
New one: graft_tree() leaves that to caller.

All the callers of graft_tree() immediately dropped that reference anyway.
Changing the interface takes care of this unnecessary overhead.

Idea proposed by Al-Viro.

Signed-off-by: Ram Pai (linuxram@us.ibm.com)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

---

 fs/namespace.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

e43480493368cfdc525357e242bcd01a3bfdc5db
diff --git a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -650,7 +650,6 @@ static int graft_tree(struct vfsmount *m
 		attach_mnt(mnt, nd);
 		list_add_tail(&head, &mnt->mnt_list);
 		list_splice(&head, current->namespace->list.prev);
-		mntget(mnt);
 		err = 0;
 		touch_namespace(current->namespace);
 	}
@@ -702,8 +701,7 @@ static int do_loopback(struct nameidata 
 		spin_lock(&vfsmount_lock);
 		umount_tree(mnt);
 		spin_unlock(&vfsmount_lock);
-	} else
-		mntput(mnt);
+	}
 
 out:
 	up_write(&current->namespace->sem);
@@ -857,15 +855,17 @@ int do_add_mount(struct vfsmount *newmnt
 		goto unlock;
 
 	newmnt->mnt_flags = mnt_flags;
-	newmnt->mnt_namespace = current->namespace;
-	err = graft_tree(newmnt, nd);
+	if ((err = graft_tree(newmnt, nd)))
+		goto unlock;
 
-	if (err == 0 && fslist) {
+	if (fslist) {
 		/* add to the specified expiration list */
 		spin_lock(&vfsmount_lock);
 		list_add_tail(&newmnt->mnt_expire, fslist);
 		spin_unlock(&vfsmount_lock);
 	}
+	up_write(&current->namespace->sem);
+	return 0;
 
 unlock:
 	up_write(&current->namespace->sem);

                 reply	other threads:[~2005-11-08  2:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1EZInj-0001En-AM@ZenIV.linux.org.uk \
    --to=viro@ftp.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxram@us.ibm.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).