1994-05-24 10:09:53 +00: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 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00: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 10:09:53 +00:00
|
|
|
#include <sys/filedesc.h>
|
2001-05-01 08:13:21 +00: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-21 23:19:50 +00:00
|
|
|
#include <sys/mutex.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/namei.h>
|
1997-02-10 02:22:35 +00:00
|
|
|
#include <sys/stat.h>
|
2001-05-01 08:13:21 +00: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 */
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
#include <vm/vm_object.h> /* for vm cache coherency */
|
2002-04-08 06:57:43 +00:00
|
|
|
#include <vm/uma.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
2001-05-23 09:42:29 +00:00
|
|
|
#include <fs/unionfs/union.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
2002-03-19 22:20:14 +00:00
|
|
|
extern int union_init(void);
|
1995-12-03 14:54:48 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/* must be power of two, otherwise change UNION_HASH() */
|
|
|
|
#define NHASH 32
|
|
|
|
|
|
|
|
/* unsigned int ... */
|
|
|
|
#define UNION_HASH(u, l) \
|
1998-07-15 04:17:55 +00:00
|
|
|
(((((uintptr_t) (u)) + ((uintptr_t) l)) >> 8) & (NHASH-1))
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2000-05-26 02:09:24 +00:00
|
|
|
static LIST_HEAD(unhead, union_node) unhead[NHASH];
|
1994-05-24 10:09:53 +00:00
|
|
|
static int unvplock[NHASH];
|
|
|
|
|
2002-03-19 22:20:14 +00:00
|
|
|
static void union_dircache_r(struct vnode *vp, struct vnode ***vppp,
|
|
|
|
int *cntp);
|
|
|
|
static int union_list_lock(int ix);
|
|
|
|
static void union_list_unlock(int ix);
|
|
|
|
static int union_relookup(struct union_mount *um, struct vnode *dvp,
|
1997-02-12 14:45:23 +00:00
|
|
|
struct vnode **vpp,
|
|
|
|
struct componentname *cnp,
|
|
|
|
struct componentname *cn, char *path,
|
2002-03-19 22:20:14 +00:00
|
|
|
int pathlen);
|
|
|
|
static void union_updatevp(struct union_node *un,
|
1995-12-03 14:54:48 +00:00
|
|
|
struct vnode *uppervp,
|
2002-03-19 22:20:14 +00:00
|
|
|
struct vnode *lowervp);
|
|
|
|
static void union_newlower(struct union_node *, struct vnode *);
|
|
|
|
static void union_newupper(struct union_node *, struct vnode *);
|
|
|
|
static int union_copyfile(struct vnode *, struct vnode *,
|
|
|
|
struct ucred *, struct thread *);
|
|
|
|
static int union_vn_create(struct vnode **, struct union_node *,
|
|
|
|
struct thread *);
|
|
|
|
static int union_vn_close(struct vnode *, int, struct ucred *,
|
|
|
|
struct thread *);
|
1995-12-03 14:54:48 +00:00
|
|
|
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
bzero((caddr_t)unvplock, sizeof(unvplock));
|
1994-05-25 09:21:21 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
if (unvplock[ix] & UNVP_LOCKED) {
|
|
|
|
unvplock[ix] |= UNVP_WANT;
|
1994-10-06 21:07:04 +00:00
|
|
|
(void) tsleep((caddr_t) &unvplock[ix], PINOD, "unllck", 0);
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
unvplock[ix] |= UNVP_LOCKED;
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
unvplock[ix] &= ~UNVP_LOCKED;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
if (unvplock[ix] & UNVP_WANT) {
|
|
|
|
unvplock[ix] &= ~UNVP_WANT;
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
/*
|
|
|
|
* union_updatevp:
|
|
|
|
*
|
|
|
|
* The uppervp, if not NULL, must be referenced and not locked by us
|
|
|
|
* The lowervp, if not NULL, must be referenced.
|
|
|
|
*
|
2002-09-22 08:54:17 +00:00
|
|
|
* If uppervp and lowervp match pointers already installed, then
|
|
|
|
* nothing happens. The passed vp's (when matching) are not adjusted.
|
|
|
|
*
|
|
|
|
* This routine may only be called by union_newupper() and
|
|
|
|
* union_newlower().
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
*/
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static void
|
1994-05-24 10:09:53 +00: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 10:09:53 +00: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 10:09:53 +00:00
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
if (lhash != uhash) {
|
1997-02-10 02:22:35 +00:00
|
|
|
while (union_list_lock(lhash))
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
while (union_list_lock(uhash))
|
|
|
|
continue;
|
1994-05-24 10:09:53 +00: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 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (ohash != nhash)
|
|
|
|
union_list_unlock(ohash);
|
|
|
|
|
1994-05-24 10:09:53 +00: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 10:09:53 +00: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 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docache && (ohash != nhash)) {
|
1994-05-24 10:09:53 +00: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 10:09:53 +00: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 20:52:41 +00: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 10:09:53 +00: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 20:52:41 +00: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 10:09:53 +00: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 20:52:41 +00:00
|
|
|
UDEBUG(("union: %s size now %ld\n",
|
|
|
|
(uppersz != VNOVAL ? "upper" : "lower"), (long)sz));
|
2001-05-17 04:52:57 +00:00
|
|
|
/*
|
2002-09-22 08:54:17 +00:00
|
|
|
* There is no need to change size of non-existent object.
|
2001-05-17 04:52:57 +00:00
|
|
|
*/
|
|
|
|
/* vnode_pager_setsize(vp, sz); */
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* 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.
|
2002-09-22 08:54:17 +00:00
|
|
|
* allocvp() makes no changes to 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 20:52:41 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
2002-09-22 08:54:17 +00:00
|
|
|
* dvp may or may not be locked. allocvp() makes no changes
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* 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 04:40:01 +00: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 20:52:41 +00: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
|
2002-09-22 08:54:17 +00:00
|
|
|
* later on. Only used if lowervp is valid. The contents
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* 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 10:09:53 +00:00
|
|
|
*
|
2002-09-22 08:54:17 +00: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
|
1994-05-24 10:09:53 +00:00
|
|
|
* removed when the vfs reclaim entry is called.
|
|
|
|
*
|
2002-09-22 08:54:17 +00:00
|
|
|
* A single lock is kept for the entire list. This is
|
1994-05-24 10:09:53 +00:00
|
|
|
* 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
|
2002-09-22 08:54:17 +00:00
|
|
|
* vnode. This lock is only taken if we are going to
|
|
|
|
* call getnewvnode(), since the kernel itself is single-threaded.
|
1994-05-24 10:09:53 +00:00
|
|
|
*
|
2002-09-22 08:54:17 +00:00
|
|
|
* If an entry is found on the list, then call vget() to
|
|
|
|
* take a reference. This is done because there may be
|
1994-05-24 10:09:53 +00:00
|
|
|
* 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 20:52:41 +00:00
|
|
|
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
union_allocvp(vpp, mp, dvp, upperdvp, cnp, uppervp, lowervp, docache)
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
struct vnode *dvp; /* parent union vnode */
|
|
|
|
struct vnode *upperdvp; /* parent vnode of uppervp */
|
1994-05-24 10:09:53 +00: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 10:09:53 +00:00
|
|
|
{
|
|
|
|
int error;
|
1994-05-25 09:21:21 +00:00
|
|
|
struct union_node *un = 0;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = (cnp) ? cnp->cn_thread : curthread;
|
1998-12-14 05:00:59 +00:00
|
|
|
int hash = 0;
|
1997-02-10 02:22:35 +00:00
|
|
|
int vflag;
|
1994-05-24 10:09:53 +00:00
|
|
|
int try;
|
|
|
|
|
|
|
|
if (uppervp == NULLVP && lowervp == NULLVP)
|
|
|
|
panic("union: unidentifiable allocation");
|
|
|
|
|
|
|
|
if (uppervp && lowervp && (uppervp->v_type != lowervp->v_type)) {
|
2001-05-17 04:40:01 +00:00
|
|
|
vrele(lowervp);
|
1994-05-24 10:09:53 +00: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);
|
|
|
|
}
|
2002-08-04 10:29:36 +00:00
|
|
|
vflag = VV_ROOT;
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
loop:
|
1997-02-10 02:22:35 +00:00
|
|
|
if (!docache) {
|
|
|
|
un = 0;
|
|
|
|
} else for (try = 0; try < 3; try++) {
|
1994-05-24 10:09:53 +00: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 10:09:53 +00: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,
|
2001-09-12 08:38:13 +00:00
|
|
|
cnp ? cnp->cn_thread : NULL)) {
|
1994-05-24 10:09:53 +00: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 20:52:41 +00: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 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
if (dvp && un->un_vnode != dvp) {
|
|
|
|
struct vnode *scan = un->un_vnode;
|
|
|
|
|
|
|
|
do {
|
|
|
|
scan = VTOUNION(scan)->un_pvp;
|
2002-09-14 09:02:28 +00:00
|
|
|
} while (scan && scan->v_op == union_vnodeop_p &&
|
|
|
|
scan != 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 20:52:41 +00:00
|
|
|
if (scan != dvp) {
|
|
|
|
/*
|
|
|
|
* our new un is above dvp (we never saw dvp
|
|
|
|
* while moving up the tree).
|
|
|
|
*/
|
|
|
|
VREF(dvp);
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(dvp, 0, td);
|
|
|
|
error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td);
|
|
|
|
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, td);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
vrele(dvp);
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* our new un is under dvp
|
|
|
|
*/
|
2001-09-12 08:38:13 +00:00
|
|
|
error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
}
|
|
|
|
} else if (dvp == NULLVP) {
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* dvp is NULL, we need to lock un.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2001-09-12 08:38:13 +00:00
|
|
|
error = vn_lock(un->un_vnode, LK_EXCLUSIVE, td);
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
/*
|
|
|
|
* dvp == un->un_vnode, we are already locked.
|
|
|
|
*/
|
|
|
|
error = 0;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
if (error)
|
|
|
|
goto loop;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
* 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 10:09:53 +00:00
|
|
|
*/
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
UDEBUG(("Modify existing un %p vn %p upper %p(refs %d) -> %p(refs %d)\n",
|
|
|
|
un, un->un_vnode, un->un_uppervp,
|
2002-09-25 02:32:42 +00:00
|
|
|
(un->un_uppervp ? vrefcnt(un->un_uppervp) : -99),
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
uppervp,
|
2002-09-25 02:32:42 +00:00
|
|
|
(uppervp ? vrefcnt(uppervp) : -99)
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
));
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (uppervp != un->un_uppervp) {
|
2002-09-25 02:32:42 +00:00
|
|
|
KASSERT(uppervp == NULL || vrefcnt(uppervp) > 0, ("union_allocvp: too few refs %d (at least 1 required) on uppervp", vrefcnt(uppervp)));
|
1994-05-24 10:09:53 +00:00
|
|
|
union_newupper(un, uppervp);
|
|
|
|
} else if (uppervp) {
|
2002-09-25 02:32:42 +00:00
|
|
|
KASSERT(vrefcnt(uppervp) > 1, ("union_allocvp: too few refs %d (at least 2 required) on uppervp", vrefcnt(uppervp)));
|
1994-05-24 10:09:53 +00:00
|
|
|
vrele(uppervp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save information about the lower layer.
|
|
|
|
* This needs to keep track of pathname
|
2002-09-22 08:54:17 +00:00
|
|
|
* and directory information which union_vn_create()
|
1994-05-24 10:09:53 +00:00
|
|
|
* 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 10:09:53 +00: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 20:52:41 +00: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 10:09:53 +00:00
|
|
|
*vpp = UNIONTOV(un);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docache) {
|
|
|
|
/*
|
2002-09-22 08:54:17 +00:00
|
|
|
* Otherwise lock the vp list while we call getnewvnode()
|
1997-02-10 02:22:35 +00:00
|
|
|
* since that can block.
|
|
|
|
*/
|
|
|
|
hash = UNION_HASH(uppervp, lowervp);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (union_list_lock(hash))
|
|
|
|
goto loop;
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
/*
|
2002-09-22 08:54:17 +00:00
|
|
|
* Create new node rather than replace old node.
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
*/
|
|
|
|
|
2002-09-14 09:02:28 +00:00
|
|
|
error = getnewvnode("union", mp, union_vnodeop_p, vpp);
|
1994-05-24 10:09:53 +00:00
|
|
|
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 20:52:41 +00:00
|
|
|
/*
|
2002-09-22 08:54:17 +00:00
|
|
|
* If an error occurs, clear out vnodes.
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
if (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 20:52:41 +00:00
|
|
|
if (uppervp)
|
|
|
|
vrele(uppervp);
|
|
|
|
if (upperdvp)
|
|
|
|
vrele(upperdvp);
|
|
|
|
*vpp = NULL;
|
1994-05-24 10:09:53 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
MALLOC((*vpp)->v_data, void *, sizeof(struct union_node),
|
|
|
|
M_TEMP, M_WAITOK);
|
|
|
|
|
2002-08-04 10:29:36 +00:00
|
|
|
ASSERT_VOP_LOCKED(*vpp, "union_allocvp");
|
|
|
|
(*vpp)->v_vflag |= vflag;
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
bzero(un, sizeof(*un));
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
un->un_vnode = *vpp;
|
|
|
|
un->un_uppervp = uppervp;
|
1997-02-10 02:22:35 +00:00
|
|
|
un->un_uppersz = VNOVAL;
|
1994-05-24 10:09:53 +00: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 20:52:41 +00: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 10:09:53 +00: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 20:52:41 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (cnp && (lowervp != NULLVP)) {
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
un->un_dirvp = NULL;
|
1994-05-24 10:09:53 +00: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 10:09:53 +00:00
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
out:
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docache)
|
|
|
|
union_list_unlock(hash);
|
1994-05-24 10:09:53 +00: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 10:09:53 +00:00
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
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 20:52:41 +00:00
|
|
|
un->un_pvp = NULL;
|
|
|
|
}
|
|
|
|
if (un->un_uppervp != NULLVP) {
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
un->un_uppervp = NULL;
|
|
|
|
}
|
|
|
|
if (un->un_lowervp != NULLVP) {
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
un->un_lowervp = NULL;
|
|
|
|
}
|
|
|
|
if (un->un_dirvp != NULLVP) {
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
un->un_dirvp = NULL;
|
|
|
|
}
|
|
|
|
if (un->un_path) {
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
un->un_path = NULL;
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
FREE(vp->v_data, M_TEMP);
|
|
|
|
vp->v_data = 0;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-09-22 08:54:17 +00:00
|
|
|
* copyfile. Copy the vnode (fvp) to the vnode (tvp)
|
|
|
|
* using a sequence of reads and writes. Both (fvp)
|
1994-05-24 10:09:53 +00:00
|
|
|
* 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 20:52:41 +00:00
|
|
|
*
|
|
|
|
* fvp and tvp are both exclusive locked on call, but their refcount's
|
|
|
|
* haven't been bumped at all.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_copyfile(fvp, tvp, cred, td)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode *fvp;
|
|
|
|
struct vnode *tvp;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct ucred *cred;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
struct uio uio;
|
|
|
|
struct iovec iov;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* strategy:
|
2002-09-22 08:54:17 +00:00
|
|
|
* Allocate a buffer of size MAXBSIZE.
|
|
|
|
* Loop doing reads and writes, keeping track
|
1994-05-24 10:09:53 +00:00
|
|
|
* of the current uio offset.
|
2002-09-22 08:54:17 +00:00
|
|
|
* Give up at the first sign of trouble.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
bzero(&uio, sizeof(uio));
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
uio.uio_td = td;
|
1994-05-24 10:09:53 +00:00
|
|
|
uio.uio_segflg = UIO_SYSSPACE;
|
|
|
|
uio.uio_offset = 0;
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_LEASE(fvp, td, cred, LEASE_READ);
|
|
|
|
VOP_LEASE(tvp, td, cred, LEASE_WRITE);
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
int count;
|
|
|
|
int bufoffset;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
/*
|
2002-09-22 08:54:17 +00:00
|
|
|
* Setup for big 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 20:52:41 +00:00
|
|
|
*/
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
if ((error = VOP_READ(fvp, &uio, 0, cred)) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get bytes read, handle read eof case and setup for
|
2002-09-22 08:54:17 +00:00
|
|
|
* write loop.
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
*/
|
|
|
|
if ((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 10:09:53 +00: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 20:52:41 +00:00
|
|
|
iov.iov_base = buf + bufoffset;
|
|
|
|
iov.iov_len = count - bufoffset;
|
|
|
|
uio.uio_offset = offset + bufoffset;
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
if ((error = VOP_WRITE(tvp, &uio, 0, cred)) != 0)
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
bufoffset += (count - bufoffset) - uio.uio_resid;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
uio.uio_offset = offset + bufoffset;
|
1994-05-24 10:09:53 +00: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 20:52:41 +00: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 20:52:41 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_copyup(un, docopy, cred, td)
|
1997-02-10 02:22:35 +00:00
|
|
|
struct union_node *un;
|
|
|
|
int docopy;
|
|
|
|
struct ucred *cred;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1997-02-10 02:22:35 +00:00
|
|
|
{
|
|
|
|
int error;
|
2000-07-11 22:07:57 +00:00
|
|
|
struct mount *mp;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *lvp, *uvp;
|
|
|
|
|
1997-08-14 03:57:46 +00:00
|
|
|
/*
|
|
|
|
* If the user does not have read permission, the vnode should not
|
|
|
|
* be copied to upper layer.
|
|
|
|
*/
|
2001-09-12 08:38:13 +00:00
|
|
|
vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, td);
|
|
|
|
error = VOP_ACCESS(un->un_lowervp, VREAD, cred, td);
|
|
|
|
VOP_UNLOCK(un->un_lowervp, 0, td);
|
1997-08-14 03:57:46 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
2000-07-11 22:07:57 +00:00
|
|
|
if ((error = vn_start_write(un->un_dirvp, &mp, V_WAIT | PCATCH)) != 0)
|
1997-02-10 02:22:35 +00:00
|
|
|
return (error);
|
2001-09-12 08:38:13 +00:00
|
|
|
if ((error = union_vn_create(&uvp, un, td)) != 0) {
|
2000-07-11 22:07:57 +00:00
|
|
|
vn_finished_write(mp);
|
|
|
|
return (error);
|
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
lvp = un->un_lowervp;
|
|
|
|
|
2002-09-25 02:32:42 +00:00
|
|
|
KASSERT(vrefcnt(uvp) > 0, ("copy: uvp refcount 0: %d", vrefcnt(uvp)));
|
1997-02-10 02:22:35 +00:00
|
|
|
if (docopy) {
|
|
|
|
/*
|
|
|
|
* XX - should not ignore errors
|
2002-09-22 08:54:17 +00:00
|
|
|
* from VOP_CLOSE()
|
1997-02-10 02:22:35 +00:00
|
|
|
*/
|
2001-09-12 08:38:13 +00:00
|
|
|
vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td);
|
|
|
|
error = VOP_OPEN(lvp, FREAD, cred, td);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
if (error == 0 && vn_canvmio(lvp) == TRUE)
|
2001-09-12 08:38:13 +00:00
|
|
|
error = vfs_object_create(lvp, td, cred);
|
1997-02-10 02:22:35 +00:00
|
|
|
if (error == 0) {
|
2001-09-12 08:38:13 +00:00
|
|
|
error = union_copyfile(lvp, uvp, cred, td);
|
|
|
|
VOP_UNLOCK(lvp, 0, td);
|
|
|
|
(void) VOP_CLOSE(lvp, FREAD, cred, td);
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
|
|
|
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 20:52:41 +00:00
|
|
|
UDEBUG(("union: copied up %s\n", un->un_path));
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
}
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(uvp, 0, td);
|
2000-07-11 22:07:57 +00: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 20:52:41 +00:00
|
|
|
union_newupper(un, uvp);
|
2002-09-25 02:32:42 +00:00
|
|
|
KASSERT(vrefcnt(uvp) > 0, ("copy: uvp refcount 0: %d", vrefcnt(uvp)));
|
2001-09-12 08:38:13 +00:00
|
|
|
union_vn_close(uvp, FWRITE, cred, td);
|
2002-09-25 02:32:42 +00:00
|
|
|
KASSERT(vrefcnt(uvp) > 0, ("copy: uvp refcount 0: %d", vrefcnt(uvp)));
|
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++) {
|
2001-09-12 08:38:13 +00:00
|
|
|
(void) VOP_CLOSE(lvp, FREAD, cred, td);
|
|
|
|
(void) VOP_OPEN(uvp, FREAD, cred, td);
|
1997-02-10 02:22:35 +00:00
|
|
|
}
|
1999-09-28 05:48:39 +00:00
|
|
|
if (un->un_openl) {
|
|
|
|
if (vn_canvmio(uvp) == TRUE)
|
2001-09-12 08:38:13 +00:00
|
|
|
error = vfs_object_create(uvp, td, cred);
|
1999-09-28 05:48:39 +00:00
|
|
|
}
|
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 20:52:41 +00: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
|
2002-09-22 08:54:17 +00:00
|
|
|
* 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.
|
1997-02-10 02:22:35 +00:00
|
|
|
* Conclusion: Horrible.
|
|
|
|
*/
|
|
|
|
cn->cn_namelen = pathlen;
|
2002-04-08 06:57:43 +00:00
|
|
|
cn->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK);
|
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 20:52:41 +00:00
|
|
|
cn->cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN);
|
2001-09-12 08:38:13 +00:00
|
|
|
cn->cn_thread = cnp->cn_thread;
|
1997-02-10 02:22:35 +00:00
|
|
|
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);
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(dvp, 0, cnp->cn_thread);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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) {
|
2001-09-12 08:38:13 +00:00
|
|
|
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_thread);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
return(error);
|
1997-04-13 06:27:09 +00: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 20:52:41 +00: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 10:09:53 +00: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 20:52:41 +00:00
|
|
|
* (dvp) is the directory in which to create the shadow directory,
|
2002-09-22 08:54:17 +00:00
|
|
|
* It is locked (but not ref'd) on entry and return.
|
|
|
|
* (cnp) is the component name to be created.
|
1994-05-24 10:09:53 +00:00
|
|
|
* (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 20:52:41 +00:00
|
|
|
* is returned locked and ref'd
|
1994-05-24 10:09:53 +00: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;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = cnp->cn_thread;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct componentname cn;
|
2000-07-11 22:07:57 +00:00
|
|
|
struct mount *mp;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2000-07-11 22:07:57 +00: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 22:07:57 +00:00
|
|
|
}
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
if (*vpp) {
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
2002-04-08 06:57:43 +00:00
|
|
|
uma_zfree(namei_zone, cn.cn_pnbuf);
|
1999-12-15 23:02:35 +00:00
|
|
|
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 20:52:41 +00:00
|
|
|
if (dvp == *vpp)
|
|
|
|
vrele(*vpp);
|
|
|
|
else
|
|
|
|
vput(*vpp);
|
2000-07-11 22:07:57 +00:00
|
|
|
vn_finished_write(mp);
|
1997-02-10 02:22:35 +00:00
|
|
|
*vpp = NULLVP;
|
|
|
|
return (EEXIST);
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
2002-09-22 08:54:17 +00:00
|
|
|
* Policy: when creating the shadow directory in the
|
1994-05-24 10:09:53 +00:00
|
|
|
* 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 10:09:53 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/* VOP_LEASE: dvp is locked */
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_LEASE(dvp, td, cn.cn_cred, LEASE_WRITE);
|
1994-05-24 10:09:53 +00: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) {
|
2002-04-08 06:57:43 +00:00
|
|
|
uma_zfree(namei_zone, cn.cn_pnbuf);
|
1999-12-15 23:02:35 +00:00
|
|
|
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 20:52:41 +00:00
|
|
|
/*vput(dvp);*/
|
2000-07-11 22:07:57 +00: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.
|
2002-09-22 08:54:17 +00:00
|
|
|
* It is locked on entry and return.
|
|
|
|
* (cnp) is the component name to be created.
|
1997-02-10 02:22:35 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
union_mkwhiteout(um, dvp, cnp, path)
|
|
|
|
struct union_mount *um;
|
|
|
|
struct vnode *dvp;
|
|
|
|
struct componentname *cnp;
|
|
|
|
char *path;
|
|
|
|
{
|
|
|
|
int error;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = cnp->cn_thread;
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *wvp;
|
|
|
|
struct componentname cn;
|
2000-07-11 22:07:57 +00:00
|
|
|
struct mount *mp;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
2000-07-11 22:07:57 +00: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 22:07:57 +00:00
|
|
|
if (error) {
|
|
|
|
vn_finished_write(mp);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
2000-07-11 22:07:57 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
if (wvp) {
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
2002-04-08 06:57:43 +00:00
|
|
|
uma_zfree(namei_zone, cn.cn_pnbuf);
|
1999-12-15 23:02:35 +00:00
|
|
|
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 20:52:41 +00:00
|
|
|
if (wvp == dvp)
|
|
|
|
vrele(wvp);
|
|
|
|
else
|
|
|
|
vput(wvp);
|
2000-07-11 22:07:57 +00:00
|
|
|
vn_finished_write(mp);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (EEXIST);
|
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/* VOP_LEASE: dvp is locked */
|
2002-02-27 18:32:23 +00:00
|
|
|
VOP_LEASE(dvp, td, td->td_ucred, LEASE_WRITE);
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
error = VOP_WHITEOUT(dvp, &cn, CREATE);
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
2002-04-08 06:57:43 +00:00
|
|
|
uma_zfree(namei_zone, cn.cn_pnbuf);
|
1999-12-15 23:02:35 +00:00
|
|
|
cn.cn_flags &= ~HASBUF;
|
|
|
|
}
|
2000-07-11 22:07:57 +00:00
|
|
|
vn_finished_write(mp);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* union_vn_create: creates and opens a new shadow file
|
2002-09-22 08:54:17 +00:00
|
|
|
* 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
|
1994-05-24 10:09:53 +00:00
|
|
|
* things, and b) it doesn't start at the "right" directory,
|
2002-09-22 08:54:17 +00:00
|
|
|
* 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 20:52:41 +00: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 10:09:53 +00:00
|
|
|
*/
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_vn_create(vpp, un, td)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode **vpp;
|
|
|
|
struct union_node *un;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
struct vnode *vp;
|
2002-02-27 18:32:23 +00:00
|
|
|
struct ucred *cred = td->td_ucred;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vattr vat;
|
|
|
|
struct vattr *vap = &vat;
|
|
|
|
int fmode = FFLAGS(O_WRONLY|O_CREAT|O_TRUNC|O_EXCL);
|
|
|
|
int error;
|
2002-01-13 11:58:06 +00:00
|
|
|
int cmode;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct componentname cn;
|
|
|
|
|
|
|
|
*vpp = NULLVP;
|
2002-01-13 11:58:06 +00:00
|
|
|
FILEDESC_LOCK(td->td_proc->p_fd);
|
|
|
|
cmode = UN_FILEMODE & ~td->td_proc->p_fd->fd_cmask;
|
|
|
|
FILEDESC_UNLOCK(td->td_proc->p_fd);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Build a new componentname structure (for the same
|
2002-09-22 08:54:17 +00:00
|
|
|
* reasons outlines in union_mkshadow()).
|
1994-05-24 10:09:53 +00:00
|
|
|
* 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);
|
2002-04-08 06:57:43 +00:00
|
|
|
cn.cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK);
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
cn.cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN);
|
2001-09-12 08:38:13 +00:00
|
|
|
cn.cn_thread = td;
|
2002-02-27 18:32:23 +00:00
|
|
|
cn.cn_cred = td->td_ucred;
|
1994-05-24 10:09:53 +00:00
|
|
|
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 20:52:41 +00:00
|
|
|
/*
|
|
|
|
* Pass dvp unlocked and referenced on call to relookup().
|
|
|
|
*
|
|
|
|
* If an error occurs, dvp will be returned unlocked and dereferenced.
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
VREF(un->un_dirvp);
|
1994-10-10 07:55:48 +00:00
|
|
|
error = relookup(un->un_dirvp, &vp, &cn);
|
|
|
|
if (error)
|
1994-05-24 10:09:53 +00: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 20:52:41 +00: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 10:09:53 +00: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 20:52:41 +00:00
|
|
|
vput(un->un_dirvp);
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
2002-04-08 06:57:43 +00:00
|
|
|
uma_zfree(namei_zone, cn.cn_pnbuf);
|
1999-12-15 23:02:35 +00:00
|
|
|
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 20:52:41 +00:00
|
|
|
if (vp == un->un_dirvp)
|
|
|
|
vrele(vp);
|
1994-05-24 10:09:53 +00: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 20:52:41 +00:00
|
|
|
vput(vp);
|
1994-05-24 10:09:53 +00: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;
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_LEASE(un->un_dirvp, td, cred, LEASE_WRITE);
|
1998-05-07 04:58:58 +00:00
|
|
|
error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap);
|
1999-12-15 23:02:35 +00:00
|
|
|
if (cn.cn_flags & HASBUF) {
|
2002-04-08 06:57:43 +00:00
|
|
|
uma_zfree(namei_zone, cn.cn_pnbuf);
|
1999-12-15 23:02:35 +00:00
|
|
|
cn.cn_flags &= ~HASBUF;
|
|
|
|
}
|
1998-05-07 04:58:58 +00:00
|
|
|
vput(un->un_dirvp);
|
|
|
|
if (error)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
error = VOP_OPEN(vp, fmode, cred, td);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
if (error == 0 && vn_canvmio(vp) == TRUE)
|
2001-09-12 08:38:13 +00:00
|
|
|
error = vfs_object_create(vp, td, cred);
|
1994-10-10 07:55:48 +00:00
|
|
|
if (error) {
|
1994-05-24 10:09:53 +00:00
|
|
|
vput(vp);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
vp->v_writecount++;
|
|
|
|
*vpp = vp;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-11-18 15:07:35 +00:00
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_vn_close(vp, fmode, cred, td)
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
int fmode;
|
|
|
|
struct ucred *cred;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
if (fmode & FWRITE)
|
|
|
|
--vp->v_writecount;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (VOP_CLOSE(vp, fmode, cred, td));
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
#if 0
|
|
|
|
|
|
|
|
/*
|
|
|
|
* union_removed_upper:
|
|
|
|
*
|
|
|
|
* called with union_node unlocked. XXX
|
|
|
|
*/
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
void
|
|
|
|
union_removed_upper(un)
|
|
|
|
struct union_node *un;
|
|
|
|
{
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = curthread; /* XXX */
|
1997-04-16 16:24:24 +00:00
|
|
|
struct vnode **vpp;
|
1997-02-10 02:22:35 +00:00
|
|
|
|
1997-04-16 16:24:24 +00: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 16:24:24 +00: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 16:24:24 +00: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 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2002-09-22 08:54:17 +00:00
|
|
|
* Determine whether a whiteout is needed
|
1997-02-10 02:22:35 +00:00
|
|
|
* during a remove/rmdir operation.
|
|
|
|
*/
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_dowhiteout(un, cred, td)
|
1997-02-10 02:22:35 +00:00
|
|
|
struct union_node *un;
|
|
|
|
struct ucred *cred;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1997-02-10 02:22:35 +00:00
|
|
|
{
|
|
|
|
struct vattr va;
|
|
|
|
|
|
|
|
if (un->un_lowervp != NULLVP)
|
|
|
|
return (1);
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
if (VOP_GETATTR(un->un_uppervp, &va, cred, td) == 0 &&
|
1997-02-10 02:22:35 +00:00
|
|
|
(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 *
|
2001-09-12 08:38:13 +00:00
|
|
|
union_dircache(vp, td)
|
1997-02-10 02:22:35 +00:00
|
|
|
struct vnode *vp;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td;
|
1997-02-10 02:22:35 +00:00
|
|
|
{
|
|
|
|
int cnt;
|
|
|
|
struct vnode *nvp;
|
|
|
|
struct vnode **vpp;
|
|
|
|
struct vnode **dircache;
|
|
|
|
struct union_node *un;
|
|
|
|
int error;
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
|
1997-02-10 02:22:35 +00:00
|
|
|
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 20:52:41 +00: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 20:52:41 +00: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;
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
/*vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td);*/
|
2002-09-25 02:32:42 +00:00
|
|
|
UDEBUG(("ALLOCVP-3 %p ref %d\n", *vpp, (*vpp ? vrefcnt(*vpp) : -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 20:52:41 +00:00
|
|
|
error = union_allocvp(&nvp, vp->v_mount, NULLVP, NULLVP, NULL, *vpp, NULLVP, 0);
|
2002-09-25 02:32:42 +00:00
|
|
|
UDEBUG(("ALLOCVP-3B %p ref %d\n", nvp, (*vpp ? vrefcnt(*vpp) : -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:
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(vp, 0, td);
|
1997-02-10 02:22:35 +00:00
|
|
|
return (nvp);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
1998-11-03 08:01:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Module glue to remove #ifdef UNION from vfs_syscalls.c
|
|
|
|
*/
|
|
|
|
static int
|
2001-09-12 08:38:13 +00:00
|
|
|
union_dircheck(struct thread *td, struct vnode **vp, struct file *fp)
|
1998-11-03 08:01:48 +00:00
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
if ((*vp)->v_op == union_vnodeop_p) {
|
|
|
|
struct vnode *lvp;
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
lvp = union_dircache(*vp, td);
|
1998-11-03 08:01:48 +00:00
|
|
|
if (lvp != NULLVP) {
|
|
|
|
struct vattr va;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the directory is opaque,
|
|
|
|
* then don't show lower entries
|
|
|
|
*/
|
2001-09-12 08:38:13 +00:00
|
|
|
error = VOP_GETATTR(*vp, &va, fp->f_cred, td);
|
1998-11-03 08:01:48 +00:00
|
|
|
if (va.va_flags & OPAQUE) {
|
|
|
|
vput(lvp);
|
|
|
|
lvp = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lvp != NULLVP) {
|
2001-09-12 08:38:13 +00:00
|
|
|
error = VOP_OPEN(lvp, FREAD, fp->f_cred, td);
|
This is a major fixup of unionfs. At least 30 serious bugs have been
fixed (many due to changing semantics in other parts of the kernel and not
the original author's fault), including one critical one: unionfs could
cause UFS corruption in the fronting store due to calling VOP_OPEN for
writing without turning on vmio for the UFS vnode.
Most of the bugs were related to semantics changes in VOP calls, lock
ordering problems (causing deadlocks), improper handling of a read-only
backing store (such as an NFS mount), improper referencing and locking
of vnodes, not using real struct locks for vnode locking, not using
recursive locks when accessing the fronting store, and things like that.
New functionality has been added: unionfs now has mmap() support, but
only partially tested, and rename has been enhanced considerably.
There are still some things that unionfs cannot do. You cannot
rename a directory without confusing unionfs, and there are issues
with softlinks, hardlinks, and special files. unionfs mostly doesn't
understand them (and never did).
There are probably still panic situations, but hopefully no where near
as many as before this commit.
The unionfs in this commit has been tested overlayed on /usr/src
(backing /usr/src being a read-only NFS mount, fronting /usr/src being
a local filesystem). kernel builds have been tested, buildworld is
undergoing testing. More testing is necessary.
1999-09-26 20:52:41 +00:00
|
|
|
if (error == 0 && vn_canvmio(lvp) == TRUE)
|
2001-09-12 08:38:13 +00:00
|
|
|
error = vfs_object_create(lvp, td, fp->f_cred);
|
1998-11-03 08:01:48 +00:00
|
|
|
if (error) {
|
|
|
|
vput(lvp);
|
|
|
|
return (error);
|
|
|
|
}
|
2001-09-12 08:38:13 +00:00
|
|
|
VOP_UNLOCK(lvp, 0, td);
|
2002-01-13 11:58:06 +00:00
|
|
|
FILE_LOCK(fp);
|
1998-11-03 08:01:48 +00:00
|
|
|
fp->f_data = (caddr_t) lvp;
|
|
|
|
fp->f_offset = 0;
|
2002-01-13 11:58:06 +00:00
|
|
|
FILE_UNLOCK(fp);
|
2001-09-12 08:38:13 +00:00
|
|
|
error = vn_close(*vp, FREAD, fp->f_cred, td);
|
1998-11-03 08:01:48 +00:00
|
|
|
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 20:52:41 +00: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 20:52:41 +00:00
|
|
|
|
1998-11-03 08:01:48 +00:00
|
|
|
DECLARE_MODULE(union_dircheck, union_mod, SI_SUB_VFS, SI_ORDER_ANY);
|