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