Partial backport of r10356: no longer preallocates space for attributes,

attribute directories, and symlinks.
This reduces the space usage of the image created by makehdimage quite
a bit already (dropped from currently 56 MB to 34 MB).
The core of r10356, the fix for the preallocation memory leak, however,
has not been backported (it would probably save another 5 MB on the final
image).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12797 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-05-24 11:04:10 +00:00
parent 36cb9bac61
commit b926763e09
2 changed files with 12 additions and 6 deletions

View File

@ -1,7 +1,7 @@
/* Inode - inode access functions
**
** Initial version by Axel Dörfler, axeld@pinc-software.de
** This file may be used under the terms of the Haiku License.
** Copyright 2001-2005, Axel Dörfler, axeld@pinc-software.de
** This file may be used under the terms of the MIT License.
*/
@ -1227,8 +1227,13 @@ Inode::GrowStream(Transaction *transaction, off_t size)
// blocks we need to allocate may be different from the one we request
// from the block allocator
// should we preallocate some blocks (currently, always 64k)?
if (blocksRequested < (65536 >> fVolume->BlockShift()) && fVolume->FreeBlocks() > 128)
// Should we preallocate some blocks (currently, always 64k)?
// Attributes, attribute directories, and long symlinks usually won't get that big,
// and should stay close to the inode - preallocating could be counterproductive.
// Also, if free disk space is tight, we probably don't want to do this as well.
if (!IsAttribute() && !IsAttributeDirectory() && !IsSymLink()
&& blocksRequested < (65536 >> fVolume->BlockShift())
&& fVolume->FreeBlocks() > 128)
blocksRequested = 65536 >> fVolume->BlockShift();
while (blocksNeeded > 0) {

View File

@ -2,8 +2,8 @@
#define INODE_H
/* Inode - inode access functions
**
** Copyright 2001-2004, Axel Dörfler, axeld@pinc-software.de
** This file may be used under the terms of the OpenBeOS License.
** Copyright 2001-2005, Axel Dörfler, axeld@pinc-software.de
** This file may be used under the terms of the MIT License.
*/
@ -105,6 +105,7 @@ class Inode : public CachedBlock {
bool IsIndex() const { return (Mode() & (S_INDEX_DIR | 0777)) == S_INDEX_DIR; }
// that's a stupid check, but AFAIK the only possible method...
bool IsAttributeDirectory() const { return (Mode() & S_ATTR_DIR) != 0; }
bool IsAttribute() const { return Mode() & S_ATTR; }
bool IsFile() const { return Mode() & S_IFREG; }
bool IsRegularNode() const { return (Mode() & (S_ATTR_DIR | S_INDEX_DIR | S_ATTR)) == 0; }