| 791 | |
| 792 | |
| 793 | bool PIO_write(thread_db* tdbb, jrd_file* file, BufferDesc* bdb, Ods::pag* page, FbStatusVector* status_vector) |
| 794 | { |
| 795 | /************************************** |
| 796 | * |
| 797 | * P I O _ w r i t e |
| 798 | * |
| 799 | ************************************** |
| 800 | * |
| 801 | * Functional description |
| 802 | * Write a data page. Oh wow. |
| 803 | * |
| 804 | **************************************/ |
| 805 | int i; |
| 806 | SINT64 bytes; |
| 807 | FB_UINT64 offset; |
| 808 | |
| 809 | if (file->fil_desc == -1) |
| 810 | return unix_error("write", file, isc_io_write_err, status_vector); |
| 811 | |
| 812 | Database* const dbb = tdbb->getDatabase(); |
| 813 | |
| 814 | EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY); |
| 815 | |
| 816 | const SLONG size = dbb->dbb_page_size; |
| 817 | |
| 818 | for (i = 0; i < IO_RETRY; i++) |
| 819 | { |
| 820 | if (!(file = seek_file(file, bdb, &offset, status_vector))) |
| 821 | return false; |
| 822 | |
| 823 | if ((bytes = os_utils::pwrite(file->fil_desc, page, size, LSEEK_OFFSET_CAST offset)) == size) |
| 824 | { |
| 825 | // os_utils::posix_fadvise(file->desc, offset, size, POSIX_FADV_DONTNEED); |
| 826 | return true; |
| 827 | } |
| 828 | |
| 829 | if (bytes < 0 && !SYSCALL_INTERRUPTED(errno)) |
| 830 | return unix_error("write", file, isc_io_write_err, status_vector); |
| 831 | } |
| 832 | |
| 833 | return unix_error("write_retry", file, isc_io_write_err, status_vector); |
| 834 | } |
| 835 | |
| 836 | |
| 837 | static jrd_file* seek_file(jrd_file* file, BufferDesc* bdb, FB_UINT64* offset, |
no test coverage detected