History log of /haiku/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp
Revision Date Author Comments
# 425ac1b6 20-Jun-2023 Alexander von Gluck IV <kallisti5@unixzen.com>

refactor: Swap %Ld for %lld in all format usages

* %Ld is an undocumented alias for %lld in glibc.
* muslc doesn't implement it for this reason.
* While we will likely never drop %Ld support,
lets clean house and set a better example.

Change-Id: Id46dad3104abae483e80cc5c05d1464d3ecd8030
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6636
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# 050515f6 16-Feb-2023 Augustin Cavalier <waddlesplash@gmail.com>

BFS: Fix missing trim of last range in a corner case.

The previous logic of _AddTrim plus _TrimNext meant that if a trim
range was specified in the final call to _TrimNext (i.e. with force=true),
but the trim buffer was already full at that point, that last range
would not actually be trimmed.

Now, _AddTrim returns true when the buffer is filled and trimming
should be done, rather than delaying it and requiring a second
add after trimming.

Change-Id: I4b782948e8dc9267c63e61bce0c078fd4e834177
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6070
Tested-by: Automation <automation@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 187f73db 29-Jun-2022 Jérôme Duval <jerome.duval@gmail.com>

bfs: take in account the block_run allocation group when computing reserved blocks.

after hrev56221, the block bitmaps can span over multiple allocation groups.
Blocks would be allocated in the block bitmaps, especially root indexes (for instance 2.5TB, blocksize 2k).

Change-Id: I35d21d48e84945e5f949a272d530c466ae6506ac
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5420
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# b5417d20 27-Jun-2022 Jérôme Duval <jerome.duval@gmail.com>

bfs: don't allocate more than the maximum in an AllocationGroup

* The reserved blocks could exhaust the first allocation group, so iterate as much as needed.
* fix #11753

Change-Id: Ib1d7f87946f7b96dfcade8f5778a14065d965f6b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5417
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>


# bd02d81c 30-Jun-2021 David Sebek <dasebek@gmail.com>

Fix trim-related issues

Fixes:
* Use uint64 instead of off_t when handling offset and size
of the trimmed range in the fs_trim_data structure
* BlockAllocator::Trim: Correct the size of a buffer
* ram_disk, mmc: Do not trim past device capacity

Improvements:
* BlockAllocator::Trim: Because the received offset and size
are ignored by BFS (the functionality is not implemented yet),
return B_UNSUPPORTED if the range does not cover the whole
partition
* ram_disk, mmc: More accurate calculation of the number
of trimmed bytes
* devfs: Add a uint64 version of translate_partition_access()

Change-Id: I24f4c08674f123ad33a5fef6e28996a4ada6ff0d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4155
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 3d43a905 30-Aug-2020 John Scipione <jscipione@gmail.com>

bfs: Enable logging on DEBUG build

Fix DEBUG build errors by using B_PRI macros in BlockAllocator.cpp,
CheckVisitor.cpp, Inode.cpp, Journal.cpp, and kernel_interface.cpp

Add optional type parameter from BlockAllocator::IsValidBlockRun()
and actually PRINT it, type parameter is already optional on
BlockAllocator::CheckBlockRun().

Remove a couple of casts as we are printing the expected type, int32.

Cast mode_t to (unsigned int) and use %u because 32-bit Haiku didn't
like B_PRIu32.

Verified to compile on both regular and DEBUG builds on both 32-bit
and 64-bit.

Change-Id: I8bb39afd400768b7f69d36384974f0b91b3ef48c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3184
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: John Scipione <jscipione@gmail.com>


# 93845aec 11-Jun-2020 Axel Dörfler <axeld@pinc-software.de>

block_cache: Change signature of *_etc() functions

* This allows file systems to retrieve the actual error code on a
failure, and report it to the user.
* All affected file systems have been adjusted to the API change.
This is a binary incompatible change.

Change-Id: Id73392aaf9c6cb7d643ff9adcb8bf80f3037874c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2913
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# aa775038 05-Jul-2012 ahenriksson <sausageboy@gmail.com>

bfs: split checkfs code into FileSystemVisitor and CheckVisitor

Another FileSystemVisitor implementation will be used for resizing

Change-Id: I2d5f47dcbefb4c76834487b194a99c6f5ae7de50
Reviewed-on: https://review.haiku-os.org/c/923
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 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.


# 39f437f7 04-Jan-2017 Axel Dörfler <axeld@pinc-software.de>

bfs: Always check if NodeGetter succeeded.

* There were quite a few cases that just assumed that the disk access
would succeed.
* This also fixes bug #12962.


# 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.


# 22d300c2 02-Mar-2014 Axel Dörfler <axeld@pinc-software.de>

AHCI/BFS: fixed temporary trim debug output.


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

trim: added debug output.

* Can you give it another try, Alexander? The outcome won't change, I'm afraid,
but maybe we'll know some more afterwards.


# 99086aa3 14-Aug-2013 Axel Dörfler <axeld@pinc-software.de>

trim: Target SCSI UNMAP command instead of WRITE SAME.

* The UNMAP command is theoretically much faster, as it can get many block
ranges instead of just a single range.
* Furthermore, the ATA TRIM command resembles it much better.
* Therefore, fs_trim_data now gets an array of ranges, and we use SCSI UNMAP
to trim.
* Updated BFS code to collect array ranges to fully support the new
fs_trim_data possibilities.


# 0a0ba4b5 04-Aug-2013 Axel Dörfler <axeld@pinc-software.de>

Added B_TRIM_DEVICE support to BFS.

* It currently ignores the offset/size, though, and always trims everything.
* Now only SCSI support is missing.


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

Incorrect checking of already set double indirect blocks

Wrong variable usage in inner loop caused some double indirect stream
runs to be checked twice when block size was smaller than
DOUBLE_INDIRECT_ARRAY_SIZE, while some were incorrectly marked as
unallocated in the bitmap.

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


# 46cf7a5a 14-Nov-2012 Przemysław Buczkowski <przemub@yahoo.pl>

Fix typos: super block -> superblock (#8974)

Signed-off-by: Przemysław Buczkowski <przemub@yahoo.pl>
Signed-off-by: Matt Madia <mattmadia@gmail.com>


# bd97ee39 30-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Style fix.


# caa1e8b7 31-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.


# 3cd66dda 31-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.


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

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


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

CheckBlocks() calculated the group block incorrectly

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


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

The inode must be write locked. Dunno how that could work before.


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

Make PrepareIndices() fail if there isn't anything left to do.


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

Fixed a possible KDL; the inode might be NULL.

* This happens in case the inode could not be opened in the first place.


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

Minor cleanup.


# 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.


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

Made fLock a recursive lock instead of a mutex.

* This should fix bug #8069.


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

No need for 'else' after return.


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

When running checkfs, BPlusTree::Validate() is now called.


# d86197ce 11-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Fix build with DEBUG on.


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

* Minor simplification.


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


# 105eeb9c 07-Aug-2011 Jérôme Duval <korli@users.berlios.de>

When checkfs stop checking, the block allocator tries to write more blocks than present in fCheckBitmap, so we constrain it
to fNumBlocks.


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


# bdce1498 06-Aug-2011 Jérôme Duval <korli@users.berlios.de>

added std::nothrow for some new calls, and initialize fCheckCookie


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


# 21d6b8e2 12-Jun-2011 Axel Dörfler <axeld@pinc-software.de>

* Let checkfs collect stats of how the data streams are used.
* Would be nice to only show this when an extra argument had been passed to
checkfs, but I'm afraid the API is somewhat limited, not to say pretty much
unusable for the task.


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


# 5cb190ed 08-Jun-2011 Axel Dörfler <axeld@pinc-software.de>

* Remove the entry from the entry cache as well when removing a bad inode.


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


# 579e19f5 17-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed CID 1703: buffer could be leaked. Thanks to Stefano for the note.


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


# a9022acd 09-Mar-2010 Axel Dörfler <axeld@pinc-software.de>

* BlockAllocator::CheckNextNode() did enter an endless loop if it experienced
problems iterating over a B+tree (due to corruption).
* For now, it will stop the check process when this happens, but we definitely
need to be able to fix broken B+trees in the future.


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


# 5edde94c 06-Mar-2010 Axel Dörfler <axeld@pinc-software.de>

* checkfs is now working again; I couldn't test my earlier changes because I had
no time left, but I didn't want to lose them either.
* This fixes bug #5536, sorry for the inconvenience.


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


# d501707d 03-Mar-2010 Axel Dörfler <axeld@pinc-software.de>

* Removed the cookie field of the check_control structure; that really was
a stupid idea. Instead, the already existing fCheckCookie member is used.
* bfs_ioctl() now accesses all userland buffers safely, this should help with
#3264, and move the crash where it belongs.
* Changes not yet tested; they only affect checkfs.


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


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

* Replaced the specialized inode in transaction mechanism with a generic one.
That costs 12 more bytes per inode on 32 bit platforms, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35491 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


# 9c258e29 10-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Added group pointers to the "bfs_allocator" command.


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


# aeb099b3 19-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Added a very simple way to fragment your disk.


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


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

* Build fix for the boot loader (it's now using the new utility functions as
well). Sorry!


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


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

* Inode::FindBlockRun() now checks the block run size of double indirect runs,
and stops processing if it finds something wrong.
* The default indirect/double array size differs from BeOS' BFS. I've changed
the size for double indirect arrays only, since the other size should work
either way (not tested yet, this change has a negative effect on the maximum
file size, but improves BeOS compatibility).
* The read/write path of BFS is now double indirect block size agnostic, and
should work with what it finds.
* Merged all double indirect size computation into some utility inline
functions.


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


# 1a60fd72 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced the Inode::GetTree() method with a simple getter - the tree is
always created for directories since quite some time now.


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


# 64b14593 29-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* checkfs is now also able to fix name mismatches (when the inode contains a
different name than the directory entry pointing to it). The BeOS BFS is known
to create such problems from time to time.


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


