Commit Graph

154 Commits

Author SHA1 Message Date
riastradh 46e71c7d57 Make VOP_LINK return directory still locked and referenced.
Ride 7.99.10 bump.
2015-04-20 22:59:19 +00:00
riastradh 944fbd0d8b Cull unused vnode v_iflags: VI_LAYER, VI_LOCKSHARE. 2015-04-20 19:36:55 +00:00
riastradh f6139440c5 Make vget always return vnode unlocked.
Convert callers who want locks to use vn_lock afterward.

Add extra argument so the compiler will report stragglers.
2015-04-20 13:44:16 +00:00
hannken 645887d187 A union node may be reactivated while it is being reclaimed so
change union_freevp() to detach the vnode from the union node
by clearing the vnode backpointer and the lower node sizes.
2015-02-24 16:08:01 +00:00
hannken 8596fa407f Change union to vcache. Use address of the union node as key.
It would be better to use (uppervp, lowervp) as key, but either
may be NULL and may change any time.
2015-02-16 10:22:00 +00:00
hannken c20c5717d4 Add reference count to union node. 2015-02-16 10:21:25 +00:00
hannken 9c6a12fd82 Remove a superfluous vref(), VOP_CREATE() was changed to
keep dvp referenced and locked some time ago.
2015-02-16 10:20:57 +00:00
snj f0a7346d21 src is too big these days to tolerate superfluous apostrophes. It's
"its", people!
2014-10-18 08:33:23 +00:00
uebayasi fe9a32c84e Define filesystem attributes with vfs dependency. 2014-10-11 06:42:18 +00:00
matt 82ef6ef7b8 Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.
2014-09-05 09:26:16 +00:00
dholland 05d075b3ae Add VOP_FALLOCATE and VOP_FDISCARD to every vnode ops table I can
find.

The filesystem ones all call genfs_eopnotsupp - right now I am only
implementing the plumbing and we can implement fallocate and/or
fdiscard for files later.

The device ones call spec_fallocate (which is also genfs_eopnotsupp)
and spec_fdiscard, which dispatches to the device-level op.

The fifo ones all call vn_fifo_bypass, which also ends up being
EOPNOTSUPP.
2014-07-25 08:20:51 +00:00
hannken 11b42c4183 Unlock directory vnode after VOP_CREATE. 2014-06-17 12:38:12 +00:00
dholland 8e1257d82c Also set or assert that *vpp is null before calling VOP_MKDIR. 2014-05-17 04:07:15 +00:00
dholland 3955d2067a Set *vpp to NULL before calling VOP_CREATE. This always happens when
calling using nameidata, and if not something went wrong, so we'd like
to be able to assert about it.
2014-05-17 04:03:49 +00:00
maxv 23f76b6d00 An (un)privileged user can easily make the kernel dereference a NULL
pointer.

The kernel allows 'data' to be NULL; it's the fs's responsibility to
ensure that it isn't NULL (if the fs actually needs data).

ok christos@
2014-04-16 18:55:17 +00:00
hannken f3cf481632 - Make VI_XLOCK, VI_CLEAN and VI_LOCKSHARE private to kern/vfs_*.c.
- Make vwait() static.
- Add  vdead_check() to check a vnode for being or becoming dead.

Discussed on tech-kern.

Welcome to 6.99.38
2014-03-24 13:42:40 +00:00
hannken 6d285189fb Change all vfsops to use C99 designated initializers.
No functional changes intended.
2014-03-23 15:21:15 +00:00
hannken 5e8d36ac30 Restructure union_lock() to always lock before testing for dead node.
Add two little helpers to lock or unlock a node.  Use "vp" for the
union node and "lockvp" for the node to be locked.  Use ISSET() to
test flags, add assertions.
2014-03-12 09:40:05 +00:00
hannken 2b6ec89863 The current implementation of vn_lock() is racy. Modification of
the vnode operations vector for active vnodes is unsafe because it
is not known whether deadfs or the original file system will be
called.

- Pass down LK_RETRY to the lock operation (hint for deadfs only).

