// preserve in-memory contiguity and not mess with the alignment.
// Otherwise a costly rebuild could happen in e.g. `KernelDevice`.
buffer_appender.append_zero(padding_len);
- buffer_appender.flush();
buffer.splice(buffer.length() - padding_len, padding_len, &bl);
// Deep copy the tail here. This allows to avoid costlier copy on
// bufferlist rebuild in e.g. `KernelDevice` and minimizes number
// padding on a dedicated, 4 KB long memory chunk. This shouldn't
// trigger the rebuild while still being less expensive.
buffer_appender.substr_of(bl, bl.length() - padding_len - tail, tail);
- buffer_appender.flush();
buffer.splice(buffer.length() - tail, tail, &tail_block);
} else {
tail_block.clear();
ceph_assert(!h->file->deleted);
ceph_assert(h->file->num_readers.load() == 0);
- h->buffer_appender.flush();
-
bool buffered;
if (h->file->fnode.ino == 1)
buffered = false;
int BlueFS::_flush(FileWriter *h, bool force, bool *flushed)
{
- h->buffer_appender.flush();
uint64_t length = h->get_buffer_length();
uint64_t offset = h->pos;
if (flushed) {
// we never truncate internal log files
ceph_assert(h->file->fnode.ino > 1);
- h->buffer_appender.flush();
-
// truncate off unflushed data?
if (h->pos < offset &&
h->pos + h->get_buffer_length() > offset) {
}
uint64_t get_effective_write_pos() {
- buffer_appender.flush();
return pos + buffer.length();
}
};
ceph_assert(r == 0);
}
void try_flush(FileWriter *h) {
- h->buffer_appender.flush();
if (h->get_buffer_length() >= cct->_conf->bluefs_min_flush_size) {
flush(h, true);
}
{
auto a = bl.get_page_aligned_appender(5);
a.append("asdf", 4);
- a.flush();
cout << bl << std::endl;
ASSERT_EQ(1u, bl.get_num_buffers());
ASSERT_TRUE(bl.contents_equal("asdf", 4));
for (unsigned n = 0; n < 3 * CEPH_PAGE_SIZE; ++n) {
a.append("x", 1);
}
- a.flush();
cout << bl << std::endl;
ASSERT_EQ(1u, bl.get_num_buffers());
// verify the beginning
for (unsigned n = 0; n < 3 * CEPH_PAGE_SIZE; ++n) {
a.append("y", 1);
}
- a.flush();
cout << bl << std::endl;
ASSERT_EQ(2u, bl.get_num_buffers());
a.append_zero(42);
- a.flush();
// ensure append_zero didn't introduce a fragmentation
ASSERT_EQ(2u, bl.get_num_buffers());
// verify the end is actually zeroed
// moreover, the next C string-taking `append()` had to
// create anoter `ptr_node` instance but...
a.append("xyz", 3);
- a.flush();
ASSERT_EQ(4u, bl.get_num_buffers());
// ... it should point to the same `buffer::raw` instance
}
}
- // `flush()` should be called by automatically when destructing
- // the appender.
{
cout << bl << std::endl;
ASSERT_EQ(6u, bl.get_num_buffers());