Commit Graph

191 Commits

Author SHA1 Message Date
christos 79e3c74f8e Introduce genfs_pathconf() and use it for the default case in all filesystems. 2020-06-27 17:29:17 +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 9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
jdolecek 5dec3f0781 when determining I/O block size for VBLK device, only use pi_bsize
returned by DIOCGPARTINFO if it's bigger than DEV_BSIZE and less
than MAXBSIZE (MAXPHYS)

fixes panic "buf mem pool index 8" in buf_mempoolidx() when the
disklabel contains bsize 128KB and something reads the block device -
buffer cache can't allocate bufs bigger than MAXPHYS
2020-04-13 20:02:27 +00:00
christos 02cdd248ec Add a new member to struct vfsstat and grow the unused members
The new member is caled f_mntfromlabel and it is the dkw_wname
of the corresponding wedge. This is now used by df -W to display
the mountpoint name as NAME=
2019-09-22 22:59:37 +00:00
riastradh d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
hannken 3764143ef7 Refuse to open a block device with zero open count when it has
a mountpoint set.  This may happen after forced detach or unplug
of a mounted block device.
2017-06-24 12:14:21 +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
martin c3c564b370 Make the non-DIAGNOSTIC version compile 2017-04-12 06:43:56 +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
hannken 88ed6a1725 Add a diagnostic test for buffers written to a block device holding
a read-only mounted file system.

This will become a KASSERT in the near future.
2017-03-01 10:46:05 +00:00
hannken 998709c439 Rename vget() to vcache_vget() and vcache_tryvget() respectively and
move the definitions to sys/vnode_impl.h.

No functional change intended.

Welcome to 7.99.54
2017-01-02 10:33:28 +00:00
nat f1631e52a4 Add functions to access device flags. This restores simultaneous audio
open/close.

OK hannken@ christos@
2016-12-09 19:13:47 +00:00
nat 82924a36bf The audio sub-system now supports the following features as
posted to tech-kern:

    * Simultaneous playback and mixing of multiple streams
    * Playback streams can be of different encoding, frequency, precision
      and number of channels
    * Simultaneous recording to different formats
    * One audio device per process
    * Sysctls to set the common format frequency, precision and channels
    * Independent mixer controls for recording/playback per stream
    * Utilizes little cpu time for multiple streams / good performance
    * Compatible with existing programs that use OSS/NetBSD audio
    * Changes to audioctl(1) to allow specifying process id for corresponding
      audio device
2016-12-08 10:28:44 +00:00
pgoyette 7dfb5aa5af Revert rev 1.164. This will be redone differently (using "dummy"
modules).

This implementation requires changes to a base kernel in order to
update the set of "special" modules, kinda defeating the purpose of
having modules in the first place.  The new method will use dummy
modules (with name tap and tun) which will depend on the real
modules with the if_ prefix.

Coming soon to a NetBSD near you.
2016-09-08 08:45:52 +00:00
pgoyette 75d5796c6e if_config processing wants to auto-load modules named with an if_ prefix,
while specfc wants to auto-load modules without the prefix.  For modules
which can be loaded both ways (ie, if_tap and if_tun), provide a simple
conversion table for specfs so it can auto-load the if_ module.

This table should always be quite small, and the auto-load operation is
relatively infrequent, so the additional overhead of comparing names should
be tolerable.
2016-09-08 00:07:48 +00:00
hannken 7139aab724 Remove now obsolete operation vcache_remove().
Welcome to 7.99.36
2016-08-20 12:37:06 +00:00
hannken 1c27fb53ee Avoid a race with spec_revoke for the assertion too.
Final fix for PR kern/50467 Panic from disconnecting phone while reading
its contents
2016-04-04 08:03:53 +00:00
hannken d222105946 Whhen spec_strategy() extracts v_rdev take care to avoid a
race with spec_revoke.

Fixes PR kern/50467 Panic from disconnecting phone while reading its contents
2016-03-26 14:58:13 +00:00
pgoyette 64f5396545 Fix a couple of checks for kernel vm_space, and convert the 'naked
panic" code to KASSERT/KASSERTMSG.