- Change deadfs lock operation to return ENOENT if LK_RETRY is unset.

- Change all other lock operations to check for dead vnode once
  the vnode is locked and unlock and return ENOENT in this case.

With these changes in place vnode lock operations will never succeed
after vclean() has marked the vnode as VI_XLOCK and before vclean()
has changed the operations vector.

Adresses PR kern/37706 (Forced unmount of file systems is unsafe)

Discussed on tech-kern.

Welcome to 6.99.33
2014-02-27 16:51:37 +00:00
pooka 4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
hannken c36eeb723b Change union_allocvp() to take an unlocked uppervp and to return the
union node unlocked.  Another VI_XLOCK hack is gone.
2014-02-16 09:50:25 +00:00
hannken 32bc55a7e7 Member un_flags is unused now -- remove. 2014-02-14 08:50:27 +00:00
martin 478bc1f91d Remove an unused variable 2014-02-13 21:05:26 +00:00
hannken 8757071efb Get rid of UN_KLOCK to keep a lock on vput(). It is not really needed
and makes the source difficult to read.  Always hold references to the
union nodes until the operation is done.
2014-02-13 09:55:04 +00:00
hannken 15a20e1e67 Fix the DOT and DOTDOT case for union_lookup1(). 2014-02-13 09:50:31 +00:00
hannken 97834f7ba0 Change vnode operation lookup to return the resulting vnode *vpp unlocked.
Change cache_lookup() to return an unlocked vnode.

Discussed on tech-kern@

Welcome to 6.99.31
2014-02-07 15:29:20 +00:00
hannken 04c776e5c8 Change vnode operations create, mknod, mkdir and symlink to return
the resulting vnode *vpp unlocked.

Discussed on tech-kern@

Welcome to 6.99.30
2014-01-23 10:13:55 +00:00
hannken 1139274440 Change vnode operations create, mknod, mkdir and symlink to keep the
directory node dvp locked on return.

Discussed on tech-kern@

Welcome to 6.99.29
2014-01-17 10:55:01 +00:00
christos ba0dd1c1e6 remove unused code 2013-10-17 21:03:50 +00:00
dholland 1617a81dd1 Disentangle the namecache from the internals of namei.
- Move the namecache's hash computation to inside the namecache code,
instead of being spread out all over the place. Remove cn_hash from
struct componentname and delete all uses of it.

 - It is no longer necessary (if it ever was) for cache_lookup and
cache_lookup_raw to clear MAKEENTRY from cnp->cn_flags for the cases
that cache_enter already checks for.

 - Rearrange the interface of cache_lookup (and cache_lookup_raw) to
make it somewhat simpler, to exclude certain nonexistent error
conditions, and (most importantly) to make it not require write access
to cnp->cn_flags.

This change requires a kernel bump.
2012-11-05 17:24:09 +00:00
rmind f1d428af19 - Replace some malloc(9) uses with kmem(9).
- G/C M_IPMOPTS, M_IPMADDR and M_BWMETER.
2012-04-30 22:51:27 +00:00
hannken 1ebfe67c9f The union file system is as stable as other layered file systems so
no longer print a warning to the console.

Gnats is waiting ...
2011-12-05 11:12:10 +00:00
hannken ea1a52c704 When union_allocvp() finds a node being cleaned out and the caller holds
a lock, ignore the node and continue.  To allow the cleaning to succeed
the current threadmust make progress.
For a brief time the cache may contain more than one vnode referring to
a lower node.

Don't unlock the hash mutex if getnewvnode fails -- we don't hold it.
2011-11-25 11:19:10 +00:00
hannken 035b1022bb Use hashinit() / hashdone() to create the union node hash list.
Cleanup the hash lookup in union_allocvp().

Needs more work as there is still a possible deadlock between
union_allocvp() and vclean().
2011-11-23 19:39:11 +00:00
hannken 4e825063cf Replace flag based union node locking with generic vnode lock, support
shared and nowait locks and protect un_uppervp and un_*sz with mutex.

