This commit is contained in:
bowang 2022-05-16 11:59:03 -07:00
parent a5c5ab454c
commit a8ef59a448
2 changed files with 10 additions and 6 deletions

View File

@ -836,11 +836,13 @@ IOStatus WritableFileWriter::WriteDirectWithChecksum(
// limiter
size_t data_size = left;
if (rate_limiter_ != nullptr && rate_limiter_priority_used != Env::IO_TOTAL) {
size_t size;
size = rate_limiter_->RequestToken(data_size, buf_.Alignment(),
writable_file_->GetIOPriority(), stats_,
RateLimiter::OpType::kWrite);
data_size -= size;
while (data_size > 0) {
size_t size;
size = rate_limiter_->RequestToken(data_size, buf_.Alignment(),
writable_file_->GetIOPriority(),
stats_, RateLimiter::OpType::kWrite);
data_size -= size;
}
}
{

View File

@ -108,6 +108,8 @@ class WritableFileWriterIOPriorityTest : public testing::Test {
IODebugContext* /*dbg*/) override {
EXPECT_EQ(options.rate_limiter_priority, io_priority_);
}
bool IsSyncThreadSafe() const override { return true; }
};
std::unique_ptr<WritableFileWriter> writer_;
@ -117,7 +119,7 @@ TEST_F(WritableFileWriterIOPriorityTest, Append) {
writer_->Append(Slice("abc"));
}
// TEST_F(WritableFileWriterIOPriorityTest, Pad) { writer_->Pad(10); }
TEST_F(WritableFileWriterIOPriorityTest, Pad) { writer_->Pad(500); }
TEST_F(WritableFileWriterIOPriorityTest, Flush) { writer_->Flush(); }