summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Stultz <johnstul@us.ibm.com>2010-04-28 23:31:49 -0700
committerThomas Gleixner <tglx@linutronix.de>2010-04-29 11:57:13 +0200
commit4329d1ae261df5ae61f8a4db7253fbe316efb590 (patch)
tree4558d10eb94d04defcde2225e440dc449d0dd531
parenta0a59617869efb2ec0e80c6cf11cfc90735600f6 (diff)
downloadlwn-4329d1ae261df5ae61f8a4db7253fbe316efb590.tar.gz
lwn-4329d1ae261df5ae61f8a4db7253fbe316efb590.zip
fs: Fix namespace related hangs
Nick converted the dentry->d_mounted counter to a flag, however with namespaces, dentries can be mounted multiple times (and more importantly unmounted multiple times). If a namespace was created and then released, the unmount_tree would remove the DCACHE_MOUNTED flag and that would make d_mountpoint fail, causing the mounts to be lost. This patch coverts it back to a counter, and adds some extra WARN_ONs to make sure things are accounted properly. Signed-off-by: John Stultz <johnstul@us.ibm.com> Cc: "Luis Claudio R. Goncalves" <lclaudio@uudg.org> Cc: Nick Piggin <npiggin@suse.de> LKML-Reference: <1272522942.1967.12.camel@work-vm> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--fs/autofs4/expire.c5
-rw-r--r--fs/dcache.c1
-rw-r--r--fs/libfs.c1
-rw-r--r--fs/namespace.c5
-rw-r--r--include/linux/dcache.h3
5 files changed, 10 insertions, 5 deletions
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index dc629eea0b91..60a7c6ce0a0d 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -296,7 +296,8 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
if (d_mountpoint(root)) {
ino->flags |= AUTOFS_INF_MOUNTPOINT;
spin_lock(&root->d_lock);
- root->d_flags &= ~DCACHE_MOUNTED;
+ WARN_ON(root->d_mounted == 0);
+ root->d_mounted--;
spin_unlock(&root->d_lock);
}
ino->flags |= AUTOFS_INF_EXPIRING;
@@ -536,7 +537,7 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
spin_lock(&sbi->fs_lock);
if (ino->flags & AUTOFS_INF_MOUNTPOINT) {
spin_lock(&sb->s_root->d_lock);
- sb->s_root->d_flags |= DCACHE_MOUNTED;
+ sb->s_root->d_mounted++;
spin_unlock(&sb->s_root->d_lock);
ino->flags &= ~AUTOFS_INF_MOUNTPOINT;
}
diff --git a/fs/dcache.c b/fs/dcache.c
index c2a4d2ebe0e4..89b9d1f14871 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1187,6 +1187,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
dentry->d_sb = NULL;
dentry->d_op = NULL;
dentry->d_fsdata = NULL;
+ dentry->d_mounted = 0;
INIT_HLIST_NODE(&dentry->d_hash);
INIT_LIST_HEAD(&dentry->d_lru);
INIT_LIST_HEAD(&dentry->d_subdirs);
diff --git a/fs/libfs.c b/fs/libfs.c
index 48fe7c883d27..98d2717e9027 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -265,6 +265,7 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name,
d_instantiate(dentry, root);
s->s_root = dentry;
s->s_flags |= MS_ACTIVE;
+ WARN_ON(mnt->mnt_flags & MNT_MOUNTED);
mnt->mnt_flags |= MNT_MOUNTED;
simple_set_mnt(mnt, s);
return 0;
diff --git a/fs/namespace.c b/fs/namespace.c
index 6c115d86a157..64db957bb992 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -586,7 +586,8 @@ static void dentry_reset_mounted(struct vfsmount *mnt, struct dentry *dentry)
{
if (!__lookup_mnt(mnt, dentry, 0)) {
spin_lock(&dentry->d_lock);
- dentry->d_flags &= ~DCACHE_MOUNTED;
+ WARN_ON(dentry->d_mounted == 0);
+ dentry->d_mounted--;
spin_unlock(&dentry->d_lock);
}
}
@@ -610,7 +611,7 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry,
child_mnt->mnt_parent = mntget(mnt);
spin_lock(&dentry->d_lock);
child_mnt->mnt_mountpoint = dget_dlock(dentry);
- dentry->d_flags |= DCACHE_MOUNTED;
+ dentry->d_mounted++;
spin_unlock(&dentry->d_lock);
}
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 39872ea86c6a..bc5a5ff141c8 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -99,6 +99,7 @@ struct dentry {
atomic_t d_count;
unsigned int d_flags; /* protected by d_lock */
spinlock_t d_lock; /* per dentry lock */
+ int d_mounted;
seqcount_t d_seq; /* per dentry seqlock */
struct inode *d_inode; /* Where the name belongs to - NULL is
* negative */
@@ -364,7 +365,7 @@ extern void dput(struct dentry *);
static inline int d_mountpoint(struct dentry *dentry)
{
- return dentry->d_flags & DCACHE_MOUNTED;
+ return dentry->d_mounted;
}
extern struct vfsmount *lookup_mnt(struct path *);