From 019d327dce8b1f29774529115800d574674d35c4 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 31 Aug 2019 12:04:04 -0400 Subject: [PATCH] ramfs: Just use the linked list for attributes instead of a hash table. This is what packagefs does; so if it's performant enough for packagefs, it's performant enough for us. Greatly simplifies this code (and will allow for further simplification of the NodeChildHash.) --- .../file_systems/ramfs/AllocationInfo.cpp | 23 -------------- .../file_systems/ramfs/AllocationInfo.h | 6 ---- .../kernel/file_systems/ramfs/Node.cpp | 3 -- .../kernel/file_systems/ramfs/Volume.cpp | 30 ------------------- .../kernel/file_systems/ramfs/Volume.h | 6 +--- 5 files changed, 1 insertion(+), 67 deletions(-) diff --git a/src/add-ons/kernel/file_systems/ramfs/AllocationInfo.cpp b/src/add-ons/kernel/file_systems/ramfs/AllocationInfo.cpp index d155123689..f1d510102b 100644 --- a/src/add-ons/kernel/file_systems/ramfs/AllocationInfo.cpp +++ b/src/add-ons/kernel/file_systems/ramfs/AllocationInfo.cpp @@ -20,9 +20,6 @@ AllocationInfo::AllocationInfo() fDirectoryEntryTableArraySize(0), fDirectoryEntryTableVectorSize(0), fDirectoryEntryTableElementCount(0), - fNodeAttributeTableArraySize(0), - fNodeAttributeTableVectorSize(0), - fNodeAttributeTableElementCount(0), fAttributeCount(0), fAttributeSize(0), @@ -73,18 +70,6 @@ AllocationInfo::AddDirectoryEntryTableAllocation(size_t arraySize, fDirectoryEntryTableElementCount += elementCount; } -// AddNodeAttributeTableAllocation -void -AllocationInfo::AddNodeAttributeTableAllocation(size_t arraySize, - size_t vectorSize, - size_t elementSize, - size_t elementCount) -{ - fNodeAttributeTableArraySize += arraySize; - fNodeAttributeTableVectorSize += vectorSize * elementSize; - fNodeAttributeTableElementCount += elementCount; -} - // AddAttributeAllocation void AllocationInfo::AddAttributeAllocation(size_t size) @@ -187,14 +172,6 @@ AllocationInfo::Dump() const areaSize += fDirectoryEntryTableArraySize * sizeof(int32) + fDirectoryEntryTableVectorSize; - PRINT(" attribute table:\n"); - PRINT(" array size: %9lu\n", fNodeAttributeTableArraySize); - PRINT(" vector size: %9lu\n", fNodeAttributeTableVectorSize); - PRINT(" elements: %9lu\n", fNodeAttributeTableElementCount); - areaCount += 2; - areaSize += fNodeAttributeTableArraySize * sizeof(int32) - + fNodeAttributeTableVectorSize; - PRINT(" attributes: %9lu, size: %9lu\n", fAttributeCount, fAttributeSize); heapCount += fAttributeCount; heapSize += fAttributeCount * sizeof(Attribute); diff --git a/src/add-ons/kernel/file_systems/ramfs/AllocationInfo.h b/src/add-ons/kernel/file_systems/ramfs/AllocationInfo.h index d2bf764bc9..b0c81cff66 100644 --- a/src/add-ons/kernel/file_systems/ramfs/AllocationInfo.h +++ b/src/add-ons/kernel/file_systems/ramfs/AllocationInfo.h @@ -17,9 +17,6 @@ public: void AddDirectoryEntryTableAllocation(size_t arraySize, size_t vectorSize, size_t elementSize, size_t elementCount); - void AddNodeAttributeTableAllocation(size_t arraySize, size_t vectorSize, - size_t elementSize, - size_t elementCount); void AddAttributeAllocation(size_t size); void AddDirectoryAllocation(); @@ -42,9 +39,6 @@ private: size_t fDirectoryEntryTableArraySize; size_t fDirectoryEntryTableVectorSize; size_t fDirectoryEntryTableElementCount; - size_t fNodeAttributeTableArraySize; - size_t fNodeAttributeTableVectorSize; - size_t fNodeAttributeTableElementCount; size_t fAttributeCount; size_t fAttributeSize; diff --git a/src/add-ons/kernel/file_systems/ramfs/Node.cpp b/src/add-ons/kernel/file_systems/ramfs/Node.cpp index f2187b8e12..20d2610e69 100644 --- a/src/add-ons/kernel/file_systems/ramfs/Node.cpp +++ b/src/add-ons/kernel/file_systems/ramfs/Node.cpp @@ -274,7 +274,6 @@ Node::FindAttribute(const char *name, Attribute **_attribute) const { status_t error = (name && _attribute ? B_OK : B_BAD_VALUE); if (error == B_OK) { -/* Attribute *attribute = NULL; while (GetNextAttribute(&attribute) == B_OK) { if (!strcmp(attribute->GetName(), name)) { @@ -283,8 +282,6 @@ Node::FindAttribute(const char *name, Attribute **_attribute) const } } error = B_ENTRY_NOT_FOUND; -*/ - error = GetVolume()->FindNodeAttribute(GetID(), name, _attribute); } return error; } diff --git a/src/add-ons/kernel/file_systems/ramfs/Volume.cpp b/src/add-ons/kernel/file_systems/ramfs/Volume.cpp index 6e8c08d3a8..c1b374ff3b 100644 --- a/src/add-ons/kernel/file_systems/ramfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/ramfs/Volume.cpp @@ -136,7 +136,6 @@ Volume::Volume(fs_volume* volume) fNextNodeID(kRootParentID + 1), fNodeTable(NULL), fDirectoryEntryTable(NULL), - fNodeAttributeTable(NULL), fIndexDirectory(NULL), fRootDirectory(NULL), fName(kDefaultVolumeName), @@ -213,14 +212,6 @@ Volume::Mount(uint32 flags) else SET_ERROR(error, B_NO_MEMORY); } - // create the node attribute table - if (error == B_OK) { - fNodeAttributeTable = new(nothrow) NodeAttributeTable; - if (fNodeAttributeTable) - error = fNodeAttributeTable->InitCheck(); - else - SET_ERROR(error, B_NO_MEMORY); - } // create the index directory if (error == B_OK) { fIndexDirectory = new(nothrow) IndexDirectory(this); @@ -272,10 +263,6 @@ Volume::Unmount() fNodeListeners = NULL; } // delete the tables - if (fNodeAttributeTable) { - delete fNodeAttributeTable; - fNodeAttributeTable = NULL; - } if (fDirectoryEntryTable) { delete fDirectoryEntryTable; fDirectoryEntryTable = NULL; @@ -660,7 +647,6 @@ Volume::NodeAttributeAdded(ino_t id, Attribute *attribute) { status_t error = (attribute ? B_OK : B_BAD_VALUE); if (error == B_OK) { - error = fNodeAttributeTable->AddNodeChild(id, attribute); // notify the respective attribute index if (error == B_OK) { if (AttributeIndex *index = FindAttributeIndex( @@ -678,7 +664,6 @@ Volume::NodeAttributeRemoved(ino_t id, Attribute *attribute) { status_t error = (attribute ? B_OK : B_BAD_VALUE); if (error == B_OK) { - error = fNodeAttributeTable->RemoveNodeChild(id, attribute); // notify the respective attribute index if (error == B_OK) { if (AttributeIndex *index = FindAttributeIndex( @@ -699,19 +684,6 @@ Volume::NodeAttributeRemoved(ino_t id, Attribute *attribute) return error; } -// FindNodeAttribute -status_t -Volume::FindNodeAttribute(ino_t id, const char *name, Attribute **attribute) -{ - status_t error = (attribute ? B_OK : B_BAD_VALUE); - if (error == B_OK) { - *attribute = fNodeAttributeTable->GetNodeChild(id, name); - if (!*attribute) - error = B_ENTRY_NOT_FOUND; - } - return error; -} - // GetNameIndex NameIndex * Volume::GetNameIndex() const @@ -841,8 +813,6 @@ Volume::GetAllocationInfo(AllocationInfo &info) fNodeTable->GetAllocationInfo(info); info.AddOtherAllocation(sizeof(DirectoryEntryTable)); fDirectoryEntryTable->GetAllocationInfo(info); - info.AddOtherAllocation(sizeof(NodeAttributeTable)); - fNodeAttributeTable->GetAllocationInfo(info); // node hierarchy fRootDirectory->GetAllocationInfo(info); // name diff --git a/src/add-ons/kernel/file_systems/ramfs/Volume.h b/src/add-ons/kernel/file_systems/ramfs/Volume.h index 05af40653c..1cbec3c129 100644 --- a/src/add-ons/kernel/file_systems/ramfs/Volume.h +++ b/src/add-ons/kernel/file_systems/ramfs/Volume.h @@ -47,7 +47,6 @@ class IndexDirectory; class LastModifiedIndex; class NameIndex; class Node; -class NodeAttributeTable; class NodeListener; class NodeListenerTree; class NodeTable; @@ -136,11 +135,9 @@ public: uint32 flags); status_t RemoveEntryListener(EntryListener *listener, Entry *entry); - // node attribute table + // node attributes status_t NodeAttributeAdded(ino_t id, Attribute *attribute); status_t NodeAttributeRemoved(ino_t id, Attribute *attribute); - status_t FindNodeAttribute(ino_t id, const char *name, - Attribute **attribute); // indices IndexDirectory *GetIndexDirectory() const { return fIndexDirectory; } @@ -186,7 +183,6 @@ private: ino_t fNextNodeID; NodeTable *fNodeTable; DirectoryEntryTable *fDirectoryEntryTable; - NodeAttributeTable *fNodeAttributeTable; IndexDirectory *fIndexDirectory; Directory *fRootDirectory; String fName;