# b5a51254 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Don't use Inode::Remove() when the inode could not be opened, because it
actually relies on that.
* Instead, _RemoveInvalidNode() now manipulates the parent tree manually.


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


# e66295e5 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* The inode may actually not be known when calling _RemoveInvalidNode(), this
could cause a KDL.
* Added a "force" argument to Inode::Remove() which should make it remove inodes
more reliably for checkfs.


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


# 84ce48c2 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* checkfs should now also remove unaccessible files. Not yet tested.


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


# 450a9b8e 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* AllocateBlocks() now guarantees that the returned allocation size is a
multiple of "minimum".


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


# 2990bea7 25-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* The bitmap size was computed incorrectly, and thus, StopChecking() could
access the block bitmap out of bounds (which usually resulted in a crash).


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


# 66ae5b2d 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* The block allocator will no longer try to fix a missing allocation on a
read-only volume. This fixes bug #3432.
* Journal::ReplayLog() will now return an error on a read-only device, rendering
read-only dirty volumes unmountable.


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


# 2dbad065 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed two bugs in CheckBlocks(), might help with bug #4042.


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


# 3e69a3c2 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* BFS allocated always full allocation groups in the bitmap, even if the last
group was a partial one. This caused bug #3963 (Be's BFS didn't do that).
* Added new BlockAllocator::CheckBlocks() that does not depend on allocation
group limits - this fixes the problematic check in
BlockAllocator::_Initialize() to see if the super block, the block bitmap,
and the log area are all allocated - this only worked if they all fit into
the first allocation group (which happens only with partitions with more
than 1 billion blocks, ie. 2 TB would already be problematic with a 2K block
size).


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


# 2f3d29ce 08-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* The attribute directory of the root directory was ignored. This could lead to
data corruption after a checkfs run. Fixes bug #3963.
* Added some more debug output.


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


# 992fba36 16-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* There is now a list of removed vnodes in Volume - while asking the VFS for
this seemed to be a good idea, there is one race condition that cannot be
solved otherwise (the vnode must be added/removed to that list while holding
the transaction lock, and we cannot guarantee that in the VFS).
* We are using an unused area of the in-memory bfs_inode to store the list
links (bfs_inode::pad - this will also work on 64 bit platforms).
* Inode no longer adds a singly linked list link - the transaction list now
shares the doubly linked list with the removed vnodes list.
* Added an in-memory flag INODE_IN_TRANSACTION to avoid searching an inode
to be added in the list.
* Removing an attribute directory did not hold its write lock.
* If removing an attribute failed for some reason, the INODE_DELETED flag
was not removed (the transaction would not have failed because of that).


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


# e621d84d 15-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Now takes the removed but not yet deleted vnodes into account when allocating
spaces on the bitmap.
* This fixes bug #3730.


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


# 9ec59fc9 09-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Improved tracing of the allocations at block level.
* Turned on extra check on allocation when KDEBUG is set.
* The "bfs" KDL command now also prints the block bitmap block for the
specified block.


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


# e677f5aa 10-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed two possible crashing bugs in the file system check code: the checker
was attached to the inode instead of the file descriptor, causing it to call
BlockAllocator::StopChecking() whenever anyone closed the device's root node
during the check. The other bug was that it tried to fix errors even if the
device was read-only.
* Added TODO that ioctl() accesses userland buffers unsafely.
* Removed no longer valid or superfluous comments.


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


# 64e0d084 02-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Inodes are no longer trimmed from the checking thread. This should fix bug
#3190.


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


# 897a2e21 05-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* The block allocator now uses block_cache_discard() to make sure the file
and the block cache don't interfere when working on the same blocks.
* This has fixed all kinds of file corruptions I could reproduce before,
therefore likely also bug #3010.


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


# 6c3348f1 01-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* The check mechanism in the block allocator now locks the journal as well to
fix a potential deadlock.
* Journal::Lock() now accepts another parameter that specified whether child
transactions should be split - this is nothing you would want in normal
operation unless the parent transaction is only there to prevent others from
writing (such as with the block allocator check stuff).


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


# a0a1bf7f 16-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Disabled the allocation group check again.
* Fixed warnings.


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


# 58a77fd3 16-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the incorrect ASSERT that possibly dropped you into KDL while deleting
something (as reported by Marcus and Bruno on the mailing list).
* AllocationGroup::Allocate() would always invalidate the largest block if
it did not cover the largest part of the group; now it only invalidates it
if it has been cut before.
* Added small test app for the invalidation part.


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


# f00aecf4 15-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

Cleanup in AllocateBlocks():
* Replaced "group" with groupIndex, "group" is now a reference to the
AllocationGroup.
* Renamed some variables for clarity.
* No functional change.


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


# ab8b37cf 15-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed another check, the warning "first free too late" was printed even
though there was no problem.
* Nevertheless, improved output of that warning :-)


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


# b06a5d91 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bad bug (that I introduced with one of the last commits...) that
could check memory beyond the block and then tried to allocate that on the
correct block (would possibly lead to KDL).
* Made AllocationBlock::Allocate() and Free() inline.


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


# 8cc45109 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed build when DEBUG_ALLOCATION_GROUPS is not defined, thanks Rene.


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


# 98ec129e 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* I obviously need some sleep: messed up the fix, and forgot some parenthesis...


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


# 4986b5c7 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the wrong check for the largest block: it was always checked, no matter
if the largest block was marked invalid or not. Thanks for testing, luroh :-)
* Fixed warning.


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


# a8744b0e 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Each allocation group now lazily maintains the largest free block separately,
so that allocations can be directly fulfilled from that block without having
to search for it.
* This should further improve the allocator's performance, but it could need
more tuning (ie. when to rebuild the free block).
* Added debugging code to check if the largest block is maintained correctly;
it's currently turned on (DEBUG_ALLOCATION_GROUPS) which makes allocations
actually pretty slow - I'll disable it again after it has been tested a bit
more.
* Added a "bfs_allocator_blocks" KDL command that allows you to show all
tracing entries that affect a specific block (only available if BFS has
been compiled with tracing support).


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


