aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/p9fs
Commit message (Collapse)AuthorAgeFilesLines
* p9fs: Implement msize mount option and bump default to 128 KiBAlex Richardson33 hours3-4/+14
| | | | | | | | | | | | | | | QEMU warns when msize is <= 8192 due to degraded performance. This change bumps our default msize to 128 KiB, matching the Linux Kernel v5.15 and newer default. Linux supports even larger values, but 128 KiB is a sensible default. We also add a new 'msize' mount option to allow users to override this value, and we validate it against our maximum supported MTU (currently fixed by the UMA zone size). Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56496
* p9fs: Refactor buffer allocations to avoid zeroing large payloadsAlex Richardson33 hours2-55/+44
| | | | | | | | | | | | | | | | | | Allocating large buffers with M_ZERO adds unnecessary overhead since the data is immediately overwritten. This change embeds the tc and rc p9_buffer structs directly into p9_req_t so we only zero the small metadata headers. The actual data payload is allocated with M_NOWAIT. Embedding the metadata headers by value also allows the p9fs_buf_zone UMA items to be sized exactly to P9FS_MTU, ensuring they are nicely aligned. This also adds proper error handling to p9_get_request() to handle UMA allocation failures. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56495
* p9fs: Fix creating files with restrictive permissionsAlex Richardson2026-05-072-6/+32
| | | | | | | | | | | | | | | | | | | | | | | | When a file is created via p9fs with restrictive permissions (like 000), the 9P TCREATE request successfully creates and natively opens the file, returning an open, writable file descriptor. Previously, p9fs would attempt a subsequent TOPEN. That TOPEN would fail with EACCES due to the restrictive mode, leaving a 0-byte file and causing operations like 'mv' to abort. We now preserve the writable descriptor returned by TCREATE so that the subsequent VOP_OPEN can use it directly, avoiding the failing TOPEN. Additionally, p9fs_compatible_mode now appropriately isolates the base access intent when matching fids, preventing extended flags from breaking the match. A test case for this behavior has been submitted to pjdfstest: https://github.com/pjd/pjdfstest/pull/87 Resolves: https://github.com/CTSRD-CHERI/cheribsd/issues/2617 Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56494
* p9fs: implement basic pathconf supportAlex Richardson2026-05-072-2/+72
| | | | | | | | | | | | | | | | This is needed for various pjdfstest tests which fail with syntax errors if pathconf _PC_NAME_MAX/_PC_PATH_MAX return -1. For NAME_MAX we can use the 9P2000.L Tstatfs call to get namelen from the host. While this could theoretically be different for nested filesystems in the shared mount it is a much better guess than just returning 255. There does not seem to be a way to get the host PATH_MAX, so we just return the conservative kernel default. Found while fixing https://github.com/CTSRD-CHERI/cheribsd/issues/2617. Reviewed by: markj, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56493
* p9fs: Move UMA zone initialization to VFS module lifecycleAlex Richardson2026-05-071-0/+4
| | | | | | | | | | | | | | | | | | Previously, the UMA zones required for 9P requests (p9fs_buf_zone, p9fs_req_zone, etc.) were initialized and destroyed in the virtio_p9fs transport module. This caused issues when unloading the core p9fs module. This change moves p9_init_zones() and p9_destroy_zones() into p9fs_init() and p9fs_uninit() inside p9fs_vfsops.c so that they are correctly bound to the VFS filesystem module lifecycle via vfs_modevent, aligning p9fs with standard FreeBSD VFS semantics. Found while fixing https://github.com/CTSRD-CHERI/cheribsd/issues/2617. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56492
* pmap_qenter/qremove: Use void * instead of vm_offset_tJohn Baldwin2026-04-231-3/+3
| | | | | | | Effort: CHERI upstreaming Reviewed by: kib Sponsored by: AFRL, DARPA Pull Request: https://github.com/freebsd/freebsd-src/pull/2068
* p9fs: use atomics for updating node->flagsKonstantin Belousov2026-03-103-10/+13
| | | | | | | | | | This should prevent seeing inconsistent flags values when updating it under the shared vnode lock. Noted and reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D55665
* p9fs: locking improvements for p9fs_stat_vnode_dotl()Konstantin Belousov2026-03-101-3/+39
| | | | | | | | | | | | | | | | | If the vnode is share-locked: - Use vn_delayed_setsize() to avoid calling vnode_pager_setsize() with the vnode only shared locked. - Interlock the vnode to get exclusive mode for updating the node fields. Reciprocally, interlock the vnode in p9fs_getattr_dotl() to observe the consistent values on read. PR: 293492 Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D55665
* VOP_RENAME(9): add flags argumentKonstantin Belousov2026-03-051-0/+5
| | | | | | | | Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D55539
* p9fs: Use proper prototype for SYSINIT functionsZhenlei Huang2025-10-131-2/+1
| | | | MFC after: 1 week
* vfs: retire the NULLVP macroMateusz Guzik2025-09-272-8/+8
| | | | | | | | | | | | The kernel was already mostly using plain NULL, just whack it and be doen with the legacy. Churn generated with coccinelle: @@ @@ - NULLVP + NULL
* vfs: Introduce VN_ISDEV() macroDag-Erling Smørgrav2025-08-171-1/+1
| | | | | | | | | | | | | | We frequently need to check if a vnode refers to either a character or block special, so we might as well have a macro for it. We somewhat less frequently need to perform similar checks on things that aren't vnodes (usually a struct vattr *), so add VATTR_ISDEV() and a generic VTYPE_ISDEV() as well. Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D51947
* p9fs: Set vnode state in p9fs_vget_common()Mark Johnston2025-08-041-1/+1
| | | | | | | | | | | Once a new vnode is visible from the mountpoint hash, we should set its state from VSTATE_UNINITIALIZED to VSTATE_CONSTRUCTED. I do not think this affects correctness at all, but the bug trips a check in vop_unlock_debugpost(), previously hidden under options DEBUG_VFS_LOCKS. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D51720
* p9fs: Set *eofflag in p9fs_readdir()Mark Johnston2025-07-151-1/+7
| | | | | | Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D50760
* p9fs: Call VN_LOCK_ASHARE on new vnodesMark Johnston2025-06-131-0/+2
| | | | | | | | | | We set MNTK_LOOKUP_SHARED on p9fs mounts, but disable shared locking of vnodes (i.e., LK_SHARED requests are automatically translated to LK_EXCLUSIVE. Reviewed by: kib Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50759
* machine/stdarg.h -> sys/stdarg.hBrooks Davis2025-06-111-1/+1
| | | | | | | | | | | | | Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
* namei: Fix cn_flags width in various placesMark Johnston2025-05-271-1/+1
| | | | | | | | | This truncation is mostly harmless today, but fix it anyway to avoid pain later down the road. Reviewed by: olce, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D50417
* p9fs: Use UNLINKAT instead of REMOVE to implement removalsMark Johnston2024-11-074-7/+38
| | | | | | | | | | REMOVE doesn't work properly in the face of hard links. Use UNLINKAT instead, which is implemented by qemu and bhyve and lets the client specify the name being removed. PR: 282432 Reviewed by: dfr Differential Revision: https://reviews.freebsd.org/D47438
* p9fs: Fix whitespace in request tag handling functionsMark Johnston2024-10-251-11/+11
| | | | | | No functional change intended. Sponsored by: Klara, Inc.
* p9fs: Properly handle paths containing "."Bakul Shah2024-08-261-1/+1
| | | | | Fixes: 56e4622588ed ("p9fs: fix lookup of "." for lib9p-based 9P servers") Pull Request: https://github.com/freebsd/freebsd-src/pull/1361
* p9fs: remove duplicated codeDanilo Egea Gondolfo2024-07-131-10/+0
| | | | | | | | | | | | This code is using the vnode after it has been released and causing a panic when a p9fs shared volume is unmounted. In fact, it seems like it's just duplicated code left behind from a bad merge. PR: 279887 Reported by: Michael Dexter Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1323
* p9fs: implement working putpages (fix mmap write)Val Packett2024-06-242-0/+85
| | | | | | | | | | | Mostly copied from smbfs. This driver in its current state has the exact same issue that prevents the generic putpages implementation from working. Sponsored by: https://www.patreon.com/valpackett Reviewed by: dfr Differential Revision: https://reviews.freebsd.org/D45639 MFC after: 3 months
* p9fs: fix lookup of "." for lib9p-based 9P serversDoug Rabson2024-06-241-0/+6
| | | | | | | | | The lib9p implementation takes a strict interpretation of the Twalk RPC call and returns an error for attempts to lookup ".". The workaround is to fake the lookup locally. Reviewed by: Val Packett <val@packett.cool> MFC after: 3 months
* p9fs: Fix the build for 32-bit kernelsDoug Rabson2024-06-191-1/+1
| | | | MFC after: 3 months
* Add an implementation of the 9P filesystemDoug Rabson2024-06-1912-0/+5965
This is derived from swills@ fork of the Juniper virtfs with many changes by me including bug fixes, style improvements, clearer layering and more consistent logging. The filesystem is renamed to p9fs to better reflect its function and to prevent possible future confusion with virtio-fs. Several updates and fixes from Juniper have been integrated into this version by Val Packett and these contributions along with the original Juniper authors are credited below. To use this with bhyve, add 'virtio_p9fs_load=YES' to loader.conf. The bhyve virtio-9p device allows access from the guest to files on the host by mapping a 'sharename' to a host path. It is possible to use p9fs as a root filesystem by adding this to /boot/loader.conf: vfs.root.mountfrom="p9fs:sharename" for non-root filesystems add something like this to /etc/fstab: sharename /mnt p9fs rw 0 0 In both examples, substitute the share name used on the bhyve command line. The 9P filesystem protocol relies on stateful file opens which map protocol-level FIDs to host file descriptors. The FreeBSD vnode interface doesn't really support this and we use heuristics to guess the right FID to use for file operations. This can be confused by privilege lowering and does not guarantee that the FID created for a given file open is always used for file operations, even if the calling process is using the file descriptor from the original open call. Improving this would involve changes to the vnode interface which is out-of-scope for this import. Differential Revision: https://reviews.freebsd.org/D41844 Reviewed by: kib, emaste, dch MFC after: 3 months Co-authored-by: Val Packett <val@packett.cool> Co-authored-by: Ka Ho Ng <kahon@juniper.net> Co-authored-by: joyu <joyul@juniper.net> Co-authored-by: Kumara Babu Narayanaswamy <bkumara@juniper.net>