Mark file system MPSAFE.
2011-11-21 18:29:22 +00:00
hannken 7c028d0f99 VOP_ABORTOP() has no specific lock requirements so there is no need
to force locked vnodes here.  It should be impossible to come here
with a nil upper node.

Relock the directory vnode after copyup.  A locked union node with an
unlocked upper vnode can no longer exist so make FIXUP() an assertion.
2011-11-14 18:42:57 +00:00
hannken 3e29235de5 Remove a needless vnode lock/unlock dance. This is a leftover from the
removal of VOP_LEASE().

Function union_removed_upper() always works on unlocked upper vnodes so
remove the test-and-unlock and add an assertion.
2011-11-14 18:38:13 +00:00
hannken 749d77682d VOP_GETATTR() needs a shared lock at least. 2011-10-18 09:22:53 +00:00
hannken 8dc51ab7d8 Print the warning message on mount once.
Should fix PR #42795 (patch to make mounting union filesystems less obnoxious)
2011-08-28 08:27:57 +00:00
hannken f937bd97b7 Stop abusing relookup() to prepare the creation of new nodes
in the upper layer.
Replace union_relookup() with union_do_lookup() that prepares
a component, calls VOP_LOOKUP() and does the EEXIST test.
2011-08-23 07:39:37 +00:00
hannken 1147247693 Use mutexes to protect the hash lists instead of tsleep/wakeup. 2011-08-13 10:48:14 +00:00
hannken 94fc281af2 Change some `#ifdef DIAGNOSTIC' to `KASSERT'.
Instead of a `pid_t' use a `lwp_t *' for locking diagnostics.

No functional changes intended.
2011-08-12 17:41:17 +00:00
hannken b8e5efdc84 Add missing parts to mount devices from a union file system:
- union_close()    has to lock/unlock the lower vnode.
- union_fsync()    has to call spec_fsync() for the union vnode.
- union_strategy() must allow writes to devices on the lower file system.
- union_bwrite()   was completely missing.
2011-08-12 14:36:29 +00:00
hannken 7b19d6d068 When creating a union node representing a device initialize
the spec_node to make vrele() happy.
2011-08-12 06:40:10 +00:00
hannken 3ec6312958 Update the (shared) v_interlock if the upper node changes. 2011-08-10 15:56:01 +00:00
hannken b80057eeb2 For devices, sockets and fifos ignore setting the file size to zero to make
open(..., O_TRUNC) happy and allow them to write through the lower layer.

Fixes PR #43560 (writing to null device in unionfs fails)
2011-08-10 06:27:02 +00:00
hannken 9be6a4a9b4 Use LK_SHARED, it is sufficient for VOP_GETATTR() and VOP_READDIR(). 2011-08-10 06:19:54 +00:00
hannken 342315ffad Change union rmdir semantics to fail directory removal for
non-empty directories like all other file systems do.

Change test accordingly.
2011-08-07 06:01:51 +00:00
hannken efc3d2ec25 When union_lookup() creates a shadow directory and nameiop is not LOOKUP
it has to restart the lookup to get the componentname right.

Fixes PR #44383 (an endless stream of whiteout and opaque dir problems ...)
2011-08-05 08:17:47 +00:00
rmind e225b7bd09 Welcome to 5.99.53! Merge rmind-uvmplock branch:
- Reorganize locking in UVM and provide extra serialisation for pmap(9).
  New lock order: [vmpage-owner-lock] -> pmap-lock.

- Simplify locking in some pmap(9) modules by removing P->V locking.

- Use lock object on vmobjlock (and thus vnode_t::v_interlock) to share
  the locks amongst UVM objects where necessary (tmpfs, layerfs, unionfs).

- Rewrite and optimise x86 TLB shootdown code, make it simpler and cleaner.
  Add TLBSTATS option for x86 to collect statistics about TLB shootdowns.

- Unify /dev/mem et al in MI code and provide required locking (removes
  kernel-lock on some ports).  Also, avoid cache-aliasing issues.

Thanks to Andrew Doran and Joerg Sonnenberger, as their initial patches
formed the core changes of this branch.
2011-06-12 03:35:36 +00:00