# 976eeb4d 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

Squashed a TODO in the block allocator:
* BlockAllocator::AllocateBlocks() was implemented pretty crappy: instead of
just remembering the best run on the first pass, it made a second pass through
all allocation groups when it couldn't fulfill the maximum request.
* Even worse, it would then also only allocate the first run that satisied the
minimum request. Now, it will always choose the best allocation, leading to
less fragmentation, and an improved runtime.
* Now mmlr hopefully won't need to wait 10 minutes for the bloc allocator to
create the swap file on his fragmented volume...


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


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

* Removed no longer needed IOCTL_FILE_UNCACHED_IO definition.
* Some cleanup, no functional change.


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


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

* Unmounting a volume didn't wait for the block allocator's initializer thread.
* This fixed bug #2541.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26679 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


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

* Work-around for the KDEBUG "holder" mechanism; we actually want to lock the
mutex in another thread here than we will unlock it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26300 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


# 8e8edffc 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed at least the "dd" part of bug #2148: the second double indirect array
block would be incorrectly addressed when allocating a stream - this could
cause random blocks to be overwritten, and therefore could cause many sorts
of problems.
* Moved BFS_TRACING macro to the tracing_config.h file, and let it follow the
new semantics of those other macros in there.


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


# 797a92d8 07-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Made super block log handling endian-safe.
* Made all debugging functions endian-safe.
* Added tracing for log entries.
* Added new KDL command "bfs_journal" to dump all pending log entries.
* When BFS_DEBUGGER_COMMANDS is defined, the LogEntry class will also track
the transaction ID it belonged to.
* The "bfs" KDL command now sets some useful debugger variables.
* The "bfs_allocator" KDL command now accepts the group index as 3rd argument.
* Renamed Journal::_TransactionListener() to _TransactionIdle(), as that's
all it is for.
* Removed TODO comment in Volume::WriteSuperBlock(), as it's actually not true.


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


# 7ffafac8 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reorganized the FS interface a little:
- Moved most file_system_module_info hooks into separate structures.
Those that operate on mounted volumes to fs_volume_ops, those
operating on a vnode to fs_vnode_ops.
- Got rid of the fs_volume, fs_cookie, fs_vnode typedefs. We use void*
again.
- Instead of a void* volume and node cookie hooks are passed a
fs_volume and fs_vnode structure pointer, which contain the cookie
and an ops pointer (fs_volume a few more things).
- The VFS {new,publish,get,...}_vnode() functions take a fs_volume*
instead of the volume ID. So does vfs_get_fs_node_from_path().
- Added type and flags arguments to publish_vnode() and the
get_vnode() hook and removed the type argument from lookup() hook.
Added vnode::type using formerly unused bits to store the node type.
Simplified a few things in the VFS due to the now always available
node type.
- Added fs_volume_ops::{create,delete}_sub_vnode() and
fs_vnode_ops::get_super_vnode() hooks. They are used to support file
system layers, e.g. allowing to extend an FS not supporting BeOS
attribute with attribute support. Needs some more work in the VFS.
- Added fs_vnode_ops::create_special_node() hook for creating special
nodes (e.g. FIFOs).
* Adjusted the built-in file systems and BFS according to the interface
changes. Removed all other FSs from the image for the time being.
We'll see whether further API changes are necessary before porting
them.
* Adjusted the bfs_shell accordingly.
* Implemented create_special_node() in rootfs to support special nodes.
* Added support for FIFOs:
- Added syscall _kern_create_fifo() (used by mkfifo()), which creates
a special node (type S_IFIFO) in the respective file system.
- When a special node is published the VFS creates a respective sub
node. Currently only FIFOs are supported.
- Added a little support for FIFO subnodes by using functionality from
the pipefs.
- Added mkfifo to the image. It can create FIFOs in the rootfs, but
the FIFOs aren't really usable ATM, since they still work like
pipes, i.e. readers and writers need to have them open at the same
time.
* Some smaller changes in the VFS:
- Made the *_CALL macros nicer to use (vargs).
- Refactored FS entry lookup into new function lookup_dir_entry().
- create_vnode() no longer just calls the FS create() hook. First it
looks up the entry and uses open_vnode(), if it already exists. This
is necessary for two reasons: 1) The FS might not support create()
while still allowing to open() entries. 2) When the FS has other
layers on to of it (or the respective node) it might not be
responsible for opening the node.


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


# 2f20bf15 25-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added "bfs" prefix to tracing output.
* When an inode is trimmed, it now also traces the previous internal
size as well as the target size.
* Remove extraneous white space.


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


# f7a5d9c5 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed TraceEntry::Dump() to take a TraceOutput& and removed
AbstractTraceEntry::AddDump(char*, size_t).


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


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

Improved tracing output a bit.


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


# 5d0afa4e 18-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* cache_detach_sub_transaction() didn't really work: it did not put all needed
blocks into the new transaction, but it would set that transaction on all
blocks of the old transaction, too. Also, it did not correctly update the
num_blocks/sub_num_blocks fields of the old transaction. Even worse, it did
return B_OK instead of the ID of the new transaction...
* get_writable_cached_block() did not correctly maintain the number of blocks
in the sub transaction.
* write_cached_block() did not free the original_data of a block when it wrote
it back as part of a previous transaction.
* Changed "cookie" for cache_next_block_in_transaction() to "long", so it will
be 64 bits when needed.
* Improved the API for detaching sub transactions: you can now get the blocks
of only the main (parent) transaction as well, added new
cache_block_in_main_transaction() function.
* BFS now flushes the log when there is no space left for the current
transaction.
* _WriteTransactionToLog() allocated a "vecs" array, but never freed it.
* _WriteTransactionToLog() now also supports detaching the current sub
transaction if the whole thing is getting too large (it will now also panic
if that doesn't work out).
* Removed a useless optimization: making the blocks available in the cache
isn't really needed, as all blocks in a transaction are locked into the
cache, anyway.
* Implemented Transaction::WriteBlocks().
* Minor cleanup, removed some dead code, fixed warnings in the fs_shell's
block_cache when compiled with debug output on.


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


# 09c46ea8 15-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed bug in the BlockAllocator::Allocate() function which did not
compute the bit offsets correctly if the last block of the whole
bitmap was only a partial block.
* Added new bfs_allocator KDL command.
* Renamed the KDL command bfsinode to bfs_inode.
* Added "--help" argument to bfs_inode and bfs KDL commands.
* Added more tracing in the block allocator.
* Turned on the ASSERT() macro in non-debug builds.
* Minor cleanup.


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


# 42ef796e 13-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Added a bit more tracing output to the block allocations.


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


# 4fc4f2c8 13-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a transaction listener mechanism to be notified when a
transaction ends or has been aborted.
* BFS now listens for transactions when it created an inode to see if
the transaction will be aborted without freeing the inode (in which
case it will panic for now).
* Started implementing tracing support, but it's not working yet.
* Minor cleanup.


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


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

Some more work on the tracing API:
* Added function to allocate space in the buffer.
* Dump() now fills a buffer instead of printing its data directly.
* This allows the new "#pattern" argument of the "traced" command to
work. When you're using that, the index of the trace entry is printed
out, too, so that you can then get a full dump around the hits.
* Added an AddDump() method to the AbstractTraceEntry class so that
there is no need to call the inherited function anymore.
* Minor cleanup.


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


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

* Made the additions of the KDL debugger commands independant from the
DEBUG macro; they are now added only if BFS_DEBUGGER_COMMANDS is
defined (which is now done by default in the Jamfile).
* Added "bfs" KDL command which dumps volume information and the super
block.
* Made use of the new tracing API to trace block and inode actions
(and the new AbstractTraceEntry class I forgot to mention in the last
commit). Is compiled in only when BFS_TRACING is enabled (defaults to
off in the standard builds).


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


# 245aecda 21-Jun-2007 Axel Dörfler <axeld@pinc-software.de>

Got rid of vnode_id and mount_id, replaced with ino_t and dev_t.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21485 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


# 68f08f67 07-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bug introduced with big-endian fixes in r17557; the super block's blocks_per_ag
field was always 1, and therefore, the last allocation group could grow too large.
Thanks to Samuel Rodriguez Perez for reporting the error (bfs_shell was crashing on
larger images).
* Minor cleanup in BlockAllocator::_Initialize().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21053 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


# fc317af2 23-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Writing to attributes was deadlock prone; the BFS volume lock was acquired with
the BFS Journal lock held.
Since our get_vnode() is no longer unsafe (unlike Be's version of it), we can
get rid of the UNSAFE_GET_VNODE stuff, which also solves this bug.


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


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

CheckInode() could find an invalid data stream for symlinks without a data stream;
the data stream area is reused as link data in this case.
Reported by Robert Szeleney.


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


# 85baf76e 28-Sep-2006 Axel Dörfler <axeld@pinc-software.de>

The computation of the number of blocks in the last allocation group was wrong; it
would usually be one block too small - this fixes bug #659.


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


# 60a50e3a 26-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

Aborted "svn commit" a little bit too late: build fix for the previous revision.


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


# f41837b4 26-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

* The AllocationGroup now has a field for its number of blocks, as well as public
getter methods.
* Fixed allocation problem of an incomplete last allocation group, as reported by
Robert Szeleney.
* Minor cleanup, slightly improved comments, renamed private methods to have a
leading '_'.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16507 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


# a9d0f0e5 26-May-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a minor bug in the file system check code: it was not always correctly
determined if the parent directory had the wrong type.


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


# 805cd92d 12-Dec-2004 Axel Dörfler <axeld@pinc-software.de>

Just a commentary changed.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10401 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


# 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


# 34cf473d 03-May-2004 Axel Dörfler <axeld@pinc-software.de>

BlockAllocator::CheckBlockRun() can now also check for non-allocated ranges.
Fixed a possible endian problem in CheckBlockRun(), too.


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


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

Fixed a race condition in the block allocator initialization (the lock was held
too late, and could theoretically already be acquired by someone else).


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


# 5b25332a 01-Feb-2004 Axel Dörfler <axeld@pinc-software.de>

This should fix the recently introduced locking problems:
- locking policy is now: 1) the volume lock, 2) the inode lock, 3) start
the transaction (the journal lock) - you don't need all locks, but you
have to follow this order when you need more than one of them.
- in many cases, this makes our inode read/write lock useless. I am really
looking forward to the OpenBeOS VFS layer where we can remove many of
these locks again.


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


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

