Commit Graph

94 Commits

Author SHA1 Message Date
riastradh 9fc453562f Round of uvm.h cleanup.
The poorly named uvm.h is generally supposed to be for uvm-internal
users only.

- Narrow it to files that actually need it -- mostly files that need
  to query whether curlwp is the pagedaemon, which should maybe be
  exposed by an external header.

- Use uvm_extern.h where feasible and uvm_*.h for things not exposed
  by it.  We should split up uvm_extern.h but this will serve for now
  to reduce the uvm.h dependencies.

- Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use
  UVMHIST(ubchist), since ubchist is declared in uvm.h but the
  reference evaporates if UVMHIST is not defined, so we reduce header
  file dependencies.

- Make uvm_device.h and uvm_swap.h independently includable while
  here.

ok chs@
2020-09-05 16:30:10 +00:00
ad 4b8a875ae2 uvm_availmem(): give it a boolean argument to specify whether a recent
cached value will do, or if the very latest total must be fetched.  It can
be called thousands of times a second and fetching the totals impacts not
only the calling LWP but other CPUs doing unrelated activity in the VM
system.
2020-06-11 19:20:42 +00:00
ad 0eaaa024ea Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-23 23:42:41 +00:00
christos 8cd8e685a0 fix accessx confusion (thanks hannken@) 2020-05-20 17:04:58 +00:00
christos 9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
ad f5ad84fdb3 PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of itself)
- Add new flag UBC_ISMAPPED which tells ubc_uiomove() the object is mmap()ed
  somewhere.  Use it to decide whether to do direct-mapped copy, rather than
  poking around directly in the vnode in ubc_uiomove(), which is ugly and
  doesn't work for tmpfs.  It would be nicer to contain all this in UVM but
  the filesystem provides the needed locking here (VV_MAPPED) and to
  reinvent that would suck more.

- Rename UBC_UNMAP_FLAG() to UBC_VNODE_FLAGS().  Pass in UBC_ISMAPPED where
  appropriate.
2020-04-23 21:47:07 +00:00
ad c90f9c8c81 Merge the remaining changes from the ad-namecache branch, affecting namei()
and getcwd():

- push vnode locking back as far as possible.
- do most lookups directly in the namecache, avoiding vnode locks & refs.
- don't block new refs to vnodes across VOP_INACTIVE().
- get shared locks for VOP_LOOKUP() if the file system supports it.
- correct lock types for VOP_ACCESS() / VOP_GETATTR() in a few places.

Possible future enhancements:

