fix: OPEN_ATOMIC_WRITE_AND_CREATE did not create a new file handle for the replacement file, so when the disk queue calls replaceFile, truncates against the old file handle will happen on the new file resulting in corruption
This commit is contained in:
parent
d7491a8f30
commit
78e81e514a
|
@ -738,7 +738,6 @@ private:
|
|||
.detail("FileCount", machineCache.count(self->filename));
|
||||
renameFile(sourceFilename.c_str(), self->filename.c_str());
|
||||
|
||||
ASSERT(!machineCache.count(self->filename));
|
||||
machineCache[self->filename] = machineCache[sourceFilename];
|
||||
machineCache.erase(sourceFilename);
|
||||
self->actualFilename = self->filename;
|
||||
|
@ -2479,19 +2478,19 @@ Future<Reference<class IAsyncFile>> Sim2FileSystem::open(const std::string& file
|
|||
if (flags & IAsyncFile::OPEN_UNCACHED) {
|
||||
auto& machineCache = g_simulator.getCurrentProcess()->machine->openFiles;
|
||||
std::string actualFilename = filename;
|
||||
if (machineCache.find(filename) == machineCache.end()) {
|
||||
if (flags & IAsyncFile::OPEN_ATOMIC_WRITE_AND_CREATE) {
|
||||
actualFilename = filename + ".part";
|
||||
auto partFile = machineCache.find(actualFilename);
|
||||
if (partFile != machineCache.end()) {
|
||||
Future<Reference<IAsyncFile>> f = AsyncFileDetachable::open(partFile->second);
|
||||
if (FLOW_KNOBS->PAGE_WRITE_CHECKSUM_HISTORY > 0)
|
||||
f = map(f, [=](Reference<IAsyncFile> r) {
|
||||
return Reference<IAsyncFile>(new AsyncFileWriteChecker(r));
|
||||
});
|
||||
return f;
|
||||
}
|
||||
if (flags & IAsyncFile::OPEN_ATOMIC_WRITE_AND_CREATE) {
|
||||
actualFilename = filename + ".part";
|
||||
auto partFile = machineCache.find(actualFilename);
|
||||
if (partFile != machineCache.end()) {
|
||||
Future<Reference<IAsyncFile>> f = AsyncFileDetachable::open(partFile->second);
|
||||
if (FLOW_KNOBS->PAGE_WRITE_CHECKSUM_HISTORY > 0)
|
||||
f = map(f, [=](Reference<IAsyncFile> r) {
|
||||
return Reference<IAsyncFile>(new AsyncFileWriteChecker(r));
|
||||
});
|
||||
return f;
|
||||
}
|
||||
}
|
||||
if (machineCache.find(actualFilename) == machineCache.end()) {
|
||||
// Simulated disk parameters are shared by the AsyncFileNonDurable and the underlying SimpleFile.
|
||||
// This way, they can both keep up with the time to start the next operation
|
||||
auto diskParameters =
|
||||
|
|
Loading…
Reference in New Issue