Switched from direct get_vnode() usage to the Vnode class.
Now acquires the volume lock always before get_vnode() is called as long
as UNSAFE_GET_VNODE is defined (which now is by default).
May cause some unwanted side-effects; it still has to be thorougly tested.


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


# 11805f2d 28-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

BlockAllocator::InitializeAndClearBitmap() now also sets the used_blocks
field of the super block correctly.


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


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

Added some more debug output and checks.


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


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

Implemented initalizing the bitmap of a fresh volume in the new call
BlockAllocator::InitializeAndClearBitmap().
Added BlockAllocator::BitmapSize() which returns the size of the block
bitmap in bytes - used it where appropriate.


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


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

Switched to kernel_cpp.h/cpp.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6291 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


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

Added a simple magic field mechanism to make chkbfs calls a little more safe.


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


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

Removed the possibility to create a Semaphore object without specifying
a name - that's mostly done to:
1) force better fitting lock names
2) make the API consistent (the empty ReadWriteLock constructor doesn't
initialize the lock anymore).


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


# 6ac535c5 25-May-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed another bad bug in the block allocator: the size of the last block
of the block bitmap could be computed wrong - this could cause all sorts
of errors like: overwriting data, creating the "new_vnode with different
cookie" problem, etc.
Should really be the last bug in that piece of code ;-P


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3331 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


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

Fixed many warnings.


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


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

The new block bitmap is now written using through the log for chkbfs.


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


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

Fixed a stupid bug, used Inode::Name() without locking.


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


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

Now uses Inode::GetName() and strlcpy().


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


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

