From b926763e096df7499a11a130dbfa204ff9aac62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 24 May 2005 11:04:10 +0000 Subject: [PATCH] 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 --- .../add-ons/kernel/file_systems/bfs/r5/Inode.cpp | 13 +++++++++---- .../add-ons/kernel/file_systems/bfs/r5/Inode.h | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.cpp b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.cpp index ebcc8c2b36..6ff9221a3d 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.cpp +++ b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.cpp @@ -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) { diff --git a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h index c1d4be40ca..c6d9b727ae 100644 --- a/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h +++ b/src/tests/add-ons/kernel/file_systems/bfs/r5/Inode.h @@ -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; }