Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/jrd/nbak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,14 @@ bool BackupManager::extendDatabase(thread_db* tdbb)
if (maxAllocPage >= maxPage)
return true;

if (!pgSpace->extend(tdbb, maxPage, true))
return false;
if (pgSpace->extend(tdbb, maxPage, true))
{
maxAllocPage = pgSpace->maxAlloc();
if (maxAllocPage >= maxPage)
return true;
}

maxAllocPage = pgSpace->maxAlloc();
// Fast file extension not succeeded for some reason, try file extension via direct file writes.
while (maxAllocPage < maxPage)
{
const USHORT ret = PIO_init_data(tdbb, pgSpace->file, tdbb->tdbb_status_vector,
Expand Down
5 changes: 3 additions & 2 deletions src/jrd/os/pio_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ void PIO_close(Jrd::jrd_file*);
Jrd::jrd_file* PIO_create(Jrd::thread_db*, const Firebird::PathName&,
const bool, const bool);
bool PIO_expand(const TEXT*, USHORT, TEXT*, FB_SIZE_T);
void PIO_extend(Jrd::thread_db*, Jrd::jrd_file*, const ULONG, const USHORT);
bool PIO_fast_extension_is_supported(const Jrd::jrd_file& file) noexcept;
bool PIO_extend(Jrd::thread_db* tdbb, Jrd::jrd_file* file, ULONG extPages, USHORT pageSize);
void PIO_flush(Jrd::thread_db*, Jrd::jrd_file*);
void PIO_force_write(Jrd::jrd_file*, const bool);
ULONG PIO_get_number_of_pages(const Jrd::jrd_file*, const USHORT);
bool PIO_header(Jrd::thread_db*, UCHAR*, unsigned);
USHORT PIO_init_data(Jrd::thread_db*, Jrd::jrd_file*, Jrd::FbStatusVector*, ULONG, USHORT);
USHORT PIO_init_data(Jrd::thread_db* tdbb, Jrd::jrd_file* file, Jrd::FbStatusVector* status_vector, ULONG startPage, USHORT initPages);
Jrd::jrd_file* PIO_open(Jrd::thread_db*, const Firebird::PathName&,
const Firebird::PathName&);
bool PIO_read(Jrd::thread_db*, Jrd::jrd_file*, Jrd::BufferDesc*, Ods::pag*, Jrd::FbStatusVector*);
Expand Down
24 changes: 17 additions & 7 deletions src/jrd/os/posix/unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,17 @@ bool PIO_expand(const TEXT* file_name, USHORT file_length, TEXT* expanded_name,
}


void PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USHORT pageSize)
bool PIO_fast_extension_is_supported(const Jrd::jrd_file& file) noexcept
{
#if defined(HAVE_LINUX_FALLOC_H) && defined(HAVE_FALLOCATE)
return !(file.fil_flags & FIL_no_fast_extend);
#else
return false;
#endif
}


bool PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USHORT pageSize)
{
/**************************************
*
Expand All @@ -317,8 +327,8 @@ void PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USH

EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY);

if (file->fil_flags & FIL_no_fast_extend)
return;
if (!PIO_fast_extension_is_supported(*file))
return false;

const ULONG filePages = PIO_get_number_of_pages(file, pageSize);
const ULONG extendBy = MIN(MAX_ULONG - filePages, extPages);
Expand All @@ -341,7 +351,7 @@ void PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USH
unix_error("fallocate", file, isc_io_write_err);

file->fil_flags |= FIL_no_fast_extend;
return;
return false;
}

if (r == IO_RETRY)
Expand All @@ -352,12 +362,12 @@ void PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USH
#endif
unix_error("fallocate_retry", file, isc_io_write_err);
}

return true;
#else
file->fil_flags |= FIL_no_fast_extend;
return false;
#endif // fallocate present

// not implemented
return;
}


Expand Down
12 changes: 10 additions & 2 deletions src/jrd/os/win32/winnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,13 @@ bool PIO_expand(const TEXT* file_name, USHORT file_length, TEXT* expanded_name,
}


void PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USHORT pageSize)
bool PIO_fast_extension_is_supported(const Jrd::jrd_file& file) noexcept
{
return true;
}


bool PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USHORT pageSize)
{
/**************************************
*
Expand All @@ -238,7 +244,7 @@ void PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USH

// if file have no extend lock it is better to not extend file than corrupt it
if (!file->fil_ext_lock)
return;
return false;

EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY);
FileExtendLockGuard extLock(file->fil_ext_lock, true);
Expand All @@ -257,6 +263,8 @@ void PIO_extend(thread_db* tdbb, jrd_file* file, const ULONG extPages, const USH

if (!SetEndOfFile(hFile))
nt_error("SetEndOfFile", file, isc_io_write_err, NULL);

return true;
}


Expand Down
Loading
Loading