Added support for aborted "chkbfs" runs (so that they won't do any harm).


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


# 8a3e35d8 21-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

AllocationBlock::Allocate() still had the 0xffff thing implemented, now
also the numBlocks parameter is ASSERTed - when compiled with DEBUG turned
off, BFS will enter the kernel debugger in this case (through the use of
the DIE() macro).
Same for AllocationBlock::Free() (but the 0xffff mode was already removed
there).


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


# 98887c63 21-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Symbolic link data streams (for long symlinks) now are located in the same
allocation group as the inode, if possible.
Moved the group used blocks info maintaining code into AllocationGroup::Allocate()
and AllocationGroup::Free() (instead of letting the BlockAllocator class do
the work).
Removed the buggy and useless extra 0xffff mode for AllocationBlock::Allocate()
and AllocationBlock::Free(), both methods now ASSERT their parameter range.
Changed some comments, style cleanups.


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


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

BlockAllocator::CheckInode() now has support for the double indirect region
of the stream (so the "chkbfs" functionality is complete now).
Fixed wrong block number report in BlockAllocator::CheckBlockRun(), blocks are
now printed out in absolute numbers (not allocation_group relative anymore).
Use Inode::IsContainer() where necessary instead of Inode::IsDirectory().
Fixed a big and nasty bug in AllocationBlock::SetTo(): the number of bits in
a block could be calculated wrong for a partial allocation group which need
more than one block in the bitmap - hopefully, that was the last remaining
big bug in the block allocator.


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


# 3f870da9 17-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Almost complete and working "chkbfs" functionality for BFS. It can be used
via the private ioctls defined in bfs_control.h.
Detects all kinds of errors, and can correct most of them. It doesn't fix
any errors in the b+trees (like the ones created by an earlier version
of the BPlusTree class ;-), and it also can't fix the "blocks are already set"
error, which occurs if more than one file claims a particular block (or
range of blocks) for itself.
The double indirect data range is not yet supported, so use with care, or
run the original chkbfs afterwards to fix any errors because of that.
Might not yet analyze 100% correct (shows way to many errors for my tastes...).
A "chkbfs" command will be made available shortly.


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


# 23d098b6 22-Oct-2002 Axel Dörfler <axeld@pinc-software.de>

Forgot to set the new "start" within the blocks range in
AllocationGroup::Allocate()/Free().


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


# 820dca19 22-Oct-2002 Axel Dörfler <axeld@pinc-software.de>

Rearranged some code in the BlockAllocator; AllocationGroup now has Allocate()
and Free() methods which operate on the AllocationBlocks.
BlockAllocator::AllocateBlocks() couldn't correctly reserve space for allocation
groups with more than 2 blocks - AllocationGroup::Allocate() now can, which
is now used by AllocateBlocks() (but it's slightly less fast).
Began implementing functionality for a chkbfs-like command.
Some style changes.


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


# 2b5451f1 16-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Added private non-implemented copy constructor and assignment operators
for many classes for the sake of completeness.
Added a Transaction::IsStarted() method to not let it look like as if the
transaction is started more than once.
Changes made after suggestions from Mike Nordell, again :-)


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


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

Fixed two bugs in the block allocator:
- the maximum number of blocks a block_run can cover is 65535 not 65536
- allocations over a block boundary in the block bitmap always failed due
to a incorrectly handled status

Both bugs could prevent BFS to create the VM swap file which led BeOS to
stop booting under certain circumstances.


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


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

Volume::Free(), and BlockAllocator::Free() now pass the block_run by value
rather than by reference.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@848 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


# 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.


# 22d300c2ce97ec49774238e51d2ff95380c9ba7b 02-Mar-2014 Axel Dörfler <axeld@pinc-software.de>

AHCI/BFS: fixed temporary trim debug output.


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

trim: added debug output.

* Can you give it another try, Alexander? The outcome won't change, I'm afraid,
but maybe we'll know some more afterwards.


# 99086aa32333be5792b0f059ccbbe3c90be05ea6 14-Aug-2013 Axel Dörfler <axeld@pinc-software.de>

trim: Target SCSI UNMAP command instead of WRITE SAME.

* The UNMAP command is theoretically much faster, as it can get many block
ranges instead of just a single range.
* Furthermore, the ATA TRIM command resembles it much better.
* Therefore, fs_trim_data now gets an array of ranges, and we use SCSI UNMAP
to trim.
* Updated BFS code to collect array ranges to fully support the new
fs_trim_data possibilities.


# 0a0ba4b5f09da93410943578b6c5aa1f3aa60cb0 04-Aug-2013 Axel Dörfler <axeld@pinc-software.de>

Added B_TRIM_DEVICE support to BFS.

* It currently ignores the offset/size, though, and always trims everything.
* Now only SCSI support is missing.


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

Incorrect checking of already set double indirect blocks

Wrong variable usage in inner loop caused some double indirect stream
runs to be checked twice when block size was smaller than
DOUBLE_INDIRECT_ARRAY_SIZE, while some were incorrectly marked as
unallocated in the bitmap.

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


# 46cf7a5a73679c6e4fde91710e4a4885242e49d1 14-Nov-2012 Przemysław Buczkowski <przemub@yahoo.pl>

Fix typos: super block -> superblock (#8974)

Signed-off-by: Przemysław Buczkowski <przemub@yahoo.pl>
Signed-off-by: Matt Madia <mattmadia@gmail.com>


# bd97ee39e0e93fe8c7774d89e411de8b85ad0cbf 30-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Style fix.


# caa1e8b74245bd1602bd9d6ae642e34beb583a00 31-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.


# 3cd66dda5e623130a5ef7560da6851d421fd591e 31-Jul-2012 Alex Smith <alex@alex-smith.me.uk>

Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.


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

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


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

CheckBlocks() calculated the group block incorrectly

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


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

The inode must be write locked. Dunno how that could work before.


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

Make PrepareIndices() fail if there isn't anything left to do.


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

Fixed a possible KDL; the inode might be NULL.

* This happens in case the inode could not be opened in the first place.


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

Minor cleanup.


# 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.


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

Made fLock a recursive lock instead of a mutex.

* This should fix bug #8069.


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

No need for 'else' after return.


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

When running checkfs, BPlusTree::Validate() is now called.


# d86197cec3b4572b8be206d2aa6eb10e41093967 11-Dec-2011 Michael Lotz <mmlr@mlotz.ch>

Fix build with DEBUG on.


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

* Minor simplification.


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


# 105eeb9c848f63c5e8c18ceff9180383f5977229 07-Aug-2011 Jérôme Duval <korli@users.berlios.de>

When checkfs stop checking, the block allocator tries to write more blocks than present in fCheckBitmap, so we constrain it
to fNumBlocks.


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


# bdce14985bcbea5f3f62404df1e877386a11d7a5 06-Aug-2011 Jérôme Duval <korli@users.berlios.de>

added std::nothrow for some new calls, and initialize fCheckCookie


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


# 21d6b8e2c7d3f4506007547fd2faf25b42d43fd6 12-Jun-2011 Axel Dörfler <axeld@pinc-software.de>

* Let checkfs collect stats of how the data streams are used.
* Would be nice to only show this when an extra argument had been passed to
checkfs, but I'm afraid the API is somewhat limited, not to say pretty much
unusable for the task.


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


# 5cb190eda296ba1f5b0ca1d3933eadb27f77f0af 08-Jun-2011 Axel Dörfler <axeld@pinc-software.de>

* Remove the entry from the entry cache as well when removing a bad inode.


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


# 579e19f5b954c0ef288404f3c071a3e0fc9f7ff2 17-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Fixed CID 1703: buffer could be leaked. Thanks to Stefano for the note.


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


# a9022acd2a3d91edd6ed4350b166acf02134eda6 09-Mar-2010 Axel Dörfler <axeld@pinc-software.de>

* BlockAllocator::CheckNextNode() did enter an endless loop if it experienced
problems iterating over a B+tree (due to corruption).
* For now, it will stop the check process when this happens, but we definitely
need to be able to fix broken B+trees in the future.


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


# 5edde94cab42af0a1194c04466bc6731ff0b708b 06-Mar-2010 Axel Dörfler <axeld@pinc-software.de>

* checkfs is now working again; I couldn't test my earlier changes because I had
no time left, but I didn't want to lose them either.
* This fixes bug #5536, sorry for the inconvenience.


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


# d501707d8abd1f3648bed3a4f975e3a984a5e6f1 03-Mar-2010 Axel Dörfler <axeld@pinc-software.de>

* Removed the cookie field of the check_control structure; that really was
a stupid idea. Instead, the already existing fCheckCookie member is used.
* bfs_ioctl() now accesses all userland buffers safely, this should help with
#3264, and move the crash where it belongs.
* Changes not yet tested; they only affect checkfs.


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


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

* Replaced the specialized inode in transaction mechanism with a generic one.
That costs 12 more bytes per inode on 32 bit platforms, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35491 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


# 9c258e291d36b3ebad59a772d253797eae718654 10-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Added group pointers to the "bfs_allocator" command.


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


# aeb099b317eda4eb3c4b3318222e0a7d3ed2867f 19-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Added a very simple way to fragment your disk.


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


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

* Build fix for the boot loader (it's now using the new utility functions as
well). Sorry!


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


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

* Inode::FindBlockRun() now checks the block run size of double indirect runs,
and stops processing if it finds something wrong.
* The default indirect/double array size differs from BeOS' BFS. I've changed
the size for double indirect arrays only, since the other size should work
either way (not tested yet, this change has a negative effect on the maximum
file size, but improves BeOS compatibility).
* The read/write path of BFS is now double indirect block size agnostic, and
should work with what it finds.
* Merged all double indirect size computation into some utility inline
functions.


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


# 1a60fd72cf588ed0d25028da354261b4d8409c08 06-Aug-2009 Axel Dörfler <axeld@pinc-software.de>

* Replaced the Inode::GetTree() method with a simple getter - the tree is
always created for directories since quite some time now.


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


# 64b145930e28cd1b717da8951d787d3916c9ed37 29-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* checkfs is now also able to fix name mismatches (when the inode contains a
different name than the directory entry pointing to it). The BeOS BFS is known
to create such problems from time to time.


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


# b5a51254dc88420043623914ada12e2ab778611b 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* Don't use Inode::Remove() when the inode could not be opened, because it
actually relies on that.
* Instead, _RemoveInvalidNode() now manipulates the parent tree manually.


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


# e66295e5e578267d488a98387f2f29f38d7242e9 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* The inode may actually not be known when calling _RemoveInvalidNode(), this
could cause a KDL.
* Added a "force" argument to Inode::Remove() which should make it remove inodes
more reliably for checkfs.


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


# 84ce48c248d78df09ca356e082b14980b31a2cd6 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* checkfs should now also remove unaccessible files. Not yet tested.


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


# 450a9b8e7e5eb95bbdd3125983138b7e8d0c68e1 26-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* AllocateBlocks() now guarantees that the returned allocation size is a
multiple of "minimum".


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


# 2990bea7667181d26f75380c7404eccf28b5c2d0 25-Jul-2009 Axel Dörfler <axeld@pinc-software.de>

* The bitmap size was computed incorrectly, and thus, StopChecking() could
access the block bitmap out of bounds (which usually resulted in a crash).


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


# 66ae5b2d993e457764f5c72d2ea9ea604068187f 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* The block allocator will no longer try to fix a missing allocation on a
read-only volume. This fixes bug #3432.
* Journal::ReplayLog() will now return an error on a read-only device, rendering
read-only dirty volumes unmountable.


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


# 2dbad0651eadd7dbc96ae3164c4f71974ecf3599 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed two bugs in CheckBlocks(), might help with bug #4042.


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


# 3e69a3c24a9ed31bf574a834cd720fca67846f60 26-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* BFS allocated always full allocation groups in the bitmap, even if the last
group was a partial one. This caused bug #3963 (Be's BFS didn't do that).
* Added new BlockAllocator::CheckBlocks() that does not depend on allocation
group limits - this fixes the problematic check in
BlockAllocator::_Initialize() to see if the super block, the block bitmap,
and the log area are all allocated - this only worked if they all fit into
the first allocation group (which happens only with partitions with more
than 1 billion blocks, ie. 2 TB would already be problematic with a 2K block
size).


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


# 2f3d29cec74de01f0aca9a64ca69d48d713de362 08-Jun-2009 Axel Dörfler <axeld@pinc-software.de>

* The attribute directory of the root directory was ignored. This could lead to
data corruption after a checkfs run. Fixes bug #3963.
* Added some more debug output.


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


# 992fba36eef8b17808a06d483f2fdad90173b01d 16-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* There is now a list of removed vnodes in Volume - while asking the VFS for
this seemed to be a good idea, there is one race condition that cannot be
solved otherwise (the vnode must be added/removed to that list while holding
the transaction lock, and we cannot guarantee that in the VFS).
* We are using an unused area of the in-memory bfs_inode to store the list
links (bfs_inode::pad - this will also work on 64 bit platforms).
* Inode no longer adds a singly linked list link - the transaction list now
shares the doubly linked list with the removed vnodes list.
* Added an in-memory flag INODE_IN_TRANSACTION to avoid searching an inode
to be added in the list.
* Removing an attribute directory did not hold its write lock.
* If removing an attribute failed for some reason, the INODE_DELETED flag
was not removed (the transaction would not have failed because of that).


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


# e621d84da32d3c925f6ca5154069467088e55bbb 15-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Now takes the removed but not yet deleted vnodes into account when allocating
spaces on the bitmap.
* This fixes bug #3730.


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


# 9ec59fc934e3faebec57771fe94ed5676674ba95 09-Apr-2009 Axel Dörfler <axeld@pinc-software.de>

* Improved tracing of the allocations at block level.
* Turned on extra check on allocation when KDEBUG is set.
* The "bfs" KDL command now also prints the block bitmap block for the
specified block.


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


# e677f5aa675fce95e7558cf58fee40afd6df554d 10-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Fixed two possible crashing bugs in the file system check code: the checker
was attached to the inode instead of the file descriptor, causing it to call
BlockAllocator::StopChecking() whenever anyone closed the device's root node
during the check. The other bug was that it tried to fix errors even if the
device was read-only.
* Added TODO that ioctl() accesses userland buffers unsafely.
* Removed no longer valid or superfluous comments.


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


# 64e0d0841b2276f67a953dd09e900743b7cb5a2b 02-Jan-2009 Axel Dörfler <axeld@pinc-software.de>

* Inodes are no longer trimmed from the checking thread. This should fix bug
#3190.


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


# 897a2e211316e5b08bb6784cc59ad0c80762aa46 05-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* The block allocator now uses block_cache_discard() to make sure the file
and the block cache don't interfere when working on the same blocks.
* This has fixed all kinds of file corruptions I could reproduce before,
therefore likely also bug #3010.


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


# 6c3348f1cd611725029432cd0cb8c35a7e2e5924 01-Nov-2008 Axel Dörfler <axeld@pinc-software.de>

* The check mechanism in the block allocator now locks the journal as well to
fix a potential deadlock.
* Journal::Lock() now accepts another parameter that specified whether child
transactions should be split - this is nothing you would want in normal
operation unless the parent transaction is only there to prevent others from
writing (such as with the block allocator check stuff).


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


# a0a1bf7fb0617843d4ef133b2a80bb07ea9276c7 16-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Disabled the allocation group check again.
* Fixed warnings.


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


# 58a77fd3c964a1e89e1ce1bd1b4e94f501dcfff8 16-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the incorrect ASSERT that possibly dropped you into KDL while deleting
something (as reported by Marcus and Bruno on the mailing list).
* AllocationGroup::Allocate() would always invalidate the largest block if
it did not cover the largest part of the group; now it only invalidates it
if it has been cut before.
* Added small test app for the invalidation part.


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


# f00aecf4b646fff6bf67ef38521510b7a5abd8ac 15-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

Cleanup in AllocateBlocks():
* Replaced "group" with groupIndex, "group" is now a reference to the
AllocationGroup.
* Renamed some variables for clarity.
* No functional change.


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


# ab8b37cf9f50c31f74fbd21cfb694d071cc3d5f4 15-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed another check, the warning "first free too late" was printed even
though there was no problem.
* Nevertheless, improved output of that warning :-)


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


