cache/ImageWriteback.cc
cache/ObjectCacherObjectDispatch.cc
cache/ObjectCacherWriteback.cc
- cache/PassthroughImageCache.cc
cache/pwl/InitRequest.cc
cache/pwl/ShutdownRequest.cc
cache/WriteAroundObjectDispatch.cc
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_LIBRBD_CACHE_IMAGE_CACHE
-#define CEPH_LIBRBD_CACHE_IMAGE_CACHE
-
-#include "include/buffer_fwd.h"
-#include "include/int_types.h"
-#include "librbd/io/Types.h"
-#include <vector>
-
-class Context;
-
-namespace librbd {
-struct ImageCtx;
-namespace cache {
-
-/**
- * client-side, image extent cache interface
- */
-template <typename ImageCtxT = ImageCtx>
-struct ImageCache {
-protected:
- ImageCache() {}
-public:
- typedef io::Extent Extent;
- typedef io::Extents Extents;
-
- virtual ~ImageCache() {}
-
- /// client AIO methods
- virtual void aio_read(Extents&& image_extents, ceph::bufferlist* bl,
- int fadvise_flags, Context *on_finish) = 0;
- virtual void aio_write(Extents&& image_extents, ceph::bufferlist&& bl,
- int fadvise_flags, Context *on_finish) = 0;
- virtual void aio_discard(uint64_t offset, uint64_t length,
- uint32_t discard_granularity_bytes,
- Context *on_finish) = 0;
- virtual void aio_flush(io::FlushSource flush_source, Context *on_finish) = 0;
- virtual void aio_writesame(uint64_t offset, uint64_t length,
- ceph::bufferlist&& bl,
- int fadvise_flags, Context *on_finish) = 0;
- virtual void aio_compare_and_write(Extents&& image_extents,
- ceph::bufferlist&& cmp_bl,
- ceph::bufferlist&& bl,
- uint64_t *mismatch_offset,
- int fadvise_flags,
- Context *on_finish) = 0;
-
- /// internal state methods
- virtual void init(Context *on_finish) = 0;
- virtual void shut_down(Context *on_finish) = 0;
-
- virtual void invalidate(Context *on_finish) = 0;
- virtual void flush(Context *on_finish) = 0;
-};
-
-} // namespace cache
-} // namespace librbd
-
-extern template class librbd::cache::ImageCache<librbd::ImageCtx>;
-
-#endif // CEPH_LIBRBD_CACHE_IMAGE_CACHE
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "PassthroughImageCache.h"
-#include "include/buffer.h"
-#include "common/dout.h"
-#include "librbd/ImageCtx.h"
-
-#define dout_subsys ceph_subsys_rbd
-#undef dout_prefix
-#define dout_prefix *_dout << "librbd::PassthroughImageCache: " << this << " " \
- << __func__ << ": "
-
-namespace librbd {
-namespace cache {
-
-template <typename I>
-PassthroughImageCache<I>::PassthroughImageCache(ImageCtx &image_ctx)
- : m_image_ctx(image_ctx), m_image_writeback(image_ctx) {
-}
-
-template <typename I>
-void PassthroughImageCache<I>::aio_read(Extents &&image_extents, bufferlist *bl,
- int fadvise_flags, Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << "image_extents=" << image_extents << ", "
- << "on_finish=" << on_finish << dendl;
-
- m_image_writeback.aio_read(std::move(image_extents), bl, fadvise_flags,
- on_finish);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::aio_write(Extents &&image_extents,
- bufferlist&& bl,
- int fadvise_flags,
- Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << "image_extents=" << image_extents << ", "
- << "on_finish=" << on_finish << dendl;
-
- m_image_writeback.aio_write(std::move(image_extents), std::move(bl),
- fadvise_flags, on_finish);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::aio_discard(uint64_t offset, uint64_t length,
- uint32_t discard_granularity_bytes,
- Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << "offset=" << offset << ", "
- << "length=" << length << ", "
- << "on_finish=" << on_finish << dendl;
-
- m_image_writeback.aio_discard(offset, length, discard_granularity_bytes,
- on_finish);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::aio_flush(librbd::io::FlushSource flush_source, Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << "on_finish=" << on_finish << dendl;
-
- m_image_writeback.aio_flush(flush_source, on_finish);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::aio_writesame(uint64_t offset, uint64_t length,
- bufferlist&& bl, int fadvise_flags,
- Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << "offset=" << offset << ", "
- << "length=" << length << ", "
- << "data_len=" << bl.length() << ", "
- << "on_finish=" << on_finish << dendl;
-
- m_image_writeback.aio_writesame(offset, length, std::move(bl), fadvise_flags,
- on_finish);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::aio_compare_and_write(Extents &&image_extents,
- bufferlist&& cmp_bl,
- bufferlist&& bl,
- uint64_t *mismatch_offset,
- int fadvise_flags,
- Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << "image_extents=" << image_extents << ", "
- << "on_finish=" << on_finish << dendl;
-
- m_image_writeback.aio_compare_and_write(
- std::move(image_extents), std::move(cmp_bl), std::move(bl), mismatch_offset,
- fadvise_flags, on_finish);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::init(Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << dendl;
-
- on_finish->complete(0);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::shut_down(Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << dendl;
-
- on_finish->complete(0);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::invalidate(Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << dendl;
-
- // dump cache contents (don't have anything)
- on_finish->complete(0);
-}
-
-template <typename I>
-void PassthroughImageCache<I>::flush(Context *on_finish) {
- CephContext *cct = m_image_ctx.cct;
- ldout(cct, 20) << dendl;
-
- // internal flush -- nothing to writeback but make sure
- // in-flight IO is flushed
- aio_flush(librbd::io::FLUSH_SOURCE_INTERNAL, on_finish);
-}
-
-} // namespace cache
-} // namespace librbd
-
-template class librbd::cache::PassthroughImageCache<librbd::ImageCtx>;
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE
-#define CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE
-
-#include "ImageCache.h"
-#include "ImageWriteback.h"
-
-namespace librbd {
-
-struct ImageCtx;
-
-namespace cache {
-
-/**
- * Example passthrough client-side, image extent cache
- */
-template <typename ImageCtxT = librbd::ImageCtx>
-class PassthroughImageCache : public ImageCache<ImageCtxT> {
-public:
- using typename ImageCache<ImageCtxT>::Extents;
- explicit PassthroughImageCache(ImageCtx &image_ctx);
-
- /// client AIO methods
- void aio_read(Extents&& image_extents, ceph::bufferlist *bl,
- int fadvise_flags, Context *on_finish) override;
- void aio_write(Extents&& image_extents, ceph::bufferlist&& bl,
- int fadvise_flags, Context *on_finish) override;
- void aio_discard(uint64_t offset, uint64_t length,
- uint32_t discard_granularity_bytes,
- Context *on_finish) override;
- void aio_flush(librbd::io::FlushSource flush_source, Context *on_finish) override;
- void aio_writesame(uint64_t offset, uint64_t length,
- ceph::bufferlist&& bl,
- int fadvise_flags, Context *on_finish) override;
- void aio_compare_and_write(Extents&& image_extents,
- ceph::bufferlist&& cmp_bl, ceph::bufferlist&& bl,
- uint64_t *mismatch_offset,int fadvise_flags,
- Context *on_finish) override;
-
- /// internal state methods
- void init(Context *on_finish) override;
- void shut_down(Context *on_finish) override;
-
- void invalidate(Context *on_finish) override;
- void flush(Context *on_finish) override;
-
-private:
- ImageCtxT &m_image_ctx;
- ImageWriteback<ImageCtxT> m_image_writeback;
-
-};
-
-} // namespace cache
-} // namespace librbd
-
-extern template class librbd::cache::PassthroughImageCache<librbd::ImageCtx>;
-
-#endif // CEPH_LIBRBD_CACHE_PASSTHROUGH_IMAGE_CACHE
#include "common/RWLock.h"
#include "common/WorkQueue.h"
#include "common/AsyncOpTracker.h"
-#include "librbd/cache/ImageCache.h"
#include "librbd/cache/ImageWriteback.h"
#include "librbd/Utils.h"
#include "librbd/BlockGuard.h"
#define CEPH_LIBRBD_CACHE_RWL_REQUEST_H
#include "include/Context.h"
-#include "librbd/cache/ImageCache.h"
#include "librbd/cache/pwl/Types.h"
#include "librbd/cache/pwl/LogOperation.h"
*
* An Extent ("image extent") identifies a range by start and length.
*
- * The ImageCache interface is defined in terms of image extents, and
+ * The ImageDispatch interface is defined in terms of image extents, and
* requires no alignment of the beginning or end of the extent. We
* convert between image and block extents here using a "block size"
* of 1.