History log of /haiku/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp
Revision Date Author Comments
# 53bc9ad0 28-Nov-2023 Alexander von Gluck IV <kallisti5@unixzen.com>

bfs: Reduce potential for garbage value ingestion

* Pointed out by clang static analysis. These are
later read while not being completely validated.

Change-Id: I4546526535d6e011aee40c74136f992962ab8cff
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7159
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# cba63b64 05-Jan-2021 Adrien Destugues <adrien.destugues@opensource.viveris.fr>

bfs: build fix.

I built only the bootloader for sparc when testing, so some code was
disabled because it's guarded by _BOOT_MODE.

Confirmed that the generated assembler is not larger than before (the
disassembly file is the same size, but for some reason functions were in
a different order, making it difficult to compare more closely)


# 60f8e54f 05-Jan-2021 PulkoMandy <pulkomandy@pulkomandy.tk>

bfs: fix misaligned access

The BFS on-disk data is not aligned. Reading it to memory and trying to
access fields directly does not work on sparc. memcpy the data to an
aligned variable before handling it with its native size.

gcc knows how to access unaligned data, but we need to tell it when to do
so. This is done with the "packed" attribute, but it works only on
structs. So we have to wrap the values in a struct.

Thanks to C++ features, we can make the struct
relatively transparent by having an assigment operator (for writes) and
a cast operator (for read access), so there is no need to access the
value inside the struct with ".value" everywhere. The rest of the code
is then largely unchanged (except for use in printf statements and other
vararg functions, where the implicit casting can't work).

gcc takes care of performing the access in the correct way on platforms
that need it (old ARM, sparc) and can still optimize things on other
architectures where specific code is not needed for unaligned access.

Fixes #9255

Change-Id: I3bf62590dee059ad32b1845bdc4eace165b73203
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2363
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# ee8cf35f 06-Apr-2020 Kyle Ambroff-Kao <kyle@ambroffkao.com>

bfs: Return B_NAME_TOO_LONG from BPlusTree::Find

This patch makes "UnitTester BNode" pass.

Several tests which attempt to create or access a directory entry that
exceeds the maximum length assume that B_NAME_TOO_LONG status will be
returned, since that is what BeOS does. When constructing a BNode with
a path like "/tmp/some really long filename larger than 256
characters...", the vfs eventually calls bfs_lookup() which calls
BPlusTree::Find(). In the case of a really long entry, Find() returns
B_BAD_VALUE.

This patch just changes BPlusTree::Find to return the more specific
error that matches BeOS.

Additionally this patch fixes some assertions in NodeTest. BeOS seems
to have been missing some error checking code in the initialization of
BNode, specifically with BNode(Directory*, const char*) and the
equivalent SetTo method. If you provide an empty string for the child
entry name to either of those, B_OK will be returned. But either way
you initialize the object, when you try to use it, like with
BNode::GetAttrInfo(), you'll get B_BAD_VALUE.

This just changes any assertions for this situation to expect
B_ENTRY_NOT_FOUND, which is the actual initialization error Haiku
sets.

This and the change to bfs resolves many assertions the following
storage tests:
* TestCaller BFile::Init Test 1
* TestCaller BFile::Init Test 2
* TestCaller BNode::Init Test1
* TestCaller BNode::Init Test2
* TestCaller BSymLink::Init Test 1
* TestCaller BSymLink::Init Test 2

Change-Id: I8598352aa341ffcab9f7bc3e6740ae1cb3dbab8c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2490
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 3431d8f2 14-Apr-2017 Axel Dörfler <axeld@pinc-software.de>

BFS: Fixed readdir() again.

* We still need to return B_BUFFER_OVERFLOW if the passed in buffer was
smaller than INODE_FILE_NAME_LENGTH, as that's what must be expected
from the caller.


# 4069e1f3 08-Apr-2017 Axel Dörfler <axeld@pinc-software.de>

BFS: Fixed maximum index key length.

* The maximum key length of the B+tree, and the one BFS uses are now
separated. This allows to stay BeOS compatible to only put a maximum
of 255 bytes into the index, but also to handle the already existing
larger keys (we did allow 256 bytes) without issue.
* TreeIterator::Traverse() now always cuts off string keys at the
maximum buffer length, and only reports a B_BUFFER_OVERFLOW for the
fixed length types.
* This fixes the important part of #13254.


# 1e6dd3fe 24-Apr-2015 Murai Takashi <tmurai01@gmail.com>

Fix GCC 5 maybe-uninitialized warnings.

Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

Fixes #12020


# 8b6e513a 19-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

BFS: _SplitNode() could overflow the new node.

* When the keys were large enough, a large key entering the node could
overflow the available data in the target node. This caused tree and
memory corruption.
* This fixes bug #6034.


# 33d9fb86 19-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

BFS: Fix check of key compare in BPlusTree::_ValidateChildren().

In ba320218245aeb11cb74c37ecf7132d0b9903957 the key comparison was fixed
to use a compatible version. Since then the check can actually return
results other than -1. The check done on the result was too strict
however. The child nodes may never contain keys that are larger than the
keys they are reached by. But the last key of a child node may be equal
to the one in the parent. This change fixes the check to take this
special case into account.

Fixes #11026 and #11289. The issue was unproblematic in so far that it
was only hit during a filesystem check and, since BPlusTree does not
yet attempt to correct corrupted trees, did not result in any actual
actions.


# de9c0613 03-Jul-2014 Axel Dörfler <axeld@pinc-software.de>

bfs: Use the QueryParserUtils instead of its own copy.

* Ingo copied the methods into a shared location, and then obviously
"forgot" to let BFS use them. As a side note for Ingo: the complete
error GCC reported was "std::fssh_size_t" not defined with the macro
wrapper as code location. The actual problem was a "using std::size_t"
in some C++ header that accidentally got included after the wrapper.
* The shared Query code is not yet used. That'll be done another time.
* Renamed BFS_SHELL define to FS_SHELL, such that QueryParserUtils can be
used in any file system shell, not just the bfs_shell.


# ba320218 03-Jul-2014 Axel Dörfler <axeld@pinc-software.de>

bfs: fixed wrong key comparison in validator.

* bplustree_header::DataType() is not compatible with the type constants
compareKeys() expects. Use _CompareKeys() instead.


# 1a7bcf69 01-Jun-2014 Oliver Tappe <zooey@hirschkaefer.de>

Lots of B_PRI... insertions to fix errors with DEBUG=1.


# 8a43cad2 02-May-2013 Michael Lotz <mmlr@mlotz.ch>

BPlusTree: Fix fCurrentKey in backward TreeIterator traversal.

When reaching the next node the current key should be set to the next
valid index within that node (0 for forward and NumKeys() - 1 for
backward). This did not cause any harm as BFS uses forward traversal
only.


# 50ef2db4 02-May-2013 Michael Lotz <mmlr@mlotz.ch>

BPlusTree: Fix GCC4 false positive of possible unintialized use.


# 1a5e87cc 02-May-2013 Michael Lotz <mmlr@mlotz.ch>

haiku_loader: Reuse BPlusTree implementation of the BFS add-on.

Instead of having an almost exact, albeit read only, duplicate of the
implementation.


# 6b65a838 02-May-2013 Michael Lotz <mmlr@mlotz.ch>

BPlusTree: Style cleanup only, no functional change.


# 91b4626a 28-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Check for and report an error on key buffer overrun.

This usually wasn't a problem as the key buffer is generally large
enough to hold a single value. Still on short buffers or very long
it could have silently overrun before.


# 35dc734b 23-Jul-2012 ahenriksson <sausageboy@gmail.com>

Single values are allowed in regular duplicate nodes

Not in duplicate fragments, however. This oversight in hrev44359 made
checkfs incorrectly rebuild valid indices, causing #8762.

Signed-off-by: Axel Dörfler <axeld@pinc-software.de>


# 1c24ebaa 22-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

64-bit compilation fixes for BFS, add to x86_64 boot image.


# d9879edd 17-Jul-2012 ahenriksson <sausageboy@gmail.com>

A duplicate array with a single value is not allowed

Such arrays could be created by the BFS code between hrev43837 and
hrev43924, and cause the array to not be free'd when the entry is
removed.

The check in _InsertDuplicate() is not changed, as doing an insertion
will actually repair this problem.

Potentially, the code could be modified to handle this state instead,
but since checkfs can fix it, it doesn't seem necessary.

Signed-off-by: Axel Dörfler <axeld@pinc-software.de>


# 7fef0374 01-Apr-2012 Axel Dörfler <axeld@pinc-software.de>

Make sure it isn't part of a transaction upon destruction.


# 8cf89e5c 01-Apr-2012 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


# b5310b16 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Fixed another bug I introduced with r43837.

* Really the same thing, just for fragment nodes this time.


# e109dcf9 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Don't bail out just because a node couldn't be read.

* Added a new CachedNode::SetTo() variant that actually returns an error code.
* Only bail out if there was an actual I/O error, not already if the offset
was invalid.
* This should help fixing some corruption corner cases.


# cb8941c4 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

We must not check the node here.

* The node might not be a normal tree node, so we must not check it before
writing.
* Also, it's always a good idea to check if the function you called didn't
succeed.
* This fixes a crashing bug when running checkfs in some rare circumstances.


# e0927e2c 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Improved debug output.


# 624b5ef3 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


# 657e62d2 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Fixed the invalid duplicate left over nodes.

* Accidently introduced that bug in r43837; the arrayCount variable was not
being updated after the value got removed.


# 55e5a42d 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Fixed misuse of Transaction::Split().

* This would cause "transaction too large" messages, and repairing the index
would actually be thrown away.
* We now properly finish/restart transactions instead which is actually
working.
* Removed the misleading Split() method altogether, as it's not even used
anywhere (not very surprising given that it doesn't do what its name
suggests).


# 09ec0ad9 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Also report errors when the free list is broken.

* This will cause the whole B+tree to be rewritten in that case, too.
* Added a TODO comment that describes an alternative solution for this.


# ce17af69 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Implemented repairing index b+trees.

* There are now two passes in case a corrupted index tree has been found.
* The second pass will clear the affected indices at first, and will then walk
over all inodes again to fill them.
* As a side effect, this will also defragment the indices; ie. the same
mechanism could be used for this some day.


# aed54a9a 30-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Use ID() instead of BlockNumber() for the debug output.


# 87d5beae 09-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Made the duplicate_array endian safe. Cleanup.

* Renamed the sorted_array to duplicate_array (which was only a typedef
before), and moved it into the BPlusTree.cpp file, as its specific to
that one.
* Utilities.cpp is no longer needed.
* Introduced endian safe getters/setters so that little endian BFS volumes
should now work fine on a big endian architecture.


# 82e06fff 06-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Implemented BPlusTree::Validate().

* Walks the complete B+tree and checks all nodes for validity
(duplicate/fragment as well), ie. if no key is larger than those of its
parent, and that the left/right links are valid.
* This does not yet support repairing of broken trees, though.


# f7f996cc 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* BPlusTree is now using the TransactionListener mechanism to update its private
fHeader copy on failure.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35492 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2a8ae7fb 16-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* CachedNode::SetToWritable() already needs the updated header, so we need to
Unset() the header in Allocate() before calling it. This fixes bug #5410.
* CachedNode::Allocate() does not need to revert its changes; the transaction
will take care of that. However, BPlusTree::fHeader is currently not correctly
maintained if a transaction fails (working on that now).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35490 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a05e4ed3 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* BPlusTree no longer caches the header in its own block, instead, it aggregates
a copy of its structure. CachedNode is only used to write to the header, now.
This should cause the block_cache to no longer have any referenced blocks
outside of any I/O.
* Coding style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35473 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8859eeab 24-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced "%Ld" and "%lld" in printf()s by the new B_PRI* macros to avoid
warnings when building with a 64 bit compiler.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34216 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 265694bb 12-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed warnings when compiled with DEBUG=1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33550 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aee4b7e2 03-May-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed two bugs in BPlusTree::Remove(): it could update the tree iterators
incorrectly in case of duplicates. And also, more importantly, it did not
check if the entry to remove had the same value -- it would happily remove
any entry with the same attribute content. This could only happen in the
reindex case, though, and was the cause of bug #3854.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30616 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e5b1c10e 15-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Calm down debug output a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28148 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b33ba0e9 20-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Followed Marcus' suggestion and made the array a static const one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27663 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6126236e 18-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27627 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35a16d8f 18-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Moved the inode_types into Utilities.h.
* Added a S_EXTENDED_TYPES constant to simplify some checks.
* Simplified the fAllowDuplicates computation in BPlusTree::SetTo().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27625 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1be4b7c0 04-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Build fix when built with DEBUG defined.
* Forgot to remove the "bfs_block_runs" debugger command on module unload.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26800 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02c8f6c8 02-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Coding style cleanups, no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26728 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2accd07b 01-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Replaced Chain with the new SinglyLinkedList.
* Renamed openModeToAccess() to open_mode_to_access().
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26718 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e3477e3 31-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Changed the inode write locking to be held as long as the transaction is
running - this fixes several cases where someone could see outdated data
when a transaction had to be reverted (the time between unlocking the inode
and actually reverting the blocks). For that, Inodes can now be put into a
singly linked list.
* Added a TODO in Inode::WriteAt() which explains why it cannot use the above
method: seems that our VFS/VM locking model isn't really that good.
* Fixed a possible deadlock in Attribute::_Truncate() where the inode write
lock was held before starting the transaction.
* Added an InodeReadLocker convenience class, that should be used instead
of ReadLocker - Inode::Lock() only still exists because of the needs of
bfs_io().
* Moved the bfs_io() callback hooks out of the exported module API region,
and removed their bfs_ prefix.
* Added a Volume::IsInitializing() method that should be used rather than
checking if Volume::ID() is >= 0.
* Removed the MultiInodeLocker again, as it's pretty much superfluous now.
* Moved openModeToAccess() to the Utility.h header.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b99521f2 30-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

First round of locking fixes:
* Moved locking the data stream out of the BPlusTree methods; this fixes at
least two locations where another thread could have seen outdated/incorrect
data.
* Removed some superfluous code in bfs_rename(): we don't have to revert to the
previous situation, the transaction does this for us automatically.
* Added a simple MultiWriteLocker, even though it's not really necessary anymore
(since we always hold the transaction lock first when we lock more than one
inode at a time).
* Inode::Create() called InodeAllocator::Keep() a bit too early, the file cache
and map wasn't created and assigned yet.
* InodeAllocator now keeps the inode write locked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26689 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9083840f 20-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

bonefish + mmlr + axeld:
* Fixed a bug that could easily corrupt your disks (yeah, one of those
again): bfs_get_file_map() truncated the last vec incorrectly and
would potentially return a too large file size -- which was later
happily overwritten with file data, but could have belonged to
anything but that file (like inodes, B+trees, etc.).
* Renamed previous round_up() function to key_align().
* Added round_up() template function, and used it where appropriate.
* The latter actually fixed two bugs where the and mask was computed in
32 bit where it should have been in 64 bit.
* Inode::FindBlockRun() should have checked the max indirect size
instead of the direct size - this didn't cause any problems, though.
* White space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26531 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1bde8b03 08-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Replaced BFS's ReadWriteLock implementation with the kernel's rw_lock.
* The BlockAllocator now uses the new mutex_transfer_lock() function instead
of clobbering the mutex directly.
* Removed Lock.h - it's no longer needed.
* Minor white space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26317 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03fa417b 07-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Removed the home-brewn locking classes in BFS besides the read/write lock
(for now).
* Inode::fSmallDataLock is now a recursive_lock, Journal::fLock is now
a recursive_lock, too, Journal::fEntriesLock is now a mutex, as is
BPlusTree::fIteratorLock.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26298 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cdde324d 10-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Looks like r24456 was a bit premature: with string attributes, it makes sense
to ignore a trailing null byte, which the code now didn't do anymore.
* This caused bug #2054.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24888 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 974e087e 19-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* If two equal keys were compared, the check for the key end was
incorrect; only the length of the key matters, not if they are null
terminated. It would still return the correct value, though, it would
just access one byte beyond the buffer (which didn't really matter
in this specific case).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7a3ecb82 16-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* _SeekDown() now checks if it has already reached the maximum tree
depth, and will bail out if it hasn't reached the leaf level then.
* This should at least avoid the crash of bug #1911; there is not much
more I can do about that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24411 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9402b5ed 02-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

Patch by Vasilis Kaoutsis to fix some warnings, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24203 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 12046492 19-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* When shrinking the stream size after a node had been removed, its
parent node could temporarily get invalid (ie. CheckNode() would
fail).
* Since shrinking the stream was done in edge cases only, anyway, we
will no longer do that which works around the problem. This fixes
bug #1716.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d1ba9c8a 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Fixed warnings when building the bfs_shell.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23462 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ab88b095 29-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

* bfs_{read|write}_pages() now only try to lock - this fixes a possible
deadlock whenever someone without a lock (like the page_writer()) is calling
this function.
* Added a new ReadWriteLock::TryLock() method.
* Renamed bfs_read_vnode() and bfs_release_vnode() to bfs_get_vnode() and
bfs_put_vnode() just like those functions are called in fs_interface.h.
* Fixed a warning in BPlusTree::_SplitNode().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22372 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a10c0b5 06-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Changes in BPlusTree::_SplitNode():
* Added check for invalid keyIndex parameter.
* Removed superfluous break condition in the second loop.
* Increment "out" in the second loop only when we have processed a key
that will end up in the node. Thus, after the loop, the variable will
contain the numbers of keys to be copied/moved, not that number + 1.
Adjusted later use of "out" accordingly, save in one place where it
was used incorrectly, which resulted in one key length and value to
many to be copied, thus occasionally causing a page fault (bug #1363).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22195 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fd0831b9 19-Jul-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
Fixed off-by-one error in the b+ tree code splitting a node, which could
result in a read beyond the block bounds thus causing a page fault. Was
nicely reproducible when unzipping big archives. Now bug #1003 seems to
be fixed for real.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21671 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5acd132f 16-Jun-2007 Jérôme Duval <korli@users.berlios.de>

replaced uint32 by addr_t where it applies to please gcc on x86_64


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21422 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 37593af2 22-May-2007 Axel Dörfler <axeld@pinc-software.de>

Fixed a memory leak in _SplitNode() spotted by Stefano - thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21200 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3bef51f0 06-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Removed unused code when USER is defined - the fs_shell no longer does this, but
provides a kernel emulation layer.
* Renamed all private BPlusTree methods to have the '_' prefix.
* Removed useless set_sem_owner() from Lock.h - all semaphores created in the kernel
always belong to the system team automatically.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21054 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c391f84b 26-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Prepared the BFS sources to be used with the new FS shell:
- Moved all inclusions of system headers into a new
system_dependencies.h header, which conditionally either includes
these or the FS shell headers.
- Fixed compiler warnings related to printf-like functions (int32 is
int, not long on non-BeOS platforms).
* Build a new bfs_shell. Compiles and links, but does nothing ATM.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20860 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ecf0475a 05-Oct-2006 Axel Dörfler <axeld@pinc-software.de>

Porting r18992 to the R5 version of BFS (and therefore, bfs_shell used to build the
Haiku image) revealed a problem with that change:
* If the root node only contained a single entry it was freed instead of just making
it a leaf node - that could produce an invalid b+tree (could only happen with
attribute or index trees, as directories always contain '.' and '..').


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19006 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0d01edba 03-Oct-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a stupid bug found by accident:
* When removing the last key from a leaf node, the node wasn't freed, but just
emptied, and thus the whole tree structure would never combast.
* This could also cause a bug in the TreeIterator: if the last entry was not
in the last node, every second readdir() after the last one would return
the last entry again. I only found this because that happens to be what
Tracker does (which would run in an endless loop while scanning the directory
then).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18992 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2594778c 22-May-2006 Axel Dörfler <axeld@pinc-software.de>

* Imported PPC big endian fixes into Haiku's BFS.
* Fixed another issue in BPlusTree::RemoveKey().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17558 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 866d738a 22-Feb-2006 Jérôme Duval <korli@users.berlios.de>

added error tracing to help on bug #106


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16498 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4af3d066 21-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Better debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16017 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13971875 08-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5e796c3b 28-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

A couple of endian fixes, inspired by Ingo - there might be some more left, though,
it's untested yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15693 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bdf1da4d 22-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

Slightly improved debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b68efdca 18-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

We now use the kernel's Stack class instead of our own copy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1733a442 29-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a very stupid bug I introduced in r10056 (the Haiku-only switch):
CachedNode::Allocate() could return the wrong offset for the new node when
taken from the free node pool (it accidently returned the offset for the
next free node...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14084 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0afc66fa 29-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Made CachedNode::SetTo[Header]() return a const node/header. Made some other methods
that were supposed to be const const as well.
Found one bug this way: in one case, a duplicate node might not have been part of a
transaction (and thus, was not written back). This bug only affected the Haiku version
of BFS, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14083 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4dcc6e97 25-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed two bugs in BPlusTree::RemoveDuplicate():
- if the left duplicate node of a removed node was the last node, the "array" variable
still pointed to the old node when the loop was reentered which could lead to a tree
corruption.
- if the value to be removed could not be found in the fragment it should have been in,
the method still returned B_OK instead of B_ENTRY_NOT_FOUND.
Small cleanup, updated/improved comments.
Changed bplustree_node::FragmentsUsed() from int32 to uint32. Moved the calculation
of the maximal number of fragments in a node to the new bplustree_node::MaxFragments()
method.
If a bplustree_header is not valid, BPlusTree::SetTo() will now dump the header when
compiled with DEBUG defined.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14063 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bae91f0a 21-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug I introduced when porting BFS to Haiku: when the file size of a BPlusTree
could be shrinked (because the last node was freed), the free node pointer of the
header was still accidently set to that node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14040 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 634c2346 12-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

If allocating a new node fails, the bplustree_header::maximum_size field is now
reseted to its old value.
BPlusTree::SetTo() is now less strict about maximum_size vs. inode size differences;
it will now print a warning and set the maximum_size to the inode size, even though
the tree might be corrupted (reading should always be as compatible and forgiving
as possible).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13946 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fbdd53ac 12-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Extended the node checker a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13944 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c52ae3e 01-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

SeekDown() now prints out an error message when failing in a certain way (instead
of just using the RETURN_ERROR() macro).
Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13878 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7eefd82 02-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed warnings: possibly uninitialized variable, missing friend classifier (struct/class).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11558 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41eca62b 22-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed debug build.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb02804a 19-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Big update while moving over completely to the Haiku kernel:
- Ported over BFS to the new cache API
- Inode no longer inherits from CachedBlock, and therefore, no longer
keeps the whole inode block in memory. It now has a copy of the bfs_inode
structure in memory instead. This has a number of advantages but also some
disadvantages, so it might be reverted later, even if it's unlikely.
- Added a NodeGetter class that can be used whenever the real block needs
to be accessed (ie. for attributes)
- Changed *transaction to &transaction where possible
- Removed support for KEEP_WRONG_DIRENT_RECLEN
- Removed support for uncached file access since that's no longer needed
- Fixed some endian issues in bfs_write_stat()
- Removed the install BFS rules, since they don't make any sense anymore
(unless you are running Haiku ;-))

Note, logged streams are not supported anymore right now. Also, the
transaction code is pretty simple and slow - it will be improved later
on. Attribute code is pretty much untested in the new environment.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10053 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c46a51bb 29-May-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed oddly indented comment.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7681 a95241bf-73f2-0310-859d-f6bbb57e9c96


# feec20d6 07-May-2004 Axel Dörfler <axeld@pinc-software.de>

It's now <util/kernel_cpp.h> rather than <kernel_cpp.h>.
Forgot to commit that...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7442 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 01338285 29-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Some minor style changes.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 55b5474b 25-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Added _PACKED to the on-disk structures.
Switched to kernel_cpp.h/cpp.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6287 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a49a098 07-Nov-2003 Nathan Whitehorn <nwhitehorn@nowhere.fake>

Bunches of changes to make mwcc like the code. I also coded an _atomic_set() and _atomic_test_and_set() for PowerPC. Of course, there's already one in the kernel tree, but mine's better. :P Now builds (and works, after a fashion) on R5 PowerPC.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5280 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb94280c 16-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

The file system is now almost endian-aware.
Used lazy unreadable conversion: ==, !=, == 0, != 0 are endian-safe
and don't need byte swapping.
If the platform endian differs from the one selected at compile time,
it will mount all volumes read-only for now.
Uncomment BFS_BIG_ENDIAN_ONLY in the Jamfile to build the big endian
version under x86.
No matter on what platform, the compilation defaults to build BFS as
little endian file system (see bfs_endian.h for details).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d81d3bfa 16-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

Added B_SSIZE_T_TYPE, B_SIZE_T_TYPE, B_OFF_T_TYPE to compareKeys().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cca15c01 31-May-2003 Axel Dörfler <axeld@pinc-software.de>

Added a little more debug output in BPlusTree::Find().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3393 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 98b972c9 25-Feb-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed all warnings that appeared with DEBUG=1 set.
Also fixed missing return codes in BufferPool::ReleaseBuffer() and Journal::WriteLogEntry().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2845 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b4d14910 24-Feb-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed some warnings, and some minor style issues.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2836 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 89e64f44 05-Dec-2002 Axel Dörfler <axeld@pinc-software.de>

Added more checks in the BPlusTree implementation if DEBUG is defined.
The correctness of max_number_of_levels is now checked in Find().
Added a class NodeChecker which checks the integrity of the specified node
when the object is destructed (via new method bplustree_node::CheckIntegrity());
now used in Remove() and Insert().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2169 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 006928f8 29-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Fixed the bug in the query code: B_MIME_STRING_TYPE was not correctly
translated into B_STRING_TYPE for the key comparison (it was translated
but not saved under the new type).
compareKeys() will now return -1 if it didn't know the type to compare.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2121 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d3698937 25-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Removed the usage of Inode::Name() in the debug output.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2080 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 68ca164d 19-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Switched from Inode::IsDirectory() to Inode::IsContainer() where necessary.
Now makes use of the changed Inode::Create() logic.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2031 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e335b08a 06-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Fixed the wrong maintainance of the max_number_of_levels field in the
B+tree's header.
Some style cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1870 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c42ee134 07-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

Initial revision


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@639 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8b6e513a2e12a04cb518e491f04e28439087ecae 19-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

BFS: _SplitNode() could overflow the new node.

* When the keys were large enough, a large key entering the node could
overflow the available data in the target node. This caused tree and
memory corruption.
* This fixes bug #6034.


# 33d9fb8663e384b7ad8edb015eac2b2ee88c2d3b 19-Oct-2014 Michael Lotz <mmlr@mlotz.ch>

BFS: Fix check of key compare in BPlusTree::_ValidateChildren().

In ba320218245aeb11cb74c37ecf7132d0b9903957 the key comparison was fixed
to use a compatible version. Since then the check can actually return
results other than -1. The check done on the result was too strict
however. The child nodes may never contain keys that are larger than the
keys they are reached by. But the last key of a child node may be equal
to the one in the parent. This change fixes the check to take this
special case into account.

Fixes #11026 and #11289. The issue was unproblematic in so far that it
was only hit during a filesystem check and, since BPlusTree does not
yet attempt to correct corrupted trees, did not result in any actual
actions.


# de9c0613398645390b8d450089051b2888e2e15b 03-Jul-2014 Axel Dörfler <axeld@pinc-software.de>

bfs: Use the QueryParserUtils instead of its own copy.

* Ingo copied the methods into a shared location, and then obviously
"forgot" to let BFS use them. As a side note for Ingo: the complete
error GCC reported was "std::fssh_size_t" not defined with the macro
wrapper as code location. The actual problem was a "using std::size_t"
in some C++ header that accidentally got included after the wrapper.
* The shared Query code is not yet used. That'll be done another time.
* Renamed BFS_SHELL define to FS_SHELL, such that QueryParserUtils can be
used in any file system shell, not just the bfs_shell.


# ba320218245aeb11cb74c37ecf7132d0b9903957 03-Jul-2014 Axel Dörfler <axeld@pinc-software.de>

bfs: fixed wrong key comparison in validator.

* bplustree_header::DataType() is not compatible with the type constants
compareKeys() expects. Use _CompareKeys() instead.


# 1a7bcf6962e1c99906cce0fe602e08c3fcda46f6 01-Jun-2014 Oliver Tappe <zooey@hirschkaefer.de>

Lots of B_PRI... insertions to fix errors with DEBUG=1.


# 8a43cad2ef51b227d80be6e20f37b14c2a0dbde4 02-May-2013 Michael Lotz <mmlr@mlotz.ch>

BPlusTree: Fix fCurrentKey in backward TreeIterator traversal.

When reaching the next node the current key should be set to the next
valid index within that node (0 for forward and NumKeys() - 1 for
backward). This did not cause any harm as BFS uses forward traversal
only.


# 50ef2db4a80d096978fd27c5d77306c631f8a181 02-May-2013 Michael Lotz <mmlr@mlotz.ch>

BPlusTree: Fix GCC4 false positive of possible unintialized use.


# 1a5e87cc6491bdc291ac44287232d66b2055deca 02-May-2013 Michael Lotz <mmlr@mlotz.ch>

haiku_loader: Reuse BPlusTree implementation of the BFS add-on.

Instead of having an almost exact, albeit read only, duplicate of the
implementation.


# 6b65a838e01488536628e807b7b65bb73468f8d4 02-May-2013 Michael Lotz <mmlr@mlotz.ch>

BPlusTree: Style cleanup only, no functional change.


# 91b4626a782adfdd150002cf824cd26b97f4f83a 28-Apr-2013 Michael Lotz <mmlr@mlotz.ch>

Check for and report an error on key buffer overrun.

This usually wasn't a problem as the key buffer is generally large
enough to hold a single value. Still on short buffers or very long
it could have silently overrun before.


# 35dc734b484f6569be670a4c8a4f719b107cd6ed 23-Jul-2012 ahenriksson <sausageboy@gmail.com>

Single values are allowed in regular duplicate nodes

Not in duplicate fragments, however. This oversight in hrev44359 made
checkfs incorrectly rebuild valid indices, causing #8762.

Signed-off-by: Axel Dörfler <axeld@pinc-software.de>


# 1c24ebaa5fdc1d07cd40a296c59463c9477b8fbd 22-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

64-bit compilation fixes for BFS, add to x86_64 boot image.


# d9879eddbf9e4b01f07679af1769e9f439d4e0ef 17-Jul-2012 ahenriksson <sausageboy@gmail.com>

A duplicate array with a single value is not allowed

Such arrays could be created by the BFS code between hrev43837 and
hrev43924, and cause the array to not be free'd when the entry is
removed.

The check in _InsertDuplicate() is not changed, as doing an insertion
will actually repair this problem.

Potentially, the code could be modified to handle this state instead,
but since checkfs can fix it, it doesn't seem necessary.

Signed-off-by: Axel Dörfler <axeld@pinc-software.de>


# 7fef0374fe81c8477c5b335cc37ca955b94aac47 01-Apr-2012 Axel Dörfler <axeld@pinc-software.de>

Make sure it isn't part of a transaction upon destruction.


# 8cf89e5cd34190bfc0a9ebbaccead5ab9a38246b 01-Apr-2012 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


# b5310b1638606e8f17001af473f1957086ff567d 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Fixed another bug I introduced with r43837.

* Really the same thing, just for fragment nodes this time.


# e109dcf97b6b2e77132c171908af021468004485 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Don't bail out just because a node couldn't be read.

* Added a new CachedNode::SetTo() variant that actually returns an error code.
* Only bail out if there was an actual I/O error, not already if the offset
was invalid.
* This should help fixing some corruption corner cases.


# cb8941c48f7eeff3b6b0c0ac963569febb54b30c 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

We must not check the node here.

* The node might not be a normal tree node, so we must not check it before
writing.
* Also, it's always a good idea to check if the function you called didn't
succeed.
* This fixes a crashing bug when running checkfs in some rare circumstances.


# e0927e2c4414f9e43ca84b4332c3b69ae6242ba9 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Improved debug output.


# 624b5ef3e6476077be291f58effd76121f19b49e 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


# 657e62d2223387f5b968e6cfc15f7caef68ade76 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Fixed the invalid duplicate left over nodes.

* Accidently introduced that bug in r43837; the arrayCount variable was not
being updated after the value got removed.


# 55e5a42d7316254bec05c7cb362caf5406e5b6a7 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Fixed misuse of Transaction::Split().

* This would cause "transaction too large" messages, and repairing the index
would actually be thrown away.
* We now properly finish/restart transactions instead which is actually
working.
* Removed the misleading Split() method altogether, as it's not even used
anywhere (not very surprising given that it doesn't do what its name
suggests).


# 09ec0ad9c3a6df800816b8df6617dc9e30ba24ca 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Also report errors when the free list is broken.

* This will cause the whole B+tree to be rewritten in that case, too.
* Added a TODO comment that describes an alternative solution for this.


# ce17af69dc33c82dfec3a956c384725ef0b2a656 31-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Implemented repairing index b+trees.

* There are now two passes in case a corrupted index tree has been found.
* The second pass will clear the affected indices at first, and will then walk
over all inodes again to fill them.
* As a side effect, this will also defragment the indices; ie. the same
mechanism could be used for this some day.


# aed54a9a464b24a96df17fb349a46c171e362f47 30-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Use ID() instead of BlockNumber() for the debug output.


# 87d5beae86a208ed47523046cf7f28ac717af969 09-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Made the duplicate_array endian safe. Cleanup.

* Renamed the sorted_array to duplicate_array (which was only a typedef
before), and moved it into the BPlusTree.cpp file, as its specific to
that one.
* Utilities.cpp is no longer needed.
* Introduced endian safe getters/setters so that little endian BFS volumes
should now work fine on a big endian architecture.


# 82e06fff6805b01eac1b56cc5665bd8b1c4f1204 06-Mar-2012 Axel Dörfler <axeld@pinc-software.de>

Implemented BPlusTree::Validate().

* Walks the complete B+tree and checks all nodes for validity
(duplicate/fragment as well), ie. if no key is larger than those of its
parent, and that the left/right links are valid.
* This does not yet support repairing of broken trees, though.


# f7f996cc323798bc72eae39433e8aaa0f8dbd7df 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* BPlusTree is now using the TransactionListener mechanism to update its private
fHeader copy on failure.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35492 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2a8ae7fb92985550913ac2eb04bfb8513d40f886 16-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* CachedNode::SetToWritable() already needs the updated header, so we need to
Unset() the header in Allocate() before calling it. This fixes bug #5410.
* CachedNode::Allocate() does not need to revert its changes; the transaction
will take care of that. However, BPlusTree::fHeader is currently not correctly
maintained if a transaction fails (working on that now).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35490 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a05e4ed3300374f57c66c71d838c718061bb1af0 15-Feb-2010 Axel Dörfler <axeld@pinc-software.de>

* BPlusTree no longer caches the header in its own block, instead, it aggregates
a copy of its structure. CachedNode is only used to write to the header, now.
This should cause the block_cache to no longer have any referenced blocks
outside of any I/O.
* Coding style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35473 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8859eeab5349da39ee9972ee0943919740754b77 24-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Replaced "%Ld" and "%lld" in printf()s by the new B_PRI* macros to avoid
warnings when building with a 64 bit compiler.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34216 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 265694bb1fcc00cd7fb87195db31786674ea2d91 12-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed warnings when compiled with DEBUG=1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33550 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aee4b7e237c5e1e2aa73c398f04836e81e91362a 03-May-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed two bugs in BPlusTree::Remove(): it could update the tree iterators
incorrectly in case of duplicates. And also, more importantly, it did not
check if the entry to remove had the same value -- it would happily remove
any entry with the same attribute content. This could only happen in the
reindex case, though, and was the cause of bug #3854.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30616 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e5b1c10e58bb3664ccd2e3e9eea12d7e512310aa 15-Oct-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Calm down debug output a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28148 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b33ba0e92efbc62e10d10f587e169021146c4626 20-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Followed Marcus' suggestion and made the array a static const one.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27663 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6126236e8af22024446694b0a0f799ccc585649e 18-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27627 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35a16d8f5e035b37cf8dc6a242cadf54b23eb142 18-Sep-2008 Axel Dörfler <axeld@pinc-software.de>

* Moved the inode_types into Utilities.h.
* Added a S_EXTENDED_TYPES constant to simplify some checks.
* Simplified the fAllowDuplicates computation in BPlusTree::SetTo().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27625 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1be4b7c0c5aee2c80d83ba5a36eb8945e7de2015 04-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Build fix when built with DEBUG defined.
* Forgot to remove the "bfs_block_runs" debugger command on module unload.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26800 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 02c8f6c89d13b94c5507012eaadddc79982c976f 02-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Coding style cleanups, no functional changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26728 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2accd07be4d2731332674ebf8d801260b5388130 01-Aug-2008 Axel Dörfler <axeld@pinc-software.de>

* Replaced Chain with the new SinglyLinkedList.
* Renamed openModeToAccess() to open_mode_to_access().
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26718 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2e3477e3d851cc46fa682712c3f73dbb82d64fd9 31-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Changed the inode write locking to be held as long as the transaction is
running - this fixes several cases where someone could see outdated data
when a transaction had to be reverted (the time between unlocking the inode
and actually reverting the blocks). For that, Inodes can now be put into a
singly linked list.
* Added a TODO in Inode::WriteAt() which explains why it cannot use the above
method: seems that our VFS/VM locking model isn't really that good.
* Fixed a possible deadlock in Attribute::_Truncate() where the inode write
lock was held before starting the transaction.
* Added an InodeReadLocker convenience class, that should be used instead
of ReadLocker - Inode::Lock() only still exists because of the needs of
bfs_io().
* Moved the bfs_io() callback hooks out of the exported module API region,
and removed their bfs_ prefix.
* Added a Volume::IsInitializing() method that should be used rather than
checking if Volume::ID() is >= 0.
* Removed the MultiInodeLocker again, as it's pretty much superfluous now.
* Moved openModeToAccess() to the Utility.h header.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b99521f213e60f88b3d7700f395fb0c4bf99f63a 30-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

First round of locking fixes:
* Moved locking the data stream out of the BPlusTree methods; this fixes at
least two locations where another thread could have seen outdated/incorrect
data.
* Removed some superfluous code in bfs_rename(): we don't have to revert to the
previous situation, the transaction does this for us automatically.
* Added a simple MultiWriteLocker, even though it's not really necessary anymore
(since we always hold the transaction lock first when we lock more than one
inode at a time).
* Inode::Create() called InodeAllocator::Keep() a bit too early, the file cache
and map wasn't created and assigned yet.
* InodeAllocator now keeps the inode write locked.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26689 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9083840f3462752eeba06158182a11a1e86c7aac 20-Jul-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

bonefish + mmlr + axeld:
* Fixed a bug that could easily corrupt your disks (yeah, one of those
again): bfs_get_file_map() truncated the last vec incorrectly and
would potentially return a too large file size -- which was later
happily overwritten with file data, but could have belonged to
anything but that file (like inodes, B+trees, etc.).
* Renamed previous round_up() function to key_align().
* Added round_up() template function, and used it where appropriate.
* The latter actually fixed two bugs where the and mask was computed in
32 bit where it should have been in 64 bit.
* Inode::FindBlockRun() should have checked the max indirect size
instead of the direct size - this didn't cause any problems, though.
* White space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26531 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1bde8b03e7789d10cdc063a8a4b23ce3cba6f2e1 08-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Replaced BFS's ReadWriteLock implementation with the kernel's rw_lock.
* The BlockAllocator now uses the new mutex_transfer_lock() function instead
of clobbering the mutex directly.
* Removed Lock.h - it's no longer needed.
* Minor white space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26317 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 03fa417b706f63305263982a61eb1002e6ff9d96 07-Jul-2008 Axel Dörfler <axeld@pinc-software.de>

* Removed the home-brewn locking classes in BFS besides the read/write lock
(for now).
* Inode::fSmallDataLock is now a recursive_lock, Journal::fLock is now
a recursive_lock, too, Journal::fEntriesLock is now a mutex, as is
BPlusTree::fIteratorLock.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26298 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cdde324d77b99ef1d2eefe5c5127cdbbe2617778 10-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Looks like r24456 was a bit premature: with string attributes, it makes sense
to ignore a trailing null byte, which the code now didn't do anymore.
* This caused bug #2054.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24888 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 974e087ef1deda8ca00349a2ec32b4b3956c2fe5 19-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* If two equal keys were compared, the check for the key end was
incorrect; only the length of the key matters, not if they are null
terminated. It would still return the correct value, though, it would
just access one byte beyond the buffer (which didn't really matter
in this specific case).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24456 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7a3ecb82ba8f1f1cea595389406a7d73fd7958ff 16-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* _SeekDown() now checks if it has already reached the maximum tree
depth, and will bail out if it hasn't reached the leaf level then.
* This should at least avoid the crash of bug #1911; there is not much
more I can do about that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24411 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9402b5edc660d250422ad570232b8b01508e1eb2 02-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

Patch by Vasilis Kaoutsis to fix some warnings, thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24203 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1204649234b40eefdce649dae0e039b3256508eb 19-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* When shrinking the stream size after a node had been removed, its
parent node could temporarily get invalid (ie. CheckNode() would
fail).
* Since shrinking the stream was done in edge cases only, anyway, we
will no longer do that which works around the problem. This fixes
bug #1716.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d1ba9c8adcff423098753d2ec8726a98f8a41f01 12-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Fixed warnings when building the bfs_shell.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23462 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ab88b095f209c11a9d1d97fdbc7aa45f69639040 29-Sep-2007 Axel Dörfler <axeld@pinc-software.de>

* bfs_{read|write}_pages() now only try to lock - this fixes a possible
deadlock whenever someone without a lock (like the page_writer()) is calling
this function.
* Added a new ReadWriteLock::TryLock() method.
* Renamed bfs_read_vnode() and bfs_release_vnode() to bfs_get_vnode() and
bfs_put_vnode() just like those functions are called in fs_interface.h.
* Fixed a warning in BPlusTree::_SplitNode().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22372 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8a10c0b5a7eb9195fa1dd3258f90b41b4434b931 06-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Changes in BPlusTree::_SplitNode():
* Added check for invalid keyIndex parameter.
* Removed superfluous break condition in the second loop.
* Increment "out" in the second loop only when we have processed a key
that will end up in the node. Thus, after the loop, the variable will
contain the numbers of keys to be copied/moved, not that number + 1.
Adjusted later use of "out" accordingly, save in one place where it
was used incorrectly, which resulted in one key length and value to
many to be copied, thus occasionally causing a page fault (bug #1363).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22195 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fd0831b98da02dfc53398ffb622bd9c95d93574e 19-Jul-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
Fixed off-by-one error in the b+ tree code splitting a node, which could
result in a read beyond the block bounds thus causing a page fault. Was
nicely reproducible when unzipping big archives. Now bug #1003 seems to
be fixed for real.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21671 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5acd132fa47d06377bf58bac6b8d57f4eeec27a7 16-Jun-2007 Jérôme Duval <korli@users.berlios.de>

replaced uint32 by addr_t where it applies to please gcc on x86_64


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21422 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 37593af2840854a0588f366dfad14d75ba26dfc1 22-May-2007 Axel Dörfler <axeld@pinc-software.de>

Fixed a memory leak in _SplitNode() spotted by Stefano - thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21200 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3bef51f0ae9112a7e60576abf6fb0b476b2f6584 06-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Removed unused code when USER is defined - the fs_shell no longer does this, but
provides a kernel emulation layer.
* Renamed all private BPlusTree methods to have the '_' prefix.
* Removed useless set_sem_owner() from Lock.h - all semaphores created in the kernel
always belong to the system team automatically.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21054 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c391f84b2c732398288276bc8354ac4060dc5a4d 26-Apr-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Prepared the BFS sources to be used with the new FS shell:
- Moved all inclusions of system headers into a new
system_dependencies.h header, which conditionally either includes
these or the FS shell headers.
- Fixed compiler warnings related to printf-like functions (int32 is
int, not long on non-BeOS platforms).
* Build a new bfs_shell. Compiles and links, but does nothing ATM.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20860 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ecf0475ad0e8b4612363562992f3ef29eb4be646 05-Oct-2006 Axel Dörfler <axeld@pinc-software.de>

Porting r18992 to the R5 version of BFS (and therefore, bfs_shell used to build the
Haiku image) revealed a problem with that change:
* If the root node only contained a single entry it was freed instead of just making
it a leaf node - that could produce an invalid b+tree (could only happen with
attribute or index trees, as directories always contain '.' and '..').


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19006 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0d01edbaba8ca55329e78dcb3200d5cf20503ba0 03-Oct-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed a stupid bug found by accident:
* When removing the last key from a leaf node, the node wasn't freed, but just
emptied, and thus the whole tree structure would never combast.
* This could also cause a bug in the TreeIterator: if the last entry was not
in the last node, every second readdir() after the last one would return
the last entry again. I only found this because that happens to be what
Tracker does (which would run in an endless loop while scanning the directory
then).
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18992 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2594778c84a0a48def7df7d334cf9fef39a58880 22-May-2006 Axel Dörfler <axeld@pinc-software.de>

* Imported PPC big endian fixes into Haiku's BFS.
* Fixed another issue in BPlusTree::RemoveKey().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17558 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 866d738a052dec5802a8992ad4d2bc6d44470544 22-Feb-2006 Jérôme Duval <korli@users.berlios.de>

added error tracing to help on bug #106


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16498 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4af3d066e11b8f69de836b0697978b995ef67280 21-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Better debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16017 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 139718753266d4a45bb6b54df4202c4549be94a6 08-Jan-2006 Axel Dörfler <axeld@pinc-software.de>

Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15871 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5e796c3bb3981c3a4b4ee2b6fbe8e21f2abf332f 28-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

A couple of endian fixes, inspired by Ingo - there might be some more left, though,
it's untested yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15693 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bdf1da4d6e74086b9e31033fa0212f05ebe5bdcb 22-Dec-2005 Axel Dörfler <axeld@pinc-software.de>

Slightly improved debug output.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15656 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b68efdcaa7f9c148cbf77b6e8bf60978f0bd5978 18-Oct-2005 Axel Dörfler <axeld@pinc-software.de>

We now use the kernel's Stack class instead of our own copy.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1733a442315835e29473905c2da8c330367fa2ea 29-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a very stupid bug I introduced in r10056 (the Haiku-only switch):
CachedNode::Allocate() could return the wrong offset for the new node when
taken from the free node pool (it accidently returned the offset for the
next free node...).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14084 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0afc66fa69b676d3fed34cf50e965d362cad6a93 29-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Made CachedNode::SetTo[Header]() return a const node/header. Made some other methods
that were supposed to be const const as well.
Found one bug this way: in one case, a duplicate node might not have been part of a
transaction (and thus, was not written back). This bug only affected the Haiku version
of BFS, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14083 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4dcc6e972ea29e7a1a57ebf553a4e735ddfa6839 25-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed two bugs in BPlusTree::RemoveDuplicate():
- if the left duplicate node of a removed node was the last node, the "array" variable
still pointed to the old node when the loop was reentered which could lead to a tree
corruption.
- if the value to be removed could not be found in the fragment it should have been in,
the method still returned B_OK instead of B_ENTRY_NOT_FOUND.
Small cleanup, updated/improved comments.
Changed bplustree_node::FragmentsUsed() from int32 to uint32. Moved the calculation
of the maximal number of fragments in a node to the new bplustree_node::MaxFragments()
method.
If a bplustree_header is not valid, BPlusTree::SetTo() will now dump the header when
compiled with DEBUG defined.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14063 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bae91f0a4cf253b68e831b33edf946643024ed24 21-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a bug I introduced when porting BFS to Haiku: when the file size of a BPlusTree
could be shrinked (because the last node was freed), the free node pointer of the
header was still accidently set to that node.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14040 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 634c23467b681d3f2873898aa4fd3b788ba32e81 12-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

If allocating a new node fails, the bplustree_header::maximum_size field is now
reseted to its old value.
BPlusTree::SetTo() is now less strict about maximum_size vs. inode size differences;
it will now print a warning and set the maximum_size to the inode size, even though
the tree might be corrupted (reading should always be as compatible and forgiving
as possible).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13946 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fbdd53ace293294f26b9010503229f96840a9a17 12-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

Extended the node checker a bit.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13944 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8c52ae3e9621af62e24f3ea9c1c776e1f4bce17c 01-Aug-2005 Axel Dörfler <axeld@pinc-software.de>

SeekDown() now prints out an error message when failing in a certain way (instead
of just using the RETURN_ERROR() macro).
Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13878 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f7eefd8207342f7216f4822773fe9d4a5c0a0eef 02-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed warnings: possibly uninitialized variable, missing friend classifier (struct/class).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11558 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 41eca62b6992ddce1fab5511ba20b1617ba0a3c7 22-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed debug build.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10196 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fb02804a89b1100c0f20c3e3c28be28215103c44 19-Nov-2004 Axel Dörfler <axeld@pinc-software.de>

Big update while moving over completely to the Haiku kernel:
- Ported over BFS to the new cache API
- Inode no longer inherits from CachedBlock, and therefore, no longer
keeps the whole inode block in memory. It now has a copy of the bfs_inode
structure in memory instead. This has a number of advantages but also some
disadvantages, so it might be reverted later, even if it's unlikely.
- Added a NodeGetter class that can be used whenever the real block needs
to be accessed (ie. for attributes)
- Changed *transaction to &transaction where possible
- Removed support for KEEP_WRONG_DIRENT_RECLEN
- Removed support for uncached file access since that's no longer needed
- Fixed some endian issues in bfs_write_stat()
- Removed the install BFS rules, since they don't make any sense anymore
(unless you are running Haiku ;-))

Note, logged streams are not supported anymore right now. Also, the
transaction code is pretty simple and slow - it will be improved later
on. Attribute code is pretty much untested in the new environment.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10053 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c46a51bb815a1f554acb273cecbd8466559eddb4 29-May-2004 Axel Dörfler <axeld@pinc-software.de>

Fixed oddly indented comment.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7681 a95241bf-73f2-0310-859d-f6bbb57e9c96


# feec20d64b8c5be705c76f8ac957408c7c95df97 07-May-2004 Axel Dörfler <axeld@pinc-software.de>

It's now <util/kernel_cpp.h> rather than <kernel_cpp.h>.
Forgot to commit that...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7442 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 01338285a9dd86dc5d0353598d6615016890cd0d 29-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Some minor style changes.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6417 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 55b5474b8b3755e14a99260e03c07d642d78b16c 25-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Added _PACKED to the on-disk structures.
Switched to kernel_cpp.h/cpp.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6287 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1a49a0986bd50ef30d406b4f5001a0784d344015 07-Nov-2003 Nathan Whitehorn <nwhitehorn@nowhere.fake>

Bunches of changes to make mwcc like the code. I also coded an _atomic_set() and _atomic_test_and_set() for PowerPC. Of course, there's already one in the kernel tree, but mine's better. :P Now builds (and works, after a fashion) on R5 PowerPC.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5280 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb94280c6b8450b48764df889cdf0a8fd19af64b 16-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

The file system is now almost endian-aware.
Used lazy unreadable conversion: ==, !=, == 0, != 0 are endian-safe
and don't need byte swapping.
If the platform endian differs from the one selected at compile time,
it will mount all volumes read-only for now.
Uncomment BFS_BIG_ENDIAN_ONLY in the Jamfile to build the big endian
version under x86.
No matter on what platform, the compilation defaults to build BFS as
little endian file system (see bfs_endian.h for details).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4715 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d81d3bfa4cd5b8397eaa6d91f8b1fe5af5244888 16-Sep-2003 Axel Dörfler <axeld@pinc-software.de>

Added B_SSIZE_T_TYPE, B_SIZE_T_TYPE, B_OFF_T_TYPE to compareKeys().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4713 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cca15c0166f1fb70556c639c3895fc020bcaa09c 31-May-2003 Axel Dörfler <axeld@pinc-software.de>

Added a little more debug output in BPlusTree::Find().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3393 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 98b972c906051113e46d46cfe8c02f5adebdd599 25-Feb-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed all warnings that appeared with DEBUG=1 set.
Also fixed missing return codes in BufferPool::ReleaseBuffer() and Journal::WriteLogEntry().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2845 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b4d14910f51ee93b6a2d17afbc46ff73240f9334 24-Feb-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed some warnings, and some minor style issues.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2836 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 89e64f44becc8482422f252682295c5ba88d0d66 05-Dec-2002 Axel Dörfler <axeld@pinc-software.de>

Added more checks in the BPlusTree implementation if DEBUG is defined.
The correctness of max_number_of_levels is now checked in Find().
Added a class NodeChecker which checks the integrity of the specified node
when the object is destructed (via new method bplustree_node::CheckIntegrity());
now used in Remove() and Insert().


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2169 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 006928f81b2ab30d54835dbc9964c04c07d392d7 29-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Fixed the bug in the query code: B_MIME_STRING_TYPE was not correctly
translated into B_STRING_TYPE for the key comparison (it was translated
but not saved under the new type).
compareKeys() will now return -1 if it didn't know the type to compare.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2121 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d36989378165a1f1fea1b66e60d4dbcb520e9051 25-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Removed the usage of Inode::Name() in the debug output.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2080 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 68ca164dc31cdd523830f8875ffa42ac963039b6 19-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Switched from Inode::IsDirectory() to Inode::IsContainer() where necessary.
Now makes use of the changed Inode::Create() logic.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2031 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e335b08a3335666e5832b2d99742095cb57ef4db 06-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Fixed the wrong maintainance of the max_number_of_levels field in the
B+tree's header.
Some style cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1870 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c42ee13401be80c431846910959d587949a1ad10 07-Aug-2002 Axel Dörfler <axeld@pinc-software.de>

Initial revision


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@639 a95241bf-73f2-0310-859d-f6bbb57e9c96