# b06a5d91f921a811d4a2dfc19c5ed56a19b48475 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bad bug (that I introduced with one of the last commits...) that
could check memory beyond the block and then tried to allocate that on the
correct block (would possibly lead to KDL).
* Made AllocationBlock::Allocate() and Free() inline.


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


# 8cc45109d2a77637ae26fd9bd4cf23ef5c475cf1 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed build when DEBUG_ALLOCATION_GROUPS is not defined, thanks Rene.


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


# 98ec129e53f76c5e14ddfdd64b8a5c415f1c350e 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* I obviously need some sleep: messed up the fix, and forgot some parenthesis...


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


# 4986b5c767fd4d8d6b7515a16cac1456a283531e 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed the wrong check for the largest block: it was always checked, no matter
if the largest block was marked invalid or not. Thanks for testing, luroh :-)
* Fixed warning.


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


# a8744b0ee99cd1972d6dd72ca705c24c326869bf 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

* Each allocation group now lazily maintains the largest free block separately,
so that allocations can be directly fulfilled from that block without having
to search for it.
* This should further improve the allocator's performance, but it could need
more tuning (ie. when to rebuild the free block).
* Added debugging code to check if the largest block is maintained correctly;
it's currently turned on (DEBUG_ALLOCATION_GROUPS) which makes allocations
actually pretty slow - I'll disable it again after it has been tested a bit
more.
* Added a "bfs_allocator_blocks" KDL command that allows you to show all
tracing entries that affect a specific block (only available if BFS has
been compiled with tracing support).


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


# 976eeb4da0acac95630383c8997f7fb0fd349814 14-Oct-2008 Axel Dörfler <axeld@pinc-software.de>

Squashed a TODO in the block allocator:
* BlockAllocator::AllocateBlocks() was implemented pretty crappy: instead of
just remembering the best run on the first pass, it made a second pass through
all allocation groups when it couldn't fulfill the maximum request.
* Even worse, it would then also only allocate the first run that satisied the
minimum request. Now, it will always choose the best allocation, leading to
less fragmentation, and an improved runtime.
* Now mmlr hopefully won't need to wait 10 minutes for the bloc allocator to
create the swap file on his fragmented volume...


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


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

* Removed no longer needed IOCTL_FILE_UNCACHED_IO definition.
* Some cleanup, no functional change.


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


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

* Unmounting a volume didn't wait for the block allocator's initializer thread.
* This fixed bug #2541.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26679 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


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

* Work-around for the KDEBUG "holder" mechanism; we actually want to lock the
mutex in another thread here than we will unlock it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26300 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


# 8e8edffce7fdf16a8ae17b2de36bffa05082114e 29-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed at least the "dd" part of bug #2148: the second double indirect array
block would be incorrectly addressed when allocating a stream - this could
cause random blocks to be overwritten, and therefore could cause many sorts
of problems.
* Moved BFS_TRACING macro to the tracing_config.h file, and let it follow the
new semantics of those other macros in there.


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


# 797a92d84d79bf10ac426c11fcee064b5bcc4609 07-Apr-2008 Axel Dörfler <axeld@pinc-software.de>

