Skip to content

Commit 2db7f53

Browse files
author
Artyom Ivanov
committed
Fixes after review
1 parent de152bf commit 2db7f53

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/jrd/nbak.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,12 @@ bool BackupManager::extendDatabase(thread_db* tdbb)
389389
if (maxAllocPage >= maxPage)
390390
return true;
391391

392-
const auto allocatedPages = pgSpace->extend(tdbb, maxPage, true);
393-
maxAllocPage = pgSpace->maxAlloc();
394-
if (allocatedPages.has_value() && maxAllocPage > maxPage)
395-
return true;
392+
if (pgSpace->extend(tdbb, maxPage, true))
393+
{
394+
maxAllocPage = pgSpace->maxAlloc();
395+
if (maxAllocPage >= maxPage)
396+
return true;
397+
}
396398

397399
// Fast file extension not succeeded for some reason, try file extension via direct file writes.
398400
while (maxAllocPage < maxPage)

src/jrd/pag.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,8 @@ namespace
312312
const ULONG usedPages = sequence * pageMgr.pagesPerPIP + pipUsed;
313313

314314
const bool allocateExactNumberOfPages = dbb->dbb_flags & DBB_no_reserve;
315-
const auto allocatedPages = pageSpace->extend(tdbb, usedPages + initPages, allocateExactNumberOfPages);
316-
if (allocatedPages.has_value())
317-
initPages = allocatedPages.value();
315+
if (const auto allocatedPages = pageSpace->extend(tdbb, usedPages + initPages, allocateExactNumberOfPages))
316+
initPages = allocatedPages;
318317
else
319318
{
320319
// For some reason fast file extension failed, maybe it is not supported by filesystem, or
@@ -1938,7 +1937,7 @@ ULONG PageSpace::usedPages(const Database* dbb)
19381937
return pgSpace->usedPages();
19391938
}
19401939

1941-
std::optional<ULONG> PageSpace::extend(thread_db* tdbb, const ULONG pageNum, bool forceSize)
1940+
ULONG PageSpace::extend(thread_db* tdbb, const ULONG pageNum, bool forceSize)
19421941
{
19431942
/**************************************
19441943
*
@@ -1958,7 +1957,7 @@ std::optional<ULONG> PageSpace::extend(thread_db* tdbb, const ULONG pageNum, boo
19581957
fb_assert(dbb == tdbb->getDatabase());
19591958

19601959
if (!PIO_fast_extension_is_supported(*file))
1961-
return std::nullopt;
1960+
return 0;
19621961

19631962
// First, check it with the cached `maxPageNumber` value.
19641963
if (pageNum < maxPageNumber || pageNum < maxAlloc())
@@ -1989,10 +1988,9 @@ std::optional<ULONG> PageSpace::extend(thread_db* tdbb, const ULONG pageNum, boo
19891988
try
19901989
{
19911990
if (!PIO_extend(tdbb, file, extPages, dbb->dbb_page_size))
1992-
return std::nullopt;
1991+
return 0;
19931992

1994-
// File was extended, reset cached value
1995-
maxPageNumber = 0;
1993+
maxPageNumber += extPages;
19961994

19971995
return extPages;
19981996
}
@@ -2013,7 +2011,7 @@ std::optional<ULONG> PageSpace::extend(thread_db* tdbb, const ULONG pageNum, boo
20132011
{
20142012
gds__log("Error extending file \"%s\" by %lu page(s).\nCurrently allocated %lu pages, requested page number %lu",
20152013
file->fil_string, extPages, maxPageNumber, pageNum);
2016-
return std::nullopt;
2014+
return 0;
20172015
}
20182016
}
20192017
}

src/jrd/pag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class PageSpace : public pool_alloc<type_PageSpace>
130130
static ULONG usedPages(const Database* dbb);
131131

132132
// extend page space
133-
std::optional<ULONG> extend(thread_db* tdbb, ULONG pageNum, bool forceSize);
133+
ULONG extend(thread_db* tdbb, ULONG pageNum, bool forceSize);
134134

135135
// get SCN's page number
136136
ULONG getSCNPageNum(ULONG sequence) noexcept;

0 commit comments

Comments
 (0)