#include <fcntl.h>
#include <unistd.h>
-#include "BlockDevice.h"
+#include "KernelDevice.h"
#include "include/types.h"
#include "include/compat.h"
#include "common/errno.h"
#undef dout_prefix
#define dout_prefix *_dout << "bdev(" << path << ") "
-BlockDevice::BlockDevice(aio_callback_t cb, void *cbpriv)
+KernelDevice::KernelDevice(aio_callback_t cb, void *cbpriv)
: fd_direct(-1),
fd_buffered(-1),
size(0), block_size(0),
fs(NULL), aio(false), dio(false),
- debug_lock("BlockDevice::debug_lock"),
- ioc_reap_lock("BlockDevice::ioc_reap_lock"),
- flush_lock("BlockDevice::flush_lock"),
+ debug_lock("KernelDevice::debug_lock"),
+ ioc_reap_lock("KernelDevice::ioc_reap_lock"),
+ flush_lock("KernelDevice::flush_lock"),
aio_queue(g_conf->bdev_aio_max_queue_depth),
aio_callback(cb),
aio_callback_priv(cbpriv),
zeros.zero();
}
-int BlockDevice::_lock()
+int KernelDevice::_lock()
{
struct flock l;
memset(&l, 0, sizeof(l));
return 0;
}
-int BlockDevice::open(string p)
+int KernelDevice::open(string p)
{
path = p;
int r = 0;
return r;
}
-void BlockDevice::close()
+void KernelDevice::close()
{
dout(1) << __func__ << dendl;
_aio_stop();
path.clear();
}
-int BlockDevice::flush()
+int KernelDevice::flush()
{
// serialize flushers, so that we can avoid weird io_since_flush
// races (w/ multipler flushers).
return r;
}
-int BlockDevice::_aio_start()
+int KernelDevice::_aio_start()
{
if (g_conf->bdev_aio) {
dout(10) << __func__ << dendl;
return 0;
}
-void BlockDevice::_aio_stop()
+void KernelDevice::_aio_stop()
{
if (g_conf->bdev_aio) {
dout(10) << __func__ << dendl;
}
}
-void BlockDevice::_aio_thread()
+void KernelDevice::_aio_thread()
{
dout(10) << __func__ << " start" << dendl;
while (!aio_stop) {
dout(10) << __func__ << " end" << dendl;
}
-void BlockDevice::_aio_log_start(
+void KernelDevice::_aio_log_start(
IOContext *ioc,
uint64_t offset,
uint64_t length)
}
}
-void BlockDevice::_aio_log_finish(
+void KernelDevice::_aio_log_finish(
IOContext *ioc,
uint64_t offset,
uint64_t length)
}
}
-void BlockDevice::aio_submit(IOContext *ioc)
+void KernelDevice::aio_submit(IOContext *ioc)
{
dout(20) << __func__ << " ioc " << ioc
<< " pending " << ioc->num_pending.read()
}
}
-int BlockDevice::aio_write(
+int KernelDevice::aio_write(
uint64_t off,
bufferlist &bl,
IOContext *ioc,
return 0;
}
-int BlockDevice::aio_zero(
+int KernelDevice::aio_zero(
uint64_t off,
uint64_t len,
IOContext *ioc)
return aio_write(off, bl, ioc, false);
}
-int BlockDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
+int KernelDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
IOContext *ioc,
bool buffered)
{
return r < 0 ? r : 0;
}
-int BlockDevice::read_buffered(uint64_t off, uint64_t len, char *buf)
+int KernelDevice::read_buffered(uint64_t off, uint64_t len, char *buf)
{
dout(5) << __func__ << " " << off << "~" << len << dendl;
assert(len > 0);
return r < 0 ? r : 0;
}
-int BlockDevice::invalidate_cache(uint64_t off, uint64_t len)
+int KernelDevice::invalidate_cache(uint64_t off, uint64_t len)
{
dout(5) << __func__ << " " << off << "~" << len << dendl;
assert(off % block_size == 0);
return r;
}
-void BlockDevice::queue_reap_ioc(IOContext *ioc)
+void KernelDevice::queue_reap_ioc(IOContext *ioc)
{
Mutex::Locker l(ioc_reap_lock);
if (ioc_reap_count.read() == 0)
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
-#ifndef CEPH_OS_BLUESTORE_BLOCKDEVICE
-#define CEPH_OS_BLUESTORE_BLOCKDEVICE
+#ifndef CEPH_OS_BLUESTORE_KERNELDEVICE_H
+#define CEPH_OS_BLUESTORE_KERNELDEVICE_H
#include "os/fs/FS.h"
#include "include/interval_set.h"
-/// track in-flight io
-struct IOContext {
- void *priv;
-
- Mutex lock;
- Cond cond;
- //interval_set<uint64_t> blocks; ///< blocks with aio in flight
-
- list<FS::aio_t> pending_aios; ///< not yet submitted
- list<FS::aio_t> running_aios; ///< submitting or submitted
- atomic_t num_pending;
- atomic_t num_running;
- atomic_t num_reading;
- atomic_t num_waiting;
-
- IOContext(void *p)
- : priv(p),
- lock("IOContext::lock")
- {}
-
- // no copying
- IOContext(const IOContext& other);
- IOContext &operator=(const IOContext& other);
-
- bool has_aios() {
- Mutex::Locker l(lock);
- return num_pending.read() + num_running.read();
- }
-
- void aio_wait();
-};
+#include "BlockDevice.h"
-class BlockDevice {
+class KernelDevice : public BlockDevice {
public:
typedef void (*aio_callback_t)(void *handle, void *aio);
bool aio_stop;
struct AioCompletionThread : public Thread {
- BlockDevice *bdev;
- AioCompletionThread(BlockDevice *b) : bdev(b) {}
+ KernelDevice *bdev;
+ AioCompletionThread(KernelDevice *b) : bdev(b) {}
void *entry() {
bdev->_aio_thread();
return NULL;
int _lock();
public:
- BlockDevice(aio_callback_t cb, void *cbpriv);
+ KernelDevice(aio_callback_t cb, void *cbpriv);
void aio_submit(IOContext *ioc);
#include "include/interval_set.h"
-/// track in-flight io
-struct IOContext {
- void *priv;
-
- Mutex lock;
- Cond cond;
- //interval_set<uint64_t> blocks; ///< blocks with aio in flight
-
- list<FS::aio_t> pending_aios; ///< not yet submitted
- list<FS::aio_t> running_aios; ///< submitting or submitted
- atomic_t num_pending;
- atomic_t num_running;
- atomic_t num_reading;
- atomic_t num_waiting;
-
- IOContext(void *p)
- : priv(p),
- lock("IOContext::lock")
- {}
-
- // no copying
- IOContext(const IOContext& other);
- IOContext &operator=(const IOContext& other);
-
- bool has_aios() {
- Mutex::Locker l(lock);
- return num_pending.read() + num_running.read();
- }
-
- void aio_wait();
-};
+#include "BlockDevice.h"
-typedef void (*blockdev_completion_cb)(void *ref, int status);
+class NVMEDevice : public BlockDevice {
+ typedef void (*aio_callback_t)(void *handle, void *aio);
-class NVMEDevice {
private:
/**
* points to pinned, physically contiguous memory region;