ramfs: Rehabilitate AllocationInfo support.
At least we won't double-count files now.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include "File.h"
|
||||
#include "SymLink.h"
|
||||
|
||||
// constructor
|
||||
|
||||
AllocationInfo::AllocationInfo()
|
||||
: fNodeTableArraySize(0),
|
||||
fNodeTableVectorSize(0),
|
||||
@@ -30,10 +30,6 @@ AllocationInfo::AllocationInfo()
|
||||
fSymLinkCount(0),
|
||||
fSymLinkSize(0),
|
||||
|
||||
fAreaCount(0),
|
||||
fAreaSize(0),
|
||||
fBlockCount(0),
|
||||
fBlockSize(0),
|
||||
fListCount(0),
|
||||
fListSize(0),
|
||||
fOtherCount(0),
|
||||
@@ -43,34 +39,32 @@ AllocationInfo::AllocationInfo()
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
|
||||
AllocationInfo::~AllocationInfo()
|
||||
{
|
||||
}
|
||||
|
||||
// AddNodeTableAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddNodeTableAllocation(size_t arraySize, size_t vectorSize,
|
||||
size_t elementSize, size_t elementCount)
|
||||
size_t elementSize, size_t elementCount)
|
||||
{
|
||||
fNodeTableArraySize += arraySize;
|
||||
fNodeTableVectorSize += vectorSize * elementSize;
|
||||
fNodeTableElementCount += elementCount;
|
||||
}
|
||||
|
||||
// AddDirectoryEntryTableAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddDirectoryEntryTableAllocation(size_t arraySize,
|
||||
size_t vectorSize,
|
||||
size_t elementSize,
|
||||
size_t elementCount)
|
||||
size_t vectorSize, size_t elementSize, size_t elementCount)
|
||||
{
|
||||
fDirectoryEntryTableArraySize += arraySize;
|
||||
fDirectoryEntryTableVectorSize += vectorSize * elementSize;
|
||||
fDirectoryEntryTableElementCount += elementCount;
|
||||
}
|
||||
|
||||
// AddAttributeAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddAttributeAllocation(size_t size)
|
||||
{
|
||||
@@ -78,21 +72,21 @@ AllocationInfo::AddAttributeAllocation(size_t size)
|
||||
fAttributeSize += size;
|
||||
}
|
||||
|
||||
// AddDirectoryAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddDirectoryAllocation()
|
||||
{
|
||||
fDirectoryCount++;
|
||||
}
|
||||
|
||||
// AddEntryAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddEntryAllocation()
|
||||
{
|
||||
fEntryCount++;
|
||||
}
|
||||
|
||||
// AddFileAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddFileAllocation(size_t size)
|
||||
{
|
||||
@@ -100,7 +94,7 @@ AllocationInfo::AddFileAllocation(size_t size)
|
||||
fFileSize += size;
|
||||
}
|
||||
|
||||
// AddSymLinkAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddSymLinkAllocation(size_t size)
|
||||
{
|
||||
@@ -108,23 +102,7 @@ AllocationInfo::AddSymLinkAllocation(size_t size)
|
||||
fSymLinkSize += size;
|
||||
}
|
||||
|
||||
// AddAreaAllocation
|
||||
void
|
||||
AllocationInfo::AddAreaAllocation(size_t size, size_t count)
|
||||
{
|
||||
fAreaCount += count;
|
||||
fAreaSize += count * size;
|
||||
}
|
||||
|
||||
// AddBlockAllocation
|
||||
void
|
||||
AllocationInfo::AddBlockAllocation(size_t size)
|
||||
{
|
||||
fBlockCount++;
|
||||
fBlockSize += size;
|
||||
}
|
||||
|
||||
// AddListAllocation
|
||||
void
|
||||
AllocationInfo::AddListAllocation(size_t capacity, size_t elementSize)
|
||||
{
|
||||
@@ -132,7 +110,7 @@ AllocationInfo::AddListAllocation(size_t capacity, size_t elementSize)
|
||||
fListSize += capacity * elementSize;
|
||||
}
|
||||
|
||||
// AddOtherAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddOtherAllocation(size_t size, size_t count)
|
||||
{
|
||||
@@ -140,7 +118,7 @@ AllocationInfo::AddOtherAllocation(size_t size, size_t count)
|
||||
fOtherSize += size * count;
|
||||
}
|
||||
|
||||
// AddStringAllocation
|
||||
|
||||
void
|
||||
AllocationInfo::AddStringAllocation(size_t size)
|
||||
{
|
||||
@@ -148,7 +126,7 @@ AllocationInfo::AddStringAllocation(size_t size)
|
||||
fStringSize += size;
|
||||
}
|
||||
|
||||
// Dump
|
||||
|
||||
void
|
||||
AllocationInfo::Dump() const
|
||||
{
|
||||
@@ -193,10 +171,6 @@ AllocationInfo::Dump() const
|
||||
heapSize += fSymLinkCount * sizeof(SymLink);
|
||||
|
||||
PRINT(" areas: %9lu, size: %9lu\n", fAreaCount, fAreaSize);
|
||||
areaCount += fAreaCount;
|
||||
areaSize += fAreaSize;
|
||||
|
||||
PRINT(" blocks: %9lu, size: %9lu\n", fBlockCount, fBlockSize);
|
||||
|
||||
PRINT(" lists: %9lu, size: %9lu\n", fListCount, fListSize);
|
||||
heapCount += fListCount;
|
||||
@@ -211,6 +185,5 @@ AllocationInfo::Dump() const
|
||||
heapSize += fStringSize;
|
||||
|
||||
PRINT("heap: %9lu allocations, size: %9lu\n", heapCount, heapSize);
|
||||
PRINT("areas: %9lu allocations, size: %9lu\n", areaCount, areaSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,18 +5,19 @@
|
||||
#ifndef ALLOCATION_INFO_H
|
||||
#define ALLOCATION_INFO_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
class AllocationInfo {
|
||||
public:
|
||||
AllocationInfo();
|
||||
~AllocationInfo();
|
||||
|
||||
void AddNodeTableAllocation(size_t arraySize, size_t vectorSize,
|
||||
size_t elementSize, size_t elementCount);
|
||||
size_t elementSize, size_t elementCount);
|
||||
void AddDirectoryEntryTableAllocation(size_t arraySize, size_t vectorSize,
|
||||
size_t elementSize,
|
||||
size_t elementCount);
|
||||
size_t elementSize, size_t elementCount);
|
||||
|
||||
void AddAttributeAllocation(size_t size);
|
||||
void AddDirectoryAllocation();
|
||||
@@ -24,8 +25,6 @@ public:
|
||||
void AddFileAllocation(size_t size);
|
||||
void AddSymLinkAllocation(size_t size);
|
||||
|
||||
void AddAreaAllocation(size_t size, size_t count = 1);
|
||||
void AddBlockAllocation(size_t size);
|
||||
void AddListAllocation(size_t capacity, size_t elementSize);
|
||||
void AddOtherAllocation(size_t size, size_t count = 1);
|
||||
void AddStringAllocation(size_t size);
|
||||
@@ -49,10 +48,6 @@ private:
|
||||
size_t fSymLinkCount;
|
||||
size_t fSymLinkSize;
|
||||
|
||||
size_t fAreaCount;
|
||||
size_t fAreaSize;
|
||||
size_t fBlockCount;
|
||||
size_t fBlockSize;
|
||||
size_t fListCount;
|
||||
size_t fListSize;
|
||||
size_t fOtherCount;
|
||||
@@ -61,4 +56,5 @@ private:
|
||||
size_t fStringSize;
|
||||
};
|
||||
|
||||
|
||||
#endif // ALLOCATION_INFO_H
|
||||
|
||||
@@ -149,8 +149,6 @@ Attribute::DetachAttributeIterator(AttributeIterator *iterator)
|
||||
void
|
||||
Attribute::GetAllocationInfo(AllocationInfo &info)
|
||||
{
|
||||
DataContainer::GetAllocationInfo(info);
|
||||
info.AddAttributeAllocation(GetSize());
|
||||
info.AddAttributeAllocation(DataContainer::GetCommittedSize());
|
||||
info.AddStringAllocation(fName.GetLength());
|
||||
}
|
||||
|
||||
|
||||
@@ -252,14 +252,13 @@ DataContainer::WriteAt(off_t offset, const void *_buffer, size_t size,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DataContainer::GetAllocationInfo(AllocationInfo &info)
|
||||
off_t
|
||||
DataContainer::GetCommittedSize() const
|
||||
{
|
||||
if (_IsCacheMode()) {
|
||||
info.AddAreaAllocation(fCache->committed_size);
|
||||
} else {
|
||||
// ...
|
||||
}
|
||||
if (_IsCacheMode())
|
||||
return sizeof(VMForVnodeCache) + fCache->committed_size;
|
||||
else
|
||||
return fSmallBufferSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
struct vm_page;
|
||||
class VMCache;
|
||||
class AllocationInfo;
|
||||
class Volume;
|
||||
|
||||
|
||||
@@ -27,6 +26,7 @@ public:
|
||||
|
||||
status_t Resize(off_t newSize);
|
||||
off_t GetSize() const { return fSize; }
|
||||
off_t GetCommittedSize() const;
|
||||
|
||||
VMCache* GetCache(struct vnode* vnode);
|
||||
|
||||
@@ -35,9 +35,6 @@ public:
|
||||
virtual status_t WriteAt(off_t offset, const void *buffer, size_t size,
|
||||
size_t *bytesWritten);
|
||||
|
||||
// debugging
|
||||
void GetAllocationInfo(AllocationInfo &info);
|
||||
|
||||
private:
|
||||
inline bool _RequiresCacheMode(size_t size);
|
||||
inline bool _IsCacheMode() const;
|
||||
|
||||
@@ -76,6 +76,6 @@ File::GetSize() const
|
||||
void
|
||||
File::GetAllocationInfo(AllocationInfo &info)
|
||||
{
|
||||
info.AddFileAllocation(GetSize());
|
||||
info.AddFileAllocation(DataContainer::GetCommittedSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -725,7 +725,7 @@ Volume::UpdateLiveQueries(Entry *entry, Node* node, const char *attribute,
|
||||
|
||||
|
||||
void
|
||||
Volume::GetAllocationInfo(AllocationInfo &info)
|
||||
Volume::GetAllocationInfo(AllocationInfo &info) const
|
||||
{
|
||||
// tables
|
||||
info.AddOtherAllocation(sizeof(NodeTable));
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
|
||||
ino_t NextNodeID() { return fNextNodeID++; }
|
||||
|
||||
void GetAllocationInfo(AllocationInfo &info);
|
||||
void GetAllocationInfo(AllocationInfo &info) const;
|
||||
|
||||
bigtime_t GetAccessTime() const { return fAccessTime; }
|
||||
|
||||
|
||||
@@ -300,22 +300,22 @@ ramfs_ioctl(fs_volume* _volume, fs_vnode* /*node*/, void* /*cookie*/,
|
||||
switch (cmd) {
|
||||
case RAMFS_IOCTL_GET_ALLOCATION_INFO:
|
||||
{
|
||||
if (buffer) {
|
||||
VolumeReadLocker locker(volume);
|
||||
if (!locker.IsLocked()) {
|
||||
AllocationInfo *info = (AllocationInfo*)buffer;
|
||||
volume->GetAllocationInfo(*info);
|
||||
} else
|
||||
SET_ERROR(error, B_ERROR);
|
||||
} else
|
||||
SET_ERROR(error, B_BAD_VALUE);
|
||||
if (buffer == NULL)
|
||||
RETURN_ERROR(B_BAD_VALUE);
|
||||
|
||||
VolumeReadLocker locker(volume);
|
||||
if (!locker.IsLocked())
|
||||
RETURN_ERROR(B_ERROR);
|
||||
|
||||
AllocationInfo *info = (AllocationInfo*)buffer;
|
||||
volume->GetAllocationInfo(*info);
|
||||
break;
|
||||
}
|
||||
case RAMFS_IOCTL_DUMP_INDEX:
|
||||
{
|
||||
if (buffer) {
|
||||
VolumeReadLocker locker(volume);
|
||||
if (!locker.IsLocked()) {
|
||||
if (locker.IsLocked()) {
|
||||
const char *name = (const char*)buffer;
|
||||
PRINT(" RAMFS_IOCTL_DUMP_INDEX, `%s'\n", name);
|
||||
IndexDirectory *indexDir = volume->GetIndexDirectory();
|
||||
|
||||
Reference in New Issue
Block a user