aboutsummaryrefslogtreecommitdiff
path: root/sys
Commit message (Collapse)AuthorAgeFilesLines
* ufs_direnter: move directory truncation to ffs_vput_pair().Konstantin Belousov2021-02-123-25/+46
| | | | | | | | | | | | | | | | VOP_VPUT_PAIR() provides the hook to do the truncation right before unlock, which is required since truncation might need to fsync(), which itself might unlock the directory vnode. Set new flag IN_ENDOFF which indicates that i_endoff is valid and should be checked against inode size. Excessive size is chomped, but this operation is advisory and failure to truncate should not result in the failure of the main VOP. Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* ffs_vput_pair(): try harder to recover from the vnode reclaimKonstantin Belousov2021-02-121-3/+36
| | | | | | | | | | | | | | | | | In particular, if unlock_vp is false, save vp's inode number and generation. If ffs_inotovp() can re-create the vnode with the same number and generation after we finished with handling dvp, then we most likely raced with unmount, and were able to restore atomicity of open. We use FFSV_REPLACE_DOOMED there, to drop the old vnode. This additional recovery is not strictly required, but it improves the quality of the implementation. Suggested by: mckusick Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* FFS: implement special VOP_VPUT_PAIR().Konstantin Belousov2021-02-121-0/+55
| | | | | | | | | | | | It cleans IN_NEEDSYNC flag on dvp before returning, by applying ffs_syncvnode() until success or an error different from ERELOOKUP. IN_NEEDSYNC cleanup is required to avoid creating holes in the directories when extended into indirect block. Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* nfsserver: use VOP_VPUT_PAIR().Konstantin Belousov2021-02-121-16/+22
| | | | | | | | | | Apply VOP_VPUT_PAIR() to the end of vnode operations after the VOP_MKNOD(), VOP_MKDIR(), VOP_LINK(), VOP_SYMLINK(), VOP_CREATE(). Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* ffs_snapshot: use VOP_VPUT_PAIR after VOP_CREATE.Konstantin Belousov2021-02-121-2/+7
| | | | | | | | | If the snapshot embrio was reclaimed under us, return error outright. Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* Use VOP_VPUT_PAIR() for eligible VFS syscalls.Konstantin Belousov2021-02-123-21/+18
| | | | | | | | | | | The current list is limited to the cases where UFS needs to handle vput(dvp) specially. Which means VOP_CREATE(), VOP_MKDIR(), VOP_MKNOD(), VOP_LINK(), and VOP_SYMLINK(). Reviewed by: chs, mkcusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* nullfs: provide special bypass for VOP_VPUT_PAIRKonstantin Belousov2021-02-121-0/+49
| | | | | | | | | Generic bypass cannot understand the rules of liveness for the VOP. Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* Add VOP_VPUT_PAIR() with trivial default implementation.Konstantin Belousov2021-02-122-0/+24
| | | | | | | | | | | | | | | | | | | | | | The VOP is intended to be used in situations where VFS has two referenced locked vnodes, typically a directory vnode dvp and a vnode vp that is linked from the directory, and at least dvp is vput(9)ed. The child vnode can be also vput-ed, but optionally left referenced and locked. There, at least UFS may need to do some actions with dvp which cannot be done while vp is also locked, so its lock might be dropped temporary. For instance, in some cases UFS needs to sync dvp to avoid filesystem state that is currently not handled by either kernel nor fsck. Having such VOP provides the neccessary context for filesystem which can do correct locking and handle potential reclamation of vp after relock. Trivial implementation does vput(dvp) and optionally vput(vp). Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* vn_open(): If the vnode is reclaimed during open(2), do not return error.Konstantin Belousov2021-02-122-4/+9
| | | | | | | | | | | | | | Most future operations on the returned file descriptor will fail anyway, and application should be ready to handle that failures. Not forcing it to understand the transient failure mode on open, which is implementation-specific, should make us less special without loss of reporting of errors. Suggested by: chs Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* ufs_direnter/SU: unconditionally UFS_UPDATE inode when extending directoryKonstantin Belousov2021-02-121-3/+1
| | | | | | | | | | for all kinds of async/SU mount variants. Submitted by: mckusick Reviewed by: chs Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* ffs_syncvnode: only clear IN_NEEDSYNC after successfull syncKonstantin Belousov2021-02-121-1/+2
| | | | | | | | | | If it is cleaned before the sync, other threads might see the inode without the flag set, because syncing could unlock it. Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* Merge ufs_fhtovp() into ffs_inotovp().Konstantin Belousov2021-02-123-30/+17
| | | | | | | | | | The function alone was not used for anything but ffs_fstovp() for long time. Suggested by: mckusick Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* ffs_inotovp(): interface to convert (ino, gen) into alive vnodeKonstantin Belousov2021-02-124-29/+40
| | | | | | | | | | | | It generalizes the VFS_FHTOVP() interface, making it possible to fetch the inode without faking filehandle. Also it adds the ffs flags argument which allows to control ffs_vgetf() call. Requested by: mckusick Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* ffs: Add FFSV_REPLACE_DOOMED flag to ffs_vgetf()Konstantin Belousov2021-02-122-4/+8
| | | | | | | | | | | | It specifies that caller requests a fresh non-doomed vnode. If doomed vnode is found in the hash, it should behave similarly to FFSV_REPLACE. Or, to put it differently, the flag is same as FFSV_REPLACE, but only when the found hashed vnode is doomed. Reviewed by: chs, mkcusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* ffs: call ufsdirhash_dirtrunc() right after setting directory sizeKonstantin Belousov2021-02-123-6/+13
| | | | | | | | | | | Later processing of ffs_truncate() might temporary unlock the directory vnode, causing unsychronized dirhash and inode sizes if update is postponed to UFS_TRUNCATE() callers. Reviewed by: chs, mkcusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
* buf SU hooks: track buf_start() calls with B_IOSTARTED flagKonstantin Belousov2021-02-123-7/+27
| | | | | | | | | | | | | | | | | and only call buf_complete() if previously started. Some error paths, like CoW failire, might skip buf_start() and do bufdone(), which itself call buf_complete(). Various SU handle_written_XXX() functions check that io was started and incomplete parts of the buffer data reverted before restoring them. This is a useful invariant that B_IO_STARTED on buffer layer allows to keep instead of changing check and panic into check and return. Reported by: pho Reviewed by: chs, mckusick Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundations
* ffs_vnops.c: Move opt_*.h includes to the top.Konstantin Belousov2021-02-121-2/+3
| | | | | | | | | | as it is done in other places. Header files might need options defined for correct operation. Reviewed by: chs, mckusick Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week
* Fix blackhole/reject routes.Alexander V. Chernikov2021-02-111-2/+56
| | | | | | | | | | | | | | | | | | | Traditionally *BSD routing stack required to supply some interface data for blackhole/reject routes. This lead to varieties of hacks in routing daemons when inserting such routes. With the recent routeing stack changes, gateway sockaddr without RTF_GATEWAY started to be treated differently, purely as link identifier. This change broke net/bird, which installs blackhole routes with 127.0.0.1 gateway without RTF_GATEWAY flags. Fix this by automatically constructing necessary gateway data at rtsock level if RTF_REJECT/RTF_BLACKHOLE is set. Reported by: Marek Zarychta <zarychtam at plan-b.pwste.edu.pl> Reviewed by: donner MFC after: 1 week
* cam: Properly find the sim in the assertion in xpt_pollwait().John Baldwin2021-02-111-1/+2
| | | | | | | | I had missed merging this fixup into 447b3557a9cc5f00a301be8404339f21a9a0faa8 before pushing it. Pointy hat to: jhb MFC after: 2 weeks
* iscsi: Mark iSCSI CAM sims as non-pollable.John Baldwin2021-02-111-9/+1
| | | | | | | | | | | | | Previously, iscsi_poll() just panicked. This meant if you got a panic on a box when using the iSCSI initiator, the attempt to shutdown would trigger a nested panic and never write out a core. Now, CCB's sent to iSCSI devices (such as the sychronize-cache request in dashutdown()) just fail with a timeout during a panic shutdown. Reviewed by: scottl, mav MFC after: 2 weeks Sponsored by: Chelsio Differential Revision: https://reviews.freebsd.org/D28455
* cam: Don't permit crashdumps on non-pollable devices.John Baldwin2021-02-113-4/+7
| | | | | | | | | | | If a disk's SIM doesn't support polling, then it can't be used to store crashdumps. Leave d_dump NULL in that case so that dumpon(8) fails gracefully rather than having dumps fail at crash time. Reviewed by: scottl, mav, imp MFC after: 2 weeks Sponsored by: Chelsio Differential Revision: https://reviews.freebsd.org/D28454
* cam: Permit non-pollable sims.John Baldwin2021-02-113-1/+15
| | | | | | | | | | | | | | Some CAM sim drivers do not support polling (notably iscsi(4)). Rather than using a no-op poll routine that always times out requests, permit a SIM to set a NULL poll callback. cam_periph_runccb() will fail polled requests non-pollable sims immediately as if they had timed out. Reviewed by: scottl, mav (earlier version) Reviewed by: imp MFC after: 2 weeks Sponsored by: Chelsio Differential Revision: https://reviews.freebsd.org/D28453
* Widen ifnet_detach_sxlock coverageKristof Provost2021-02-113-7/+11
| | | | | | | | | Widen the ifnet_detach_sxlock to cover the entire vnet sysuninit code. This ensures that we can't end up having the vnet_sysuninit free the UDP pcb while the detach code is running and trying to purge the UDP pcb. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28530
* mlx4, mthca: Silence warnings about no-op alignment operationsMark Johnston2021-02-114-9/+13
| | | | | | | | | | | | | Since commit 8fa6abb6f4f64f ("Expose clang's alignment builtins and use them for roundup2/rounddown2"), clang emits warnings for several alignment operations in these drivers because the operation is a no-op. The compiler is arguably being too strict here, but in the meantime let's silence the warnings by conditionally compiling the alignment operations. Reviewed by: arichardson, hselasky MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D28576
* [udp] fix possible mbuf and lock leak in udp_input().Andrey V. Elsukov2021-02-111-5/+8
| | | | | | | | | | | | | | In error case we can leave `inp' locked, also we need to free mbuf chain `m' in the same case. Release the lock and use `badunlocked' label to exit with freed mbuf. Also modify UDP error statistic to match the IPv6 code. Remove redundant INP_RUNLOCK() from the `if (last == NULL)' block, there are no ways to reach this point with locked `inp'. Obtained from: Yandex LLC MFC after: 3 days Sponsored by: Yandex LLC
* [udp6] fix possible panic due to lack of locking.Andrey V. Elsukov2021-02-111-33/+28
| | | | | | | | | | | | | | | | | The lookup for a IPv6 multicast addresses corresponding to the destination address in the datagram is protected by the NET_EPOCH section. Access to each PCB is protected by INP_RLOCK during comparing. But access to socket's so_options field is not protected. And in some cases it is possible, that PCB pointer is still valid, but inp_socket is not. The patch wides lock holding to protect access to inp_socket. It copies locking strategy from IPv4 UDP handling. PR: 232192 Obtained from: Yandex LLC MFC after: 3 days Sponsored by: Yandex LLC Differential Revision: https://reviews.freebsd.org/D28232
* arm64: if_dwc is also needed by intel stratix10 platformEmmanuel Vadot2021-02-101-2/+3
| | | | MFC after: 3 days
* arm64: Add a SOC_BRCM_NS2 optionEmmanuel Vadot2021-02-103-3/+5
| | | | | | | | Only compile files needed for this platform if the option is enabled in the kernel config file. Add the option to GENERIC. MFC after: 3 days
* arm64: Make thunderx vnic file depend on soc_cavm_thunderxEmmanuel Vadot2021-02-101-4/+4
| | | | MFC after: 3 days
* arm64: Order sys/conf/files.arm64Emmanuel Vadot2021-02-101-420/+474
| | | | | | | | This is now easier to read and see what's compiled-in No functional changes intended. MFC after: 3 days
* netgraph/ng_bridge: Add counters for the first link, tooLutz Donnerhacke2021-02-101-21/+38
| | | | | | | | | | | For broadcast, multicast and unknown unicast, the replication loop sends a copy of the packet to each link, beside the first one. This special path is handled later, but the counters are not updated. Factor out the common send and count actions as a function. Reviewed by: kp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28537
* vm: Honour the "noreuse" flag to vm_page_unwire_managed()Mark Johnston2021-02-101-1/+1
| | | | | | | | | | | | | | | | | | This flag indicates that the page should be enqueued near the head of the inactive queue, skipping the LRU queue. It is used when unwiring pages from the buffer cache following direct I/O or after I/O when POSIX_FADV_NOREUSE or _DONTNEED advice was specified, or when sendfile(SF_NOCACHE) completes. For the direct I/O and sendfile cases we only enqueue the page if we decide not to free it, typically because it's mapped. Pass "noreuse" through to vm_page_release_toq() so that we actually honour the desired LRU policy for these scenarios. Reported by: bdrewery Reviewed by: alc, kib MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D28555
* Fix non-IPv6 build post 57785538c6e0d7e8ca0f161ab95bae10fd304047.Cy Schubert2021-02-101-4/+0
| | | | | | | | | | | | 57785538c6e0d7e8ca0f161ab95bae10fd304047 change the test for FreeBSD from __FreeBSD_version to __FreeBSD__. However this test was performed before sys/param.h was included, therefore __FreeBSD_version was never defined. As the test was never true opt_random_ip_id.h was never included. Submitted by: bdragon Reported by: bdragon MFC after: 1 week X-MFC with: 57785538c6e0d7e8ca0f161ab95bae10fd304047
* netgraph/ng_bridge: Document staleness in multithreaded operationLutz Donnerhacke2021-02-091-1/+4
| | | | | | | | | | | | In the data path of ng_bridge(4), the only value of the host struct, which needs to be modified, is the staleness, which is reset every time a frame is received. It's save to leave the code as it is. This patch is part of a series to make ng_bridge(4) multithreaded. Reviewed by: kp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28546
* netgraph/ng_bridge: Merge internal structuresLutz Donnerhacke2021-02-092-48/+44
| | | | | | | | | | | | | | | | In a earlier version of ng_bridge(4) the exernal visible host entry structure was a strict subset of the internal one. So internal view was a direct annotation of the external structure. This strict inheritance was lost many versions ago. There is no need to encapsulate a part of the internal represntation as a separate structure. This patch is a preparation to make the internal structure read only in the data path in order to make ng_bridge(4) multithreaded. Reviewed by: kp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28545
* Set file mode during zfs_writeAntonio Russo2021-02-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply https://github.com/openzfs/zfs/pull/11576 Direct commit from upstream openzfs. Full commit message below: Set file mode during zfs_write 3d40b65 refactored zfs_vnops.c, which shared much code verbatim between Linux and BSD. After a successful write, the suid/sgid bits are reset, and the mode to be written is stored in newmode. On Linux, this was propagated to both the in-memory inode and znode, which is then updated with sa_update. 3d40b65 accidentally removed the initialization of newmode, which happened to occur on the same line as the inode update (which has been moved out of the function). The uninitialized newmode can be saved to disk, leading to a crash on stat() of that file, in addition to a merely incorrect file mode. Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Antonio Russo <aerusso@aerusso.net> Closes #11474 Closes #11576 Obtained from: openzfs/zfs@f8ce8aed0 MFC after: 0 days Sponsored by: iXsystems, Inc.
* cache: assorted comment fixupsMateusz Guzik2021-02-091-7/+12
|
* Revert "amd64: implement strlen in assembly"Mateusz Guzik2021-02-092-66/+1
| | | | | | | | | | | This reverts commit af366d353b84bdc4e730f0fc563853abc338271c. Trips over '\xa4' byte and terminates early, as found in lib/libc/gen/setdomainname_test:setdomainname_basic testcase However, keep moving libkern/strlen.c out of conf/files. Reported by: lwhsu
* arm32: Align arguments of sync_icache() syscall to cacheline size.Michal Meloun2021-02-091-6/+3
| | | | | Otherwise, we may miss synchronization of the last cacheline. MFC after: 3 days
* loader: remove BORDER_PIXELSToomas Soome2021-02-091-1/+0
| | | | | | | | BORDER_PIXELS is left over from picking up the source from illumos port. Since FreeBSD VT does not use border in terminal size calculation, there is no reason why should loader use it. MFC after: 1 week
* kern: sonewconn: set so_options before pru_attach()Kyle Evans2021-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | Protocol attachment has historically been able to observe and modify so->so_options as needed, and it still can for newly created sockets. 779f106aa169 moved this to after pru_attach() when we re-acquire the lock on the listening socket. Restore the historical behavior so that pru_attach implementations can consistently use it. Note that some pru_attach() do currently rely on this, though that may change in the future. D28265 contains a change to remove the use in TCP and IB/SDP bits, as resetting the requested linger time on incoming connections seems questionable at best. This does move the assignment out from under the head's listen lock, but glebius notes that head won't be going away and applications cannot assume any specific ordering with a race between a connection coming in and the application changing socket options anyways. Discussed-with: glebius MFC-after: 1 week
* devfs: fix use count leak when using TIOCSCTTYMateusz Guzik2021-02-091-1/+1
| | | | | | by matching devfs_ctty_ref Fixes: 3b44443626603f65 ("devfs: rework si_usecount to track opens")
* Simplify the FreeBSD check using __FreeBSD__ compiler macro.Cy Schubert2021-02-0918-59/+59
| | | | | | | | Rather than rely on __FreeBSD_version, defined in sys/param.h, use __FreeBSD__ defined by the compiler. Reported by: emaste MFC after: 1 week
* ZFS: fix assertions with INVARIANTSAlan Somers2021-02-081-0/+2
| | | | | | | | | | | AFAICT, this was an oversight from 9e5787d2284e187abb5b654d924394a65772e004 (svn r364746). That revision inadvertently disabled assertions unconditionally. Reviewed by: freqlabs MFC after: 3 days Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D28256
* Revert "SO_RERROR indicates that receive buffer overflows should be handled ↵Alexander V. Chernikov2021-02-0819-79/+33
| | | | | | | | as errors." Wrong version of the change was pushed inadvertenly. This reverts commit 4a01b854ca5c2e5124958363b3326708b913af71.
* hid: bump HID_ITEM_MAXUSAGES to 8Warner Losh2021-02-081-1/+1
| | | | | | | | | | | My YOGA requires a minimum of 7 to parse w/o an error. Since the memory savings are trivial and the yoga a popular system, bump the default up to 8. There's no API/ABI issues in doing this. This hid_item struct isn't exported to userland and the one libusbhid has is different and only shares a name... MFC After: 3 days Reviewed by: wulf@ Differential Revision: https://reviews.freebsd.org/D28543
* acpi: limit the AMDI0020/AMDI0010 workaround to an optionWarner Losh2021-02-082-0/+4
| | | | | | | | | | | | | It appears that production versions of EPYC firmware get the _STA method right for these nodes. In fact, this workaround breaks on production hardware by including too many uart nodes. This work around was for pre-release hardware that wound up not having a large deployment. Move this work around to a kernel option since the machines that needed it have been powered off and are difficult to resurrect. Should there be a more significant deployment than is understood, we can restrict it based on smbios strings. Discussed with: mmacy@, seanc@, jhb@ MFC After: 3 days
* Turn off forgotten multipath debug messagesAlexander V. Chernikov2021-02-081-1/+0
| | | | | Reported by: mike tancsa<mike at sentex.net> MFC after: 3 days
* SO_RERROR indicates that receive buffer overflows should be handled as errors.Alexander V. Chernikov2021-02-0819-33/+79
| | | | | | | | | | | | Historically receive buffer overflows have been ignored and programs could not tell if they missed messages or messages had been truncated because of overflows. Since programs historically do not expect to get receive overflow errors, this behavior is not the default. This is really really important for programs that use route(4) to keep in sync with the system. If we loose a message then we need to reload the full system state, otherwise the behaviour from that point is undefined and can lead to chasing bogus bug reports.
* wsp: Add sysctl tunable for Z-Axis inversionVladimir Kondratyev2021-02-081-1/+6
| | | | | | | | | | This adds a new sysctl to Wellspring Touchpad driver for controlling Z-Axis (2-finger vertical scroll) direction "hw.usb.wsp.z_invert". Submitted by: James Wright <james.wright_AT_digital-chaos_DOT_com> Reviewed by: wulf PR: 253321 Differential revision: https://reviews.freebsd.org/D28521