-
-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error when changing force write mode #8146
base: v5.0-release
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,8 @@ void PIO_close(jrd_file* main_file) | |
|
||
for (jrd_file* file = main_file; file; file = file->fil_next) | ||
{ | ||
WriteLockGuard writeGuard(file->fil_desc_lock, FB_FUNCTION); | ||
|
||
if (file->fil_desc && file->fil_desc != -1) | ||
{ | ||
close(file->fil_desc); | ||
|
@@ -336,6 +338,8 @@ void PIO_extend(thread_db* tdbb, jrd_file* main_file, const ULONG extPages, cons | |
int r; | ||
for (r = 0; r < IO_RETRY; r++) | ||
{ | ||
ReadLockGuard readGuard(file->fil_desc_lock, FB_FUNCTION); | ||
|
||
int err = fallocate(file->fil_desc, 0, filePages * pageSize, extendBy * pageSize); | ||
if (err == 0) | ||
break; | ||
|
@@ -393,6 +397,8 @@ void PIO_flush(thread_db* tdbb, jrd_file* main_file) | |
|
||
for (jrd_file* file = main_file; file; file = file->fil_next) | ||
{ | ||
ReadLockGuard readGuard(file->fil_desc_lock, FB_FUNCTION); | ||
|
||
if (file->fil_desc != -1) | ||
{ | ||
// This really should be an error | ||
|
@@ -432,6 +438,7 @@ void PIO_force_write(jrd_file* file, const bool forcedWrites, const bool notUseF | |
|
||
const int control = (forcedWrites ? SYNC : 0) | (notUseFSCache ? O_DIRECT : 0); | ||
|
||
WriteLockGuard writeGuard(file->fil_desc_lock, FB_FUNCTION); | ||
#ifndef FCNTL_BROKEN | ||
if (fcntl(file->fil_desc, F_SETFL, control) == -1) | ||
{ | ||
|
@@ -479,6 +486,8 @@ ULONG PIO_get_number_of_pages(const jrd_file* file, const USHORT pagesize) | |
* | ||
**************************************/ | ||
|
||
ReadLockGuard readGuard(file->fil_desc_lock, FB_FUNCTION); | ||
|
||
if (file->fil_desc == -1) | ||
unix_error("fstat", file, isc_io_access_err); | ||
|
||
|
@@ -545,6 +554,8 @@ void PIO_header(thread_db* tdbb, UCHAR* address, int length) | |
PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE); | ||
jrd_file* file = pageSpace->file; | ||
|
||
ReadLockGuard readGuard(file->fil_desc_lock, FB_FUNCTION); | ||
|
||
if (file->fil_desc == -1) | ||
unix_error("PIO_header", file, isc_io_read_err); | ||
|
||
|
@@ -637,6 +648,8 @@ USHORT PIO_init_data(thread_db* tdbb, jrd_file* main_file, FbStatusVector* statu | |
{ | ||
if (!(file = seek_file(file, &bdb, &offset, status_vector))) | ||
return false; | ||
|
||
ReadLockGuard readGuard(file->fil_desc_lock, FB_FUNCTION); | ||
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)) | ||
|
@@ -751,13 +764,13 @@ bool PIO_read(thread_db* tdbb, jrd_file* file, BufferDesc* bdb, Ods::pag* page, | |
SINT64 bytes; | ||
FB_UINT64 offset; | ||
|
||
EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY); | ||
ReadLockGuard readGuard(file->fil_desc_lock, FB_FUNCTION); | ||
|
||
if (file->fil_desc == -1) | ||
return unix_error("read", file, isc_io_read_err, status_vector); | ||
|
||
Database* const dbb = tdbb->getDatabase(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be before EngineCheckout ? At least from logical POV |
||
|
||
EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY); | ||
|
||
const SLONG size = dbb->dbb_page_size; | ||
|
||
for (i = 0; i < IO_RETRY; i++) | ||
|
@@ -803,13 +816,13 @@ bool PIO_write(thread_db* tdbb, jrd_file* file, BufferDesc* bdb, Ods::pag* page, | |
SINT64 bytes; | ||
FB_UINT64 offset; | ||
|
||
EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY); | ||
ReadLockGuard readGuard(file->fil_desc_lock, FB_FUNCTION); | ||
|
||
if (file->fil_desc == -1) | ||
return unix_error("write", file, isc_io_write_err, status_vector); | ||
|
||
Database* const dbb = tdbb->getDatabase(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as in PIO_read above |
||
|
||
EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY); | ||
|
||
const SLONG size = dbb->dbb_page_size; | ||
|
||
for (i = 0; i < IO_RETRY; i++) | ||
|
@@ -858,6 +871,8 @@ static jrd_file* seek_file(jrd_file* file, BufferDesc* bdb, FB_UINT64* offset, | |
break; | ||
} | ||
|
||
ReadLockGuard readGuard(file->fil_desc_lock, FB_FUNCTION); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks as not necessary when |
||
if (file->fil_desc == -1) | ||
{ | ||
unix_error("lseek", file, isc_io_access_err, status_vector); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error code is already used in master