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.
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.
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>
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.
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.
* 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>
* 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.
* 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>
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>
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>
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>
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.
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>
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.
* 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.
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.
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.)
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.
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.