From 7781a5df6b33e6ccc6a410a80a8236fc35a6e855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 18 Nov 2002 01:14:30 +0000 Subject: [PATCH] Now uses block_run::MergeableWith() in Inode::GrowStream() - that also fixes the bug where a block_run could get a zero length after merging it... Updated a comment in Inode::Remove(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1986 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Inode.cpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.cpp b/src/add-ons/kernel/file_systems/bfs/Inode.cpp index 75cb1e996b..3ee2cadd12 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Inode.cpp @@ -1090,13 +1090,11 @@ Inode::GrowStream(Transaction *transaction, off_t size) if (free < NUM_DIRECT_BLOCKS) { // can we merge the last allocated run with the new one? int32 last = free - 1; - if (free > 0 - && data->direct[last].allocation_group == run.allocation_group - && data->direct[last].start + data->direct[last].length == run.start) { + if (free > 0 && data->direct[last].MergeableWith(run)) data->direct[last].length += run.length; - } else { + else data->direct[free] = run; - } + data->max_direct_range += run.length * fVolume->BlockSize(); data->size = blocksNeeded > 0 ? data->max_direct_range : size; continue; @@ -1145,13 +1143,11 @@ Inode::GrowStream(Transaction *transaction, off_t size) // try to insert the run to the last one - note that this doesn't // take block borders into account, so it could be further optimized int32 last = free - 1; - if (free > 0 - && runs[last].allocation_group == run.allocation_group - && runs[last].start + runs[last].length == run.start) { + if (free > 0 && runs[last].MergeableWith(run)) runs[last].length += run.length; - } else { + else runs[free] = run; - } + data->max_indirect_range += run.length << fVolume->BlockShift(); data->size = blocksNeeded > 0 ? data->max_indirect_range : size; @@ -1627,8 +1623,8 @@ Inode::Remove(Transaction *transaction, const char *name, off_t *_id, bool isDir if (inode->Flags() & INODE_NO_CACHE) return B_NOT_ALLOWED; - // It's a bit stupid, but indices are regarded as directories - // in BFS - so a test for a directory always succeeds, but you + // Inode::IsDirectory() is true also for indices (furthermore, the S_IFDIR + // bit is set for indices in BFS, not for attribute directories) - but you // should really be able to do whatever you want with your indices // without having to remove all files first :) if (!inode->IsIndex()) {