LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: viro@zeniv.linux.org.uk
Cc: akpm@linux-foundation.org, linuxram@us.ibm.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [patch 3/7] vfs: mountinfo: add mount ID
Date: Thu, 27 Mar 2008 13:06:22 +0100 [thread overview]
Message-ID: <20080327122355.594127612@szeredi.hu> (raw)
In-Reply-To: <20080327120619.031944658@szeredi.hu>
[-- Attachment #1: mountinfo_mnt_id.patch --]
[-- Type: text/plain, Size: 2507 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
Add a unique ID to each vfsmount using the IDR infrastructure. The
identifiers are reused after the vfsmount is freed.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/namespace.c | 20 ++++++++++++++++++++
include/linux/mount.h | 1 +
2 files changed, 21 insertions(+)
Index: vfs-2.6/fs/namespace.c
===================================================================
--- vfs-2.6.orig/fs/namespace.c 2008-03-27 12:05:55.000000000 +0100
+++ vfs-2.6/fs/namespace.c 2008-03-27 12:06:08.000000000 +0100
@@ -27,6 +27,7 @@
#include <linux/mount.h>
#include <linux/ramfs.h>
#include <linux/log2.h>
+#include <linux/idr.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include "pnode.h"
@@ -39,6 +40,7 @@
__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
static int event;
+static DEFINE_IDA(mnt_id_ida);
static struct list_head *mount_hashtable __read_mostly;
static struct kmem_cache *mnt_cache __read_mostly;
@@ -58,10 +60,26 @@ static inline unsigned long hash(struct
#define MNT_WRITER_UNDERFLOW_LIMIT -(1<<16)
+static int mnt_alloc_id(struct vfsmount *mnt)
+{
+ if (!ida_pre_get(&mnt_id_ida, GFP_KERNEL))
+ return -ENOMEM;
+
+ return ida_get_new_above(&mnt_id_ida, 1, &mnt->mnt_id);
+}
+
struct vfsmount *alloc_vfsmnt(const char *name)
{
struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
if (mnt) {
+ int err;
+
+ err = mnt_alloc_id(mnt);
+ if (err) {
+ kmem_cache_free(mnt_cache, mnt);
+ return NULL;
+ }
+
atomic_set(&mnt->mnt_count, 1);
INIT_LIST_HEAD(&mnt->mnt_hash);
INIT_LIST_HEAD(&mnt->mnt_child);
@@ -866,6 +884,8 @@ void umount_tree(struct vfsmount *mnt, i
p->mnt_mountpoint->d_mounted--;
}
change_mnt_propagation(p, MS_PRIVATE);
+ ida_remove(&mnt_id_ida, p->mnt_id);
+ p->mnt_id = 0;
}
}
Index: vfs-2.6/include/linux/mount.h
===================================================================
--- vfs-2.6.orig/include/linux/mount.h 2008-03-27 12:05:55.000000000 +0100
+++ vfs-2.6/include/linux/mount.h 2008-03-27 12:06:08.000000000 +0100
@@ -56,6 +56,7 @@ struct vfsmount {
struct list_head mnt_slave; /* slave list entry */
struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */
struct mnt_namespace *mnt_ns; /* containing namespace */
+ int mnt_id; /* mount identifier */
/*
* We put mnt_count & mnt_expiry_mark at the end of struct vfsmount
* to let these frequently modified fields in a separate cache line
--
next prev parent reply other threads:[~2008-03-27 12:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-27 12:06 [patch 0/7] vfs: mountinfo (v4) Miklos Szeredi
2008-03-27 12:06 ` [patch 1/7] vfs: mountinfo: add dentry_path() Miklos Szeredi
2008-03-27 12:06 ` [patch 2/7] vfs: mountinfo: add seq_file_root() Miklos Szeredi
2008-03-27 12:06 ` Miklos Szeredi [this message]
2008-03-27 22:13 ` [patch 3/7] vfs: mountinfo: add mount ID Al Viro
2008-03-27 12:06 ` [patch 4/7] vfs: mountinfo: add mount peer group ID Miklos Szeredi
2008-03-27 12:06 ` [patch 5/7] vfs: mountinfo: allow using process root Miklos Szeredi
2008-03-28 2:08 ` Al Viro
2008-03-28 8:59 ` Miklos Szeredi
2008-03-27 12:06 ` [patch 6/7] vfs: mountinfo: add /proc/<pid>/mountinfo Miklos Szeredi
2008-03-27 22:36 ` Al Viro
2008-03-28 8:48 ` Miklos Szeredi
2008-03-27 12:06 ` [patch 7/7] vfs: mountinfo: show dominating group id Miklos Szeredi
2008-03-27 22:42 ` Al Viro
2008-03-28 8:52 ` Miklos Szeredi
2008-03-30 18:51 ` Ram Pai
-- strict thread matches above, loose matches on Subject: below --
2008-03-26 21:11 [patch 0/7] vfs: mountinfo (v3) Miklos Szeredi
2008-03-26 21:11 ` [patch 3/7] vfs: mountinfo: add mount ID Miklos Szeredi
2008-03-26 22:25 ` Al Viro
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=20080327122355.594127612@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxram@us.ibm.com \
--cc=viro@zeniv.linux.org.uk \
--subject='Re: [patch 3/7] vfs: mountinfo: add mount ID' \
/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
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).