Commit Graph

67310 Commits

Author SHA1 Message Date
Augustin Cavalier
6193a477b8 realtekwifi & net80211: Synchronize with FreeBSD.
As of upstream fcb5e8d0c19ac21515ab3047d39a76b32d835cec.
2024-12-05 23:18:45 -05:00
Augustin Cavalier
cd730cbd7c kernel/vm: Drop an actually obsolete comment.
This was introduced in hrev27179 to refer to the member "merge_swap",
which is now gone. The "busy_writing" field isn't used in Merge().
2024-12-05 17:13:26 -05:00
Augustin Cavalier
5cf7633a39 Revert "kernel/vm: Remove an obsolete comment."
This reverts commit 1db0961121.

It turns out the comment is not obsolete; what it refers to isn't
PAE systems but true 32-bit ones. I'm not sure we should use
64-bit cache offsets even there, but that's a decision for another
time.
2024-12-05 17:05:44 -05:00
Augustin Cavalier
319bd18c13 kernel/vm: Use KERNEL_TOP in place of (KERNEL_BASE + (KERNEL_SIZE - 1)).
No functional change.
2024-12-05 17:05:44 -05:00
Niklas Poslovski
5d5dabc2dd Backgrounds: Accept color drop only if color picker is enabled.
Fixes #19264

Change-Id: I90084ae15de4797e6184860af50128ea75dedebc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8656
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
2024-12-05 20:12:35 +00:00
Augustin Cavalier
2d6c8a8481 kernel/vm: Minor coding style cleanups. 2024-12-04 16:43:12 -05:00
Augustin Cavalier
245133b2c1 kernel/vm: Check for overflows in VMUserAddressSpace::CanResizeArea().
It can happen if a very large size is specified.
2024-12-04 16:42:57 -05:00
Augustin Cavalier
6bf630c684 tests/posix: Add symlink_create_test.
Combines the testcases from #19062 and #18355.
2024-12-04 14:09:41 -05:00
Augustin Cavalier
053116301e DebugAnalyzer: Increase the size of the buffer to print pointer values.
We need at least 19 characters on 64-bit architectures:
2 for "0x", 16 for the pointer, and 1 for the \0. So just
use a round 20.

Fixes cut-off pointer values in the display.
2024-12-04 13:38:14 -05:00
Augustin Cavalier
5434ba8dff kernel/debug: Report dummy names for THREAD_BLOCK_TYPE_OTHER_OBJECT.
So that DebugAnalyzer can display them properly.
2024-12-04 13:37:32 -05:00
Augustin Cavalier
149182f6ac kernel/fs: Don't report the leaf node in vnode_path_to_vnode unless it's last.
That is, if we have a path like "/nonexistent-1/nonexistent-2/file",
we shouldn't report "nonexistent-1" as the "leaf" node, but rather
nothing at all. Otherwise, create_vnode() that expects the result to be a
directory vnode plus a nonexistent file will get confused and try
to create a file "/nonexistent-1" rather than just bailing out.

This fixes #19062. The reproducer in that ticket caused a scenario
much like the above; and since rootfs doesn't support regular files,
it returned "EINVAL" when attempting to create the "/nonexistent" file.
After this change, we get ENOENT as expected.

Change-Id: Ifcaaa858403fb747858800afbf644051bb9913ad
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8621
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-04 17:06:59 +00:00
Augustin Cavalier
4c98a54842 kernel/fs: Minor cleanup to vnode_path_to_vnode and related methods.
No functional change intended.

Change-Id: Ie198854ef6bc434db87d362ebc31fd08ab44c176
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8620
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-04 17:06:59 +00:00
Augustin Cavalier
bef7e1c1b1 kernel/device_manager: Adjust assertion in IOBuffer::GetNextVirtualVec.
cookie->mapped_area may be < 0 but not -1 because map_physical_memory_vecs
previously failed.

