Commit Graph

72 Commits

Author SHA1 Message Date
Eivind Eklund
762e6b856c Introduce NDFREE (and remove VOP_ABORTOP) 1999-12-15 23:02:35 +00:00
Eivind Eklund
6bdfe06ad9 Lock reporting and assertion changes.
* lockstatus() and VOP_ISLOCKED() gets a new process argument and a new
  return value: LK_EXCLOTHER, when the lock is held exclusively by another
  process.
* The ASSERT_VOP_(UN)LOCKED family is extended to use what this gives them
* Extend the vnode_if.src format to allow more exact specification than
  locked/unlocked.

This commit should not do any semantic changes unless you are using
DEBUG_VFS_LOCKS.

Discussed with:	grog, mch, peter, phk
Reviewed by:	peter
1999-12-11 16:13:02 +00:00
Poul-Henning Kamp
5ecdb702b0 Remove unused #includes.
Obtained from:	http://bogon.freebsd.dk/include
1999-12-08 08:59:40 +00:00
Peter Wemm
ac09d23cfa Fix an unused variable warning. 1999-11-18 09:07:30 +00:00
Eivind Eklund
dd8c04f4c7 Remove WILLRELE from VOP_SYMLINK
Note: Previous commit to these files (except coda_vnops and devfs_vnops)
that claimed to remove WILLRELE from VOP_RENAME actually removed it from
VOP_MKNOD.
1999-11-13 20:58:17 +00:00
Eivind Eklund
edfe736df9 Remove WILLRELE from VOP_RENAME 1999-11-12 03:34:28 +00:00
Poul-Henning Kamp
923502ff91 useracc() the prequel:
Merge the contents (less some trivial bordering the silly comments)
of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>.  This puts
the #defines for the vm_inherit_t and vm_prot_t types next to their
typedefs.

This paves the road for the commit to follow shortly: change
useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE}
as argument.
1999-10-29 18:09:36 +00:00
Matthew Dillon
e3a285c715 Make sure file after VOP_OPEN is VMIO'd when transfering control from
a lower layer to an upper layer.  I'm not sure how necessary this is
    for reading.

    Fix bug in union_lookup() (note: there are probably still several bugs
    in union_lookup()).  This one set lerror as a side effect without
    setting lowervp, causing copyup code further on down to crash on a null
    lowervp pointer.  Changed the side effect to use a temporary variable
    instead.
1999-09-28 05:48:39 +00:00
Matthew Dillon
2a31267e43 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
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Poul-Henning Kamp
8947a90a90 Make sure that stat(2) and friends always return a valid st_dev field.
Pseudo-FS need not fill in the va_fsid anymore, the syscall code
will use the first half of the fsid, which now looks like a udev_t
with major 255.
1999-07-02 16:29:47 +00:00
Kirk McKusick
f9c8cab591 Add a vnode argument to VOP_BWRITE to get rid of the last vnode
operator special case. Delete special case code from vnode_if.sh,
vnode_if.src, umap_vnops.c, and null_vnops.c.
1999-06-16 23:27:55 +00:00
Matthew Dillon
831a80b0d5 Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile
1999-01-27 22:42:27 +00:00
Matthew Dillon
27ed09c2f0 Cleanup uninitialized-possibly-used (but really not) warnings 1998-12-14 05:00:59 +00:00
Julian Elischer
fd5d1124e2 VOP_STRATEGY grows an (struct vnode *) argument
as the value in b_vp is often not really what you want.
(and needs to be frobbed). more cleanups will follow this.
Reviewed by: Bruce Evans <bde@freebsd.org>
1998-07-04 20:45:42 +00:00
Mike Smith
7be2d30077 In the words of the submitter:
---------
Make callers of namei() responsible for releasing references or locks
instead of having the underlying filesystems do it.  This eliminates
redundancy in all terminal filesystems and makes it possible for stacked
transport layers such as umapfs or nullfs to operate correctly.

Quality testing was done with testvn, and lat_fs from the lmbench suite.

Some NFS client testing courtesy of Patrik Kudo.

vop_mknod and vop_symlink still release the returned vpp.  vop_rename
still releases 4 vnode arguments before it returns.  These remaining cases
will be corrected in the next set of patches.
---------

