Commit 7e3d0eb0 authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

VFS: Fix UP compile error in fs/namespace.c

mnt_longterm is there only on SMP
Reported-and-tested-by: default avatarJoachim Eastwood <manabian@gmail.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f8b18087
...@@ -611,6 +611,21 @@ static void attach_mnt(struct vfsmount *mnt, struct path *path) ...@@ -611,6 +611,21 @@ static void attach_mnt(struct vfsmount *mnt, struct path *path)
list_add_tail(&mnt->mnt_child, &path->mnt->mnt_mounts); list_add_tail(&mnt->mnt_child, &path->mnt->mnt_mounts);
} }
static inline void __mnt_make_longterm(struct vfsmount *mnt)
{
#ifdef CONFIG_SMP
atomic_inc(&mnt->mnt_longterm);
#endif
}
/* needs vfsmount lock for write */
static inline void __mnt_make_shortterm(struct vfsmount *mnt)
{
#ifdef CONFIG_SMP
atomic_dec(&mnt->mnt_longterm);
#endif
}
/* /*
* vfsmount lock must be held for write * vfsmount lock must be held for write
*/ */
...@@ -626,7 +641,7 @@ static void commit_tree(struct vfsmount *mnt) ...@@ -626,7 +641,7 @@ static void commit_tree(struct vfsmount *mnt)
list_add_tail(&head, &mnt->mnt_list); list_add_tail(&head, &mnt->mnt_list);
list_for_each_entry(m, &head, mnt_list) { list_for_each_entry(m, &head, mnt_list) {
m->mnt_ns = n; m->mnt_ns = n;
atomic_inc(&m->mnt_longterm); __mnt_make_longterm(m);
} }
list_splice(&head, n->list.prev); list_splice(&head, n->list.prev);
...@@ -1189,7 +1204,7 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) ...@@ -1189,7 +1204,7 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
list_del_init(&p->mnt_list); list_del_init(&p->mnt_list);
__touch_mnt_namespace(p->mnt_ns); __touch_mnt_namespace(p->mnt_ns);
p->mnt_ns = NULL; p->mnt_ns = NULL;
atomic_dec(&p->mnt_longterm); __mnt_make_shortterm(p);
list_del_init(&p->mnt_child); list_del_init(&p->mnt_child);
if (p->mnt_parent != p) { if (p->mnt_parent != p) {
p->mnt_parent->mnt_ghosts++; p->mnt_parent->mnt_ghosts++;
...@@ -2243,16 +2258,18 @@ static struct mnt_namespace *alloc_mnt_ns(void) ...@@ -2243,16 +2258,18 @@ static struct mnt_namespace *alloc_mnt_ns(void)
void mnt_make_longterm(struct vfsmount *mnt) void mnt_make_longterm(struct vfsmount *mnt)
{ {
atomic_inc(&mnt->mnt_longterm); __mnt_make_longterm(mnt);
} }
void mnt_make_shortterm(struct vfsmount *mnt) void mnt_make_shortterm(struct vfsmount *mnt)
{ {
#ifdef CONFIG_SMP
if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) if (atomic_add_unless(&mnt->mnt_longterm, -1, 1))
return; return;
br_write_lock(vfsmount_lock); br_write_lock(vfsmount_lock);
atomic_dec(&mnt->mnt_longterm); atomic_dec(&mnt->mnt_longterm);
br_write_unlock(vfsmount_lock); br_write_unlock(vfsmount_lock);
#endif
} }
/* /*
...@@ -2292,17 +2309,17 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, ...@@ -2292,17 +2309,17 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
q = new_ns->root; q = new_ns->root;
while (p) { while (p) {
q->mnt_ns = new_ns; q->mnt_ns = new_ns;
atomic_inc(&q->mnt_longterm); __mnt_make_longterm(q);
if (fs) { if (fs) {
if (p == fs->root.mnt) { if (p == fs->root.mnt) {
fs->root.mnt = mntget(q); fs->root.mnt = mntget(q);
atomic_inc(&q->mnt_longterm); __mnt_make_longterm(q);
mnt_make_shortterm(p); mnt_make_shortterm(p);
rootmnt = p; rootmnt = p;
} }
if (p == fs->pwd.mnt) { if (p == fs->pwd.mnt) {
fs->pwd.mnt = mntget(q); fs->pwd.mnt = mntget(q);
atomic_inc(&q->mnt_longterm); __mnt_make_longterm(q);
mnt_make_shortterm(p); mnt_make_shortterm(p);
pwdmnt = p; pwdmnt = p;
} }
...@@ -2348,7 +2365,7 @@ struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) ...@@ -2348,7 +2365,7 @@ struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt)
new_ns = alloc_mnt_ns(); new_ns = alloc_mnt_ns();
if (!IS_ERR(new_ns)) { if (!IS_ERR(new_ns)) {
mnt->mnt_ns = new_ns; mnt->mnt_ns = new_ns;
atomic_inc(&mnt->mnt_longterm); __mnt_make_longterm(mnt);
new_ns->root = mnt; new_ns->root = mnt;
list_add(&new_ns->list, &new_ns->root->mnt_list); list_add(&new_ns->list, &new_ns->root->mnt_list);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment