MCPcopy Create free account
hub / github.com/apple/foundationdb / read_impl

Method read_impl

fdbrpc/sim2.actor.cpp:636–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

634 }
635
636 ACTOR static Future<int> read_impl(SimpleFile* self, void* data, int length, int64_t offset) {
637 ASSERT((self->flags & IAsyncFile::OPEN_NO_AIO) != 0 ||
638 ((uintptr_t)data % 4096 == 0 && length % 4096 == 0 && offset % 4096 == 0)); // Required by KAIO.
639 state UID opId = deterministicRandom()->randomUniqueID();
640 if (randLog)
641 fmt::print(randLog,
642 "SFR1 {0} {1} {2} {3} {4}\n",
643 self->dbgId.shortString(),
644 self->filename,
645 opId.shortString(),
646 length,
647 offset);
648
649 wait(waitUntilDiskReady(self->diskParameters, length));
650
651 if (_lseeki64(self->h, offset, SEEK_SET) == -1) {
652 TraceEvent(SevWarn, "SimpleFileIOError").detail("Location", 1);
653 throw io_error();
654 }
655
656 unsigned int read_bytes = 0;
657 if ((read_bytes = _read(self->h, data, (unsigned int)length)) == -1) {
658 TraceEvent(SevWarn, "SimpleFileIOError").detail("Location", 2);
659 throw io_error();
660 }
661
662 if (randLog) {
663 uint32_t a = crc32c_append(0, (const uint8_t*)data, read_bytes);
664 fprintf(randLog,
665 "SFR2 %s %s %s %d %d\n",
666 self->dbgId.shortString().c_str(),
667 self->filename.c_str(),
668 opId.shortString().c_str(),
669 read_bytes,
670 a);
671 }
672
673 debugFileCheck("SimpleFileRead", self->filename, data, offset, length);
674
675 INJECT_FAULT(io_timeout, "SimpleFile::read"); // SimpleFile::read io_timeout injected
676 INJECT_FAULT(io_error, "SimpleFile::read"); // SimpleFile::read io_error injected
677
678 return read_bytes;
679 }
680
681 ACTOR static Future<Void> write_impl(SimpleFile* self, StringRef data, int64_t offset) {
682 state UID opId = deterministicRandom()->randomUniqueID();

Callers

nothing calls this directly

Calls 11

deterministicRandomFunction · 0.85
waitUntilDiskReadyFunction · 0.85
TraceEventClass · 0.85
crc32c_appendFunction · 0.85
fprintfFunction · 0.85
debugFileCheckFunction · 0.85
randomUniqueIDMethod · 0.80
shortStringMethod · 0.80
detailMethod · 0.80
printFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected