linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kinglong Mee <kinglongmee@gmail.com>
To: Al Viro <viro@zeniv.linux.org.uk>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	linux-fsdevel@vger.kernel.org
Cc: NeilBrown <neilb@suse.de>,
	Trond Myklebust <trond.myklebust@primarydata.com>,
	kinglongmee@gmail.com
Subject: [PATCH 04/10 v6] fs: New helper legitimize_mntget() for getting a legitimize mnt
Date: Thu, 25 Jun 2015 22:21:33 +0800	[thread overview]
Message-ID: <558C0E6D.3000704@gmail.com> (raw)
In-Reply-To: <558C0D6A.9050104@gmail.com>

New helper legitimize_mntget for getting a mnt without setting
MNT_SYNC_UMOUNT | MNT_UMOUNT | MNT_DOOMED, otherwise return NULL.

v6, New one

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/namespace.c        | 19 +++++++++++++++++++
 include/linux/mount.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/fs/namespace.c b/fs/namespace.c
index 1f4f9da..f31d165 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1142,6 +1142,25 @@ struct vfsmount *mntget(struct vfsmount *mnt)
 }
 EXPORT_SYMBOL(mntget);
 
+struct vfsmount *legitimize_mntget(struct vfsmount *vfsmnt)
+{
+	struct mount *mnt;
+
+	if (vfsmnt == NULL)
+		return NULL;
+
+	read_seqlock_excl(&mount_lock);
+	mnt = real_mount(vfsmnt);
+	if (vfsmnt->mnt_flags & (MNT_SYNC_UMOUNT | MNT_UMOUNT | MNT_DOOMED))
+		vfsmnt = NULL;
+	else
+		mnt_add_count(mnt, 1);
+	read_sequnlock_excl(&mount_lock);
+
+	return vfsmnt;
+}
+EXPORT_SYMBOL(legitimize_mntget);
+
 struct vfsmount *mnt_clone_internal(struct path *path)
 {
 	struct mount *p;
diff --git a/include/linux/mount.h b/include/linux/mount.h
index f822c3c..8ae9dc0 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -79,6 +79,7 @@ extern void mnt_drop_write(struct vfsmount *mnt);
 extern void mnt_drop_write_file(struct file *file);
 extern void mntput(struct vfsmount *mnt);
 extern struct vfsmount *mntget(struct vfsmount *mnt);
+extern struct vfsmount *legitimize_mntget(struct vfsmount *vfsmnt);
 extern struct vfsmount *mnt_clone_internal(struct path *path);
 extern int __mnt_is_readonly(struct vfsmount *mnt);
 
-- 
2.4.3


  parent reply	other threads:[~2015-06-25 14:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25 14:17 [PATCH 00/10 v6] NFSD: Pin to vfsmount for nfsd exports cache Kinglong Mee
     [not found] ` <558C0D6A.9050104-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-06-25 14:18   ` [PATCH 01/10 v6] fs_pin: Initialize value for fs_pin explicitly Kinglong Mee
2015-06-25 14:25   ` [PATCH 05/10 v6] sunrpc: Store cache_detail in seq_file's private directly Kinglong Mee
2015-06-25 14:34   ` [PATCH 08/10] sunrpc: New helper cache_delete_entry for deleting cache_head directly Kinglong Mee
2015-06-25 14:36   ` [PATCH 09/10 v6] sunrpc: Support validate/invalidate for reference change in cache_detail Kinglong Mee
2015-06-25 14:19 ` [PATCH 02/10 v6] fs_pin: Export functions for specific filesystem Kinglong Mee
2015-06-25 14:19 ` [PATCH 03/10 v6] path: New helpers path_get_pin/path_put_unpin for path pin Kinglong Mee
2015-06-25 14:21 ` Kinglong Mee [this message]
2015-06-25 14:27 ` [PATCH 06/10 v6] sunrpc/nfsd: Remove redundant code by exports seq_operations functions Kinglong Mee
2015-06-25 14:29 ` [PATCH 07/10 v6] sunrpc: Switch to using list_head instead single list Kinglong Mee
2015-06-25 14:37 ` [PATCH 10/10 v6] nfsd: Allows user un-mounting filesystem where nfsd exports base on Kinglong Mee
2015-07-01  5:47   ` Al Viro
     [not found]     ` <20150701054751.GB17109-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2015-07-02 15:17       ` Kinglong Mee

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=558C0E6D.3000704@gmail.com \
    --to=kinglongmee@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=trond.myklebust@primarydata.com \
    --cc=viro@zeniv.linux.org.uk \
    /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).