ramfs: Clean up Iterator lockers API.

No functional change intended.
This commit is contained in:
Augustin Cavalier 2025-01-16 23:23:19 -05:00
parent c9892ac20f
commit 5ac03c3714
6 changed files with 22 additions and 37 deletions

View File

@ -64,7 +64,7 @@ AttributeIterator::Suspend()
if (fNode == NULL)
return B_ERROR;
RecursiveLocker locker(fNode->GetVolume()->AttributeIteratorLocker());
RecursiveLocker locker(fNode->GetVolume()->GetAttributeIteratorLock());
if (!locker.IsLocked())
return B_ERROR;
@ -85,7 +85,7 @@ AttributeIterator::Resume()
if (fNode == NULL)
return B_ERROR;
RecursiveLocker locker(fNode->GetVolume()->AttributeIteratorLocker());
RecursiveLocker locker(fNode->GetVolume()->GetAttributeIteratorLock());
if (!locker.IsLocked())
return B_ERROR;
@ -127,7 +127,7 @@ AttributeIterator::Rewind()
if (fNode == NULL)
return B_ERROR;
RecursiveLocker locker(fNode->GetVolume()->AttributeIteratorLocker());
RecursiveLocker locker(fNode->GetVolume()->GetAttributeIteratorLock());
if (!locker.IsLocked())
return B_ERROR;

View File

@ -190,7 +190,7 @@ Directory::RemoveEntry(Entry *entry)
: B_BAD_VALUE);
if (error == B_OK) {
// move all iterators pointing to the entry to the next entry
if (GetVolume()->IteratorLock()) {
if (recursive_lock_lock(&GetVolume()->GetIteratorLock()) == B_OK) {
// set the iterators' current entry
Entry *nextEntry = fEntries.GetNext(entry);
DoublyLinkedList<EntryIterator> *iterators
@ -208,7 +208,7 @@ Directory::RemoveEntry(Entry *entry)
nextIterators->TakeFrom(iterators);
} else
iterators->RemoveAll();
GetVolume()->IteratorUnlock();
recursive_lock_unlock(&GetVolume()->GetIteratorLock());
} else
error = B_ERROR;
// remove the entry

View File

@ -8,6 +8,8 @@
#include "EntryIterator.h"
#include "Volume.h"
#include <util/AutoLock.h>
EntryIterator::EntryIterator(Directory *directory)
:
@ -65,10 +67,10 @@ EntryIterator::Suspend()
return B_ERROR;
if (fEntry != NULL) {
if (!fDirectory->GetVolume()->IteratorLock())
RecursiveLocker locker(fDirectory->GetVolume()->GetIteratorLock());
if (!locker.IsLocked())
return B_ERROR;
fEntry->AttachEntryIterator(this);
fDirectory->GetVolume()->IteratorUnlock();
}
fSuspended = true;
@ -83,10 +85,10 @@ EntryIterator::Resume()
return B_ERROR;
if (fSuspended && fEntry != NULL) {
if (!fDirectory->GetVolume()->IteratorLock())
RecursiveLocker locker(fDirectory->GetVolume()->GetIteratorLock());
if (!locker.IsLocked())
return B_ERROR;
fEntry->DetachEntryIterator(this);
fDirectory->GetVolume()->IteratorUnlock();
}
fSuspended = false;
@ -121,7 +123,8 @@ EntryIterator::Rewind()
if (fDirectory == NULL)
return B_ERROR;
if (!fDirectory->GetVolume()->IteratorLock())
RecursiveLocker locker(fDirectory->GetVolume()->GetIteratorLock());
if (!locker.IsLocked())
return B_ERROR;
if (fSuspended && fEntry != NULL)
@ -130,7 +133,6 @@ EntryIterator::Rewind()
fEntry = NULL;
fIsNext = false;
fDone = false;
fDirectory->GetVolume()->IteratorUnlock();
return B_OK;
}

View File

@ -198,7 +198,7 @@ Node::RemoveAttribute(Attribute *attribute)
if (attribute == NULL || attribute->GetNode() != this)
return B_BAD_VALUE;
RecursiveLocker locker(GetVolume()->AttributeIteratorLocker());
RecursiveLocker locker(GetVolume()->GetAttributeIteratorLock());
if (!locker.IsLocked())
return B_ERROR;

View File

@ -140,8 +140,8 @@ Volume::Volume(fs_volume* volume)
fMounted(false)
{
rw_lock_init(&fLocker, "ramfs volume");
recursive_lock_init(&fIteratorLocker, "ramfs iterators");
recursive_lock_init(&fAttributeIteratorLocker, "ramfs attribute iterators");
recursive_lock_init(&fIteratorLock, "ramfs iterators");
recursive_lock_init(&fAttributeIteratorLock, "ramfs attribute iterators");
recursive_lock_init(&fQueryLocker, "ramfs queries");
}
@ -150,14 +150,13 @@ Volume::~Volume()
{
Unmount();
recursive_lock_destroy(&fAttributeIteratorLocker);
recursive_lock_destroy(&fIteratorLocker);
recursive_lock_destroy(&fAttributeIteratorLock);
recursive_lock_destroy(&fIteratorLock);
recursive_lock_destroy(&fQueryLocker);
rw_lock_destroy(&fLocker);
}
status_t
Volume::Mount(uint32 flags)
{
@ -765,17 +764,3 @@ Volume::WriteUnlock()
{
rw_lock_write_unlock(&fLocker);
}
bool
Volume::IteratorLock()
{
return recursive_lock_lock(&fIteratorLocker) == B_OK;
}
void
Volume::IteratorUnlock()
{
recursive_lock_unlock(&fIteratorLocker);
}

View File

@ -165,10 +165,8 @@ public:
void WriteUnlock();
inline void AssertWriteLocked() { ASSERT_WRITE_LOCKED_RW_LOCK(&fLocker); }
bool IteratorLock();
void IteratorUnlock();
recursive_lock& AttributeIteratorLocker() { return fAttributeIteratorLocker; }
recursive_lock& GetIteratorLock() { return fIteratorLock; }
recursive_lock& GetAttributeIteratorLock() { return fAttributeIteratorLock; }
protected:
fs_volume* fVolume;
@ -188,8 +186,8 @@ private:
EntryListenerTree *fEntryListeners;
EntryListenerList fAnyEntryListeners;
recursive_lock fIteratorLocker;
recursive_lock fAttributeIteratorLocker;
recursive_lock fIteratorLock;
recursive_lock fAttributeIteratorLock;
recursive_lock fQueryLocker;
QueryList fQueries;