* Made super block log handling endian-safe.
* Made all debugging functions endian-safe.
* Added tracing for log entries.
* Added new KDL command "bfs_journal" to dump all pending log entries.
* When BFS_DEBUGGER_COMMANDS is defined, the LogEntry class will also track
the transaction ID it belonged to.
* The "bfs" KDL command now sets some useful debugger variables.
* The "bfs_allocator" KDL command now accepts the group index as 3rd argument.
* Renamed Journal::_TransactionListener() to _TransactionIdle(), as that's
all it is for.
* Removed TODO comment in Volume::WriteSuperBlock(), as it's actually not true.


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


# 7ffafac8d76aa50ea68667e61038022220a90256 05-Apr-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Reorganized the FS interface a little:
- Moved most file_system_module_info hooks into separate structures.
Those that operate on mounted volumes to fs_volume_ops, those
operating on a vnode to fs_vnode_ops.
- Got rid of the fs_volume, fs_cookie, fs_vnode typedefs. We use void*
again.
- Instead of a void* volume and node cookie hooks are passed a
fs_volume and fs_vnode structure pointer, which contain the cookie
and an ops pointer (fs_volume a few more things).
- The VFS {new,publish,get,...}_vnode() functions take a fs_volume*
instead of the volume ID. So does vfs_get_fs_node_from_path().
- Added type and flags arguments to publish_vnode() and the
get_vnode() hook and removed the type argument from lookup() hook.
Added vnode::type using formerly unused bits to store the node type.
Simplified a few things in the VFS due to the now always available
node type.
- Added fs_volume_ops::{create,delete}_sub_vnode() and
fs_vnode_ops::get_super_vnode() hooks. They are used to support file
system layers, e.g. allowing to extend an FS not supporting BeOS
attribute with attribute support. Needs some more work in the VFS.
- Added fs_vnode_ops::create_special_node() hook for creating special
nodes (e.g. FIFOs).
* Adjusted the built-in file systems and BFS according to the interface
changes. Removed all other FSs from the image for the time being.
We'll see whether further API changes are necessary before porting
them.
* Adjusted the bfs_shell accordingly.
* Implemented create_special_node() in rootfs to support special nodes.
* Added support for FIFOs:
- Added syscall _kern_create_fifo() (used by mkfifo()), which creates
a special node (type S_IFIFO) in the respective file system.
- When a special node is published the VFS creates a respective sub
node. Currently only FIFOs are supported.
- Added a little support for FIFO subnodes by using functionality from
the pipefs.
- Added mkfifo to the image. It can create FIFOs in the rootfs, but
the FIFOs aren't really usable ATM, since they still work like
pipes, i.e. readers and writers need to have them open at the same
time.
* Some smaller changes in the VFS:
- Made the *_CALL macros nicer to use (vargs).
- Refactored FS entry lookup into new function lookup_dir_entry().
- create_vnode() no longer just calls the FS create() hook. First it
looks up the entry and uses open_vnode(), if it already exists. This
is necessary for two reasons: 1) The FS might not support create()
while still allowing to open() entries. 2) When the FS has other
layers on to of it (or the respective node) it might not be
responsible for opening the node.


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


# 2f20bf154eedb98beafc55d646d58b8a98ea133d 25-Mar-2008 Axel Dörfler <axeld@pinc-software.de>

* Added "bfs" prefix to tracing output.
* When an inode is trimmed, it now also traces the previous internal
size as well as the target size.
* Remove extraneous white space.


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


# f7a5d9c5831397de59dc37ad27f5b4cd17a35db1 19-Jan-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

Changed TraceEntry::Dump() to take a TraceOutput& and removed
AbstractTraceEntry::AddDump(char*, size_t).


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


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

Improved tracing output a bit.


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


# 5d0afa4e4e49f1537865d29b620e957fbcf97823 18-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* cache_detach_sub_transaction() didn't really work: it did not put all needed
blocks into the new transaction, but it would set that transaction on all
blocks of the old transaction, too. Also, it did not correctly update the
num_blocks/sub_num_blocks fields of the old transaction. Even worse, it did
return B_OK instead of the ID of the new transaction...
* get_writable_cached_block() did not correctly maintain the number of blocks
in the sub transaction.
* write_cached_block() did not free the original_data of a block when it wrote
it back as part of a previous transaction.
* Changed "cookie" for cache_next_block_in_transaction() to "long", so it will
be 64 bits when needed.
* Improved the API for detaching sub transactions: you can now get the blocks
of only the main (parent) transaction as well, added new
cache_block_in_main_transaction() function.
* BFS now flushes the log when there is no space left for the current
transaction.
* _WriteTransactionToLog() allocated a "vecs" array, but never freed it.
* _WriteTransactionToLog() now also supports detaching the current sub
transaction if the whole thing is getting too large (it will now also panic
if that doesn't work out).
* Removed a useless optimization: making the blocks available in the cache
isn't really needed, as all blocks in a transaction are locked into the
cache, anyway.
* Implemented Transaction::WriteBlocks().
* Minor cleanup, removed some dead code, fixed warnings in the fs_shell's
block_cache when compiled with debug output on.


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


# 09c46ea8bd43d9b8ccb6eeaf24f9fd5be4e8291b 15-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Fixed bug in the BlockAllocator::Allocate() function which did not
compute the bit offsets correctly if the last block of the whole
bitmap was only a partial block.
* Added new bfs_allocator KDL command.
* Renamed the KDL command bfsinode to bfs_inode.
* Added "--help" argument to bfs_inode and bfs KDL commands.
* Added more tracing in the block allocator.
* Turned on the ASSERT() macro in non-debug builds.
* Minor cleanup.


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


# 42ef796e502bfc0214b240257b62fcb7dc4fedac 13-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

Added a bit more tracing output to the block allocations.


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


# 4fc4f2c8aeefd8548dc95f51af64beabc07a4ec5 13-Jan-2008 Axel Dörfler <axeld@pinc-software.de>

* Added a transaction listener mechanism to be notified when a
transaction ends or has been aborted.
* BFS now listens for transactions when it created an inode to see if
the transaction will be aborted without freeing the inode (in which
case it will panic for now).
* Started implementing tracing support, but it's not working yet.
* Minor cleanup.


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


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

Some more work on the tracing API:
* Added function to allocate space in the buffer.
* Dump() now fills a buffer instead of printing its data directly.
* This allows the new "#pattern" argument of the "traced" command to
work. When you're using that, the index of the trace entry is printed
out, too, so that you can then get a full dump around the hits.
* Added an AddDump() method to the AbstractTraceEntry class so that
there is no need to call the inherited function anymore.
* Minor cleanup.


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


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

* Made the additions of the KDL debugger commands independant from the
DEBUG macro; they are now added only if BFS_DEBUGGER_COMMANDS is
defined (which is now done by default in the Jamfile).
* Added "bfs" KDL command which dumps volume information and the super
block.
* Made use of the new tracing API to trace block and inode actions
(and the new AbstractTraceEntry class I forgot to mention in the last
commit). Is compiled in only when BFS_TRACING is enabled (defaults to
off in the standard builds).


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


# 245aecda8ac43fc2c0c0bac6a7e4016efa9b71e1 21-Jun-2007 Axel Dörfler <axeld@pinc-software.de>

Got rid of vnode_id and mount_id, replaced with ino_t and dev_t.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21485 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


# 68f08f67f519bf2508344836ff87ea7469c2a600 07-May-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed a bug introduced with big-endian fixes in r17557; the super block's blocks_per_ag
field was always 1, and therefore, the last allocation group could grow too large.
Thanks to Samuel Rodriguez Perez for reporting the error (bfs_shell was crashing on
larger images).
* Minor cleanup in BlockAllocator::_Initialize().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21053 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


# fc317af25e51b2c96c416b3d1fc01e3f0b168595 23-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Writing to attributes was deadlock prone; the BFS volume lock was acquired with
the BFS Journal lock held.
Since our get_vnode() is no longer unsafe (unlike Be's version of it), we can
get rid of the UNSAFE_GET_VNODE stuff, which also solves this bug.


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


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

CheckInode() could find an invalid data stream for symlinks without a data stream;
the data stream area is reused as link data in this case.
Reported by Robert Szeleney.


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


# 85baf76e1a81bfc1f16a124b638615d4bf7f0746 28-Sep-2006 Axel Dörfler <axeld@pinc-software.de>

The computation of the number of blocks in the last allocation group was wrong; it
would usually be one block too small - this fixes bug #659.


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


# 60a50e3a73a16c93c119ae256a9cd1ebc255bb14 26-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

Aborted "svn commit" a little bit too late: build fix for the previous revision.


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


# f41837b49fbc9210e6f43bdbd473a63c51f297d3 26-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

* The AllocationGroup now has a field for its number of blocks, as well as public
getter methods.
* Fixed allocation problem of an incomplete last allocation group, as reported by
Robert Szeleney.
* Minor cleanup, slightly improved comments, renamed private methods to have a
leading '_'.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16507 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


# a9d0f0e57673e4d4d8e5208e97c649a0b41cc260 26-May-2005 Axel Dörfler <axeld@pinc-software.de>

Fixed a minor bug in the file system check code: it was not always correctly
determined if the parent directory had the wrong type.


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


# 805cd92d90bc34bb8ced464cac8048595d014afd 12-Dec-2004 Axel Dörfler <axeld@pinc-software.de>

Just a commentary changed.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10401 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


# 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


# 34cf473d12a62ca20b0c62cd7c4dc35ca148d075 03-May-2004 Axel Dörfler <axeld@pinc-software.de>

BlockAllocator::CheckBlockRun() can now also check for non-allocated ranges.
Fixed a possible endian problem in CheckBlockRun(), too.


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


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

Fixed a race condition in the block allocator initialization (the lock was held
too late, and could theoretically already be acquired by someone else).


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


# 5b25332a790992e509503f09c206a0c38d3c17ef 01-Feb-2004 Axel Dörfler <axeld@pinc-software.de>

This should fix the recently introduced locking problems:
- locking policy is now: 1) the volume lock, 2) the inode lock, 3) start
the transaction (the journal lock) - you don't need all locks, but you
have to follow this order when you need more than one of them.
- in many cases, this makes our inode read/write lock useless. I am really
looking forward to the OpenBeOS VFS layer where we can remove many of
these locks again.


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


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

