summaryrefslogtreecommitdiff
path: root/sys/ufs/lfs
AgeCommit message (Collapse)Author
2023-04-11lfs: Assert page identity doesn't change.riastradh
Forgot what I was debugging when I inserted a relookup in my local tree months or years ago, but whatever it was, if that solved a problem, this KDASSERT will make the problem more obvious.
2022-08-07If UFS or LFS dirhash is enabled in the kernel, set the dirhash cachesimonb
size dependant on memory size. If less than 128MB of memory, default to no cache. With 128MB of memory or more, use a maximum cache size of 1/64th of memory; cap maximum default cache size to 32MB (for systems with 2GB of memory or more). The dirhash cache sizes are still explicityly setable by sysctl(8) or by adding relevant entry(s) to sysctl.conf(5).
2022-08-06s/blity/bility/ in various words, mainly in comments.andvar
2022-05-28s/grabing/grabbing/ in comments.andvar
2022-04-24lfs: fix lint warning about empty declarationrillig
2022-03-27add a kauth vnode check for creating linkschristos
2022-03-23fix few typos for word "previous(ly)" in comments.andvar
2022-03-19Remove now unused VV_LOCKSWORK, all file systems support locking.hannken
Remove unused predicates vn_locked() and vn_anylocked(). Welcome to 9.99.95
2021-10-20Overhaul of the EVFILT_VNODE kevent(2) filter:thorpej
- Centralize vnode kevent handling in the VOP_*() wrappers, rather than forcing each individual file system to deal with it (except VOP_RENAME(), because VOP_RENAME() is a mess and we currently have 2 different ways of handling it; at least it's reasonably well-centralized in the "new" way). - Add support for NOTE_OPEN, NOTE_CLOSE, NOTE_CLOSE_WRITE, and NOTE_READ, compatible with the same events in FreeBSD. - Track which kevent notifications clients are interested in receiving to avoid doing work for events no one cares about (avoiding, e.g. taking locks and traversing the klist to send a NOTE_WRITE when someone is merely watching for a file to be deleted, for example). In support of the above: - Add support in vnode_if.sh for specifying PRE- and POST-op handlers, to be invoked before and after vop_pre() and vop_post(), respectively. Basic idea from FreeBSD, but implemented differently. - Add support in vnode_if.sh for specifying CONTEXT fields in the vop_*_args structures. These context fields are used to convey information between the file system VOP function and the VOP wrapper, but do not occupy an argument slot in the VOP_*() call itself. These context fields are initialized and subsequently interpreted by PRE- and POST-op handlers. - Version VOP_REMOVE(), uses the a context field for the file system to report back the resulting link count of the target vnode. Return this in tmpfs, udf, nfs, chfs, ext2fs, lfs, and ufs. NetBSD 9.99.92.
2021-10-15fix typos in comments.andvar
2021-08-19s/memry/memory+s/softare/software/+s/grapics/graphics+s/ouput/outputandvar
2021-07-31s/threshhold/thresholdandvar
2021-07-25#include <sys/param.h> for COHERENCY_UNIT (and KNF)skrll
2021-07-18Abolish all the silly indirection macros for initializing vnode ops tables.dholland
These are things of the form #define foofs_op genfs_op, or #define foofs_op genfs_eopnotsupp, or similar. They serve no purpose besides obfuscation, and have gotten cutpasted all over everywhere.
2021-07-18Use macros for the canned parts of device and fifo vnode op tables.dholland
Add GENFS_SPECOP_ENTRIES and GENFS_FIFOOP_ENTRIES macros that contain the portion of the vnode ops table declaration that is (conservatively) the same in every fs. Use these in every fs that supports devices and/or fifos with separate ops tables. Note that ptyfs works differently (it has one type of vnode with open-coded dispatch to the specfs code, which I haven't changed in this commit) and rump/librump/rumpvfs/rumpfs.c has an indirect dynamic dispatch that already does more or less the same thing, which I also haven't changed. Also note that this anticipates a few bits in the next changeset here and there, and adds missing but unreachable calls in some cases (e.g. most fses weren't defining whiteout on devices and fifos, but it isn't reachable there), and it changes parsepath on devices and fifos to genfs_badop from genfs_parsepath (but it's not reachable there either). It appears that devices in kernfs were missing kqfilter, so it's possible that if you try to use kqueue on /kern/rootdev that it'll explode. And finally note that the ops declaration tables aren't order-dependent. (Other than vop_default_desc has to come first.) Otherwise this wouldn't work.
2021-06-29Add containment for the cloning devices hack in vn_open.dholland
Cloning devices (and also things like /dev/stderr) work by allocating a struct file, stuffing it in the file table (which is a layer violation), stuffing the file descriptor number for it in a magic field of struct lwp (which is gross), and then "failing" with one of two magic errnos, EDUPFD or EMOVEFD. Before this commit, all callers of vn_open in the kernel (there are quite a few) were expected to check for these errors and handle the situation. Needless to say, none of them except for open() itself did, resulting in internal negative errnos being returned to userspace. This hack is fairly deeply rooted and cannot be eliminated all at once. This commit adds logic to handle the magic errnos inside vn_open; now on success vn_open returns either a vnode or an integer file descriptor, along with a flag that says whether the underlying code requested EDUPFD or EMOVEFD. Callers not prepared to cope with file descriptors can pass NULL for the extra return values, in which case if a file descriptor would be produced vn_open fails with EOPNOTSUPP. Since I'm rearranging vn_open's signature anyway, stop exposing struct nameidata. Instead, take three arguments: an optional vnode to use as the starting point (like openat()), the path, and additional namei flags to use, restricted to NOCHROOT and TRYEMULROOT. (Other namei behavior, e.g. NOFOLLOW, can be requested via the open flags.) This change requires a kernel bump. Ride the one an hour ago. (That was supposed to be coordinated; did not intend to let an hour slip by. My fault.)
2021-06-29- Add a new vnode op: VOP_PARSEPATH.dholland
- Move namei_getcomponent to genfs_vnops.c and call it genfs_parsepath. - Add a parsepath entry to every vnode ops table. VOP_PARSEPATH takes a directory vnode to be searched and a complete following path and chooses how much of that path to consume. To begin with, all parsepath calls are genfs_parsepath, which locates the first '/' as always. Note that the call doesn't take the whole struct componentname, only the string. The other bits of struct componentname should not be needed and there's no reason to cause potential complications by exposing them.
2020-12-05Remove unnecessary inclusion of <sys/timevar.h>.thorpej
2020-09-07Suppress -Waddress-of-packed-member just for lfs_accessors.h.riastradh
We can remove -Wno-error=address-of-packed-member from various makefiles now.
2020-09-05Round of uvm.h cleanup.riastradh
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-05Revert "ufs: Prevent mkdir from choking on deleted directories."riastradh
This change made no sense and should not have been committed.
2020-09-05ufs: Prevent mkdir from choking on deleted directories.riastradh
Fix some missing uvm_vnp_setsize in screw cases while here.
2020-08-13Skip unlinked inodes.riastradh
They no longer matter on disk so we don't need to write anything out for them.
2020-08-04Mark lfs vnodes with VV_LOCKSWORK, same as ffs.riastradh
2020-06-11uvm_availmem(): give it a boolean argument to specify whether a recentad
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-05-16Add ACL support for FFS. From FreeBSD.christos
2020-04-23PR kern/54759 (vm.ubc_direct deadlock when read()/write() into mapping of ↵ad
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-13Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a functionad
that hides the details and does atomic_load_relaxed(). Signature matches FreeBSD.
2020-04-04Merge the remaining changes from the ad-namecache branch, affecting namei()ad
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-03-28Comment out some of the CTASSERTS for lint until I fix lint.christos
2020-03-21Avoid misaligned access to lfs64 on-disk records in memory.riastradh
lfs64 directory entries are only 32-bit aligned in order to conserve space in directory blocks, and we had a hack to stuff a 64-bit inode in them. This replaces the hack by __aligned(4) __packed, and goes further: 1. It's not clear that all the other lfs64 data structures are 64-bit aligned on disk to begin with. We can go through these later and upgrade them from struct foo64 { ... } __aligned(4) __packed; union foo { struct foo64 f64; ... }; to struct foo64 { ... }; union foo { struct foo64 f64 __aligned(8); ... } __aligned(4) __packed; if we really want to take advantage of 64-bit memory accesses. However, the __aligned(4) __packed must remain on the union because: 2. We access even the lfs32 data structures via a union that has lfs64 members, and it turns out that compilers will assume access through a union with 64-bit aligned members implies the whole union has 64-bit alignment, even if we're only accessing a 32-bit aligned member.
2020-03-21CTASSERT lfs on-disk structure sizes.riastradh
2020-03-17Tweak the March 14th change to make page waits interlocked by pg->interlock.ad
Remove unneeded changes and only deal with the PQ_WANTED flag, to exclude possible bugs.
2020-03-16Use the module subsystem's ability to process SYSCTL_SETUP() entries topgoyette
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-14Make uvm_pagemarkdirty() responsible for putting vnodes onto the syncerad
work list. Proposed on tech-kern@.
2020-03-14Make page waits (WANTED vs BUSY) interlocked by pg->interlock. Gets RWad
locks out of the equation for sleep/wakeup, and allows observing+waiting for busy pages when holding only a read lock. Proposed on tech-kern.
2020-03-14- Hide the details of SPCF_SHOULDYIELD and related behind a couple of smallad
functions: preempt_point() and preempt_needed(). - preempt(): if the LWP has exceeded its timeslice in kernel, strip it of any priority boost gained earlier from blocking.
2020-03-14OR into bp->b_cflags; don't overwrite.ad
2020-02-23UVM locking changes, proposed on tech-kern:ad
- 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-23Fix missing <sys/evcnt.h> by removing the evcnts instead.riastradh
Just wanted to confirm that a race might happen, and indeed it did. These serve little diagnostic value otherwise.
2020-02-23Fix !DIAGNOSTIC compilead
2020-02-23Dust off the orphan detection code and try to make it work.riastradh
2020-02-23Teach LFS_ORPHAN_NEXTFREE about lfs64.riastradh
2020-02-23lfs_writer_enter can't fail; keep it simple and don't pretend it can.riastradh
Assert that mtsleep can't fail either -- it doesn't catch signals and there's no timeout.
2020-02-23Call lfs_orphan in lfs_rename while we're still in the dirop.riastradh
2020-02-23In lfs_update, hold lfs_writer around lfs_vflush.riastradh
Otherwise, we might do lfs_vflush -> lfs_seglock -> lfs_segwait(SEGM_CKP) -> lfs_writer_enter which is the reverse of the lfs_writer -> lfs_seglock ordering.
2020-02-23Initialize/destroy lfs_allclean_wakeup in modcmd, not lfs_mountfs.riastradh
Fixes reloading lfs.kmod.
2020-02-23Break deadlock in PR kern/52301.riastradh
The lock order is lfs_writer -> lfs_seglock. The problem in 52301 is that lfs_segwrite violates this lock order by sometimes doing lfs_seglock -> lfs_writer, either (a) when doing a checkpoint or (b), opportunistically, when there are no dirops pending. Both cases can deadlock, because dirops sometimes take the seglock (lfs_truncate, lfs_valloc, lfs_vfree): (a) There may be dirops pending, and they may be waiting for the seglock, so we can't wait for them to complete while holding the seglock. (b) The test for fs->lfs_dirops == 0 happens unlocked, and the state may change by the time lfs_writer_enter acquires lfs_lock. To resolve this in each case: (a) Do lfs_writer_enter before lfs_seglock, since we will need it unconditionally anyway. The worst performance impact of this should be that some dirops get delayed a little bit. (b) Create a new lfs_writer_tryenter to use at this point so that the test for fs->lfs_dirops == 0 and the acquisition of lfs_writer happen atomically under lfs_lock.
2020-02-23Don't lfs_writer_enter while holding v_interlock.riastradh
There's no need to lfs_writer_enter at all here, as far as I can see. lfs_flush_fs will do it for us.
2020-02-23Take a reference and fix assertions in lfs_flush_dirops.riastradh
Fixes panic: KASSERT((ip->i_state & IN_ADIROP) == 0) at lfs_vnops.c:1670 lfs_flush_dirops lfs_check lfs_setattr VOP_SETATTR change_mode sys_fchmod syscall This assertion -- and the assertion that vp->v_uflag has VU_DIROP set -- is valid only until we release lfs_lock, because we may race with lfs_unmark_dirop which will remove the nodes and change the flags. Further, vp itself is valid only as long as it is referenced, which it is as long as it's on the dchain, but lfs_unmark_dirop drops the dchain's reference.