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
This commit is contained in:
@@ -1090,13 +1090,11 @@ Inode::GrowStream(Transaction *transaction, off_t size)
|
|||||||
if (free < NUM_DIRECT_BLOCKS) {
|
if (free < NUM_DIRECT_BLOCKS) {
|
||||||
// can we merge the last allocated run with the new one?
|
// can we merge the last allocated run with the new one?
|
||||||
int32 last = free - 1;
|
int32 last = free - 1;
|
||||||
if (free > 0
|
if (free > 0 && data->direct[last].MergeableWith(run))
|
||||||
&& data->direct[last].allocation_group == run.allocation_group
|
|
||||||
&& data->direct[last].start + data->direct[last].length == run.start) {
|
|
||||||
data->direct[last].length += run.length;
|
data->direct[last].length += run.length;
|
||||||
} else {
|
else
|
||||||
data->direct[free] = run;
|
data->direct[free] = run;
|
||||||
}
|
|
||||||
data->max_direct_range += run.length * fVolume->BlockSize();
|
data->max_direct_range += run.length * fVolume->BlockSize();
|
||||||
data->size = blocksNeeded > 0 ? data->max_direct_range : size;
|
data->size = blocksNeeded > 0 ? data->max_direct_range : size;
|
||||||
continue;
|
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
|
// 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
|
// take block borders into account, so it could be further optimized
|
||||||
int32 last = free - 1;
|
int32 last = free - 1;
|
||||||
if (free > 0
|
if (free > 0 && runs[last].MergeableWith(run))
|
||||||
&& runs[last].allocation_group == run.allocation_group
|
|
||||||
&& runs[last].start + runs[last].length == run.start) {
|
|
||||||
runs[last].length += run.length;
|
runs[last].length += run.length;
|
||||||
} else {
|
else
|
||||||
runs[free] = run;
|
runs[free] = run;
|
||||||
}
|
|
||||||
data->max_indirect_range += run.length << fVolume->BlockShift();
|
data->max_indirect_range += run.length << fVolume->BlockShift();
|
||||||
data->size = blocksNeeded > 0 ? data->max_indirect_range : size;
|
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)
|
if (inode->Flags() & INODE_NO_CACHE)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
// It's a bit stupid, but indices are regarded as directories
|
// Inode::IsDirectory() is true also for indices (furthermore, the S_IFDIR
|
||||||
// in BFS - so a test for a directory always succeeds, but you
|
// 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
|
// should really be able to do whatever you want with your indices
|
||||||
// without having to remove all files first :)
|
// without having to remove all files first :)
|
||||||
if (!inode->IsIndex()) {
|
if (!inode->IsIndex()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user