Switched from direct get_vnode() usage to the Vnode class.
Now acquires the volume lock always before get_vnode() is called as long
as UNSAFE_GET_VNODE is defined (which now is by default).
May cause some unwanted side-effects; it still has to be thorougly tested.


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


# 11805f2d85a163813cbdd28b5abe93b1695d1614 28-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

BlockAllocator::InitializeAndClearBitmap() now also sets the used_blocks
field of the super block correctly.


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


# 0057030901fcbb2703e2f818c71ba314c1a873a2 27-Jan-2004 Axel Dörfler <axeld@pinc-software.de>

Added some more debug output and checks.


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


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

Implemented initalizing the bitmap of a fresh volume in the new call
BlockAllocator::InitializeAndClearBitmap().
Added BlockAllocator::BitmapSize() which returns the size of the block
bitmap in bytes - used it where appropriate.


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


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

Switched to kernel_cpp.h/cpp.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6291 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


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

Added a simple magic field mechanism to make chkbfs calls a little more safe.


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


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

Removed the possibility to create a Semaphore object without specifying
a name - that's mostly done to:
1) force better fitting lock names
2) make the API consistent (the empty ReadWriteLock constructor doesn't
initialize the lock anymore).


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


# 6ac535c5c5ab54de29e1837de4efbc2201189fbd 25-May-2003 Axel Dörfler <axeld@pinc-software.de>

Fixed another bad bug in the block allocator: the size of the last block
of the block bitmap could be computed wrong - this could cause all sorts
of errors like: overwriting data, creating the "new_vnode with different
cookie" problem, etc.
Should really be the last bug in that piece of code ;-P


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3331 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


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

Fixed many warnings.


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


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

The new block bitmap is now written using through the log for chkbfs.


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


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

Fixed a stupid bug, used Inode::Name() without locking.


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


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

Now uses Inode::GetName() and strlcpy().


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


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

Added support for aborted "chkbfs" runs (so that they won't do any harm).


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


# 8a3e35d8c3c94e2588ab9d40bc619ea7ef31cca0 21-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

AllocationBlock::Allocate() still had the 0xffff thing implemented, now
also the numBlocks parameter is ASSERTed - when compiled with DEBUG turned
off, BFS will enter the kernel debugger in this case (through the use of
the DIE() macro).
Same for AllocationBlock::Free() (but the 0xffff mode was already removed
there).


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


# 98887c634e6b2fc5d984fc3d9fb5edb08ef43f0a 21-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Symbolic link data streams (for long symlinks) now are located in the same
allocation group as the inode, if possible.
Moved the group used blocks info maintaining code into AllocationGroup::Allocate()
and AllocationGroup::Free() (instead of letting the BlockAllocator class do
the work).
Removed the buggy and useless extra 0xffff mode for AllocationBlock::Allocate()
and AllocationBlock::Free(), both methods now ASSERT their parameter range.
Changed some comments, style cleanups.


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


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

BlockAllocator::CheckInode() now has support for the double indirect region
of the stream (so the "chkbfs" functionality is complete now).
Fixed wrong block number report in BlockAllocator::CheckBlockRun(), blocks are
now printed out in absolute numbers (not allocation_group relative anymore).
Use Inode::IsContainer() where necessary instead of Inode::IsDirectory().
Fixed a big and nasty bug in AllocationBlock::SetTo(): the number of bits in
a block could be calculated wrong for a partial allocation group which need
more than one block in the bitmap - hopefully, that was the last remaining
big bug in the block allocator.


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


# 3f870da9c385281c6c4ec2b7e8af5e1510687153 17-Nov-2002 Axel Dörfler <axeld@pinc-software.de>

Almost complete and working "chkbfs" functionality for BFS. It can be used
via the private ioctls defined in bfs_control.h.
Detects all kinds of errors, and can correct most of them. It doesn't fix
any errors in the b+trees (like the ones created by an earlier version
of the BPlusTree class ;-), and it also can't fix the "blocks are already set"
error, which occurs if more than one file claims a particular block (or
range of blocks) for itself.
The double indirect data range is not yet supported, so use with care, or
run the original chkbfs afterwards to fix any errors because of that.
Might not yet analyze 100% correct (shows way to many errors for my tastes...).
A "chkbfs" command will be made available shortly.


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


# 23d098b60b72610b34d425e2286b81e1cccda0ac 22-Oct-2002 Axel Dörfler <axeld@pinc-software.de>

Forgot to set the new "start" within the blocks range in
AllocationGroup::Allocate()/Free().


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


# 820dca1912dd3100233342d916c2136334a20180 22-Oct-2002 Axel Dörfler <axeld@pinc-software.de>

Rearranged some code in the BlockAllocator; AllocationGroup now has Allocate()
and Free() methods which operate on the AllocationBlocks.
BlockAllocator::AllocateBlocks() couldn't correctly reserve space for allocation
groups with more than 2 blocks - AllocationGroup::Allocate() now can, which
is now used by AllocateBlocks() (but it's slightly less fast).
Began implementing functionality for a chkbfs-like command.
Some style changes.


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


# 2b5451f1642e72a8bd34ccabac5c0b670f09f664 16-Sep-2002 Axel Dörfler <axeld@pinc-software.de>

Added private non-implemented copy constructor and assignment operators
for many classes for the sake of completeness.
Added a Transaction::IsStarted() method to not let it look like as if the
transaction is started more than once.
Changes made after suggestions from Mike Nordell, again :-)


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


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

Fixed two bugs in the block allocator:
- the maximum number of blocks a block_run can cover is 65535 not 65536
- allocations over a block boundary in the block bitmap always failed due
to a incorrectly handled status

Both bugs could prevent BFS to create the VM swap file which led BeOS to
stop booting under certain circumstances.


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


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

Volume::Free(), and BlockAllocator::Free() now pass the block_run by value
rather than by reference.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@848 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