Commit Graph

289 Commits

Author SHA1 Message Date
mrg 931f53ce3f avoid an uninit warning with GCC 9. 2020-09-07 01:35:25 +00:00
christos 79e3c74f8e Introduce genfs_pathconf() and use it for the default case in all filesystems. 2020-06-27 17:29:17 +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 23bf88000c Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed().  Signature matches
FreeBSD.
2020-04-13 19:23:17 +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
pgoyette 9120d4511b Use the module subsystem's ability to process SYSCTL_SETUP() entries to
automate installation of sysctl nodes.

Note that there are still a number of device and pseudo-device modules
that create entries tied to individual device units, rather than to the
module itself.  These are not changed.
2020-03-16 21:20:09 +00:00
ad bf79731039 Tighten up the locking around vp->v_iflag a little more after the recent
split of vmobjlock & v_interlock.
2020-02-27 22:12:53 +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
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
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
kamil 417e06a66d Avoid undefined behavior semantics in msdosfs_fat.c
Do not change signedness bit with left shift.
While there avoid signed integer overflow.
Address both issues with using unsigned type.

msdosfs_fat.c:512:42, left shift of 1 by 31 places cannot be represented in type 'int'
msdosfs_fat.c:521:44, left shift of 1 by 31 places cannot be represented in type 'int'
msdosfs_fat.c:744:14, left shift of 1 by 31 places cannot be represented in type 'int'
msdosfs_fat.c:744:24, signed integer overflow: -2147483648 - 1 cannot be represented in type 'int [20]'
msdosfs_fat.c:840:13, left shift of 1 by 31 places cannot be represented in type 'int'
msdosfs_fat.c:840:36, signed integer overflow: -2147483648 - 1 cannot be represented in type 'int [20]'

Detected with micro-UBSan in the user mode.
2018-07-25 22:07:59 +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
sevan 87ebd86e7f Need strings.h for ffs()
Resolves implict declaration warning of ffs() when building tools via build.sh
2018-01-27 03:54:01 +00:00
mlelstv d8f0582ef8 relax sanity check. It's ok to have more FAT sectors than needed. 2017-11-27 15:02:05 +00:00
mlelstv 5815ca8f4d Add more sanity checks for BPB parameters. Handle FAT12 format for media
with sectors >= 32kByte.

Does fix PR 52485.
2017-08-20 11:48:15 +00:00
riastradh 93562e3f53 Eliminate crusty debugging sludge.
We have a mostly sane vnode lifecycle now.  If this needs debugging,
it should be done once at the call site of VOP_RECLAIM.
2017-05-26 14:34:19 +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
hannken 20bb034f5b Remove unused argument "nextp" from vfs_busy() and vfs_unbusy().
Remove argument "keepref" from vfs_unbusy() and add vfs_ref() where needed.
2017-04-17 08:32:00 +00:00
hannken ebb8f73b4b Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount.  Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).
2017-04-17 08:31:01 +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 61b2de1d70 Remove now redundant calls to fstrans_start()/fstrans_done(). 2017-03-01 10:41:28 +00:00
hannken a378d58ecb Enable fstrans on all file systems.
Welcome to 7.99.61
2017-02-22 09:50:13 +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 64a4d4bd11 Untangle VFS_SYNC() from VFS_SUSPENDCTL(). 2017-02-17 08:29:11 +00:00
hannken 4b595f6ef6 Take vnode lock for VOP_FSYNC(). 2017-02-17 08:27:20 +00:00
maya be48413a3c Be explicit about how we're placing part of the on-disk name into
the extension, so it doesn't appear like we are overrunning an array.
Appeases coverity, NFC.

ok riastradh
2017-01-14 17:17:53 +00:00
hannken 70ec436e39 Move vnode members "v_freelisthd" and "v_freelist" from "struct vnode"
to "struct vnode_impl" and rename to "vi_lrulisthd" and "vi_lrulist".

No functional change intended.

Welcome to 7.99.48
2016-12-14 15:48:54 +00:00
hannken 7139aab724 Remove now obsolete operation vcache_remove().
Welcome to 7.99.36
2016-08-20 12:37:06 +00:00
nonaka eafa673da3 Fix false positives when comparing long file names that have the
same first 13 (or some multiple thereof) characters.
2016-06-30 09:34:01 +00:00
mlelstv 09123a68b9 fix DEBUG build 2016-05-07 16:43:02 +00:00
mlelstv e01ac00248 Validate FAT entries to avoid some panics caused by a corrupted FAT.
Also print FAT write errors when mount is synchronous (-o sync). This
reveals problems caused by a write protected disklabel on sector 1.
2016-05-03 18:17:28 +00:00
mlelstv 200cdc61ea Use KASSERT for conditions that cannot be met with current parameters. 2016-03-06 07:33:25 +00:00
joerg 9cb0d31c43 Toolify. 2016-02-06 14:11:58 +00:00
mlelstv bbd8666d0f Split case folding table into separate source file and add full
copyright and permission notice from http://www.unicode.org/copyright.html
2016-02-06 10:40:58 +00:00
christos ae157f388e - split a long line.
- remove extra test.
- move d_namlen setting to msdosfs_vnops.c to avoid the ifdef.
2016-02-01 16:53:23 +00:00
martin 456f8519f7 Avoid unsigned/signed comparision warning to fix the build. 2016-02-01 10:37:57 +00:00
christos 76530fdb8e We can't depend on dp->d_namlen existing for the parts that are used in
makefs(8).
2016-02-01 02:59:33 +00:00
mlelstv 223c7df5b3 Add support to msdosfs and makefs to generate correct Unicode (UCS-2) directory
entries from UTF8 encoded file names.
2016-01-30 09:59:27 +00:00
dholland 398f572480 Apparently a recent round of vandalism by the C++ standards committee
includes disallowing the standard and historic type name "unsigned". Add
a gratuitous "int" to recent changes.

C++ is really a blight on the world.
2016-01-23 01:26:14 +00:00
dholland 25ebd28338 u_int{8,16,32}_t -> uint{8,16,32}_t, also u_int -> unsigned and
u_char -> unsigned char.
2016-01-22 22:53:36 +00:00
dholland cbeb02479d u_int8_t -> uint8_t 2016-01-22 22:48:18 +00:00
riastradh a26f29c67f Fix remaining read(fd, NULL, 1) cases. 2015-04-04 12:34:44 +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
christos 135c211dee catch up with DPRINTF change 2015-01-23 03:33:58 +00:00
christos 2d35608046 add some more paranoid checks about secsize and struct use. 2015-01-23 02:39:48 +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