OPTION(memstore_page_set, OPT_BOOL, true)
OPTION(memstore_page_size, OPT_U64, 64 << 10)
+OPTION(bdev_backend_type, OPT_STR, "kernel")
OPTION(bdev_debug_inflight_ios, OPT_BOOL, false)
OPTION(bdev_inject_crash, OPT_INT, 0) // if N>0, then ~ 1/N IOs will complete before we crash on flush.
OPTION(bdev_aio, OPT_BOOL, true)
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2015 XSky <haomai@xsky.com>
+ *
+ * Author: Haomai Wang <haomaiwang@gmail.com>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#include "BlockDevice.h"
+#if defined(HAVE_SPDK)
+#include "NVMEDevice.h"
+#endif
+
+BlockDevice *BlockDevice::create(const string& type, aio_callback_t cb, void *cbpriv)
+{
+ if (type == "kernel") {
+ return new KernelDevice(cb, cbpriv);
+ }
+#if defined(HAVE_SPDK)
+ if (type == "ust-nvme") {
+ return new NVMEDeivce(cb, cbpriv);
+ }
+#endif
+
+ return NULL;
+}
+
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2015 XSky <haomai@xsky.com>
+ *
+ * Author: Haomai Wang <haomaiwang@gmail.com>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#ifndef CEPH_OS_BLUESTORE_BLOCKDEVICE_H
+#define CEPH_OS_BLUESTORE_BLOCKDEVICE_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();
+};
+
+
+class BlockDevice {
+public:
+ static BlockDevice *create(CephContext *cct, const string& type,
+ aio_callback_t cb, void *cbpriv);
+
+ virtual aio_submit(IOContext *ioc) = 0;
+
+ virtual uint64_t get_size() const = 0;
+ virtual uint64_t get_block_size() const = 0;
+
+ virtual int read(uint64_t off, uint64_t len, bufferlist *pbl,
+ IOContext *ioc, bool buffered) = 0;
+
+ virtual int aio_write(uint64_t off, bufferlist& bl,
+ IOContext *ioc, bool buffered) = 0;
+ virtual int aio_zero(uint64_t off, uint64_t len, IOContext *ioc) = 0;
+ virtual int flush() = 0;
+
+ // for managing buffered readers/writers
+ virtual int invalidate_cache(uint64_t off, uint64_t len) = 0;
+ virtual int open(string path) = 0;
+ virtual void close() = 0;
+};
+
+#endif //CEPH_OS_BLUESTORE_BLOCKDEVICE_H
{
bluestore_bdev_label_t label;
assert(bdev == NULL);
- bdev = new BlockDevice(aio_cb, static_cast<void*>(this));
+ bdev = BlockDevice::create(g_conf->bdev_backend_type, aio_cb, static_cast<void*>(this));
string p = path + "/block";
int r = bdev->open(p);
if (r < 0)
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Red Hat
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
#include <unistd.h>
#include <stdlib.h>
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2014 Red Hat
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
#ifndef CEPH_OS_BLUESTORE_KERNELDEVICE_H
#define CEPH_OS_BLUESTORE_KERNELDEVICE_H