Submitted by:	Michael Hancock <michaelh@cet.co.jp>
1998-05-07 04:58:58 +00:00
KATO Takenori
b2bde4cb07 If lowervp is NULLVP, vap was clobbered.
Submitted by:	Naofumi Honda <honda@Kururu.math.sci.hokudai.ac.jp>
Obtained from:	NetBSD/pc98
1998-03-17 08:47:50 +00:00
KATO Takenori
589421d418 Deleted KLOCK-hack. 1998-02-26 03:23:56 +00:00
KATO Takenori
d6476ada99 Undo UN_KLOCK hack except union_allocvp(). Now, vput() doesn't lock
the vnode.
1998-02-10 03:32:07 +00:00
Eivind Eklund
0b08f5f737 Back out DIAGNOSTIC changes. 1998-02-06 12:14:30 +00:00
KATO Takenori
87884aad6e Workarround for DIAGNOSTIC kernel's panic in union_lookup().
Union_removed_upper() clobbers cache when file is removed.
Upper vp will be removed by union_reclaim().
1998-02-06 02:42:21 +00:00
Eivind Eklund
47cfdb166d Turn DIAGNOSTIC into a new-style option. 1998-02-04 22:34:03 +00:00
KATO Takenori
bda1412586 Delete unused code in union_fsync(). 1998-01-22 02:14:59 +00:00
KATO Takenori
3ae6029808 - Move SETKLOC and CLEARKLOCK macros into uion.h.
- Set UN_ULOCK in union_lock() when UN_KLOCK is set.  Caller expects
  that vnode is locked correctly, and may call another function which
  expects locked vnode and may unlock the vnode.
- Do not assume the behavior of inside functions in FreeBSD's
  vfs_suber.c is same as 4.4BSD-Lite2.  Vnode may be locked in
  vget() even though flag is zero.  (Locked vnode is, of course,
  unlocked before returning from vget.)
1998-01-20 10:02:54 +00:00
KATO Takenori
471f80601f Workarround for locking violation while recycling vnode which union fs
used in freelist.
1998-01-18 08:17:48 +00:00
KATO Takenori
afc2a5581f Improve and revise fixes for locking violation.
Obtained from:	NetBSD/pc98
1998-01-18 07:56:41 +00:00
Poul-Henning Kamp
dba3870c10 VFS interior redecoration.
Rename vn_default_error to vop_defaultop all over the place.
Move vn_bwrite from vfs_bio.c to vfs_default.c and call it vop_stdbwrite.
Use vop_null instead of nullop.
Move vop_nopoll from vfs_subr.c to vfs_default.c
Move vop_sharedlock from vfs_subr.c to vfs_default.c
Move vop_nolock from vfs_subr.c to vfs_default.c
Move vop_nounlock from vfs_subr.c to vfs_default.c
Move vop_noislocked from vfs_subr.c to vfs_default.c
Use vop_ebadf instead of *_ebadf.
Add vop_defaultop for getpages on master vnode in MFS.
1997-10-26 20:55:39 +00:00
Poul-Henning Kamp
987f569678 Another VFS cleanup "kilo commit"
1.  Remove VOP_UPDATE, it is (also) an UFS/{FFS,LFS,EXT2FS,MFS}
    intereface function, and now lives in the ufsmount structure.

2.  Remove VOP_SEEK, it was unused.

3.  Add mode default vops:

    VOP_ADVLOCK          vop_einval
    VOP_CLOSE            vop_null
    VOP_FSYNC            vop_null
    VOP_IOCTL            vop_enotty
    VOP_MMAP             vop_einval
    VOP_OPEN             vop_null
    VOP_PATHCONF         vop_einval
    VOP_READLINK         vop_einval
    VOP_REALLOCBLKS      vop_eopnotsupp

    And remove identical functionality from filesystems

4.   Add vop_stdpathconf, which returns the canonical stuff.  Use
     it in the filesystems.  (XXX: It's probably wrong that specfs
     and fifofs sets this vop, shouldn't it come from the "host"
     filesystem, for instance ufs or cd9660 ?)

5.   Try to make system wide VOP functions have vop_* names.

6.   Initialize the um_* vectors in LFS.

(Recompile your LKMS!!!)
1997-10-16 20:32:40 +00:00
Poul-Henning Kamp
6a525123aa Hmm, realign the vnops into two columns. 1997-10-15 10:05:29 +00:00
Poul-Henning Kamp
539ef70c2d Stylistic overhaul of vnops tables.
1. Remove comment stating the blatantly obvious.
        2. Align in two columns.
        3. Sort all but the default element alphabetically.
        4. Remove XXX comments pointing out entries not needed.
