1994-05-24 11:09:53 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1994 Jan-Simon Pendry
|
|
|
|
* Copyright (c) 1994
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed 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_subr.c 8.20 (Berkeley) 5/20/95
|
1999-08-28 02:08:13 +01:00
|
|
|
* $FreeBSD$
|
1994-05-24 11:09:53 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1997-03-23 03:37:54 +00:00
|
|
|
#include <sys/fcntl.h>
|
1998-11-03 08:01:48 +00:00
|
|
|
#include <sys/file.h>
|
1994-05-24 11:09:53 +01:00
|
|
|
#include <sys/filedesc.h>
|
2001-05-01 09:13:21 +01:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/malloc.h>
|
1998-11-03 08:01:48 +00:00
|
|
|
#include <sys/module.h>
|
1997-02-10 02:22:35 +00:00
|
|
|
#include <sys/mount.h>
|
2001-05-22 00:19:50 +01:00
|
|
|
#include <sys/mutex.h>
|
2001-05-01 09:13:21 +01:00
|
|
|
#include <sys/namei.h>
|
1997-02-10 02:22:35 +00:00
|
|
|
#include <sys/stat.h>
|
2001-05-01 09:13:21 +01:00
|
|
|
#include <sys/vnode.h>
|
|
|
|
|
1997-02-12 06:52:51 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_extern.h> /* for vnode_pager_setsize */
|
1997-12-27 02:56:39 +00:00
|
|
|
#include <vm/vm_zone.h>
|
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 21:52:41 +01:00
|
|
|
#include <vm/vm_object.h> /* for vm cache coherency */
|
2001-05-01 09:13:21 +01:00
|
|
|
|
2001-05-23 10:42:29 +01:00
|
|
|
#include <fs/unionfs/union.h>
|
1994-05-24 11:09:53 +01:00
|
|
|
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
1995-12-03 14:54:48 +00:00
|
|
|
extern int union_init __P((void));
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
/* must be power of two, otherwise change UNION_HASH() */
|
|
|
|
#define NHASH 32
|
|
|
|
|
|
|
|
/* unsigned int ... */
|
|
|
|
#define UNION_HASH(u, l) \
|
1998-07-15 05:17:55 +01:00
|
|
|
(((((uintptr_t) (u)) + ((uintptr_t) l)) >> 8) & (NHASH-1))
|
1994-05-24 11:09:53 +01:00
|
|
|
|
2000-05-26 03:09:24 +01:00
|
|
|
static LIST_HEAD(unhead, union_node) unhead[NHASH];
|
1994-05-24 11:09:53 +01:00
|
|
|
static int unvplock[NHASH];
|
|
|
|
|
1997-02-12 14:45:23 +00:00
|
|
|
static void union_dircache_r __P((struct vnode *vp, struct vnode ***vppp,
|
|
|
|
int *cntp));
|
1995-12-03 14:54:48 +00:00
|
|
|
static int union_list_lock __P((int ix));
|
|
|
|
static void union_list_unlock __P((int ix));
|
1997-02-12 14:45:23 +00:00
|
|
|
static int union_relookup __P((struct union_mount *um, struct vnode *dvp,
|
|
|
|
struct vnode **vpp,
|
|
|
|
struct componentname *cnp,
|
|
|
|
struct componentname *cn, char *path,
|
|
|
|
int pathlen));
|
1997-11-18 15:07:35 +00:00
|
|
|
static void union_updatevp __P((struct union_node *un,
|
1995-12-03 14:54:48 +00:00
|
|
|
struct vnode *uppervp,
|
|
|
|
struct vnode *lowervp));
|
1997-11-18 15:07:35 +00:00
|
|
|
static void union_newlower __P((struct union_node *, struct vnode *));
|
|
|
|
static void union_newupper __P((struct union_node *, struct vnode *));
|
|
|
|
static int union_copyfile __P((struct vnode *, struct vnode *,
|
|
|
|
struct ucred *, struct proc *));
|
|
|
|
static int union_vn_create __P((struct vnode **, struct union_node *,
|
|
|
|
struct proc *));
|
|
|
|
static int union_vn_close __P((struct vnode *, int, struct ucred *,
|
|
|
|
struct proc *));
|
1995-12-03 14:54:48 +00:00
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
int
|
|
|
|
union_init()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NHASH; i++)
|
|
|
|
LIST_INIT(&unhead[i]);
|
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 21:52:41 +01:00
|
|
|
bzero((caddr_t)unvplock, sizeof(unvplock));
|
1994-05-25 10:21:21 +01:00
|
|
|
return (0);
|
1994-05-24 11:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
union_list_lock(ix)
|
|
|
|
int ix;
|
|
|
|
{
|
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 21:52:41 +01:00
|
|
|
if (unvplock[ix] & UNVP_LOCKED) {
|
|
|
|
unvplock[ix] |= UNVP_WANT;
|
1994-10-06 22:07:04 +01:00
|
|
|
(void) tsleep((caddr_t) &unvplock[ix], PINOD, "unllck", 0);
|
1994-05-24 11:09:53 +01:00
|
|
|
return (1);
|
|
|
|
}
|
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 21:52:41 +01:00
|
|
|
unvplock[ix] |= UNVP_LOCKED;
|
1994-05-24 11:09:53 +01:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
union_list_unlock(ix)
|
|
|
|
int ix;
|
|
|
|
{
|
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 21:52:41 +01:00
|
|
|
unvplock[ix] &= ~UNVP_LOCKED;
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
if (unvplock[ix] & UNVP_WANT) {
|
|
|
|
unvplock[ix] &= ~UNVP_WANT;
|
1994-05-24 11:09:53 +01:00
|
|
|
wakeup((caddr_t) &unvplock[ix]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* union_updatevp:
|
|
|
|
*
|
|
|
|
* The uppervp, if not NULL, must be referenced and not locked by us
|
|
|
|
* The lowervp, if not NULL, must be referenced.
|
|
|
|
*
|
|
|
|
* if uppervp and lowervp match pointers already installed, nothing
|
|
|
|
* happens. The passed vp's (when matching) are not adjusted. This
|
|
|
|
* routine may only be called by union_newupper() and union_newlower().
|
|
|
|
*/
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static void
|
1994-05-24 11:09:53 +01:00
|
|
|
union_updatevp(un, uppervp, lowervp)
|
|
|
|
struct union_node *un;
|
|
|
|
struct vnode *uppervp;
|
|
|
|
struct vnode *lowervp;
|
|
|
|
{
|
|
|
|
int ohash = UNION_HASH(un->un_uppervp, un->un_lowervp);
|
|
|
|
int nhash = UNION_HASH(uppervp, lowervp);
|
1997-02-10 02:22:35 +00:00
|
|
|
int docache = (lowervp != NULLVP || uppervp != NULLVP);
|
1997-11-18 15:07:35 +00:00
|
|
|
int lhash, uhash;
|
1994-05-24 11:09:53 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
|
|
|
* Ensure locking is ordered from lower to higher
|
|
|
|
* to avoid deadlocks.
|
|
|
|
*/
|
|
|
|
if (nhash < ohash) {
|
|
|
|
lhash = nhash;
|
|
|
|
uhash = ohash;
|
|
|
|
} else {
|
|
|
|
lhash = ohash;
|
|
|
|
uhash = nhash;
|
|
|
|
}
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
if (lhash != uhash) {
|
1997-02-10 02:22:35 +00:00
|
|
|
while (union_list_lock(lhash))
|
1994-05-24 11:09:53 +01:00
|
|
|
continue;
|
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 21:52:41 +01:00
|
|
|
}
|
1994-05-24 11:09:53 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
while (union_list_lock(uhash))
|
|
|
|
continue;
|
1994-05-24 11:09:53 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (ohash != nhash || !docache) {
|
|
|
|
if (un->un_flags & UN_CACHED) {
|
|
|
|
un->un_flags &= ~UN_CACHED;
|
|
|
|
LIST_REMOVE(un, un_cache);
|
|
|
|
}
|
1994-05-24 11:09:53 +01:00
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (ohash != nhash)
|
|
|
|
union_list_unlock(ohash);
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
if (un->un_lowervp != lowervp) {
|
|
|
|
if (un->un_lowervp) {
|
|
|
|
vrele(un->un_lowervp);
|
|
|
|
if (un->un_path) {
|
|
|
|
free(un->un_path, M_TEMP);
|
|
|
|
un->un_path = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
un->un_lowervp = lowervp;
|
1997-02-10 02:22:35 +00:00
|
|
|
un->un_lowersz = VNOVAL;
|
1994-05-24 11:09:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (un->un_uppervp != uppervp) {
|
|
|
|
if (un->un_uppervp)
|
|
|
|
vrele(un->un_uppervp);
|
|
|
|
un->un_uppervp = uppervp;
|
1997-02-10 02:22:35 +00:00
|
|
|
un->un_uppersz = VNOVAL;
|
1994-05-24 11:09:53 +01:00
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docache && (ohash != nhash)) {
|
1994-05-24 11:09:53 +01:00
|
|
|
LIST_INSERT_HEAD(&unhead[nhash], un, un_cache);
|
1997-02-10 02:22:35 +00:00
|
|
|
un->un_flags |= UN_CACHED;
|
|
|
|
}
|
1994-05-24 11:09:53 +01:00
|
|
|
|
|
|
|
union_list_unlock(nhash);
|
|
|
|
}
|
|
|
|
|
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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* Set a new lowervp. The passed lowervp must be referenced and will be
|
|
|
|
* stored in the vp in a referenced state.
|
|
|
|
*/
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static void
|
1994-05-24 11:09:53 +01:00
|
|
|
union_newlower(un, lowervp)
|
|
|
|
struct union_node *un;
|
|
|
|
struct vnode *lowervp;
|
|
|
|
{
|
|
|
|
union_updatevp(un, un->un_uppervp, 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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* Set a new uppervp. The passed uppervp must be locked and will be
|
|
|
|
* stored in the vp in a locked state. The caller should not unlock
|
|
|
|
* uppervp.
|
|
|
|
*/
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static void
|
1994-05-24 11:09:53 +01:00
|
|
|
union_newupper(un, uppervp)
|
|
|
|
struct union_node *un;
|
|
|
|
struct vnode *uppervp;
|
|
|
|
{
|
|
|
|
union_updatevp(un, uppervp, un->un_lowervp);
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
|
|
|
* Keep track of size changes in the underlying vnodes.
|
|
|
|
* If the size changes, then callback to the vm layer
|
|
|
|
* giving priority to the upper layer size.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
union_newsize(vp, uppersz, lowersz)
|
|
|
|
struct vnode *vp;
|
|
|
|
off_t uppersz, lowersz;
|
|
|
|
{
|
|
|
|
struct union_node *un;
|
|
|
|
off_t sz;
|
|
|
|
|
|
|
|
/* only interested in regular files */
|
|
|
|
if (vp->v_type != VREG)
|
|
|
|
return;
|
|
|
|
|
|
|
|
un = VTOUNION(vp);
|
|
|
|
sz = VNOVAL;
|
|
|
|
|
|
|
|
if ((uppersz != VNOVAL) && (un->un_uppersz != uppersz)) {
|
|
|
|
un->un_uppersz = uppersz;
|
|
|
|
if (sz == VNOVAL)
|
|
|
|
sz = un->un_uppersz;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((lowersz != VNOVAL) && (un->un_lowersz != lowersz)) {
|
|
|
|
un->un_lowersz = lowersz;
|
|
|
|
if (sz == VNOVAL)
|
|
|
|
sz = un->un_lowersz;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sz != VNOVAL) {
|
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 21:52:41 +01:00
|
|
|
UDEBUG(("union: %s size now %ld\n",
|
|
|
|
(uppersz != VNOVAL ? "upper" : "lower"), (long)sz));
|
2001-05-17 05:52:57 +01:00
|
|
|
/*
|
|
|
|
* There is no need to change size of non-existent object
|
|
|
|
*/
|
|
|
|
/* vnode_pager_setsize(vp, sz); */
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
* union_allocvp: allocate a union_node and associate it with a
|
|
|
|
* parent union_node and one or two vnodes.
|
|
|
|
*
|
|
|
|
* vpp Holds the returned vnode locked and referenced if no
|
|
|
|
* error occurs.
|
|
|
|
*
|
|
|
|
* mp Holds the mount point. mp may or may not be busied.
|
|
|
|
* allocvp makes no changes to mp.
|
|
|
|
*
|
|
|
|
* dvp Holds the parent union_node to the one we wish to create.
|
|
|
|
* XXX may only be used to traverse an uncopied lowervp-based
|
|
|
|
* tree? XXX
|
|
|
|
*
|
|
|
|
* dvp may or may not be locked. allocvp makes no changes
|
|
|
|
* to dvp.
|
|
|
|
*
|
|
|
|
* upperdvp Holds the parent vnode to uppervp, generally used along
|
|
|
|
* with path component information to create a shadow of
|
|
|
|
* lowervp when uppervp does not exist.
|
|
|
|
*
|
|
|
|
* upperdvp is referenced but unlocked on entry, and will be
|
|
|
|
* dereferenced on return.
|
|
|
|
*
|
|
|
|
* uppervp Holds the new uppervp vnode to be stored in the
|
|
|
|
* union_node we are allocating. uppervp is referenced but
|
|
|
|
* not locked, and will be dereferenced on return.
|
|
|
|
*
|
|
|
|
* lowervp Holds the new lowervp vnode to be stored in the
|
2001-05-17 05:40:01 +01:00
|
|
|
* union_node we are allocating. lowervp is referenced but
|
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 21:52:41 +01:00
|
|
|
* not locked, and will be dereferenced on return.
|
|
|
|
*
|
|
|
|
* cnp Holds path component information to be coupled with
|
|
|
|
* lowervp and upperdvp to allow unionfs to create an uppervp
|
|
|
|
* later on. Only used if lowervp is valid. The conents
|
|
|
|
* of cnp is only valid for the duration of the call.
|
|
|
|
*
|
|
|
|
* docache Determine whether this node should be entered in the
|
|
|
|
* cache or whether it should be destroyed as soon as possible.
|
1994-05-24 11:09:53 +01:00
|
|
|
*
|
|
|
|
* all union_nodes are maintained on a singly-linked
|
|
|
|
* list. new nodes are only allocated when they cannot
|
|
|
|
* be found on this list. entries on the list are
|
|
|
|
* removed when the vfs reclaim entry is called.
|
|
|
|
*
|
|
|
|
* a single lock is kept for the entire list. this is
|
|
|
|
* needed because the getnewvnode() function can block
|
|
|
|
* waiting for a vnode to become free, in which case there
|
|
|
|
* may be more than one process trying to get the same
|
|
|
|
* vnode. this lock is only taken if we are going to
|
|
|
|
* call getnewvnode, since the kernel itself is single-threaded.
|
|
|
|
*
|
|
|
|
* if an entry is found on the list, then call vget() to
|
|
|
|
* take a reference. this is done because there may be
|
|
|
|
* zero references to it and so it needs to removed from
|
|
|
|
* the vnode free list.
|
|
|
|
*/
|
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 21:52:41 +01:00
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
int
|
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 21:52:41 +01:00
|
|
|
union_allocvp(vpp, mp, dvp, upperdvp, cnp, uppervp, lowervp, docache)
|
1994-05-24 11:09:53 +01:00
|
|
|
struct vnode **vpp;
|
|
|
|
struct mount *mp;
|
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 21:52:41 +01:00
|
|
|
struct vnode *dvp; /* parent union vnode */
|
|
|
|
struct vnode *upperdvp; /* parent vnode of uppervp */
|
1994-05-24 11:09:53 +01:00
|
|
|
struct componentname *cnp; /* may be null */
|
|
|
|
struct vnode *uppervp; /* may be null */
|
|
|
|
struct vnode *lowervp; /* may be null */
|
1997-02-10 02:22:35 +00:00
|
|
|
int docache;
|
1994-05-24 11:09:53 +01:00
|
|
|
{
|
|
|
|
int error;
|
1994-05-25 10:21:21 +01:00
|
|
|
struct union_node *un = 0;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
|
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 21:52:41 +01:00
|
|
|
struct proc *p = (cnp) ? cnp->cn_proc : curproc;
|
1998-12-14 05:00:59 +00:00
|
|
|
int hash = 0;
|
1997-02-10 02:22:35 +00:00
|
|
|
int vflag;
|
1994-05-24 11:09:53 +01:00
|
|
|
int try;
|
|
|
|
|
|
|
|
if (uppervp == NULLVP && lowervp == NULLVP)
|
|
|
|
panic("union: unidentifiable allocation");
|
|
|
|
|
|
|
|
if (uppervp && lowervp && (uppervp->v_type != lowervp->v_type)) {
|
2001-05-17 05:40:01 +01:00
|
|
|
vrele(lowervp);
|
1994-05-24 11:09:53 +01:00
|
|
|
lowervp = NULLVP;
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/* detect the root vnode (and aliases) */
|
|
|
|
vflag = 0;
|
|
|
|
if ((uppervp == um->um_uppervp) &&
|
|
|
|
((lowervp == NULLVP) || lowervp == um->um_lowervp)) {
|
|
|
|
if (lowervp == NULLVP) {
|
|
|
|
lowervp = um->um_lowervp;
|
|
|
|
if (lowervp != NULLVP)
|
|
|
|
VREF(lowervp);
|
|
|
|
}
|
|
|
|
vflag = VROOT;
|
|
|
|
}
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
loop:
|
1997-02-10 02:22:35 +00:00
|
|
|
if (!docache) {
|
|
|
|
un = 0;
|
|
|
|
} else for (try = 0; try < 3; try++) {
|
1994-05-24 11:09:53 +01:00
|
|
|
switch (try) {
|
|
|
|
case 0:
|
|
|
|
if (lowervp == NULLVP)
|
|
|
|
continue;
|
|
|
|
hash = UNION_HASH(uppervp, lowervp);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
if (uppervp == NULLVP)
|
|
|
|
continue;
|
|
|
|
hash = UNION_HASH(uppervp, NULLVP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
if (lowervp == NULLVP)
|
|
|
|
continue;
|
|
|
|
hash = UNION_HASH(NULLVP, lowervp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (union_list_lock(hash))
|
|
|
|
continue;
|
|
|
|
|
2001-02-04 12:37:48 +00:00
|
|
|
LIST_FOREACH(un, &unhead[hash], un_cache) {
|
1994-05-24 11:09:53 +01:00
|
|
|
if ((un->un_lowervp == lowervp ||
|
|
|
|
un->un_lowervp == NULLVP) &&
|
|
|
|
(un->un_uppervp == uppervp ||
|
|
|
|
un->un_uppervp == NULLVP) &&
|
|
|
|
(UNIONTOV(un)->v_mount == mp)) {
|
1997-02-10 02:22:35 +00:00
|
|
|
if (vget(UNIONTOV(un), 0,
|
|
|
|
cnp ? cnp->cn_proc : NULL)) {
|
1994-05-24 11:09:53 +01:00
|
|
|
union_list_unlock(hash);
|
|
|
|
goto loop;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
union_list_unlock(hash);
|
|
|
|
|
|
|
|
if (un)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (un) {
|
|
|
|
/*
|
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 21:52:41 +01:00
|
|
|
* Obtain a lock on the union_node. Everything is unlocked
|
|
|
|
* except for dvp, so check that case. If they match, our
|
|
|
|
* new un is already locked. Otherwise we have to lock our
|
|
|
|
* new un.
|
|
|
|
*
|
|
|
|
* A potential deadlock situation occurs when we are holding
|
|
|
|
* one lock while trying to get another. We must follow
|
|
|
|
* strict ordering rules to avoid it. We try to locate dvp
|
|
|
|
* by scanning up from un_vnode, since the most likely
|
|
|
|
* scenario is un being under dvp.
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
if (dvp && un->un_vnode != dvp) {
|
|
|
|
struct vnode *scan = un->un_vnode;
|
|
|
|
|
|
|
|
do {
|
|
|
|
scan = VTOUNION(scan)->un_pvp;
|
|
|
|
} while (scan && scan->v_tag == VT_UNION && scan != dvp);
|
|
|
|
if (scan != dvp) {
|
|
|
|
/*
|
|
|
|
* our new un is above dvp (we never saw dvp
|
|
|
|
* while moving up the tree).
|
|
|
|
*/
|
|
|
|
VREF(dvp);
|
|
|
|
VOP_UNLOCK(dvp, 0, p);
|
|
|
|
error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
|
|
|
|
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
|
|
|
|
vrele(dvp);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* our new un is under dvp
|
|
|
|
*/
|
|
|
|
error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
|
|
|
|
}
|
|
|
|
} else if (dvp == NULLVP) {
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
* dvp is NULL, we need to lock un.
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
|
1994-05-24 11:09:53 +01:00
|
|
|
} else {
|
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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* dvp == un->un_vnode, we are already locked.
|
|
|
|
*/
|
|
|
|
error = 0;
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
if (error)
|
|
|
|
goto loop;
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
* At this point, the union_node is locked and referenced.
|
|
|
|
*
|
|
|
|
* uppervp is locked and referenced or NULL, lowervp is
|
|
|
|
* referenced or NULL.
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
UDEBUG(("Modify existing un %p vn %p upper %p(refs %d) -> %p(refs %d)\n",
|
|
|
|
un, un->un_vnode, un->un_uppervp,
|
|
|
|
(un->un_uppervp ? un->un_uppervp->v_usecount : -99),
|
|
|
|
uppervp,
|
|
|
|
(uppervp ? uppervp->v_usecount : -99)
|
|
|
|
));
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
if (uppervp != un->un_uppervp) {
|
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 21:52:41 +01:00
|
|
|
KASSERT(uppervp == NULL || uppervp->v_usecount > 0, ("union_allocvp: too few refs %d (at least 1 required) on uppervp", uppervp->v_usecount));
|
1994-05-24 11:09:53 +01:00
|
|
|
union_newupper(un, uppervp);
|
|
|
|
} else if (uppervp) {
|
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 21:52:41 +01:00
|
|
|
KASSERT(uppervp->v_usecount > 1, ("union_allocvp: too few refs %d (at least 2 required) on uppervp", uppervp->v_usecount));
|
1994-05-24 11:09:53 +01:00
|
|
|
vrele(uppervp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save information about the lower layer.
|
|
|
|
* This needs to keep track of pathname
|
|
|
|
* and directory information which union_vn_create
|
|
|
|
* might need.
|
|
|
|
*/
|
|
|
|
if (lowervp != un->un_lowervp) {
|
|
|
|
union_newlower(un, lowervp);
|
1997-02-10 02:22:35 +00:00
|
|
|
if (cnp && (lowervp != NULLVP)) {
|
1994-05-24 11:09:53 +01:00
|
|
|
un->un_path = malloc(cnp->cn_namelen+1,
|
|
|
|
M_TEMP, M_WAITOK);
|
|
|
|
bcopy(cnp->cn_nameptr, un->un_path,
|
|
|
|
cnp->cn_namelen);
|
|
|
|
un->un_path[cnp->cn_namelen] = '\0';
|
|
|
|
}
|
|
|
|
} else if (lowervp) {
|
|
|
|
vrele(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 21:52:41 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* and upperdvp
|
|
|
|
*/
|
|
|
|
if (upperdvp != un->un_dirvp) {
|
|
|
|
if (un->un_dirvp)
|
|
|
|
vrele(un->un_dirvp);
|
|
|
|
un->un_dirvp = upperdvp;
|
|
|
|
} else if (upperdvp) {
|
|
|
|
vrele(upperdvp);
|
|
|
|
}
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
*vpp = UNIONTOV(un);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docache) {
|
|
|
|
/*
|
|
|
|
* otherwise lock the vp list while we call getnewvnode
|
|
|
|
* since that can block.
|
|
|
|
*/
|
|
|
|
hash = UNION_HASH(uppervp, lowervp);
|
1994-05-24 11:09:53 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (union_list_lock(hash))
|
|
|
|
goto loop;
|
|
|
|
}
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* Create new node rather then replace old node
|
|
|
|
*/
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
error = getnewvnode(VT_UNION, mp, union_vnodeop_p, vpp);
|
|
|
|
if (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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* If an error occurs clear out vnodes.
|
|
|
|
*/
|
1994-05-24 11:09:53 +01:00
|
|
|
if (lowervp)
|
|
|
|
vrele(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 21:52:41 +01:00
|
|
|
if (uppervp)
|
|
|
|
vrele(uppervp);
|
|
|
|
if (upperdvp)
|
|
|
|
vrele(upperdvp);
|
|
|
|
*vpp = NULL;
|
1994-05-24 11:09:53 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
MALLOC((*vpp)->v_data, void *, sizeof(struct union_node),
|
|
|
|
M_TEMP, M_WAITOK);
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
(*vpp)->v_flag |= vflag;
|
1994-05-24 11:09:53 +01:00
|
|
|
if (uppervp)
|
|
|
|
(*vpp)->v_type = uppervp->v_type;
|
|
|
|
else
|
|
|
|
(*vpp)->v_type = lowervp->v_type;
|
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 21:52:41 +01:00
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
un = VTOUNION(*vpp);
|
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 21:52:41 +01:00
|
|
|
bzero(un, sizeof(*un));
|
|
|
|
|
|
|
|
lockinit(&un->un_lock, PVFS, "unlock", 0, 0);
|
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, p);
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
un->un_vnode = *vpp;
|
|
|
|
un->un_uppervp = uppervp;
|
1997-02-10 02:22:35 +00:00
|
|
|
un->un_uppersz = VNOVAL;
|
1994-05-24 11:09:53 +01:00
|
|
|
un->un_lowervp = lowervp;
|
1997-02-10 02:22:35 +00:00
|
|
|
un->un_lowersz = VNOVAL;
|
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 21:52:41 +01:00
|
|
|
un->un_dirvp = upperdvp;
|
|
|
|
un->un_pvp = dvp; /* only parent dir in new allocation */
|
|
|
|
if (dvp != NULLVP)
|
|
|
|
VREF(dvp);
|
1997-02-10 02:22:35 +00:00
|
|
|
un->un_dircache = 0;
|
1994-05-24 11:09:53 +01:00
|
|
|
un->un_openl = 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 21:52:41 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (cnp && (lowervp != NULLVP)) {
|
1994-05-24 11:09:53 +01:00
|
|
|
un->un_path = malloc(cnp->cn_namelen+1, M_TEMP, M_WAITOK);
|
|
|
|
bcopy(cnp->cn_nameptr, un->un_path, cnp->cn_namelen);
|
|
|
|
un->un_path[cnp->cn_namelen] = '\0';
|
|
|
|
} else {
|
|
|
|
un->un_path = 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 21:52:41 +01:00
|
|
|
un->un_dirvp = NULL;
|
1994-05-24 11:09:53 +01:00
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docache) {
|
|
|
|
LIST_INSERT_HEAD(&unhead[hash], un, un_cache);
|
|
|
|
un->un_flags |= UN_CACHED;
|
|
|
|
}
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
out:
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docache)
|
|
|
|
union_list_unlock(hash);
|
1994-05-24 11:09:53 +01:00
|
|
|
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
union_freevp(vp)
|
|
|
|
struct vnode *vp;
|
|
|
|
{
|
|
|
|
struct union_node *un = VTOUNION(vp);
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (un->un_flags & UN_CACHED) {
|
|
|
|
un->un_flags &= ~UN_CACHED;
|
|
|
|
LIST_REMOVE(un, un_cache);
|
|
|
|
}
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
if (un->un_pvp != NULLVP) {
|
1997-02-10 02:22:35 +00:00
|
|
|
vrele(un->un_pvp);
|
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 21:52:41 +01:00
|
|
|
un->un_pvp = NULL;
|
|
|
|
}
|
|
|
|
if (un->un_uppervp != NULLVP) {
|
1994-05-24 11:09:53 +01:00
|
|
|
vrele(un->un_uppervp);
|
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 21:52:41 +01:00
|
|
|
un->un_uppervp = NULL;
|
|
|
|
}
|
|
|
|
if (un->un_lowervp != NULLVP) {
|
1994-05-24 11:09:53 +01:00
|
|
|
vrele(un->un_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 21:52:41 +01:00
|
|
|
un->un_lowervp = NULL;
|
|
|
|
}
|
|
|
|
if (un->un_dirvp != NULLVP) {
|
1994-05-24 11:09:53 +01:00
|
|
|
vrele(un->un_dirvp);
|
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 21:52:41 +01:00
|
|
|
un->un_dirvp = NULL;
|
|
|
|
}
|
|
|
|
if (un->un_path) {
|
1994-05-24 11:09:53 +01:00
|
|
|
free(un->un_path, M_TEMP);
|
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 21:52:41 +01:00
|
|
|
un->un_path = NULL;
|
|
|
|
}
|
2000-10-04 02:29:17 +01:00
|
|
|
lockdestroy(&un->un_lock);
|
1994-05-24 11:09:53 +01:00
|
|
|
|
|
|
|
FREE(vp->v_data, M_TEMP);
|
|
|
|
vp->v_data = 0;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* copyfile. copy the vnode (fvp) to the vnode (tvp)
|
|
|
|
* using a sequence of reads and writes. both (fvp)
|
|
|
|
* and (tvp) are locked on entry and exit.
|
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 21:52:41 +01:00
|
|
|
*
|
|
|
|
* fvp and tvp are both exclusive locked on call, but their refcount's
|
|
|
|
* haven't been bumped at all.
|
1994-05-24 11:09:53 +01:00
|
|
|
*/
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
1997-02-10 02:22:35 +00:00
|
|
|
union_copyfile(fvp, tvp, cred, p)
|
1994-05-24 11:09:53 +01:00
|
|
|
struct vnode *fvp;
|
|
|
|
struct vnode *tvp;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
1994-05-24 11:09:53 +01:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
struct uio uio;
|
|
|
|
struct iovec iov;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* strategy:
|
|
|
|
* allocate a buffer of size MAXBSIZE.
|
|
|
|
* loop doing reads and writes, keeping track
|
|
|
|
* of the current uio offset.
|
|
|
|
* give up at the first sign of trouble.
|
|
|
|
*/
|
|
|
|
|
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 21:52:41 +01:00
|
|
|
bzero(&uio, sizeof(uio));
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
uio.uio_procp = p;
|
|
|
|
uio.uio_segflg = UIO_SYSSPACE;
|
|
|
|
uio.uio_offset = 0;
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
VOP_LEASE(fvp, p, cred, LEASE_READ);
|
|
|
|
VOP_LEASE(tvp, p, cred, LEASE_WRITE);
|
1994-05-24 11:09:53 +01:00
|
|
|
|
|
|
|
buf = malloc(MAXBSIZE, M_TEMP, M_WAITOK);
|
|
|
|
|
|
|
|
/* ugly loop follows... */
|
|
|
|
do {
|
|
|
|
off_t offset = uio.uio_offset;
|
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 21:52:41 +01:00
|
|
|
int count;
|
|
|
|
int bufoffset;
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* Setup for big read
|
|
|
|
*/
|
1994-05-24 11:09:53 +01:00
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
|
|
|
iov.iov_base = buf;
|
|
|
|
iov.iov_len = MAXBSIZE;
|
|
|
|
uio.uio_resid = iov.iov_len;
|
|
|
|
uio.uio_rw = UIO_READ;
|
|
|
|
|
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 21:52:41 +01:00
|
|
|
if ((error = VOP_READ(fvp, &uio, 0, cred)) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get bytes read, handle read eof case and setup for
|
|
|
|
* write loop
|
|
|
|
*/
|
|
|
|
if ((count = MAXBSIZE - uio.uio_resid) == 0)
|
|
|
|
break;
|
|
|
|
bufoffset = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write until an error occurs or our buffer has been
|
|
|
|
* exhausted, then update the offset for the next read.
|
|
|
|
*/
|
|
|
|
while (bufoffset < count) {
|
1994-05-24 11:09:53 +01:00
|
|
|
uio.uio_iov = &iov;
|
|
|
|
uio.uio_iovcnt = 1;
|
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 21:52:41 +01:00
|
|
|
iov.iov_base = buf + bufoffset;
|
|
|
|
iov.iov_len = count - bufoffset;
|
|
|
|
uio.uio_offset = offset + bufoffset;
|
1994-05-24 11:09:53 +01:00
|
|
|
uio.uio_rw = UIO_WRITE;
|
|
|
|
uio.uio_resid = iov.iov_len;
|
|
|
|
|
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 21:52:41 +01:00
|
|
|
if ((error = VOP_WRITE(tvp, &uio, 0, cred)) != 0)
|
1994-05-24 11:09:53 +01:00
|
|
|
break;
|
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 21:52:41 +01:00
|
|
|
bufoffset += (count - bufoffset) - uio.uio_resid;
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
uio.uio_offset = offset + bufoffset;
|
1994-05-24 11:09:53 +01:00
|
|
|
} while (error == 0);
|
|
|
|
|
|
|
|
free(buf, M_TEMP);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +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 21:52:41 +01:00
|
|
|
*
|
|
|
|
* un's vnode is assumed to be locked on entry and remains locked on exit.
|
1997-02-10 02:22:35 +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 21:52:41 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
int
|
|
|
|
union_copyup(un, docopy, cred, p)
|
|
|
|
struct union_node *un;
|
|
|
|
int docopy;
|
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
int error;
|
2000-07-11 23:07:57 +01:00
|
|
|
struct mount *mp;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *lvp, *uvp;
|
|
|
|
|
1997-08-14 04:57:46 +01:00
|
|
|
/*
|
|
|
|
* If the user does not have read permission, the vnode should not
|
|
|
|
* be copied to upper layer.
|
|
|
|
*/
|
|
|
|
vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, p);
|
|
|
|
error = VOP_ACCESS(un->un_lowervp, VREAD, cred, p);
|
|
|
|
VOP_UNLOCK(un->un_lowervp, 0, p);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
2000-07-11 23:07:57 +01:00
|
|
|
if ((error = vn_start_write(un->un_dirvp, &mp, V_WAIT | PCATCH)) != 0)
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
2000-07-11 23:07:57 +01:00
|
|
|
if ((error = union_vn_create(&uvp, un, p)) != 0) {
|
|
|
|
vn_finished_write(mp);
|
|
|
|
return (error);
|
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
lvp = un->un_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 21:52:41 +01:00
|
|
|
KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docopy) {
|
|
|
|
/*
|
|
|
|
* XX - should not ignore errors
|
|
|
|
* from VOP_CLOSE
|
|
|
|
*/
|
|
|
|
vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p);
|
|
|
|
error = VOP_OPEN(lvp, FREAD, cred, p);
|
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 21:52:41 +01:00
|
|
|
if (error == 0 && vn_canvmio(lvp) == TRUE)
|
|
|
|
error = vfs_object_create(lvp, p, cred);
|
1997-02-10 02:22:35 +00:00
|
|
|
if (error == 0) {
|
|
|
|
error = union_copyfile(lvp, uvp, cred, p);
|
|
|
|
VOP_UNLOCK(lvp, 0, p);
|
|
|
|
(void) VOP_CLOSE(lvp, FREAD, cred, p);
|
|
|
|
}
|
|
|
|
if (error == 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 21:52:41 +01:00
|
|
|
UDEBUG(("union: copied up %s\n", un->un_path));
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
VOP_UNLOCK(uvp, 0, p);
|
2000-07-11 23:07:57 +01:00
|
|
|
vn_finished_write(mp);
|
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 21:52:41 +01:00
|
|
|
union_newupper(un, uvp);
|
|
|
|
KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
|
1997-02-10 02:22:35 +00:00
|
|
|
union_vn_close(uvp, FWRITE, cred, p);
|
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 21:52:41 +01:00
|
|
|
KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
|
|
|
* Subsequent IOs will go to the top layer, so
|
|
|
|
* call close on the lower vnode and open on the
|
|
|
|
* upper vnode to ensure that the filesystem keeps
|
|
|
|
* its references counts right. This doesn't do
|
|
|
|
* the right thing with (cred) and (FREAD) though.
|
|
|
|
* Ignoring error returns is not right, either.
|
|
|
|
*/
|
|
|
|
if (error == 0) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < un->un_openl; i++) {
|
|
|
|
(void) VOP_CLOSE(lvp, FREAD, cred, p);
|
|
|
|
(void) VOP_OPEN(uvp, FREAD, cred, p);
|
|
|
|
}
|
1999-09-28 06:48:39 +01:00
|
|
|
if (un->un_openl) {
|
|
|
|
if (vn_canvmio(uvp) == TRUE)
|
|
|
|
error = vfs_object_create(uvp, p, cred);
|
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
un->un_openl = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* union_relookup:
|
|
|
|
*
|
|
|
|
* dvp should be locked on entry and will be locked on return. No
|
|
|
|
* net change in the ref count will occur.
|
|
|
|
*
|
|
|
|
* If an error is returned, *vpp will be invalid, otherwise it
|
|
|
|
* will hold a locked, referenced vnode. If *vpp == dvp then
|
|
|
|
* remember that only one exclusive lock is held.
|
|
|
|
*/
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
static int
|
|
|
|
union_relookup(um, dvp, vpp, cnp, cn, path, pathlen)
|
|
|
|
struct union_mount *um;
|
|
|
|
struct vnode *dvp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
struct componentname *cnp;
|
|
|
|
struct componentname *cn;
|
|
|
|
char *path;
|
|
|
|
int pathlen;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A new componentname structure must be faked up because
|
|
|
|
* there is no way to know where the upper level cnp came
|
|
|
|
* from or what it is being used for. This must duplicate
|
|
|
|
* some of the work done by NDINIT, some of the work done
|
|
|
|
* by namei, some of the work done by lookup and some of
|
|
|
|
* the work done by VOP_LOOKUP when given a CREATE flag.
|
|
|
|
* Conclusion: Horrible.
|
|
|
|
*/
|
|
|
|
cn->cn_namelen = pathlen;
|
1997-09-21 05:24:27 +01:00
|
|
|
cn->cn_pnbuf = zalloc(namei_zone);
|
1997-02-10 02:22:35 +00:00
|
|
|
bcopy(path, cn->cn_pnbuf, cn->cn_namelen);
|
|
|
|
cn->cn_pnbuf[cn->cn_namelen] = '\0';
|
|
|
|
|
|
|
|
cn->cn_nameiop = CREATE;
|
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 21:52:41 +01:00
|
|
|
cn->cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN);
|
1997-02-10 02:22:35 +00:00
|
|
|
cn->cn_proc = cnp->cn_proc;
|
|
|
|
if (um->um_op == UNMNT_ABOVE)
|
|
|
|
cn->cn_cred = cnp->cn_cred;
|
|
|
|
else
|
|
|
|
cn->cn_cred = um->um_cred;
|
|
|
|
cn->cn_nameptr = cn->cn_pnbuf;
|
|
|
|
cn->cn_consume = cnp->cn_consume;
|
|
|
|
|
|
|
|
VREF(dvp);
|
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 21:52:41 +01:00
|
|
|
VOP_UNLOCK(dvp, 0, cnp->cn_proc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass dvp unlocked and referenced on call to relookup().
|
|
|
|
*
|
|
|
|
* If an error occurs, dvp will be returned unlocked and dereferenced.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((error = relookup(dvp, vpp, cn)) != 0) {
|
|
|
|
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_proc);
|
|
|
|
return(error);
|
1997-04-13 07:27:09 +01:00
|
|
|
}
|
1997-02-10 02:22:35 +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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* If no error occurs, dvp will be returned locked with the reference
|
|
|
|
* left as before, and vpp will be returned referenced and locked.
|
|
|
|
*
|
|
|
|
* We want to return with dvp as it was passed to us, so we get
|
|
|
|
* rid of our reference.
|
|
|
|
*/
|
|
|
|
vrele(dvp);
|
|
|
|
return (0);
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
/*
|
|
|
|
* Create a shadow directory in the upper layer.
|
|
|
|
* The new vnode is returned locked.
|
|
|
|
*
|
|
|
|
* (um) points to the union mount structure for access to the
|
|
|
|
* the mounting process's credentials.
|
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 21:52:41 +01:00
|
|
|
* (dvp) is the directory in which to create the shadow directory,
|
|
|
|
* it is locked (but not ref'd) on entry and return.
|
1994-05-24 11:09:53 +01:00
|
|
|
* (cnp) is the componentname to be created.
|
|
|
|
* (vpp) is the returned newly created shadow directory, which
|
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 21:52:41 +01:00
|
|
|
* is returned locked and ref'd
|
1994-05-24 11:09:53 +01:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
union_mkshadow(um, dvp, cnp, vpp)
|
|
|
|
struct union_mount *um;
|
|
|
|
struct vnode *dvp;
|
|
|
|
struct componentname *cnp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct vattr va;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
struct componentname cn;
|
2000-07-11 23:07:57 +01:00
|
|
|
struct mount *mp;
|
1994-05-24 11:09:53 +01:00
|
|
|
|
2000-07-11 23:07:57 +01:00
|
|
|
if ((error = vn_start_write(dvp, &mp, V_WAIT | PCATCH)) != 0)
|
|
|
|
return (error);
|
|
|
|
if ((error = union_relookup(um, dvp, vpp, cnp, &cn,
|
|
|
|
cnp->cn_nameptr, cnp->cn_namelen)) != 0) {
|
|
|
|
vn_finished_write(mp);
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
2000-07-11 23:07:57 +01:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
if (*vpp) {
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
|
|
|
zfree(namei_zone, cn.cn_pnbuf);
|
|
|
|
cn.cn_flags &= ~HASBUF;
|
|
|
|
}
|
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 21:52:41 +01:00
|
|
|
if (dvp == *vpp)
|
|
|
|
vrele(*vpp);
|
|
|
|
else
|
|
|
|
vput(*vpp);
|
2000-07-11 23:07:57 +01:00
|
|
|
vn_finished_write(mp);
|
1997-02-10 02:22:35 +00:00
|
|
|
*vpp = NULLVP;
|
|
|
|
return (EEXIST);
|
|
|
|
}
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
/*
|
|
|
|
* policy: when creating the shadow directory in the
|
|
|
|
* upper layer, create it owned by the user who did
|
|
|
|
* the mount, group from parent directory, and mode
|
|
|
|
* 777 modified by umask (ie mostly identical to the
|
|
|
|
* mkdir syscall). (jsp, kb)
|
|
|
|
*/
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
VATTR_NULL(&va);
|
|
|
|
va.va_type = VDIR;
|
|
|
|
va.va_mode = um->um_cmode;
|
1994-05-24 11:09:53 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/* VOP_LEASE: dvp is locked */
|
|
|
|
VOP_LEASE(dvp, p, cn.cn_cred, LEASE_WRITE);
|
1994-05-24 11:09:53 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
error = VOP_MKDIR(dvp, vpp, &cn, &va);
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
|
|
|
zfree(namei_zone, cn.cn_pnbuf);
|
|
|
|
cn.cn_flags &= ~HASBUF;
|
|
|
|
}
|
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 21:52:41 +01:00
|
|
|
/*vput(dvp);*/
|
2000-07-11 23:07:57 +01:00
|
|
|
vn_finished_write(mp);
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a whiteout entry in the upper layer.
|
|
|
|
*
|
|
|
|
* (um) points to the union mount structure for access to the
|
|
|
|
* the mounting process's credentials.
|
|
|
|
* (dvp) is the directory in which to create the whiteout.
|
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 21:52:41 +01:00
|
|
|
* it is locked on entry and return.
|
1997-02-10 02:22:35 +00:00
|
|
|
* (cnp) is the componentname to be created.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
union_mkwhiteout(um, dvp, cnp, path)
|
|
|
|
struct union_mount *um;
|
|
|
|
struct vnode *dvp;
|
|
|
|
struct componentname *cnp;
|
|
|
|
char *path;
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
struct proc *p = cnp->cn_proc;
|
|
|
|
struct vnode *wvp;
|
|
|
|
struct componentname cn;
|
2000-07-11 23:07:57 +01:00
|
|
|
struct mount *mp;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
2000-07-11 23:07:57 +01:00
|
|
|
if ((error = vn_start_write(dvp, &mp, V_WAIT | PCATCH)) != 0)
|
|
|
|
return (error);
|
1997-02-10 02:22:35 +00:00
|
|
|
error = union_relookup(um, dvp, &wvp, cnp, &cn, path, strlen(path));
|
2000-07-11 23:07:57 +01:00
|
|
|
if (error) {
|
|
|
|
vn_finished_write(mp);
|
1994-05-24 11:09:53 +01:00
|
|
|
return (error);
|
2000-07-11 23:07:57 +01:00
|
|
|
}
|
1994-05-24 11:09:53 +01:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (wvp) {
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
|
|
|
zfree(namei_zone, cn.cn_pnbuf);
|
|
|
|
cn.cn_flags &= ~HASBUF;
|
|
|
|
}
|
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 21:52:41 +01:00
|
|
|
if (wvp == dvp)
|
|
|
|
vrele(wvp);
|
|
|
|
else
|
|
|
|
vput(wvp);
|
2000-07-11 23:07:57 +01:00
|
|
|
vn_finished_write(mp);
|
1994-05-24 11:09:53 +01:00
|
|
|
return (EEXIST);
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/* VOP_LEASE: dvp is locked */
|
|
|
|
VOP_LEASE(dvp, p, p->p_ucred, LEASE_WRITE);
|
|
|
|
|
|
|
|
error = VOP_WHITEOUT(dvp, &cn, CREATE);
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
|
|
|
zfree(namei_zone, cn.cn_pnbuf);
|
|
|
|
cn.cn_flags &= ~HASBUF;
|
|
|
|
}
|
2000-07-11 23:07:57 +01:00
|
|
|
vn_finished_write(mp);
|
1994-05-24 11:09:53 +01:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* union_vn_create: creates and opens a new shadow file
|
|
|
|
* on the upper union layer. this function is similar
|
|
|
|
* in spirit to calling vn_open but it avoids calling namei().
|
|
|
|
* the problem with calling namei is that a) it locks too many
|
|
|
|
* things, and b) it doesn't start at the "right" directory,
|
|
|
|
* whereas relookup is told where to start.
|
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 21:52:41 +01:00
|
|
|
*
|
|
|
|
* On entry, the vnode associated with un is locked. It remains locked
|
|
|
|
* on return.
|
|
|
|
*
|
|
|
|
* If no error occurs, *vpp contains a locked referenced vnode for your
|
|
|
|
* use. If an error occurs *vpp iis undefined.
|
1994-05-24 11:09:53 +01:00
|
|
|
*/
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
1994-05-24 11:09:53 +01:00
|
|
|
union_vn_create(vpp, un, p)
|
|
|
|
struct vnode **vpp;
|
|
|
|
struct union_node *un;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct vnode *vp;
|
|
|
|
struct ucred *cred = p->p_ucred;
|
|
|
|
struct vattr vat;
|
|
|
|
struct vattr *vap = &vat;
|
|
|
|
int fmode = FFLAGS(O_WRONLY|O_CREAT|O_TRUNC|O_EXCL);
|
|
|
|
int error;
|
|
|
|
int cmode = UN_FILEMODE & ~p->p_fd->fd_cmask;
|
|
|
|
struct componentname cn;
|
|
|
|
|
|
|
|
*vpp = NULLVP;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build a new componentname structure (for the same
|
|
|
|
* reasons outlines in union_mkshadow).
|
|
|
|
* The difference here is that the file is owned by
|
|
|
|
* the current user, rather than by the person who
|
|
|
|
* did the mount, since the current user needs to be
|
|
|
|
* able to write the file (that's why it is being
|
|
|
|
* copied in the first place).
|
|
|
|
*/
|
|
|
|
cn.cn_namelen = strlen(un->un_path);
|
1997-09-21 05:24:27 +01:00
|
|
|
cn.cn_pnbuf = zalloc(namei_zone);
|
1994-05-24 11:09:53 +01:00
|
|
|
bcopy(un->un_path, cn.cn_pnbuf, cn.cn_namelen+1);
|
|
|
|
cn.cn_nameiop = CREATE;
|
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 21:52:41 +01:00
|
|
|
cn.cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN);
|
1994-05-24 11:09:53 +01:00
|
|
|
cn.cn_proc = p;
|
|
|
|
cn.cn_cred = p->p_ucred;
|
|
|
|
cn.cn_nameptr = cn.cn_pnbuf;
|
|
|
|
cn.cn_consume = 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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* Pass dvp unlocked and referenced on call to relookup().
|
|
|
|
*
|
|
|
|
* If an error occurs, dvp will be returned unlocked and dereferenced.
|
|
|
|
*/
|
1994-05-24 11:09:53 +01:00
|
|
|
VREF(un->un_dirvp);
|
1994-10-10 08:55:48 +01:00
|
|
|
error = relookup(un->un_dirvp, &vp, &cn);
|
|
|
|
if (error)
|
1994-05-24 11:09:53 +01:00
|
|
|
return (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 21:52:41 +01:00
|
|
|
/*
|
|
|
|
* If no error occurs, dvp will be returned locked with the reference
|
|
|
|
* left as before, and vpp will be returned referenced and locked.
|
|
|
|
*/
|
1994-05-24 11:09:53 +01:00
|
|
|
if (vp) {
|
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 21:52:41 +01:00
|
|
|
vput(un->un_dirvp);
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
|
|
|
zfree(namei_zone, cn.cn_pnbuf);
|
|
|
|
cn.cn_flags &= ~HASBUF;
|
|
|
|
}
|
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 21:52:41 +01:00
|
|
|
if (vp == un->un_dirvp)
|
|
|
|
vrele(vp);
|
1994-05-24 11:09:53 +01:00
|
|
|
else
|
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 21:52:41 +01:00
|
|
|
vput(vp);
|
1994-05-24 11:09:53 +01:00
|
|
|
return (EEXIST);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Good - there was no race to create the file
|
|
|
|
* so go ahead and create it. The permissions
|
|
|
|
* on the file will be 0666 modified by the
|
|
|
|
* current user's umask. Access to the file, while
|
|
|
|
* it is unioned, will require access to the top *and*
|
|
|
|
* bottom files. Access when not unioned will simply
|
|
|
|
* require access to the top-level file.
|
|
|
|
* TODO: confirm choice of access permissions.
|
|
|
|
*/
|
|
|
|
VATTR_NULL(vap);
|
|
|
|
vap->va_type = VREG;
|
|
|
|
vap->va_mode = cmode;
|
1997-02-10 02:22:35 +00:00
|
|
|
VOP_LEASE(un->un_dirvp, p, cred, LEASE_WRITE);
|
1998-05-07 05:58:58 +01:00
|
|
|
error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap);
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
|
|
|
zfree(namei_zone, cn.cn_pnbuf);
|
|
|
|
cn.cn_flags &= ~HASBUF;
|
|
|
|
}
|
1998-05-07 05:58:58 +01:00
|
|
|
vput(un->un_dirvp);
|
|
|
|
if (error)
|
1994-05-24 11:09:53 +01:00
|
|
|
return (error);
|
|
|
|
|
1994-10-10 08:55:48 +01:00
|
|
|
error = VOP_OPEN(vp, fmode, cred, p);
|
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 21:52:41 +01:00
|
|
|
if (error == 0 && vn_canvmio(vp) == TRUE)
|
|
|
|
error = vfs_object_create(vp, p, cred);
|
1994-10-10 08:55:48 +01:00
|
|
|
if (error) {
|
1994-05-24 11:09:53 +01:00
|
|
|
vput(vp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
vp->v_writecount++;
|
|
|
|
*vpp = vp;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
1994-05-24 11:09:53 +01:00
|
|
|
union_vn_close(vp, fmode, cred, p)
|
|
|
|
struct vnode *vp;
|
|
|
|
int fmode;
|
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
if (fmode & FWRITE)
|
|
|
|
--vp->v_writecount;
|
1995-08-17 12:53:51 +01:00
|
|
|
return (VOP_CLOSE(vp, fmode, cred, p));
|
1994-05-24 11:09:53 +01: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 21:52:41 +01:00
|
|
|
#if 0
|
|
|
|
|
|
|
|
/*
|
|
|
|
* union_removed_upper:
|
|
|
|
*
|
|
|
|
* called with union_node unlocked. XXX
|
|
|
|
*/
|
|
|
|
|
1994-05-24 11:09:53 +01:00
|
|
|
void
|
|
|
|
union_removed_upper(un)
|
|
|
|
struct union_node *un;
|
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
struct proc *p = curproc; /* XXX */
|
1997-04-16 17:24:24 +01:00
|
|
|
struct vnode **vpp;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1997-04-16 17:24:24 +01:00
|
|
|
/*
|
|
|
|
* Do not set the uppervp to NULLVP. If lowervp is NULLVP,
|
1998-01-25 09:44:33 +00:00
|
|
|
* union node will have neither uppervp nor lowervp. We remove
|
1997-04-16 17:24:24 +01:00
|
|
|
* the union node from cache, so that it will not be referrenced.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
union_newupper(un, NULLVP);
|
1997-04-16 17:24:24 +01:00
|
|
|
if (un->un_dircache != 0) {
|
|
|
|
for (vpp = un->un_dircache; *vpp != NULLVP; vpp++)
|
|
|
|
vrele(*vpp);
|
|
|
|
free(un->un_dircache, M_TEMP);
|
|
|
|
un->un_dircache = 0;
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (un->un_flags & UN_CACHED) {
|
|
|
|
un->un_flags &= ~UN_CACHED;
|
|
|
|
LIST_REMOVE(un, un_cache);
|
|
|
|
}
|
1994-05-24 11:09:53 +01:00
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* determine whether a whiteout is needed
|
|
|
|
* during a remove/rmdir operation.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
union_dowhiteout(un, cred, p)
|
|
|
|
struct union_node *un;
|
|
|
|
struct ucred *cred;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct vattr va;
|
|
|
|
|
|
|
|
if (un->un_lowervp != NULLVP)
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
if (VOP_GETATTR(un->un_uppervp, &va, cred, p) == 0 &&
|
|
|
|
(va.va_flags & OPAQUE))
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
union_dircache_r(vp, vppp, cntp)
|
|
|
|
struct vnode *vp;
|
|
|
|
struct vnode ***vppp;
|
|
|
|
int *cntp;
|
|
|
|
{
|
|
|
|
struct union_node *un;
|
|
|
|
|
|
|
|
if (vp->v_op != union_vnodeop_p) {
|
|
|
|
if (vppp) {
|
|
|
|
VREF(vp);
|
|
|
|
*(*vppp)++ = vp;
|
|
|
|
if (--(*cntp) == 0)
|
|
|
|
panic("union: dircache table too small");
|
|
|
|
} else {
|
|
|
|
(*cntp)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
un = VTOUNION(vp);
|
|
|
|
if (un->un_uppervp != NULLVP)
|
|
|
|
union_dircache_r(un->un_uppervp, vppp, cntp);
|
|
|
|
if (un->un_lowervp != NULLVP)
|
|
|
|
union_dircache_r(un->un_lowervp, vppp, cntp);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct vnode *
|
|
|
|
union_dircache(vp, p)
|
|
|
|
struct vnode *vp;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
int cnt;
|
|
|
|
struct vnode *nvp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
struct vnode **dircache;
|
|
|
|
struct union_node *un;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
|
|
|
|
dircache = VTOUNION(vp)->un_dircache;
|
|
|
|
|
|
|
|
nvp = NULLVP;
|
|
|
|
|
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 21:52:41 +01:00
|
|
|
if (dircache == NULL) {
|
1997-02-10 02:22:35 +00:00
|
|
|
cnt = 0;
|
|
|
|
union_dircache_r(vp, 0, &cnt);
|
|
|
|
cnt++;
|
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 21:52:41 +01:00
|
|
|
dircache = malloc(cnt * sizeof(struct vnode *),
|
|
|
|
M_TEMP, M_WAITOK);
|
1997-02-10 02:22:35 +00:00
|
|
|
vpp = dircache;
|
|
|
|
union_dircache_r(vp, &vpp, &cnt);
|
|
|
|
*vpp = NULLVP;
|
|
|
|
vpp = dircache + 1;
|
|
|
|
} else {
|
|
|
|
vpp = dircache;
|
|
|
|
do {
|
|
|
|
if (*vpp++ == VTOUNION(vp)->un_uppervp)
|
|
|
|
break;
|
|
|
|
} while (*vpp != NULLVP);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*vpp == NULLVP)
|
|
|
|
goto out;
|
|
|
|
|
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 21:52:41 +01:00
|
|
|
/*vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, p);*/
|
|
|
|
UDEBUG(("ALLOCVP-3 %p ref %d\n", *vpp, (*vpp ? (*vpp)->v_usecount : -99)));
|
1997-02-10 02:22:35 +00:00
|
|
|
VREF(*vpp);
|
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 21:52:41 +01:00
|
|
|
error = union_allocvp(&nvp, vp->v_mount, NULLVP, NULLVP, NULL, *vpp, NULLVP, 0);
|
|
|
|
UDEBUG(("ALLOCVP-3B %p ref %d\n", nvp, (*vpp ? (*vpp)->v_usecount : -99)));
|
1997-02-10 02:22:35 +00:00
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
VTOUNION(vp)->un_dircache = 0;
|
|
|
|
un = VTOUNION(nvp);
|
|
|
|
un->un_dircache = dircache;
|
|
|
|
|
|
|
|
out:
|
|
|
|
VOP_UNLOCK(vp, 0, p);
|
|
|
|
return (nvp);
|
1994-05-24 11:09:53 +01:00
|
|
|
}
|
1998-11-03 08:01:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Module glue to remove #ifdef UNION from vfs_syscalls.c
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
union_dircheck(struct proc *p, struct vnode **vp, struct file *fp)
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
if ((*vp)->v_op == union_vnodeop_p) {
|
|
|
|
struct vnode *lvp;
|
|
|
|
|
|
|
|
lvp = union_dircache(*vp, p);
|
|
|
|
if (lvp != NULLVP) {
|
|
|
|
struct vattr va;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the directory is opaque,
|
|
|
|
* then don't show lower entries
|
|
|
|
*/
|
|
|
|
error = VOP_GETATTR(*vp, &va, fp->f_cred, p);
|
|
|
|
if (va.va_flags & OPAQUE) {
|
|
|
|
vput(lvp);
|
|
|
|
lvp = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lvp != NULLVP) {
|
|
|
|
error = VOP_OPEN(lvp, FREAD, fp->f_cred, p);
|
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 21:52:41 +01:00
|
|
|
if (error == 0 && vn_canvmio(lvp) == TRUE)
|
|
|
|
error = vfs_object_create(lvp, p, fp->f_cred);
|
1998-11-03 08:01:48 +00:00
|
|
|
if (error) {
|
|
|
|
vput(lvp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
VOP_UNLOCK(lvp, 0, p);
|
|
|
|
fp->f_data = (caddr_t) lvp;
|
|
|
|
fp->f_offset = 0;
|
|
|
|
error = vn_close(*vp, FREAD, fp->f_cred, p);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
*vp = lvp;
|
|
|
|
return -1; /* goto unionread */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1998-11-15 15:33:52 +00:00
|
|
|
static int
|
|
|
|
union_modevent(module_t mod, int type, void *data)
|
1998-11-03 08:01:48 +00:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case MOD_LOAD:
|
|
|
|
union_dircheckp = union_dircheck;
|
|
|
|
break;
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
union_dircheckp = NULL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 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 21:52:41 +01:00
|
|
|
|
1998-11-03 08:01:48 +00:00
|
|
|
static moduledata_t union_mod = {
|
|
|
|
"union_dircheck",
|
|
|
|
union_modevent,
|
|
|
|
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 21:52:41 +01:00
|
|
|
|
1998-11-03 08:01:48 +00:00
|
|
|
DECLARE_MODULE(union_dircheck, union_mod, SI_SUB_VFS, SI_ORDER_ANY);
|