| 766 | |
| 767 | // Simulated sync does not actually do anything besides wait a random amount of time |
| 768 | ACTOR static Future<Void> sync_impl(SimpleFile* self) { |
| 769 | state UID opId = deterministicRandom()->randomUniqueID(); |
| 770 | if (randLog) |
| 771 | fprintf(randLog, |
| 772 | "SFC1 %s %s %s\n", |
| 773 | self->dbgId.shortString().c_str(), |
| 774 | self->filename.c_str(), |
| 775 | opId.shortString().c_str()); |
| 776 | |
| 777 | if (self->delayOnWrite) |
| 778 | wait(waitUntilDiskReady(self->diskParameters, 0, true)); |
| 779 | |
| 780 | if (self->flags & OPEN_ATOMIC_WRITE_AND_CREATE) { |
| 781 | self->flags &= ~OPEN_ATOMIC_WRITE_AND_CREATE; |
| 782 | auto& machineCache = g_simulator.getCurrentProcess()->machine->openFiles; |
| 783 | std::string sourceFilename = self->filename + ".part"; |
| 784 | |
| 785 | if (machineCache.count(sourceFilename)) { |
| 786 | TraceEvent("SimpleFileRename") |
| 787 | .detail("From", sourceFilename) |
| 788 | .detail("To", self->filename) |
| 789 | .detail("SourceCount", machineCache.count(sourceFilename)) |
| 790 | .detail("FileCount", machineCache.count(self->filename)); |
| 791 | renameFile(sourceFilename.c_str(), self->filename.c_str()); |
| 792 | |
| 793 | machineCache[self->filename] = machineCache[sourceFilename]; |
| 794 | machineCache.erase(sourceFilename); |
| 795 | self->actualFilename = self->filename; |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | if (randLog) |
| 800 | fprintf(randLog, |
| 801 | "SFC2 %s %s %s\n", |
| 802 | self->dbgId.shortString().c_str(), |
| 803 | self->filename.c_str(), |
| 804 | opId.shortString().c_str()); |
| 805 | |
| 806 | INJECT_FAULT(io_timeout, "SimpleFile::sync"); // SimpleFile::sync inject io_timeout |
| 807 | INJECT_FAULT(io_error, "SimpleFile::sync"); // SimpleFile::sync inject io_errot |
| 808 | |
| 809 | return Void(); |
| 810 | } |
| 811 | |
| 812 | ACTOR static Future<int64_t> size_impl(SimpleFile const* self) { |
| 813 | state UID opId = deterministicRandom()->randomUniqueID(); |
nothing calls this directly
no test coverage detected