Thanks,  Taylor!
2016-01-05 09:07:19 +00:00
pgoyette 69c1560ae5 Revert previous 2015-12-23 00:13:57 +00:00
pgoyette 3139a51881 If we attempt to autoload a driver module, make sure we return an error
if it fails.  Otherwise we might end up calling a builtin-but-disabled
driver module and that can generate all sorts of issues...
2015-12-22 23:54:37 +00:00
christos 8d10f96266 Replace DIOCGPART -> DIOCGPARTINFO which returns the data needed instead of
pointers.
2015-12-08 20:36:14 +00:00
christos 317f295fe6 unfortunately it is not that easy to get rid of DIOCGPART. DTRT for the
raw partition and print a warning if we overflowed. I guess the right solution
for this is to create yet another version of disklabel that is 64 bit friendly.
2015-12-08 01:57:13 +00:00
jnemeth 0a6f855e11 messing with uninitialized structs is a bad thing 2015-12-05 07:59:34 +00:00
christos 0f40b4d84e Use DIOCGMEDIASIZE instead of DIOCGPART so that we are not limited to 2G.
XXX: All DIOCGPART code needs to be removed...
XXX: pullup-7
2015-12-04 23:54:06 +00:00
hannken 418d71fb1c Unfortunately MFS uses v_data of its anonymous device vnode so
it cannot be used as vcache key.  Use v_interlock as key ...
2015-07-01 08:13:52 +00:00
hannken af0e5d04e4 Redo previous again, v_specnode is invariant but not unique.
Set "vp->v_data = vp" and use v_data as key.
2015-06-30 06:19:21 +00:00
hannken c6ee9f5027 Use the address of vp->v_specnode as vcache key. It is invariant
over the lifetime of the vnode.

The previous worked by luck, it took the first sizeof(void *) bytes
of struct vnode as key.

Resolves CID 1308957: wrong sizeof()
2015-06-29 16:48:20 +00:00
christos 3c9a847ffa Revert previous, and explain why. 2015-06-29 16:25:49 +00:00
christos f42b0aee93 CID 1308957: Fix wrong sizeof() 2015-06-29 15:39:40 +00:00
hannken 4e19d4c756 Add a vfs_newvnode() method to deadfs and use it to create
anonymous device vnodes with bdevvp() and cdevvp().

Implement spec_inactive() and spec_reclaim() to handle these nodes.
2015-06-23 10:42:34 +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
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
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
dholland 2b17a74d70 Implement spec_fdiscard() using bdev_discard() and cdev_discard().
Also define spec_fallocate() to genfs_eopnotsupp().
2014-07-25 08:19:19 +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 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 3881f4f3f9 Replace macro v_specmountpoint with two functions spec_node_getmountedfs()
and spec_node_setmountedfs() to manage the file system mounted on a device.
Assert the device is a block device.

Welcome to 6.99.24

Discussed on tech-kern@ some time ago.

Reviewed by: David Holland <dholland@netbsd.org>
2013-09-30 18:57:59 +00:00
dholland 8238e5b049 oops, spell b_bcount properly 2013-07-20 23:00:08 +00:00
dholland be719d1e75 In spec_strategy, if fscow_run() fails, set b_resid along with b_error
to avoid panic in biodone. Noticed by riastradh.
2013-07-20 22:42:59 +00:00
dholland 4c09dd2f8a Hang a warning banner on some nasty code I just found. 2013-06-16 20:46:24 +00:00
dholland f2458c3ff1 add missing spec_whiteout 2013-04-21 04:55:40 +00:00
hannken 9f9ac3cb83 Make the spec_node table implementation private to spec_vnops.c.
To retrieve a spec_node, two new lookup functions (by device or by mount)
are implemented.  Both return a referenced vnode, for an opened block device
the opened vnode is returned so further diagnostic checks "vp == ... sd_bdevvp"
will not fire.  Otherwise any vnode matching the criteria gets returned.

No objections on tech-kern.

Welcome to 6.99.17
2013-02-13 14:03:48 +00:00
hannken 312d89f0de Change bread() and breadn() to never return a buffer on
error and modify all callers to not brelse() on error.

Welcome to 6.99.16

PR kern/46282 (6.0_BETA crash: msdosfs_bmap -> pcbmap -> bread -> bio_doread)
2012-12-20 08:03:41 +00:00
chs 8306a9eddf change vflushbuf() to take the full FSYNC_* flags.
translate FSYNC_LAZY into PGO_LAZY for VOP_PUTPAGES() so that
genfs_do_io() can set the appropriate io priority for the I/O.
this is the first part of addressing PR 46325.
2012-04-29 22:53:59 +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
hannken 64ee4fdf9f Remove no longer needed flag FSYNC_VFS /* fsync: via FSYNC_VFS() */. 2011-04-27 09:46:27 +00:00
hannken 87522af425 Change vflushbuf() to return an error if a synchronous write fails.
Welcome to 5.99.51.
2011-04-26 11:32:38 +00:00