diff --git a/src/tests/system/kernel/file_corruption/fs/Transaction.cpp b/src/tests/system/kernel/file_corruption/fs/Transaction.cpp index c311079098..17ff144b91 100644 --- a/src/tests/system/kernel/file_corruption/fs/Transaction.cpp +++ b/src/tests/system/kernel/file_corruption/fs/Transaction.cpp @@ -59,6 +59,17 @@ Transaction::Start() } +status_t +Transaction::StartAndAddNode(Node* node, uint32 flags = 0) +{ + status_t error = Start(); + if (error != B_OK) + return error; + + return AddNode(node, flags); +} + + status_t Transaction::Commit() { @@ -128,7 +139,8 @@ Transaction::AddNode(Node* node, uint32 flags) if (info == NULL) return B_NO_MEMORY; - node->WriteLock(); + if ((flags & TRANSACTION_NODE_ALREADY_LOCKED) == 0) + node->WriteLock(); info->node = node; info->oldNodeData = node->NodeData(); @@ -189,7 +201,7 @@ Transaction::_DeleteNodeInfosAndUnlock(bool failed) while (NodeInfo* info = fNodeInfos.RemoveHead()) { if ((info->flags & TRANSACTION_DELETE_NODE) != 0) delete info->node; - else + else if ((info->flags & TRANSACTION_KEEP_NODE_LOCKED) == 0) info->node->WriteUnlock(); delete info; } diff --git a/src/tests/system/kernel/file_corruption/fs/Transaction.h b/src/tests/system/kernel/file_corruption/fs/Transaction.h index a5071aa0df..74a9dc6b7e 100644 --- a/src/tests/system/kernel/file_corruption/fs/Transaction.h +++ b/src/tests/system/kernel/file_corruption/fs/Transaction.h @@ -17,7 +17,9 @@ class Volume; enum { - TRANSACTION_DELETE_NODE = 0x1 + TRANSACTION_DELETE_NODE = 0x1, + TRANSACTION_NODE_ALREADY_LOCKED = 0x2, + TRANSACTION_KEEP_NODE_LOCKED = 0x4 }; @@ -29,6 +31,7 @@ public: int32 ID() const { return fID; } status_t Start(); + status_t StartAndAddNode(Node* node, uint32 flags = 0); status_t Commit(); void Abort();