Commit Graph

429 Commits

Author SHA1 Message Date
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
uebayasi 064389cedb Fix build; p was not used, but l was passed to kauth. Use curlwp directly. 2011-06-11 03:00:19 +00:00
matt 1f1f4e99e8 l isn't used. nuke it. 2011-06-10 21:02:46 +00:00
uebayasi 282c08f330 do_sys_rename: Kill an unused variable. 2011-06-10 13:07:14 +00:00
dsl ce8178264d Don't directly call sys_sync() from random bits of code, instead
add do_sys_sync() that takes an 'lwp' (for l_cred) as an argument.
Explicitly pass &lwp0 rather than NULL and expecting sys_sync to
  substitute some random lwp.
2011-06-05 09:04:22 +00:00
dsl 2ab3977571 Fix type in comment
(before I replace the 'l' with 'curlwp')
2011-06-02 18:54:43 +00:00
rmind 800683e30d sys_link: prevent hard links on directories (cross-mount operations are
already prevented).  File systems are no longer responsible to check this.
Clean up and add asserts (note that dvp == vp cannot happen in vop_link).

OK dholland@
2011-04-24 21:35:29 +00:00
christos a73f7b01d5 - Add O_CLOEXEC to open(2)
- Add fd_set_exclose() to encapsulate uses of FIO{,N}CLEX, O_CLOEXEC, F{G,S}ETFD
- Add a pipe1() function to allow passing flags to the fd's that pipe(2)
  opens to ease implementation of linux pipe2(2)
- Factor out fp handling code from open(2) and fhopen(2)
2011-04-10 15:45:33 +00:00
rmind 756122ce22 Remove unused M_MOUNT. 2011-04-02 04:57:35 +00:00
rmind fbc8beae75 Split off parts of vfs_subr.c into vfs_vnode.c and vfs_mount.c modules.
No functional change.  Discussed on tech-kern@.
2011-04-02 04:28:56 +00:00
yamt 448a616abd prevent cross-mount operations. 2011-03-12 07:16:50 +00:00
bouyer 063f96f3c2 merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
2011-03-06 17:08:10 +00:00
dholland 15e33f3bf4 Revert previous, which doesn't cover all the cases if F_OK isn't 0,
and just CTASSERT that it is, as that's not remotely likely to change.
Per source-changes-d; ok by Christos.
2011-02-28 03:23:44 +00:00
christos 6f2f866802 don't depend on F_OK being 0. 2011-02-28 00:12:15 +00:00
dholland 45b74603dd Check for bogus flags to access() up front. Otherwise we end up
calling VOP_ACCESS with flags 0 and something asserts deep in the
bowels of kauth. PR 44648 from Taylor Campbell. (I moved the check
earlier relative to the suggested patch.)

Pullup candidate.
2011-02-27 23:06:40 +00:00
pooka 4a92140584 allow file system to decide if it can be downgraded from r/w to r/o 2011-01-13 07:25:50 +00:00
dholland 6d2ff39e83 Remove remaining references to SAVESTART. 2011-01-02 05:12:33 +00:00
dholland 13fc777536 Remove the special refcount behavior (adding an extra reference to the
parent dir) associated with SAVESTART in relookup().

Check all call sites to make sure that SAVESTART wasn't set while
calling relookup(); if it was, adjust the refcount behavior. Remove
related references to SAVESTART.

The only code that was reaching the extra ref was msdosfs_rename,
where the refcount behavior was already fairly broken and/or gross;
repair it.

Add a dummy 4th argument to relookup to make sure code that hasn't
been inspected won't compile. (This will go away next time the
relookup semantics change, which they will.)
2011-01-02 05:09:30 +00:00
dholland a508b19c66 Remove unused nameidata field ni_startdir. 2011-01-02 05:01:20 +00:00
dholland d4eb05390d Abolish struct componentname's cn_pnbuf. Use the path buffer in the
pathbuf object passed to namei as work space instead. (For now a pnbuf
pointer appears in struct nameidata, to support certain unclean things
that haven't been fixed yet, but it will be going away in the future.)

This removes the need for the SAVENAME and HASBUF namei flags.
2010-11-30 10:29:57 +00:00
dholland 8f6ed30d57 Introduce struct pathbuf. This is an abstraction to hold a pathname
and the metadata required to interpret it. Callers of namei must now
create a pathbuf and pass it to NDINIT (instead of a string and a
uio_seg), then destroy the pathbuf after the namei session is
complete.

Update all namei call sites accordingly. Add a pathbuf(9) man page and
update namei(9).

The pathbuf interface also now appears in a couple of related
additional places that were passing string/uio_seg pairs that were
later fed into NDINIT. Update other call sites accordingly.
2010-11-19 06:44:33 +00:00
pgoyette 23d5409e7e Update the rest of the kernel to conform to the module subsystem's new
locking protocol.
2010-08-21 13:19:39 +00:00
pooka 6376b2136c Enable kernel-internal symlink creation with do_sys_symlink().
I did this a while ago already, but can't remember why i didn't
commit it then.
2010-06-30 15:44:54 +00:00
hannken 1423e65b26 Clean up vnode lock operations pass 2:
VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument.

Welcome to 5.99.32.

Discussed on tech-kern.
2010-06-24 12:58:48 +00:00
hannken 9ddf309cbe When mounting a file system re-lookup and lock the directory we mount on
after the file system is setup by VFS_MOUNT().  This way recursive vnode
locks are no longer needed here and mounts on null mounts no longer fail
as described in PR #43439 (mount_null panic: lockdebug_wantlock: locking
against myself).

