Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/client/vfs/metasystem/mds/metasystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,15 @@ Status MDSMetaSystem::DoOpen(ContextSPtr ctx, Ino ino, int flags, uint64_t fh,

// update chunk cache
auto& chunk_set = file_session->GetChunkSet();

// Reset the cached write length so that FlushFile sends the correct
// post-truncation length rather than the stale pre-truncation value.
// Without this, a fast close(fd1)+open(fd2,O_TRUNC) race leaves the
// shared chunk_set with last_write_length_ from fd1 (e.g. 4), and
// fd2's write of 2 bytes computes max(4,2)=4 → FlushFile(length=4).
if (flags & O_TRUNC) {
chunk_set->ResetLastWriteLength();
}
if (!chunks.empty()) chunk_set->Put(chunks, "open");

// update chunk memo
Expand Down
Loading