1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Copyright (c) 1994, 1995 The Regents of the University of California.
|
|
|
|
* Copyright (c) 1994, 1995 Jan-Simon Pendry.
|
1994-05-24 10:09:53 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software donated to Berkeley by
|
|
|
|
* Jan-Simon Pendry.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)union_vfsops.c 8.20 (Berkeley) 5/20/95
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Union Layer
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1994-09-22 19:38:41 +00:00
|
|
|
#include <sys/kernel.h>
|
2001-06-28 03:50:17 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/mutex.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/filedesc.h>
|
2001-05-23 09:42:29 +00:00
|
|
|
#include <fs/unionfs/union.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-10-12 20:26:33 +00:00
|
|
|
static MALLOC_DEFINE(M_UNIONFSMNT, "UNION mount", "UNION mount structure");
|
|
|
|
|
2002-03-19 22:20:14 +00:00
|
|
|
extern int union_init(struct vfsconf *);
|
|
|
|
static int union_mount(struct mount *mp, char *path, caddr_t data,
|
|
|
|
struct nameidata *ndp, struct thread *td);
|
|
|
|
static int union_root(struct mount *mp, struct vnode **vpp);
|
|
|
|
static int union_statfs(struct mount *mp, struct statfs *sbp,
|
|
|
|
struct thread *td);
|
|
|
|
static int union_unmount(struct mount *mp, int mntflags,
|
|
|
|
struct thread *td);
|
1995-03-16 18:17:34 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Mount union filesystem
|
|
|
|
*/
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_mount(mp, path, data, ndp, td)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mount *mp;
|
|
|
|
char *path;
|
|
|
|
caddr_t data;
|
|
|
|
struct nameidata *ndp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
struct union_args args;
|
|
|
|
struct vnode *lowerrootvp = NULLVP;
|
|
|
|
struct vnode *upperrootvp = NULLVP;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct union_mount *um = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct ucred *cred = 0;
|
1994-05-25 09:21:21 +00:00
|
|
|
char *cp = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
int len;
|
|
|
|
u_int size;
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
UDEBUG(("union_mount(mp = %p)\n", (void *)mp));
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-09-27 13:40:20 +00:00
|
|
|
/*
|
|
|
|
* Disable clustered write, otherwise system becomes unstable.
|
|
|
|
*/
|
|
|
|
mp->mnt_flag |= MNT_NOCLUSTERW;
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Update is a no-op
|
|
|
|
*/
|
|
|
|
if (mp->mnt_flag & MNT_UPDATE) {
|
|
|
|
/*
|
|
|
|
* Need to provide.
|
|
|
|
* 1. a way to convert between rdonly and rdwr mounts.
|
|
|
|
* 2. support for nfs exports.
|
|
|
|
*/
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get argument
|
|
|
|
*/
|
1994-10-10 07:55:48 +00:00
|
|
|
error = copyin(data, (caddr_t)&args, sizeof(struct union_args));
|
|
|
|
if (error)
|
1994-05-24 10:09:53 +00:00
|
|
|
goto bad;
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
/*
|
|
|
|
* Obtain lower vnode. Vnode is stored in mp->mnt_vnodecovered.
|
|
|
|
* We need to reference it but not lock it.
|
|
|
|
*/
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
lowerrootvp = mp->mnt_vnodecovered;
|
|
|
|
VREF(lowerrootvp);
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
#if 0
|
1997-04-14 10:52:25 +00:00
|
|
|
/*
|
|
|
|
* Unlock lower node to avoid deadlock.
|
|
|
|
*/
|
1998-01-18 07:56:41 +00:00
|
|
|
if (lowerrootvp->v_op == union_vnodeop_p)
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(lowerrootvp, 0, td);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
#endif
|
1997-04-14 10:52:25 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* Obtain upper vnode by calling namei() on the path. The
|
|
|
|
* upperrootvp will be turned referenced but not locked.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT,
|
2001-09-12 08:38:13 +00:00
|
|
|
UIO_USERSPACE, args.target, td);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1994-10-10 07:55:48 +00:00
|
|
|
error = namei(ndp);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
|
|
|
#if 0
|
1998-01-18 07:56:41 +00:00
|
|
|
if (lowerrootvp->v_op == union_vnodeop_p)
|
2001-09-12 08:38:13 +00:00
|
|
|
vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY, td);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
#endif
|
1994-10-10 07:55:48 +00:00
|
|
|
if (error)
|
1994-05-24 10:09:53 +00:00
|
|
|
goto bad;
|
|
|
|
|
1999-12-15 23:02:35 +00:00
|
|
|
NDFREE(ndp, NDF_ONLY_PNBUF);
|
1994-05-24 10:09:53 +00:00
|
|
|
upperrootvp = ndp->ni_vp;
|
|
|
|
vrele(ndp->ni_dvp);
|
|
|
|
ndp->ni_dvp = NULL;
|
|
|
|
|
1999-12-11 16:13:02 +00:00
|
|
|
UDEBUG(("mount_root UPPERVP %p locked = %d\n", upperrootvp,
|
|
|
|
VOP_ISLOCKED(upperrootvp, NULL)));
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
1997-04-14 10:52:25 +00:00
|
|
|
/*
|
|
|
|
* Check multi union mount to avoid `lock myself again' panic.
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* Also require that it be a directory.
|
1997-04-14 10:52:25 +00:00
|
|
|
*/
|
|
|
|
if (upperrootvp == VTOUNION(lowerrootvp)->un_uppervp) {
|
1997-04-19 06:04:13 +00:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
printf("union_mount: multi union mount?\n");
|
|
|
|
#endif
|
1997-04-14 10:52:25 +00:00
|
|
|
error = EDEADLK;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (upperrootvp->v_type != VDIR) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto bad;
|
|
|
|
}
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* Allocate our union_mount structure and populate the fields.
|
|
|
|
* The vnode references are stored in the union_mount as held,
|
|
|
|
* unlocked references. Depending on the _BELOW flag, the
|
|
|
|
* filesystems are viewed in a different order. In effect this
|
|
|
|
* is the same as providing a mount-under option to the mount
|
|
|
|
* syscall.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
um = (struct union_mount *) malloc(sizeof(struct union_mount),
|
2000-12-08 21:51:06 +00:00
|
|
|
M_UNIONFSMNT, M_WAITOK | M_ZERO);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
um->um_op = args.mntflags & UNMNT_OPMASK;
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
switch (um->um_op) {
|
|
|
|
case UNMNT_ABOVE:
|
|
|
|
um->um_lowervp = lowerrootvp;
|
|
|
|
um->um_uppervp = upperrootvp;
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
upperrootvp = NULL;
|
|
|
|
lowerrootvp = NULL;
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UNMNT_BELOW:
|
|
|
|
um->um_lowervp = upperrootvp;
|
|
|
|
um->um_uppervp = lowerrootvp;
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
upperrootvp = NULL;
|
|
|
|
lowerrootvp = NULL;
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UNMNT_REPLACE:
|
|
|
|
vrele(lowerrootvp);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
lowerrootvp = NULL;
|
1994-05-24 10:09:53 +00:00
|
|
|
um->um_uppervp = upperrootvp;
|
|
|
|
um->um_lowervp = lowerrootvp;
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
upperrootvp = NULL;
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
|
|
|
* Unless the mount is readonly, ensure that the top layer
|
|
|
|
* supports whiteout operations
|
|
|
|
*/
|
|
|
|
if ((mp->mnt_flag & MNT_RDONLY) == 0) {
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
error = VOP_WHITEOUT(um->um_uppervp, NULL, LOOKUP);
|
1997-02-10 02:22:35 +00:00
|
|
|
if (error)
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
2002-02-27 18:32:23 +00:00
|
|
|
um->um_cred = crhold(td->td_ucred);
|
2002-01-13 11:58:06 +00:00
|
|
|
FILEDESC_LOCK(td->td_proc->p_fd);
|
2001-09-12 08:38:13 +00:00
|
|
|
um->um_cmode = UN_DIRMODE &~ td->td_proc->p_fd->fd_cmask;
|
2002-01-13 11:58:06 +00:00
|
|
|
FILEDESC_UNLOCK(td->td_proc->p_fd);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Depending on what you think the MNT_LOCAL flag might mean,
|
|
|
|
* you may want the && to be || on the conditional below.
|
|
|
|
* At the moment it has been defined that the filesystem is
|
|
|
|
* only local if it is all local, ie the MNT_LOCAL flag implies
|
|
|
|
* that the entire namespace is local. If you think the MNT_LOCAL
|
|
|
|
* flag implies that some of the files might be stored locally
|
|
|
|
* then you will want to change the conditional.
|
|
|
|
*/
|
|
|
|
if (um->um_op == UNMNT_ABOVE) {
|
|
|
|
if (((um->um_lowervp == NULLVP) ||
|
|
|
|
(um->um_lowervp->v_mount->mnt_flag & MNT_LOCAL)) &&
|
|
|
|
(um->um_uppervp->v_mount->mnt_flag & MNT_LOCAL))
|
|
|
|
mp->mnt_flag |= MNT_LOCAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copy in the upper layer's RDONLY flag. This is for the benefit
|
|
|
|
* of lookup() which explicitly checks the flag, rather than asking
|
1998-04-17 22:37:19 +00:00
|
|
|
* the filesystem for its own opinion. This means, that an update
|
1994-05-24 10:09:53 +00:00
|
|
|
* mount of the underlying filesystem to go from rdonly to rdwr
|
|
|
|
* will leave the unioned view as read-only.
|
|
|
|
*/
|
|
|
|
mp->mnt_flag |= (um->um_uppervp->v_mount->mnt_flag & MNT_RDONLY);
|
|
|
|
|
|
|
|
mp->mnt_data = (qaddr_t) um;
|
1997-02-10 02:22:35 +00:00
|
|
|
vfs_getnewfsid(mp);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
switch (um->um_op) {
|
|
|
|
case UNMNT_ABOVE:
|
1997-02-10 02:22:35 +00:00
|
|
|
cp = "<above>:";
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
case UNMNT_BELOW:
|
1997-02-10 02:22:35 +00:00
|
|
|
cp = "<below>:";
|
1994-05-24 10:09:53 +00:00
|
|
|
break;
|
|
|
|
case UNMNT_REPLACE:
|
|
|
|
cp = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
len = strlen(cp);
|
|
|
|
bcopy(cp, mp->mnt_stat.f_mntfromname, len);
|
|
|
|
|
|
|
|
cp = mp->mnt_stat.f_mntfromname + len;
|
|
|
|
len = MNAMELEN - len;
|
|
|
|
|
|
|
|
(void) copyinstr(args.target, cp, len - 1, &size);
|
|
|
|
bzero(cp + size, len - size);
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
(void)union_statfs(mp, &mp->mnt_stat, td);
|
1994-11-04 14:41:46 +00:00
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
UDEBUG(("union_mount: from %s, on %s\n",
|
|
|
|
mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname));
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
bad:
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
if (um) {
|
|
|
|
if (um->um_uppervp)
|
|
|
|
vrele(um->um_uppervp);
|
|
|
|
if (um->um_lowervp)
|
|
|
|
vrele(um->um_lowervp);
|
|
|
|
/* XXX other fields */
|
1997-10-12 20:26:33 +00:00
|
|
|
free(um, M_UNIONFSMNT);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
if (cred)
|
|
|
|
crfree(cred);
|
|
|
|
if (upperrootvp)
|
|
|
|
vrele(upperrootvp);
|
|
|
|
if (lowerrootvp)
|
|
|
|
vrele(lowerrootvp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free reference to union layer
|
|
|
|
*/
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_unmount(mp, mntflags, td)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mount *mp;
|
|
|
|
int mntflags;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
|
|
|
|
int error;
|
1997-02-10 02:22:35 +00:00
|
|
|
int freeing;
|
1994-05-24 10:09:53 +00:00
|
|
|
int flags = 0;
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
UDEBUG(("union_unmount(mp = %p)\n", (void *)mp));
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (mntflags & MNT_FORCE)
|
|
|
|
flags |= FORCECLOSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Keep flushing vnodes from the mount list.
|
|
|
|
* This is needed because of the un_pvp held
|
|
|
|
* reference to the parent vnode.
|
|
|
|
* If more vnodes have been freed on a given pass,
|
|
|
|
* the try again. The loop will iterate at most
|
|
|
|
* (d) times, where (d) is the maximum tree depth
|
|
|
|
* in the filesystem.
|
|
|
|
*/
|
2001-05-16 18:04:37 +00:00
|
|
|
for (freeing = 0; (error = vflush(mp, 0, flags)) != 0;) {
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
/* count #vnodes held on mount list */
|
2001-06-28 03:50:17 +00:00
|
|
|
mtx_lock(&mntvnode_mtx);
|
2001-05-16 18:04:37 +00:00
|
|
|
n = 0;
|
2001-10-23 01:21:29 +00:00
|
|
|
TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes)
|
1997-02-10 02:22:35 +00:00
|
|
|
n++;
|
2001-06-28 03:50:17 +00:00
|
|
|
mtx_unlock(&mntvnode_mtx);
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
/* if this is unchanged then stop */
|
|
|
|
if (n == freeing)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* otherwise try once more time */
|
|
|
|
freeing = n;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2001-05-16 18:04:37 +00:00
|
|
|
/* If the most recent vflush failed, the filesystem is still busy. */
|
|
|
|
if (error)
|
|
|
|
return (error);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Discard references to upper and lower target vnodes.
|
|
|
|
*/
|
|
|
|
if (um->um_lowervp)
|
|
|
|
vrele(um->um_lowervp);
|
|
|
|
vrele(um->um_uppervp);
|
|
|
|
crfree(um->um_cred);
|
|
|
|
/*
|
|
|
|
* Finally, throw away the union_mount structure
|
|
|
|
*/
|
1997-10-12 20:26:33 +00:00
|
|
|
free(mp->mnt_data, M_UNIONFSMNT); /* XXX */
|
1994-05-24 10:09:53 +00:00
|
|
|
mp->mnt_data = 0;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
1994-05-24 10:09:53 +00:00
|
|
|
union_root(mp, vpp)
|
|
|
|
struct mount *mp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
|
|
|
struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/*
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* Supply an unlocked reference to um_uppervp and to um_lowervp. It
|
|
|
|
* is possible for um_uppervp to be locked without the associated
|
|
|
|
* root union_node being locked. We let union_allocvp() deal with
|
|
|
|
* it.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1999-12-11 16:13:02 +00:00
|
|
|
UDEBUG(("union_root UPPERVP %p locked = %d\n", um->um_uppervp,
|
|
|
|
VOP_ISLOCKED(um->um_uppervp, NULL)));
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
VREF(um->um_uppervp);
|
|
|
|
if (um->um_lowervp)
|
|
|
|
VREF(um->um_lowervp);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
|
|
|
error = union_allocvp(vpp, mp, NULLVP, NULLVP, NULL,
|
|
|
|
um->um_uppervp, um->um_lowervp, 1);
|
|
|
|
UDEBUG(("error %d\n", error));
|
1999-12-11 16:13:02 +00:00
|
|
|
UDEBUG(("union_root2 UPPERVP %p locked = %d\n", um->um_uppervp,
|
|
|
|
VOP_ISLOCKED(um->um_uppervp, NULL)));
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_statfs(mp, sbp, td)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mount *mp;
|
|
|
|
struct statfs *sbp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
|
|
|
|
struct statfs mstat;
|
|
|
|
int lbsize;
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
UDEBUG(("union_statfs(mp = %p, lvp = %p, uvp = %p)\n",
|
|
|
|
(void *)mp, (void *)um->um_lowervp, (void *)um->um_uppervp));
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
bzero(&mstat, sizeof(mstat));
|
|
|
|
|
|
|
|
if (um->um_lowervp) {
|
2001-09-12 08:38:13 +00:00
|
|
|
error = VFS_STATFS(um->um_lowervp->v_mount, &mstat, td);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now copy across the "interesting" information and fake the rest */
|
|
|
|
#if 0
|
|
|
|
sbp->f_type = mstat.f_type;
|
|
|
|
sbp->f_flags = mstat.f_flags;
|
|
|
|
sbp->f_bsize = mstat.f_bsize;
|
|
|
|
sbp->f_iosize = mstat.f_iosize;
|
|
|
|
#endif
|
|
|
|
lbsize = mstat.f_bsize;
|
|
|
|
sbp->f_blocks = mstat.f_blocks;
|
|
|
|
sbp->f_bfree = mstat.f_bfree;
|
|
|
|
sbp->f_bavail = mstat.f_bavail;
|
|
|
|
sbp->f_files = mstat.f_files;
|
|
|
|
sbp->f_ffree = mstat.f_ffree;
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
error = VFS_STATFS(um->um_uppervp->v_mount, &mstat, td);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
sbp->f_flags = mstat.f_flags;
|
|
|
|
sbp->f_bsize = mstat.f_bsize;
|
|
|
|
sbp->f_iosize = mstat.f_iosize;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if the lower and upper blocksizes differ, then frig the
|
|
|
|
* block counts so that the sizes reported by df make some
|
|
|
|
* kind of sense. none of this makes sense though.
|
|
|
|
*/
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (mstat.f_bsize != lbsize)
|
1997-05-07 14:37:32 +00:00
|
|
|
sbp->f_blocks = ((off_t) sbp->f_blocks * lbsize) / mstat.f_bsize;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The "total" fields count total resources in all layers,
|
|
|
|
* the "free" fields count only those resources which are
|
|
|
|
* free in the upper layer (since only the upper layer
|
|
|
|
* is writeable).
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
sbp->f_blocks += mstat.f_blocks;
|
1997-02-10 02:22:35 +00:00
|
|
|
sbp->f_bfree = mstat.f_bfree;
|
|
|
|
sbp->f_bavail = mstat.f_bavail;
|
1994-05-24 10:09:53 +00:00
|
|
|
sbp->f_files += mstat.f_files;
|
1997-02-10 02:22:35 +00:00
|
|
|
sbp->f_ffree = mstat.f_ffree;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
if (sbp != &mp->mnt_stat) {
|
1997-02-10 02:22:35 +00:00
|
|
|
sbp->f_type = mp->mnt_vfc->vfc_typenum;
|
1994-05-24 10:09:53 +00:00
|
|
|
bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
|
|
|
|
bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
|
|
|
|
bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static struct vfsops union_vfsops = {
|
1994-05-24 10:09:53 +00:00
|
|
|
union_mount,
|
1999-09-11 00:46:08 +00:00
|
|
|
vfs_stdstart, /* underlying start already done */
|
1994-05-24 10:09:53 +00:00
|
|
|
union_unmount,
|
|
|
|
union_root,
|
1999-09-07 22:42:38 +00:00
|
|
|
vfs_stdquotactl,
|
1994-05-24 10:09:53 +00:00
|
|
|
union_statfs,
|
1999-09-07 22:42:38 +00:00
|
|
|
vfs_stdsync, /* XXX assumes no cached data on union level */
|
|
|
|
vfs_stdvget,
|
|
|
|
vfs_stdfhtovp,
|
1999-09-11 00:46:08 +00:00
|
|
|
vfs_stdcheckexp,
|
1999-09-07 22:42:38 +00:00
|
|
|
vfs_stdvptofh,
|
1994-05-24 10:09:53 +00:00
|
|
|
union_init,
|
1999-12-19 06:08:07 +00:00
|
|
|
vfs_stduninit,
|
|
|
|
vfs_stdextattrctl,
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1994-09-21 03:47:43 +00:00
|
|
|
|
2001-05-24 15:20:11 +00:00
|
|
|
VFS_SET(union_vfsops, unionfs, VFCF_LOOPBACK);
|