1997-10-15 09:22:02 +00:00
Peter Wemm
a6aeade2c4 Convert select -> poll.
Delete 'always succeed' select/poll handlers, replaced with generic call.
Flag missing vnode op table entries.
1997-09-14 02:58:12 +00:00
Bruce Evans
c109c5775a Staticized. 1997-09-07 06:46:34 +00:00
KATO Takenori
6ca02614a5 Support read-only mount. 1997-09-04 03:14:49 +00:00
Bruce Evans
e4ba6a82b0 Removed unused #includes. 1997-09-02 20:06:59 +00:00
KATO Takenori
f5a5311ee8 Added DIAGNOSTIC routine to test inconsistency of vnode when cnp
points `.'.

Obtained from:	NetBSD
1997-08-15 02:36:28 +00:00
KATO Takenori
a03a24c901 Deleted unused code which adjust UN_UNLOCK flag. 1997-08-15 02:35:00 +00:00
KATO Takenori
3dc942bbe9 Backed out part of previous change. The example of -b mount in
manpage works again.
1997-08-14 03:52:27 +00:00
KATO Takenori
f8fc96b551 Fixed vnode corruption by undefined case in union_lookup(). When
uerror == 0 && lerror == EACCES, lowervp == NULLVP and union_allocvp
doesn't find existing union node and new union node is created.

Sicne it is dificult to cover all the case, union_lookup always
returns when union_lookup1() returns EACCES.

Submitted by:	Naofumi Honda <honda@Kururu.math.sci.hokudai.ac.jp>
Obtained from:	NetBSD/pc98
1997-08-12 07:18:59 +00:00
KATO Takenori
c9bf011176 1. Added cast and parenthesis in block size calculaion in
union_statfs().
2. staticized union vops.

Submitted by:	Doug Rabson <dfr@nlsystems.com>
1997-05-07 14:37:32 +00:00
KATO Takenori
32cfb899a6 Fixed panic message in union_lock(): union_link --> union_lock. 1997-05-03 01:55:19 +00:00
KATO Takenori
5f3f68a8ba Access correct union mount point in union_access. Old vnode is saved
in savedvp variable and it is used for the argument of
MOUNTTOUNIONMOUNT().  I didn't realize ap->a_vp is modified before
MOUNTTOUNIONMOUNT(), so the change by revision 1.22 is incorrect.
1997-05-02 03:21:54 +00:00
KATO Takenori
a9320ff3bd Revised fix for locking violation when unionfs calls vput with
UN_KLOCK flag.

When UN_KLOCK is set, VOP_UNLOCK should keep uppervp locked and clear
UN_ULOCK flag.  To do this, when UN_KLOCK is set, (1) union_unlock
clears UN_ULOCK and does not clear UN_KLOCK, (2) union_lock() does not
access uppervp and does not clear UN_KLOCK, and (3) callers of
vput/VOP_UNLOCK should clear UN_KLOCK.  For example, vput becomes:

	SETKLOCK(union_node);
	vput(vnode);
	CLEARKLOCK(union_node);

where SETKLOCK macro sets UN_KLOCK and CLEARKLOCK macro clears
UN_KLOCK.
1997-04-29 02:06:07 +00:00
KATO Takenori
c4ace78562 Undo 1.29. 1997-04-27 10:49:37 +00:00
KATO Takenori
a18ac0ffaf Do nothing instead of adjusting un_flags when (uppervp is locked) &&
(UN_ULOCK is not set) in union_lock.  This condition may indicate
race.  DIAGNOSTIC kernel still panic here.
1997-04-26 13:43:25 +00:00
KATO Takenori
928e13b6a1 Do not clear UN_ULOCK in certain case.
Our vput calls vm_object_deallocate() --> vm_object_terminate().  The
vm_object_terminate() calls vn_lock(), since UN_LOCKED has been
already cleared in union_unlock().  Then, union_lock locks upper vnode
when UN_ULOCK is not set.  The upper vnode is not unlocked when
UN_KLOCK is set in union_unlock(), thus, union_lock tries to lock
locked vnode and we get panic.
1997-04-26 04:09:40 +00:00
KATO Takenori
18b4c8e206 Dirty change in union_lock(). Sometimes upper vnode is locked without
UN_ULOCK flag.  This shows a locking violation but I couldn't find the
reason UN_ULOCK is not set or upper vnode is not unlocked.  I added
the code that detect this case and adjust un_flags.  DIAGNOSTIC kernel
doesn't adjust un_flags, but just panic here to help debug by kernel
hackers.
1997-04-21 15:32:24 +00:00
KATO Takenori
077f31be53 Replace VOP_LOCK with vn_lock. 1997-04-21 12:40:42 +00:00
KATO Takenori
93d71a483c Undo previous commit to avoid panic, and fix order of argument of
VOP_LINK().  The reason of strange behavior was wrong order of the
argument, that is, the operation

	# ln foo bar

in a union fs tried to do

	# ln bar foo

in ufs layer.

Now we can make a link in a union fs.
1997-04-16 03:08:34 +00:00
KATO Takenori
9095719e2b Quick-hack to avoid `lock against myself' panic. It is not the real
fix!

The ufs_link() assumes that vnode is not unlocked and tries to lock it
in certain case.  Because union_link calls VOP_LINK after locking vnode,
vn_lock in ufs_link causes above panic.

Currently, I don't know the real fix for a locking violation in
union_link, but I think it is important to avoid panic.

A vnode is unlocked before calling VOP_LINK and is locked after it if
the vnode is not union fs.  Even though panic went away, the process
that access the union fs in which link was made will hang-up.

Hang-up can be easily reproduced by following operation:

	mount -t union a b
	cd b
	ln foo bar
	ls
1997-04-15 12:56:57 +00:00
KATO Takenori
ee582cdff0 Fix locking violation when accessing `..'.
Obtained from:	NetBSD
1997-04-14 05:13:55 +00:00