mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
core: avoid fsyncing output stream twice
For some reason, I added a fsync call when the file underlying the stream gets truncated. That happens when flushing a file, which size isn't aligned to the requested DMA buffer. Instead, fsync should only be called when closing the stream, so this patch changes the code to do that. Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
This commit is contained in:
committed by
Avi Kivity
parent
89115e8da2
commit
d864da71fc
@@ -111,9 +111,7 @@ public:
|
||||
return _file->dma_write(pos, p, buf_size).then(
|
||||
[this, buf = std::move(buf), truncate] (size_t size) {
|
||||
if (truncate) {
|
||||
return _file->truncate(_pos).then([this] {
|
||||
return _file->flush();
|
||||
});
|
||||
return _file->truncate(_pos);
|
||||
}
|
||||
return make_ready_future<>();
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ SEASTAR_TEST_CASE(test_fstream) {
|
||||
buf[4095] = ']';
|
||||
w->out.write(buf, 4096).then([buf, w] {
|
||||
::free(buf);
|
||||
return w->out.flush();
|
||||
return make_ready_future<>();
|
||||
}).then([w] {
|
||||
auto buf = static_cast<char*>(::malloc(8192));
|
||||
memset(buf, 0, 8192);
|
||||
@@ -61,7 +61,7 @@ SEASTAR_TEST_CASE(test_fstream) {
|
||||
buf[8191] = ']';
|
||||
return w->out.write(buf, 8192).then([buf, w] {
|
||||
::free(buf);
|
||||
return w->out.flush();
|
||||
return w->out.close().then([w] {});
|
||||
});
|
||||
}).then([] {
|
||||
return engine().open_file_dma("testfile.tmp", open_flags::ro);
|
||||
@@ -105,7 +105,7 @@ SEASTAR_TEST_CASE(test_fstream_unaligned) {
|
||||
buf[39] = ']';
|
||||
w->out.write(buf, 40).then([buf, w] {
|
||||
::free(buf);
|
||||
return w->out.flush().then([w] {});
|
||||
return w->out.close().then([w] {});
|
||||
}).then([] {
|
||||
return engine().open_file_dma("testfile.tmp", open_flags::ro);
|
||||
}).then([] (file f) {
|
||||
|
||||
Reference in New Issue
Block a user