From c87c47960cfad10e8bff6ec921def3e8d61383c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Tue, 1 Nov 2011 09:49:05 +0000 Subject: [PATCH] Pass an existing or created transaction to CreateVolumeID(). Hopefully it's correct this time. Axel? git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43056 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Volume.cpp | 15 ++++++++------- src/add-ons/kernel/file_systems/bfs/Volume.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp b/src/add-ons/kernel/file_systems/bfs/Volume.cpp index 874511268d..3e674c499c 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp @@ -425,8 +425,12 @@ Volume::Mount(const char* deviceName, uint32 flags) if (!(fFlags & VOLUME_READ_ONLY)) { Attribute attr(fRootNode); - if (attr.Get("be:volume_id") == B_ENTRY_NOT_FOUND) - CreateVolumeID(); + if (attr.Get("be:volume_id") == B_ENTRY_NOT_FOUND) { + Transaction transaction(this, fRootNode->BlockNumber()); + fRootNode->WriteLockInTransaction(transaction); + CreateVolumeID(transaction); + transaction.Done(); + } } // all went fine @@ -509,7 +513,7 @@ Volume::CreateIndicesRoot(Transaction& transaction) status_t -Volume::CreateVolumeID() +Volume::CreateVolumeID(Transaction& transaction) { Attribute attr(fRootNode); status_t status; @@ -525,10 +529,7 @@ Volume::CreateVolumeID() uint64_t id; size_t length = sizeof(id); id = ((uint64_t)rand() << 32) | rand(); - Transaction transaction(this, fRootNode->BlockNumber()); - fRootNode->WriteLockInTransaction(transaction); attr.Write(transaction, cookie, 0, (uint8_t *)&id, &length, NULL); - transaction.Done(); } return status; } @@ -766,7 +767,7 @@ Volume::Initialize(int fd, const char* name, uint32 blockSize, return status; } - CreateVolumeID(); + CreateVolumeID(transaction); WriteSuperBlock(); transaction.Done(); diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.h b/src/add-ons/kernel/file_systems/bfs/Volume.h index 500a00f682..1e9b8f9737 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.h +++ b/src/add-ons/kernel/file_systems/bfs/Volume.h @@ -92,7 +92,7 @@ public: status_t CreateIndicesRoot(Transaction& transaction); - status_t CreateVolumeID(); + status_t CreateVolumeID(Transaction& transaction); InodeList& RemovedInodes() { return fRemovedInodes; } // This list is guarded by the transaction lock