X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fosd%2FmClockOpClassQueue.h;fp=src%2Fceph%2Fsrc%2Fosd%2FmClockOpClassQueue.h;h=1b386fe2da2026e35fbf8e00297eb32e5a4de946;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/osd/mClockOpClassQueue.h b/src/ceph/src/osd/mClockOpClassQueue.h new file mode 100644 index 0000000..1b386fe --- /dev/null +++ b/src/ceph/src/osd/mClockOpClassQueue.h @@ -0,0 +1,153 @@ +// -*- 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) 2016 Red Hat Inc. + * + * 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. + * + */ + + +#pragma once + +#include + +#include "boost/variant.hpp" + +#include "common/config.h" +#include "common/ceph_context.h" +#include "osd/PGQueueable.h" + +#include "common/mClockPriorityQueue.h" + + +namespace ceph { + + using Request = std::pair; + using Client = entity_inst_t; + + + // This class exists to bridge the ceph code, which treats the class + // as the client, and the queue, where the class is + // osd_op_type_t. So this adpater class will transform calls + // appropriately. + class mClockOpClassQueue : public OpQueue { + + enum class osd_op_type_t { + client_op, osd_subop, bg_snaptrim, bg_recovery, bg_scrub }; + + using queue_t = mClockQueue; + + queue_t queue; + + struct mclock_op_tags_t { + crimson::dmclock::ClientInfo client_op; + crimson::dmclock::ClientInfo osd_subop; + crimson::dmclock::ClientInfo snaptrim; + crimson::dmclock::ClientInfo recov; + crimson::dmclock::ClientInfo scrub; + + mclock_op_tags_t(CephContext *cct); + }; + + static std::unique_ptr mclock_op_tags; + + public: + + mClockOpClassQueue(CephContext *cct); + + static crimson::dmclock::ClientInfo + op_class_client_info_f(const osd_op_type_t& op_type); + + inline unsigned length() const override final { + return queue.length(); + } + + // Ops of this priority should be deleted immediately + inline void remove_by_class(Client cl, + std::list *out) override final { + queue.remove_by_filter( + [&cl, out] (const Request& r) -> bool { + if (cl == r.second.get_owner()) { + out->push_front(r); + return true; + } else { + return false; + } + }); + } + + inline void enqueue_strict(Client cl, + unsigned priority, + Request item) override final { + queue.enqueue_strict(get_osd_op_type(item), priority, item); + } + + // Enqueue op in the front of the strict queue + inline void enqueue_strict_front(Client cl, + unsigned priority, + Request item) override final { + queue.enqueue_strict_front(get_osd_op_type(item), priority, item); + } + + // Enqueue op in the back of the regular queue + inline void enqueue(Client cl, + unsigned priority, + unsigned cost, + Request item) override final { + queue.enqueue(get_osd_op_type(item), priority, cost, item); + } + + // Enqueue the op in the front of the regular queue + inline void enqueue_front(Client cl, + unsigned priority, + unsigned cost, + Request item) override final { + queue.enqueue_front(get_osd_op_type(item), priority, cost, item); + } + + // Returns if the queue is empty + inline bool empty() const override final { + return queue.empty(); + } + + // Return an op to be dispatch + inline Request dequeue() override final { + return queue.dequeue(); + } + + // Formatted output of the queue + void dump(ceph::Formatter *f) const override final; + + protected: + + struct pg_queueable_visitor_t : public boost::static_visitor { + osd_op_type_t operator()(const OpRequestRef& o) const { + // don't know if it's a client_op or a + return osd_op_type_t::client_op; + } + + osd_op_type_t operator()(const PGSnapTrim& o) const { + return osd_op_type_t::bg_snaptrim; + } + + osd_op_type_t operator()(const PGScrub& o) const { + return osd_op_type_t::bg_scrub; + } + + osd_op_type_t operator()(const PGRecovery& o) const { + return osd_op_type_t::bg_recovery; + } + }; // class pg_queueable_visitor_t + + static pg_queueable_visitor_t pg_queueable_visitor; + + osd_op_type_t get_osd_op_type(const Request& request); + }; // class mClockOpClassAdapter + +} // namespace ceph