btrfs: do not create Journal and ExtentAllocator for read-only

They are not needed, and the ExtentAllocator seems to currently fail on
an empty volume I created for testing.
This commit is contained in:
Adrien Destugues
2019-10-08 19:56:39 +02:00
parent 5bfbdf0dc8
commit 4337c7582c
2 changed files with 20 additions and 15 deletions
@@ -581,19 +581,19 @@ ExtentAllocator::Initialize()
status_t status = _LoadExtentTree(BTRFS_BLOCKGROUP_FLAG_DATA);
if (status != B_OK) {
ERROR("ExtentAllocator:: could not load exent tree (data)\n");
ERROR("ExtentAllocator:: could not load extent tree (data)\n");
return status;
}
status = _LoadExtentTree(BTRFS_BLOCKGROUP_FLAG_SYSTEM);
if (status != B_OK) {
ERROR("ExtentAllocator:: could not load exent tree (system)\n");
ERROR("ExtentAllocator:: could not load extent tree (system)\n");
return status;
}
status = _LoadExtentTree(BTRFS_BLOCKGROUP_FLAG_METADATA);
if (status != B_OK) {
ERROR("ExtentAllocator:: could not load exent tree (metadata)\n");
ERROR("ExtentAllocator:: could not load extent tree (metadata)\n");
return status;
}
@@ -431,19 +431,24 @@ Volume::Mount(const char* deviceName, uint32 flags)
TRACE("Volume::Mount() Find larget inode id % " B_PRIu64 "\n",
fLargestInodeID);
// Initialize Journal
fJournal = new(std::nothrow) Journal(this);
if (fJournal == NULL)
return B_NO_MEMORY;
if ((flags & B_MOUNT_READ_ONLY) != 0) {
fJournal = NULL;
fExtentAllocator = NULL;
} else {
// Initialize Journal
fJournal = new(std::nothrow) Journal(this);
if (fJournal == NULL)
return B_NO_MEMORY;
// Initialize ExtentAllocator;
fExtentAllocator = new(std::nothrow) ExtentAllocator(this);
if (fExtentAllocator == NULL)
return B_NO_MEMORY;
status = fExtentAllocator->Initialize();
if (status != B_OK) {
ERROR("could not initalize extent allocator!\n");
return status;
// Initialize ExtentAllocator;
fExtentAllocator = new(std::nothrow) ExtentAllocator(this);
if (fExtentAllocator == NULL)
return B_NO_MEMORY;
status = fExtentAllocator->Initialize();
if (status != B_OK) {
ERROR("could not initalize extent allocator!\n");
return status;
}
}
// ready