Skip to content
Open
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
48 changes: 44 additions & 4 deletions src/jrd/cch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,12 @@ void CCH_forget_page(thread_db* tdbb, WIN* window)
BufferDesc* bdb = window->win_bdb;
Database* dbb = tdbb->getDatabase();

fb_assert(bdb && bdb->ourExclusiveLock());

if (window->win_page != bdb->bdb_page || bdb->bdb_buffer->pag_type != pag_undefined)
return; // buffer was reassigned or page was reused

window->win_bdb = NULL;
window->win_bdb = nullptr;

if (bdb->bdb_flags & BDB_io_error)
dbb->dbb_flags &= ~DBB_suspend_bgio;
Expand Down Expand Up @@ -1126,10 +1128,9 @@ void CCH_forget_page(thread_db* tdbb, WIN* window)
}
#endif

bdb->bdb_page.clear();
bdb->bdb_flags = 0;

if (tdbb->tdbb_flags & TDBB_no_cache_unwind)
bdb->release(tdbb, true);
bdb->release(tdbb, true);
}


Expand Down Expand Up @@ -2292,6 +2293,45 @@ void CCH_shutdown(thread_db* tdbb)
SDW_close();
}

bool CCH_try_write(thread_db* tdbb, WIN* window)
{
/**************************************
*
* C C H _ t r y _ w r i t e
*
**************************************
*
* Functional description
* Try to write just faked page to disk. Release buffer if successful.
*
**************************************/
BufferDesc* const bdb = window->win_bdb;
BLKCHK(bdb, type_bdb);

BufferControl* bcb = bdb->bdb_bcb;

constexpr auto FLAGS = (BDB_writer | BDB_marked | BDB_faked);

fb_assert((bdb->bdb_flags & FLAGS) == FLAGS);
fb_assert(bdb->bdb_writers == 1);
fb_assert(bdb->ourExclusiveLock());
fb_assert(bdb->ourIOLock());
fb_assert(QUE_EMPTY(bdb->bdb_higher));

bdb->bdb_flags &= ~FLAGS;

bool result = write_page(tdbb, bdb, tdbb->tdbb_status_vector, false);

bdb->unLockIO(tdbb);
if (result)
{
bdb->release(tdbb, true);
window->win_bdb = nullptr;
}

return result;
}

void CCH_unwind(thread_db* tdbb, const bool punt)
{
/**************************************
Expand Down
1 change: 1 addition & 0 deletions src/jrd/cch_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void CCH_must_write(Jrd::thread_db*, Jrd::win*);
void CCH_precedence(Jrd::thread_db*, Jrd::win*, ULONG);
void CCH_precedence(Jrd::thread_db*, Jrd::win*, Jrd::PageNumber);
void CCH_tra_precedence(Jrd::thread_db*, Jrd::win*, TraNumber traNum);
bool CCH_try_write(Jrd::thread_db*, Jrd::win*);
#ifdef SUPERSERVER_V2
void CCH_prefetch(Jrd::thread_db*, SLONG*, SSHORT);
bool CCH_prefetch_pages(Jrd::thread_db*);
Expand Down
10 changes: 7 additions & 3 deletions src/jrd/os/posix/unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,18 @@ USHORT PIO_init_data(thread_db* tdbb, jrd_file* main_file, FbStatusVector* statu
for (int r = 0; r < IO_RETRY; r++)
{
if (!(file = seek_file(file, &bdb, &offset, status_vector)))
return false;
return (initPages - leftPages);

if ((written = os_utils::pwrite(file->fil_desc, zero_buff, to_write, LSEEK_OFFSET_CAST offset)) == to_write)
break;

if (written < 0 && !SYSCALL_INTERRUPTED(errno))
return unix_error("write", file, isc_io_write_err, status_vector);
{
unix_error("write", file, isc_io_write_err, status_vector);
return (initPages - leftPages);
}
}


leftPages -= write_pages;
i += write_pages;
}
Expand Down
17 changes: 3 additions & 14 deletions src/jrd/pag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,22 +801,11 @@ static ULONG ensureDiskSpace(thread_db* tdbb, WIN* pip_window, const PageNumber
// one page and handle IO errors if any.
WIN window(pageNum);
CCH_fake(tdbb, &window, 1);
CCH_must_write(tdbb, &window);
try
if (!CCH_try_write(tdbb, &window))
{
CCH_RELEASE(tdbb, &window);
}
catch (const status_exception&)
{
// forget about this page as if we never tried to fake it
CCH_forget_page(tdbb, &window);

// normally all page buffers now released by CCH_unwind
// only exception is when TDBB_no_cache_unwind flag is set
if (tdbb->tdbb_flags & TDBB_no_cache_unwind)
CCH_RELEASE(tdbb, pip_window);

throw;
CCH_RELEASE(tdbb, pip_window);
CCH_unwind(tdbb, true);
}

newUsed = relative_bit + 1;
Expand Down
6 changes: 6 additions & 0 deletions src/jrd/pag.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ class PageNumber
: pageNum(from.pageNum), pageSpaceID(from.pageSpaceID)
{ }

inline void clear()
{
pageNum = 0;
pageSpaceID = INVALID_PAGE_SPACE;
}

inline ULONG getPageNum() const
{
// fb_assert(pageSpaceID != INVALID_PAGE_SPACE);
Expand Down
20 changes: 0 additions & 20 deletions vcpkg-configuration.json

This file was deleted.

18 changes: 0 additions & 18 deletions vcpkg.json

This file was deleted.

Loading