MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / PIO_write

Function PIO_write

src/jrd/os/posix/unix.cpp:793–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791
792
793bool 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
837static jrd_file* seek_file(jrd_file* file, BufferDesc* bdb, FB_UINT64* offset,

Callers 7

CCH_write_all_shadowsFunction · 0.50
callbackMethod · 0.50
beginBackupMethod · 0.50
callbackMethod · 0.50
SDW_add_fileFunction · 0.50
PAG_add_fileFunction · 0.50

Calls 4

unix_errorFunction · 0.85
getDatabaseMethod · 0.80
seek_fileFunction · 0.70
pwriteFunction · 0.70

Tested by

no test coverage detected