| 412 | #endif |
| 413 | |
| 414 | void PIO_force_write(jrd_file* file, const bool forcedWrites, const bool notUseFSCache) |
| 415 | { |
| 416 | /************************************** |
| 417 | * |
| 418 | * P I O _ f o r c e _ w r i t e ( G E N E R I C ) |
| 419 | * |
| 420 | ************************************** |
| 421 | * |
| 422 | * Functional description |
| 423 | * Set (or clear) force write, if possible, for the database. |
| 424 | * |
| 425 | **************************************/ |
| 426 | |
| 427 | // Since all SUPERSERVER_V2 database and shadow I/O is synchronous, this is a no-op. |
| 428 | |
| 429 | #ifndef SUPERSERVER_V2 |
| 430 | const bool oldForce = (file->fil_flags & FIL_force_write) != 0; |
| 431 | const bool oldNotUseCache = (file->fil_flags & FIL_no_fs_cache) != 0; |
| 432 | |
| 433 | if (forcedWrites != oldForce || notUseFSCache != oldNotUseCache) |
| 434 | { |
| 435 | |
| 436 | const int control = (forcedWrites ? SYNC : 0) | (notUseFSCache ? O_DIRECT : 0); |
| 437 | |
| 438 | #ifndef FCNTL_BROKEN |
| 439 | if (fcntl(file->fil_desc, F_SETFL, control) == -1) |
| 440 | { |
| 441 | unix_error("fcntl() SYNC/DIRECT", file, isc_io_access_err); |
| 442 | } |
| 443 | #else //FCNTL_BROKEN |
| 444 | maybeCloseFile(file->fil_desc); |
| 445 | file->fil_desc = openFile(file->fil_string, forcedWrites, |
| 446 | notUseFSCache, file->fil_flags & FIL_readonly); |
| 447 | if (file->fil_desc == -1) |
| 448 | { |
| 449 | unix_error("re open() for SYNC/DIRECT", file, isc_io_open_err); |
| 450 | } |
| 451 | |
| 452 | lockDatabaseFile(file->fil_desc, file->fil_flags & FIL_sh_write, false, |
| 453 | file->fil_string, isc_io_open_err); |
| 454 | #endif //FCNTL_BROKEN |
| 455 | |
| 456 | #ifdef SOLARIS |
| 457 | if (notUseFSCache != oldNotUseCache && |
| 458 | directio(file->fil_desc, notUseFSCache ? DIRECTIO_ON : DIRECTIO_OFF) != 0) |
| 459 | { |
| 460 | unix_error("directio()", file, isc_io_access_err); |
| 461 | } |
| 462 | #endif |
| 463 | |
| 464 | file->fil_flags &= ~(FIL_force_write | FIL_no_fs_cache); |
| 465 | file->fil_flags |= (forcedWrites ? FIL_force_write : 0) | |
| 466 | (notUseFSCache ? FIL_no_fs_cache : 0); |
| 467 | } |
| 468 | #endif |
| 469 | } |
| 470 | |
| 471 |
no test coverage detected