X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fos%2Fbluestore%2FKernelDevice.h;fp=src%2Fceph%2Fsrc%2Fos%2Fbluestore%2FKernelDevice.h;h=f04b7f972af3a8c46e6e86e569e945c1571d3f94;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/os/bluestore/KernelDevice.h b/src/ceph/src/os/bluestore/KernelDevice.h new file mode 100644 index 0000000..f04b7f9 --- /dev/null +++ b/src/ceph/src/os/bluestore/KernelDevice.h @@ -0,0 +1,110 @@ +// -*- 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 + +#include + +#include "os/fs/FS.h" +#include "include/interval_set.h" + +#include "aio.h" +#include "BlockDevice.h" + +class KernelDevice : public BlockDevice { + int fd_direct, fd_buffered; + uint64_t size; + uint64_t block_size; + std::string path; + FS *fs; + bool aio, dio; + + Mutex debug_lock; + interval_set debug_inflight; + + std::atomic io_since_flush = {false}; + std::mutex flush_mutex; + + aio_queue_t aio_queue; + aio_callback_t aio_callback; + void *aio_callback_priv; + bool aio_stop; + + struct AioCompletionThread : public Thread { + KernelDevice *bdev; + explicit AioCompletionThread(KernelDevice *b) : bdev(b) {} + void *entry() override { + bdev->_aio_thread(); + return NULL; + } + } aio_thread; + + std::atomic_int injecting_crash; + + void _aio_thread(); + int _aio_start(); + void _aio_stop(); + + void _aio_log_start(IOContext *ioc, uint64_t offset, uint64_t length); + void _aio_log_finish(IOContext *ioc, uint64_t offset, uint64_t length); + + int _sync_write(uint64_t off, bufferlist& bl, bool buffered); + + int _lock(); + + int direct_read_unaligned(uint64_t off, uint64_t len, char *buf); + + // stalled aio debugging + aio_list_t debug_queue; + std::mutex debug_queue_lock; + aio_t *debug_oldest = nullptr; + utime_t debug_stall_since; + void debug_aio_link(aio_t& aio); + void debug_aio_unlink(aio_t& aio); + +public: + KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv); + + void aio_submit(IOContext *ioc) override; + + uint64_t get_size() const override { + return size; + } + uint64_t get_block_size() const override { + return block_size; + } + + int collect_metadata(std::string prefix, map *pm) const override; + + int read(uint64_t off, uint64_t len, bufferlist *pbl, + IOContext *ioc, + bool buffered) override; + int aio_read(uint64_t off, uint64_t len, bufferlist *pbl, + IOContext *ioc) override; + int read_random(uint64_t off, uint64_t len, char *buf, bool buffered) override; + + int write(uint64_t off, bufferlist& bl, bool buffered) override; + int aio_write(uint64_t off, bufferlist& bl, + IOContext *ioc, + bool buffered) override; + int flush() override; + + // for managing buffered readers/writers + int invalidate_cache(uint64_t off, uint64_t len) override; + int open(const std::string& path) override; + void close() override; +}; + +#endif