- make the lookups lockless.
- support dotdot lookups by being lockless and inferring absence of chroot.
- maybe make it work for layered file systems.
- avoid vnode references at the root & cwd.
2020-04-04 20:49:30 +00:00
ad d2a0ebb67a UVM locking changes, proposed on tech-kern:
- Change the lock on uvm_object, vm_amap and vm_anon to be a RW lock.
- Break v_interlock and vmobjlock apart.  v_interlock remains a mutex.
- Do partial PV list locking in the x86 pmap.  Others to follow later.
2020-02-23 15:46:38 +00:00
ad c2e9cb9413 VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode.  Matches
FreeBSD.
2020-01-17 20:08:06 +00:00
ad 5c06357c90 Rename uvm_free() -> uvm_availmem(). 2019-12-31 13:07:09 +00:00
msaitoh a5effc3ce9 s/inital/initial/ 2019-12-27 09:25:57 +00:00
ad ddd3a0be1e uvmexp.free -> uvm_free() 2019-12-21 13:00:20 +00:00
christos 4449640fc2 fix compilation 2019-09-18 18:46:00 +00:00
christos 0da0aa0234 Add newly created vnodes to the namei cache. The rest of the filesystems
already did that (or they don't support writing). Discussed in tech-kern.
2019-09-18 17:59:14 +00:00
pgoyette 31dfde78a5 Split the ufs code out of the ffs module and into its own module.
Adapt chfs and ext2fs modules accordingly.
2019-06-20 03:31:29 +00:00
ryoon cadfcb39d0 Fix build without DIAGNOSTIC 2019-06-17 17:14:56 +00:00
chs e406c140eb add a genfs method to allow a file system to limit the range of pages
that are given to a single GOP_WRITE() call.  needed by ZFS.
2018-05-28 21:04:37 +00:00
christos 87fd18f8e5 s/static inline/static __inline/g for consistency. 2018-04-19 21:50:06 +00:00
ozaki-r a208e7b3be Remove unnecessary assertions
KASSERT(!rw_lock_held()) just before rw_destroy() is useless because
rw_destroy does more strict check and provides better information on
failure.
2018-02-07 08:50:13 +00:00
sevan 9663b966f1 Drop commended out include to a hardcoded path in root's home directory. 2018-01-29 15:48:50 +00:00
riastradh 81f0ddf5e8 Fix up chfs_mountfs error branches. 2017-11-14 22:06:40 +00:00
christos 913317c461 use PR_WAITOK everywhere. 2017-11-09 22:16:38 +00:00
chs fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
riastradh 7f7aad09bd Make VOP_RECLAIM do the last unlock of the vnode.
VOP_RECLAIM naturally has exclusive access to the vnode, so having it
locked on entry is not strictly necessary -- but it means if there
are any final operations that must be done on the vnode, such as
ffs_update, requiring exclusive access to it, we can now kassert that
the vnode is locked in those operations.

We can't just have the caller release the last lock because some file
systems don't use genfs_lock, and require the vnode to remain valid
for VOP_UNLOCK to work, notably unionfs.
2017-05-26 14:20:59 +00:00
riastradh 6fa7b15833 Change VOP_REMOVE and VOP_RMDIR to preserve lock/ref on dvp.
No change to vp -- the plan is to replace the node by the
componentname in the vop parameters, and let all directory vops do
lookups internally.

Proposed on tech-kern with no objections:
https://mail-index.netbsd.org/tech-kern/2017/04/17/msg021825.html
2017-04-26 03:02:47 +00:00
riastradh 87fb32292e Make VOP_INACTIVE preserve vnode lock on return.
Discussed on tech-kern:
https://mail-index.netbsd.org/tech-kern/2017/04/01/msg021751.html

Ride 7.99.68, a bumpy bus of incremental vfs improvements!
2017-04-11 14:24:59 +00:00
riastradh 30509f8074 KASSERT(mutex_owned(vp->v_interlock)) in vnode iterator selector. 2017-04-01 19:35:56 +00:00
hannken 96f2116337 Remove now redundant calls to fstrans_start()/fstrans_done(). 2017-03-30 09:10:46 +00:00
hannken 326db3aaf6 Add generic genfs_suspendctl() and use it for all file systems.
Layered file systems need work.
2017-02-17 08:31:23 +00:00
hannken 7139aab724 Remove now obsolete operation vcache_remove().
Welcome to 7.99.36
2016-08-20 12:37:06 +00:00
dholland f048ac5803 typo in comment 2016-08-06 20:42:29 +00:00
riastradh 46e71c7d57 Make VOP_LINK return directory still locked and referenced.
Ride 7.99.10 bump.
2015-04-20 22:59:19 +00:00
maxv 6e39240181 Remove the 'cred' argument from bread(). Remove a now unused var in
ffs_snapshot.c. Update the man page accordingly.

ok hannken@
2015-03-28 19:24:04 +00:00
maxv bb338d5f26 Remove the 'cred' argument from breadn(), and update the man page
accordingly.

ok hannken@
2015-03-28 17:23:42 +00:00
riastradh 5a2d83e099 Disentangle buffer-cached I/O from page-cached I/O in UFS.
Page-cached I/O is used for regular files, and is initiated by VFS
users such as userland and NFS.

Buffer-cached I/O is used for directories and symlinks, and is issued
only internally by UFS.

New UFS routine ufs_bufio replaces vn_rdwr for internal use.
ufs_bufio is implemented by new UFS operations uo_bufrd/uo_bufwr,
which sit in ufs_readwrite.c alongside the VOP_READ/VOP_WRITE
implementations.

I preserved the code as much as possible and will leave further
simplification for future commits.  I kept the ulfs_readwrite.c
copypasta close to ufs_readwrite.c in case we ever want to merge them
back; likewise ext2fs_readwrite.c.

No externally visible semantic change.  All atf fs tests still pass.
2015-03-27 17:27:55 +00:00
christos aad3a792bf fix leak. Reported by:
http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4
2015-02-07 04:21:11 +00:00
christos cc74afd952 fix buf leak. Reported by:
http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4
2015-02-07 04:19:52 +00:00
hannken ba1d531e8e Change chfs from hashlist to vcache. 2015-01-11 17:29:57 +00:00
hannken bf7db7c8e6 Convert a bogus mnt_vnodelist traversal to vfs_vnode_iterator. 2015-01-11 17:28:22 +00:00
hannken 0a8dc26a6e Return immediately from successfull cache_lookup().
No need to unlock an unlocked vnode.
2015-01-11 17:27:54 +00:00
maxv be2f51b7f2 Do not uselessly include <sys/malloc.h>. 2014-11-09 18:23:28 +00:00
christos f694e9cab1 simplify. 2014-10-20 11:57:05 +00:00
maxv 12c7ae02a5 Memory leak.
Found by my code scanner.

ok christos@
2014-10-20 06:41:51 +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
joerg 73bd7ce90d Timestamps are bad sources of entropy, so just use cprng_fast32. 2014-09-08 17:41:11 +00:00
he 7fcec1e880 Plug memory leak in add_peb_to_free() and add_peb_to_in_use()
in case there's a duplicate in the tree.
2014-09-01 16:48:42 +00:00
he 9e25a2c2c8 Plug memory leak in error returns and normal operation in
chfs_gcollect_pristine().
2014-09-01 16:46:56 +00:00
he 3f59fd906f Plug memory leaks in error returns in chfs_readvnode(). 2014-09-01 16:33:20 +00:00
he cb8ef348c1 Plug memory leak in a corner case in chfs_get_data_nodes(). 2014-09-01 16:31:17 +00:00
he 84353ac61b Plug leak in chfs_scan_eraseblock() of the allocated buffer.
Make sure to release it both on success and failure returns.
OK'ed by ttoth@
2014-09-01 16:27:38 +00:00