log_writer = _create_writer(log_file);
log_writer->append(bl);
- r = _flush(log_writer, true);
+ r = _flush_special(log_writer);
ceph_assert(r == 0);
#ifdef HAVE_LIBAIO
if (!cct->_conf->bluefs_sync_write) {
new_log_writer->append(bl);
// 3. flush
- r = _flush(new_log_writer, true);
+ r = _flush_special(new_log_writer);
ceph_assert(r == 0);
// 4. wait
log_t.clear();
log_t.seq = 0; // just so debug output is less confusing
- int r = _flush(log_writer, true);
+ int r = _flush_special(log_writer);
ceph_assert(r == 0);
}
ceph_assert(h->file->num_readers.load() == 0);
- bool buffered;
- if (h->file->fnode.ino == 1)
- buffered = false;
- else
- buffered = cct->_conf->bluefs_buffered_io;
+ bool buffered = cct->_conf->bluefs_buffered_io;
+ ceph_assert(h->file->fnode.ino > 1);
if (offset + length <= h->pos)
return 0;
if (allocated < offset + length) {
// we should never run out of log space here; see the min runway check
// in _flush_and_sync_log.
- ceph_assert(h->file->fnode.ino != 1);
int r = _allocate(vselector->select_prefer_bdev(h->file->vselector_hint),
offset + length - allocated,
&h->file->fnode);
}
if (h->file->fnode.size < offset + length) {
h->file->fnode.size = offset + length;
- if (h->file->fnode.ino > 1) {
- // we do not need to dirty the log file (or it's compacting
- // replacement) when the file size changes because replay is
- // smart enough to discover it on its own.
- h->file->is_dirty = true;
- }
+ h->file->is_dirty = true;
}
dout(20) << __func__ << " file now, unflushed " << h->file->fnode << dendl;
+ return _flush_data(h, offset, length, buffered);
+}
+int BlueFS::_flush_data(FileWriter *h, uint64_t offset, uint64_t length, bool buffered)
+{
uint64_t x_off = 0;
auto p = h->file->fnode.seek(offset, &x_off);
ceph_assert(p != h->file->fnode.extents.end());
return r;
}
+// Flush for bluefs special files.
+// Does not add extents to h.
+// Does not mark h as dirty.
+// we do not need to dirty the log file (or it's compacting
+// replacement) when the file size changes because replay is
+// smart enough to discover it on its own.
+int BlueFS::_flush_special(FileWriter *h)
+{
+ uint64_t length = h->get_buffer_length();
+ uint64_t offset = h->pos;
+ ceph_assert(length + offset <= h->file->fnode.get_allocated());
+ if (h->file->fnode.size < offset + length) {
+ h->file->fnode.size = offset + length;
+ }
+ return _flush_data(h, offset, length, false);
+}
+
int BlueFS::_truncate(FileWriter *h, uint64_t offset)
{
dout(10) << __func__ << " 0x" << std::hex << offset << std::dec
/* signal replay log to include h->file in nearest log flush */
int _signal_dirty_to_log(FileWriter *h);
int _flush_range(FileWriter *h, uint64_t offset, uint64_t length);
+ int _flush_data(FileWriter *h, uint64_t offset, uint64_t length, bool buffered);
int _flush(FileWriter *h, bool force, std::unique_lock<ceph::mutex>& l);
int _flush(FileWriter *h, bool force, bool *flushed = nullptr);
+ int _flush_special(FileWriter *h);
int _fsync(FileWriter *h, std::unique_lock<ceph::mutex>& l);
#ifdef HAVE_LIBAIO