} else {
bdev[p->bdev]->aio_write(p->offset + x_off, t, h->iocv[p->bdev], buffered);
}
+ h->dirty_devs[p->bdev] = true;
bloff += x_len;
length -= x_len;
++p;
void BlueFS::_flush_bdev_safely(FileWriter *h)
{
+ std::array<bool, MAX_BDEV> flush_devs = h->dirty_devs;
+ h->dirty_devs.fill(false);
#ifdef HAVE_LIBAIO
if (!cct->_conf->bluefs_sync_write) {
list<aio_t> completed_ios;
lock.unlock();
wait_for_aio(h);
completed_ios.clear();
- flush_bdev();
+ flush_bdev(flush_devs);
lock.lock();
} else
#endif
{
lock.unlock();
- flush_bdev();
+ flush_bdev(flush_devs);
lock.lock();
}
}
+void BlueFS::flush_bdev(std::array<bool, MAX_BDEV>& dirty_bdevs)
+{
+ // NOTE: this is safe to call without a lock.
+ dout(20) << __func__ << dendl;
+ for (unsigned i = 0; i < MAX_BDEV; i++) {
+ if (dirty_bdevs[i])
+ bdev[i]->flush();
+ }
+}
+
void BlueFS::flush_bdev()
{
// NOTE: this is safe to call without a lock.
std::mutex lock;
std::array<IOContext*,MAX_BDEV> iocv; ///< for each bdev
+ std::array<bool, MAX_BDEV> dirty_devs;
FileWriter(FileRef f)
: file(f),
g_conf->bluefs_alloc_size / CEPH_PAGE_SIZE)) {
++file->num_writers;
iocv.fill(nullptr);
+ dirty_devs.fill(false);
}
// NOTE: caller must call BlueFS::close_writer()
~FileWriter() {
void _flush_bdev_safely(FileWriter *h);
void flush_bdev(); // this is safe to call without a lock
+ void flush_bdev(std::array<bool, MAX_BDEV>& dirty_bdevs); // this is safe to call without a lock
int _preallocate(FileRef f, uint64_t off, uint64_t len);
int _truncate(FileWriter *h, uint64_t off);