Fixes #19273.
2024-12-03 15:50:37 -05:00
Augustin Cavalier
23b34b6c0e kernel/fs: Clean up code in synchronous_io.
Minor functional changes: slightly different log message,
error return of GetNextVirtualVec is actually reported properly.
2024-12-03 15:49:53 -05:00
Augustin Cavalier
20f109414c kernel/vm: Write adjacent pages in the page_writer, if possible.
This is an optimization in two ways: first, it allows us to avoid
unlocking the cache or needing the "unreferenced" store-ref acquisition
if we can write the next page in the same cache; and second, the
I/O will be much more tightly combined, as PageWriteTransfer will
be able to merge the iovecs more often and do less I/O (and on
spinning disks, we'll write adjacent regions more often, too.)

Based on some basic logging, this happens very often. I saw adjacent
writes numbers of e.g. 203, 255 (kNumPages), 139, 15, 99, etc. There
were a fair number of 0s, but that case shouldn't add too much overhead
since we bail out very rapidly.

In the case of things like "dd if=/dev/zero of=file ...", this is a
major optimization, since it massively reduces lock contention between
the dd thread and the page_writer thread.

A compile benchmark seems relatively similar, maybe slightly faster.
2024-12-03 13:59:35 -05:00
Augustin Cavalier
487d75717a kernel/disk_device_manager: Invoke base class in KFileDiskDevice::Unset().
Otherwise, the FD won't be closed, and then the underlying vnode
won't ever be released, leading to files whose space can't be reclaimed
without rebooting and running checkfs.
2024-12-03 13:18:07 -05:00
Augustin Cavalier
896f7fdb75 kernel/disk_device_manager: Cleanup code style, fix some minor TODOs. 2024-12-03 12:31:20 -05:00
Jim906
1a98f27639 Tracker: handle case-insensitive move target error
* Do not call entry_cache_add_missing from the FAT driver, because it
  can lead the VFS to believe a filename is missing when it is
  actually present (in a different case).
* Remove CopyFile code that was added to handle a race condition when
  dragging multiple files to a FAT volume.  The race condition only
  occurred in the first place because of the above driver bug.
* Ensure the FAT driver can fail gracefully if dosfs_read_vnode is
  called with an inode number that is not present in the FAT vcache.
  Without any 'missing' entries in the entry cache, there is an
  increased chance that multiple (non-missing) entries representing
  the same file will be added to the entry cache, which can result in
  the VFS calling the FS get_vnode hook on a file after it has been
  unlinked.
* Follows up on https://review.haiku-os.org/c/haiku/+/7623.

Change-Id: I5667119d8149954e0c8a5829617a7d93a6fc7aae
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8595
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-03 16:09:11 +00:00
Augustin Cavalier
1fd15efda9 BTimedEventQueue: Use mutex_init to appease GCC2. 2024-12-02 14:06:14 -05:00
Augustin Cavalier
0ffb72029d BTimedEventQueue: Flush events on destruction, other minor cleanup.
* The Be Book specifies that events will be flushed on destruction.
   The previous implementation of this class didn't do that, but
   we ought to. Unless the queued events have attached buffers or
   a cleanup hook, this is a no-op anyway.

 * Use a mutex rather than a BLocker for the allocation lock. This
   saves a semaphore per queue.

 * Put the queue_entry in an anonymous namespace. It shouldn't have
   any global symbols anyway, but it doesn't hurt.
2024-12-02 13:57:03 -05:00
Jérôme Duval
d866277547 virtio_pci: in setup_queue(), only check queue number on v1 devices
* fix #18962
* bus->queue_count wasn't initialized yet so the check could succeed
or not, depending on the init value for memory: on release, 0 mostly,
on nightly, a non-zero value.

Change-Id: Id745932e8171abe3b8b78a3e9b2f2058c9507f7a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8618
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-12-01 19:32:25 +00:00
Autocomitter
b6190d29d6 Update translations from Pootle 2024-11-30 08:07:48 +00:00
Augustin Cavalier
4055af5143 BTimedEventQueue: Rewrite from scratch, avoiding malloc().
The previous implementation allocated and freed event objects
on every insertion and removal using malloc()/free(). It was also
licensed under a "distributions in binary form must reproduce ...
in the binary" license, which is more restrictive than the MIT license
that we prefer.

So, this is a rewrite from scratch. It uses the standard
DoublyLinkedList<> rather than rolling its own, and manages
a free list of event queue objects rather than hitting malloc()
all the time. It only frees chunks on destruction, though,
but that hopefully won't be an issue anyway.

All tests from the TimedEventQueueTest still pass, and media playback
still works as before.

Change-Id: Ia940b6176f8051ae4823b75acd305ded8783d1e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8594
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-28 17:48:23 +00:00
Oscar Lesta
2d54103521 mount_server: Tweak the scoring values to avoid (some) false positives.
Before this, having partitions with the same fsName, blocksize, and capacity,
was enough to be considered a match for `initialMountRestore` mode.

That is too prone to false positives.

Now we require those three values, plus either deviceName, or volumeName
(or both) to match, before considering a partition as a valid match for
auto-mounting.

Fixes #19253.

Modifications by waddlesplash: put the score in an enum, and use
bitwise operations in checking the score.

Change-Id: Ifae63cd8e51fe5c8a38130130343a7209bff6d0a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8565
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-26 20:35:36 +00:00
Augustin Cavalier
bb1f240594 file_systems: Invert query equation scoring values.
Previously, lower was better, and higher was worse. But really we want
the scores to be based primarily around the index sizes, which can
grow to be very large, so a maximum score is hard to determine.

Instead, start with the index size, and then divide to make it smaller
based on how "useful" the equation terms will be in searching it.

Improves the performance of queries like those in #19080; according
to humdinger's testing, the query with the most expensive term first
went from ~2.0s execution time down to ~0.7s, same as the query with
the least expensive term first.

Change-Id: Id71fa21c95cfe3d8d0019ff356bdf4935446411f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8593
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-26 17:13:29 +00:00
PulkoMandy
8fbddf13a1 POSIX 2024: add mkostemp
Change-Id: I254b3e5c64f5036e99a94513f05d8c491cbd6273
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8590
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-11-25 22:01:21 +00:00
Augustin Cavalier
4da2ed4103 kernel/vm: Let TRACE_FAULTS enable logging of all faults.
This amends 0f42cf8d7d.

That commit accidentally contained an unrelated patch to the one
described in the commit message, turning a number of prints that
happened unconditionally to ones that happened only for faults
occurring in kernel context. This change re-enables those prints
when TRACE_FAULTS is set (which it isn't by default.)

The original change to reduce prints was done to cut down on syslog spam
from applications like Boehm-GC, the JVM, or emulators that trigger
many (thousands or more) faults on purpose and then catch them in
signal handlers. In the case where these faults are crashes, then
the debug_server will still log those crashes into the syslog anyway.
2024-11-25 14:02:38 -05:00
waddlesplash
e4b10ec126 Revert "ps2_dev: shorter timeout for mouse reset"
This reverts commit 8a00ea4af6.

Reason for revert: #19266.

Change-Id: Ifecd8eac87eb3dd4f5f92a98bf849066db6ba8ed
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8598
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-25 18:55:22 +00:00
Augustin Cavalier
0f42cf8d7d kernel/vm: Handle dynamically-sized commitments properly in copy_area and cut_area.
And handle another corner case in set_memory_protection.

This should fix the remaining causes of #19012.

Change-Id: I92fc184024ffb3923239da5e0bd90efc3085da28
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8589
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-25 18:46:43 +00:00
Augustin Cavalier
3f928f8e10 kernel/vm: Correct address passed to VMCache::LookupPage.
LookupPage() takes an offset in the cache, not a global address.

Helps with #19012, but there are other causes still to be solved.
2024-11-23 13:43:57 -05:00
Autocomitter
f817735275 Update translations from Pootle 2024-11-23 08:09:30 +00:00
Augustin Cavalier
608fd0cdb9 RAMFS: More cleanup of Locker usages in kernel_interface.
No functional change intended.
2024-11-22 23:29:41 -05:00
Augustin Cavalier
ce5375c0bf RAMFS: ramfs_close_attr needs a write-lock. 2024-11-22 21:30:18 -05:00
Augustin Cavalier
bab3f64413 RAMFS: Lock attribute iterators separate from entry iterators.
And clean up the code style while at it.
2024-11-22 20:29:18 -05:00
Augustin Cavalier
e2e7d84d21 RAMFS: Properly check that the Lockers are actually locked.
They pretty much always will be, but better to be safe. Also
de-indent one level and use an early return for this.
2024-11-22 18:07:26 -05:00
Augustin Cavalier
374d7a1eb1 RAMFS: Minor code style cleanups to Volume. 2024-11-22 17:42:00 -05:00
Augustin Cavalier
fe0e833f1f fat, exfat: Add acquire_vnode/put_vnode calls in the I/O hooks.
Same as was done in BFS.
2024-11-22 16:57:27 -05:00
Augustin Cavalier
9708b08060 KPath: Use a default buffer size of B_PATH_NAME_LENGTH without + 1.
B_PATH_NAME_LENGTH == PATH_MAX, and PATH_MAX is inclusive of the final
NULL terminator, so we don't need a + 1 here.

The original KPath default was to not use + 1, but that was changed in
42e3c6f978 due to all the consumers that did.

But all those consumers are wrong, it appears; they should just be
using the default length instead. So now we do that.
2024-11-22 16:56:15 -05:00
Augustin Cavalier
cc9ea55c59 file_systems/QueryParser: Coerce types up front, and handle B_TIME_TYPE better.
* If we coerce types inside the switch(), then the "type already converted"
   check at the beginning will fail every time, causing us to reconvert,
   which is surely bad for performance.

 * B_TIME_TYPE should be INT32 or INT64 depending on what its size is.

May help with #19080.
2024-11-21 23:19:09 -05:00
Augustin Cavalier
783b77b14f BFS: Fix handling of the last_modified index.
Its values must be shifted before comparing against them.
Also handle the last-modified times correctly in NodeGetLastModifiedTime.

Fixes an issue noticed in #19080 which was a regression from
the query refactor earlier this year.

Also while at it, remove a needless lock in EntryGetName;
Inode::GetName acquires this lock for us.
2024-11-21 22:38:41 -05:00
Augustin Cavalier
1abf2059a7 BFS: Adjust CachedNode::SetToWritable for consistency with SetTo.
Follow-up to an old review comment.
2024-11-21 22:38:41 -05:00
Jérôme Duval
fbdac8d61e headers: Don't define static_assert for C23 and C++
Change-Id: I1e67b09b2a310de5cf41c4eef9af46f78b4e9de0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8586
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2024-11-21 19:26:51 +00:00
Augustin Cavalier
7de59aee29 realtekwifi: Import changes from FreeBSD HEAD.
Same source commit as the previous import of net80211 changes.

May help with USB stalls and other issues.
Tested, WiFi still works.
2024-11-21 10:43:40 -05:00
Augustin Cavalier
da3ca31854 freebsd_wlan: Synchronize net80211 with FreeBSD.
From upstream commit d99eb8230eb717ab0b2eba948614d0f2f2b5dd2b.

Includes a variety of new macros that are used by drivers.
2024-11-21 10:40:37 -05:00
Augustin Cavalier
56c5e34285 freebsd_network: Use if_inc_counter and add to the "drops" counter in HANDOFF. 2024-11-20 18:46:55 -05:00
Augustin Cavalier
f42bea3139 freebsd_wlan: Use vap->iv_output as on FreeBSD.
We pass a NULL destination address, so we need to keep the added
NULL check, but after the previous commit we can now use the
real hook function here.

WiFi still works (tested with realtekwifi.)
2024-11-20 18:46:32 -05:00
Augustin Cavalier
99dcbd9716 freebsd_network: Use if_transmit in ether_output.
This is what FreeBSD does. The default implementation (in this
same file) does what ether_output did before, but the FreeBSD
net80211 stack overrides the method.
2024-11-20 18:45:44 -05:00
Augustin Cavalier
551a9b9a01 BFS: Keep references to vnodes during asynchronous I/O.
IORequest notifications begin by notifying the "finished" condition,
then invoking the request callback, then invoking the parent callback.

vfs_{read|write}_pages wait on the "finished" condition and then
return at once, potentially releasing their references to the vnode
in question, before the request callback is even invoked. The request
callback is what (eventually) invokes iterative_io_finished_hook,
which meant that we were accessing the Inode object after our reference
to it had already been released.

We can't really change IORequest notification order, as any one of the
notifications could delete the request, and indeed the first one does here.
So the solution is just to acquire another reference to the vnode and
release it in the finished hook.

Fixes #19122 and #8405.
2024-11-20 18:03:09 -05:00
Augustin Cavalier
138d92635d kernel/block_cache: More 32-bit fixes. 2024-11-20 17:25:50 -05:00
Augustin Cavalier
282ff4240a kernel/block_cache: Adjust declaration of _IOFinished. 2024-11-20 16:48:07 -05:00