Based on a proposal from  and
Reviewed by: David A. Holland <dholland@netbsd.org>
2010-06-15 09:43:36 +00:00
yamt b1521a3612 remove redundant checks of PK_MARKER. 2010-03-03 00:47:30 +00:00
pooka 07df6e2689 Fix reference counting for vfsops in mount. Otherwise it's possible
(for an unprivileged user) to force vfs modules to remain loaded
forever.  Also, it's possible for an admin with fat fingers to have
to curse out loud (a lot) and reboot.

.. or at least fix things as much as seems to be possible without
involving 1000 zorkmids.  do_sys_mount() takes either struct vfsops
(which hopefully came properly referenced) or a userspace string
for file system type.  The standard in-kernel calling convention
of "do_sys_mount(l, vfs_getopsbyname("nfs"), NULL," is not to be
considered healthy, kosher, or even tasty (although if vfs_getopsbyname()
fails the whole thing *currently* fails without the program counter
pointing to hyperspace).
2010-01-15 01:00:46 +00:00
pooka c3183f3251 The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live
years ago when the kernel was modified to not alter ABI based on
DIAGNOSTIC, and now just call the respective function interfaces
(in lowercase).  Plenty of mix'n match upper/lowercase has creeped
into the tree since then.  Nuke the macros and convert all callsites
to lowercase.

no functional change
2010-01-08 11:35:07 +00:00
pooka 3142d3ac31 Define namei flag INRENAME and set it if a lookup operation is part
of rename.  This helps with building better asserts for rename in
the DELETE lookup ... the RENAME lookup is quite obviously a part
of rename.
2009-12-23 01:09:24 +00:00
martin cecef5e6d5 Use the kernel space version of the vfs name, not the original userspace
pointer. Avoids crashes on archs with completely separate userspace VA.
2009-12-19 20:28:27 +00:00
haad 5200b9b492 Add enum uio_seg argument to do_sys_mknod and do_sys_mkdir so these functions
can be called from kernel, too.

Change needed for zfs device node creation, until we have propoer devfs.

Oked by ad@.
2009-08-09 22:49:00 +00:00
bad 0152c542e8 Add a note to change_root() that the callers need to authorize the operation.
As requested by elad@.
2009-08-02 20:44:55 +00:00
bad 02bcf17298 As discussed on tech-kern:
Factor out common code of chroot-like syscalls into change_root() and export
that function for use in other parts of the kernel.
Rename change_dir() to chdir_lookup() as the latter describes better what
the function does.  While there, move the namei_data initialisation into
chdir_lookup(), too.  And export chdir_lookup().
2009-08-01 21:17:11 +00:00
pooka 1a0b832e88 expose mkdir to in-kernel consumers 2009-07-02 12:53:47 +00:00
dholland effcf1af5c Convert 67 namei call sites to use namei_simple, in these functions:
check_console, veriexecclose, veriexec_delete, veriexec_file_add,
emul_find_root, coff_load_shlib (sh3 version), coff_load_shlib,
compat_20_sys_statfs, compat_20_netbsd32_statfs,
ELFNAME2(netbsd32,probe_noteless), darwin_sys_statfs,
ibcs2_sys_statfs, ibcs2_sys_statvfs, linux_sys_uselib,
osf1_sys_statfs, sunos_sys_statfs, sunos32_sys_statfs,
ultrix_sys_statfs, do_sys_mount, fss_create_files (3 of 4),
adosfs_mount, cd9660_mount, coda_ioctl, coda_mount, ext2fs_mount,
ffs_mount, filecore_mount, hfs_mount, lfs_mount, msdosfs_mount,
ntfs_mount, sysvbfs_mount, udf_mount, union_mount, sys_chflags,
sys_lchflags, sys_chmod, sys_lchmod, sys_chown, sys_lchown,
sys___posix_chown, sys___posix_lchown, sys_link, do_sys_pstatvfs,
sys_quotactl, sys_revoke, sys_truncate, do_sys_utimes, sys_extattrctl,
sys_extattr_set_file, sys_extattr_set_link, sys_extattr_get_file,
sys_extattr_get_link, sys_extattr_delete_file,
sys_extattr_delete_link, sys_extattr_list_file, sys_extattr_list_link,
sys_setxattr, sys_lsetxattr, sys_getxattr, sys_lgetxattr,
sys_listxattr, sys_llistxattr, sys_removexattr, sys_lremovexattr

