Skip to content

Commit

Permalink
fix: Apply further code review suggestions
Browse files Browse the repository at this point in the history
Changes:
- update Linux client default value of write cache size parameter
(actually not changing anything write buffer size) to show the actual
behavior of the client.
- rename beingWritten member of ChunkData to writesCount to better
represent the idea of this member.
- remove an outdated comment from ChunkJobWriter::processDataChain.
  • Loading branch information
dmga44 committed Sep 15, 2024
1 parent dc62d4c commit 5d7fa58
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/mount/sauna_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ struct FsInitParams {
static constexpr float kDefaultBandwidthOveruse = 1.0;
static constexpr unsigned kDefaultChunkserverWriteTo = 5000;
static constexpr bool kDefaultIgnoreFlush = false;
static constexpr unsigned kDefaultWriteCacheSize = 128;
#ifdef _WIN32
static constexpr unsigned kDefaultWriteCacheSize = 50;
static constexpr unsigned kDefaultWriteWaveTo = 10;
#else
static constexpr unsigned kDefaultWriteCacheSize = 0;
static constexpr unsigned kDefaultWriteWaveTo = 50;
#endif
static constexpr unsigned kDefaultCachePerInodePercentage = 25;
Expand Down
13 changes: 6 additions & 7 deletions src/mount/writedata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct ChunkData {
bool inQueue = false; // true if this chunk is waiting in one of the queues or is being processed
bool workerWaitingForData = false;
std::unique_ptr<WriteChunkLocator> locator;
std::atomic<int> beingWritten = 0;
std::atomic<int> writesCount = 0;

ChunkData(uint32_t chunkIndex, inodedata *parent)
: chunkIndex(chunkIndex), parent_(parent) {
Expand Down Expand Up @@ -467,7 +467,7 @@ void write_job_delayed_end(ChunkData* chunkData, int status, int seconds, Lock &
// Don't sleep if we have to write all the data immediately
seconds = 0;
}
if (chunkData->beingWritten) {
if (chunkData->writesCount) {
inodeLock.unlock();

gLock.lock();
Expand Down Expand Up @@ -719,7 +719,6 @@ void ChunkJobWriter::processDataChain(ChunkWriter& writer) {
SAUNAFS_ERROR_TIMEOUT);
}

// Let's sleep a bit shorter if we can't be woken up by the pipe to reduce the latency
writer.processOperations(gWaveTimeout);
}
}
Expand Down Expand Up @@ -935,10 +934,10 @@ int write_blocks(inodedata *id, uint64_t offset, uint32_t size,
ChunkData *chunkData = write_get_chunkdata(chindx, id, inodeLock);
inodeLock.unlock();

chunkData->beingWritten++;
chunkData->writesCount++;
if (size > SFSBLOCKSIZE - from) {
if (write_block(chunkData, pos, from, SFSBLOCKSIZE, data, inodeLock) < 0) {
chunkData->beingWritten--;
chunkData->writesCount--;
return SAUNAFS_ERROR_IO;
}
size -= (SFSBLOCKSIZE - from);
Expand All @@ -951,12 +950,12 @@ int write_blocks(inodedata *id, uint64_t offset, uint32_t size,
}
} else {
if (write_block(chunkData, pos, from, from + size, data, inodeLock) < 0) {
chunkData->beingWritten--;
chunkData->writesCount--;
return SAUNAFS_ERROR_IO;
}
size = 0;
}
chunkData->beingWritten--;
chunkData->writesCount--;
}
return 0;
}
Expand Down

0 comments on commit 5d7fa58

Please sign in to comment.