All have been scrutinized (several times, in fact) and compile-tested,
but not all have been explicitly tested in action.

XXX: While I haven't (intentionally) changed the use or nonuse of
XXX: TRYEMULROOT in any of these places, I'm not convinced all the
XXX: uses are correct; an audit might be desirable.
2009-06-29 05:08:15 +00:00
pooka fb42667d02 Move dovfsusermount from vfs_syscalls.c to param.c: secmodel bsd44
depends on it and we can't isolate it in vfs.
(no, it doesn't really belong in param.c, but I couldn't figure out
a better place for it)
2009-05-02 14:13:28 +00:00
dyoung 3e0a641f96 Extract common code from vfs_rootmountalloc(9) and mount_domount() into
a new struct mount-allocation routine, vfs_mountalloc(9).  Documentation
updates will follow.

Attention: Synchronization Oversight Committee!  In mount_domount(),
I postpone the call mutex_enter(&mp->mnt_updating) until right before
the VFS_MOUNT(9) call because (1) that looks to me like the earliest
possible opportunity for mp to become visible to any other LWP, because
it was just kmem_zalloc(9)'d and (2) it made extracting the common code
much easier.  Tell me if my reasoning is faulty.
2009-04-29 01:03:43 +00:00
yamt a6f64ec082 do_sys_utimes: fix a bug introduced by rev.1.367.
VA_UTIMES_NULL is in va_vaflags, not va_flags.
2009-04-28 03:01:15 +00:00
yamt 6fb9967219 do_sys_unlink: remove an unused credential. 2009-03-13 11:05:26 +00:00
ad b2dec392e0 Fix some comments. 2009-02-23 20:33:30 +00:00
ad 59fcf21389 PR kern/26878 FFSv2 + softdep = livelock (no free ram)
PR kern/16942 panic with softdep and quotas
PR kern/19565 panic: softdep_write_inodeblock: indirect pointer #1 mismatch
PR kern/26274 softdep panic: allocdirect_merge: ...
PR kern/26374 Long delay before non-root users can write to softdep partitions
PR kern/28621 1.6.x "vp != NULL" panic in ffs_softdep.c:4653 while unmounting a softdep (+quota) filesystem
PR kern/29513 FFS+Softdep panic with unfsck-able file-corruption
PR kern/31544 The ffs softdep code appears to fail to write dirty bits to disk
PR kern/31981 stopping scsi disk can cause panic (softdep)
PR kern/32116 kernel panic in softdep (assertion failure)
PR kern/32532 softdep_trackbufs deadlock
PR kern/37191 softdep: locking against myself
PR kern/40474 Kernel panic after remounting raid root with softdep

Retire softdep, pass 2. As discussed and later formally announced on the
mailing lists.
2009-02-22 20:28:05 +00:00
enami fb8633d4a9 Simplify the code; we already have a hint to decide which string to copy.
(And at least gcc generates better code.)
2009-02-15 03:52:49 +00:00
christos bd1260c5ff from enami: Only apply rootdir changes if the chroot dir != / 2009-02-14 17:06:35 +00:00
christos 78a45c73e9 PR/40634: Christoph Badura: "chroot / /sbin/mount" shows only / as mounted 2009-02-14 16:55:25 +00:00
enami e6aec5115a Make revoke(2) works as before:
- vfs_syscalls.c rev. 1.342 fails to invert condition correcly when
  then-clause and else-clause is swapped.  Since then, revoke(2) fails
  if it is issued by file owner.
- Probably since rev. 1.160 of genfs_vnops.c, revoke(2) fails if it is
  applied to non-device file and drops kernel into ddb.
2009-02-05 13:37:24 +00:00
yamt cea19a4d14 malloc -> kmem_alloc. 2009-01-17 07:02:35 +00:00
christos 461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
elad 48949a2a2a Fix length passed to strlcpy(): we used to get names one character shorter
than reality.

Should be pulled up to netbsd-5.
2008-12-14 23:12:58 +00:00
ad 92ce8c6a3d Make the emulations, exec formats, coredump, NFS, and the NFS server
into modules. By and large this commit:

- shuffles header files and ifdefs
- splits code out where necessary to be modular
- adds module glue for each of the components
- adds/replaces hooks for things that can be installed at runtime
2008-11-19 18:35:57 +00:00
pooka 98bf46c51a <sys/buf.h> police 2008-11-16 18:44:07 +00:00