]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
bluestore: extract IOContext logic out of BlueStore
authorKefu Chai <kchai@redhat.com>
Mon, 20 Nov 2017 04:21:49 +0000 (12:21 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 20 Nov 2017 04:24:19 +0000 (12:24 +0800)
to avoid HAVE_LIBAIO appearing in BlueStore.cc

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/os/bluestore/BlockDevice.cc
src/os/bluestore/BlockDevice.h
src/os/bluestore/BlueStore.cc

index d82139f031f9d10f143a7f4fb03fd39cf01e93aa..004976e8a6b2591d9ee01598174a183958b4d2bc 100644 (file)
@@ -55,6 +55,33 @@ void IOContext::aio_wait()
   dout(20) << __func__ << " " << this << " done" << dendl;
 }
 
+uint64_t IOContext::get_num_ios() const
+{
+  // this is about the simplest model for transaction cost you can
+  // imagine.  there is some fixed overhead cost by saying there is a
+  // minimum of one "io".  and then we have some cost per "io" that is
+  // a configurable (with different hdd and ssd defaults), and add
+  // that to the bytes value.
+  uint64_t ios = 0;
+#ifdef HAVE_LIBAIO
+  for (auto& p : pending_aios) {
+    ios += p.iov.size();
+  }
+#endif
+#ifdef HAVE_SPDK
+  ios += total_nseg;
+#endif
+  return ios;
+}
+
+void IOContext::release_running_aios()
+{
+#ifdef HAVE_LIBAIO
+  // release aio contexts (including pinned buffers).
+  running_aios.clear();
+#endif
+}
+
 BlockDevice *BlockDevice::create(CephContext* cct, const string& path,
                                 aio_callback_t cb, void *cbpriv)
 {
index 89b76becb607a24189b16711b567e7655e4e951d..012b31d7e9ceb33f1590a78beaad40a9a61201db 100644 (file)
@@ -72,8 +72,9 @@ public:
   bool has_pending_aios() {
     return num_pending.load();
   }
-
+  void release_running_aios();
   void aio_wait();
+  uint64_t get_num_ios() const;
 
   void try_aio_wake() {
     if (num_running == 1) {
index fc9c30317400773e748cfa0639ec554a371ab6c1..12c464b89ed54543a74f23c4cb1d96f9f213b548 100644 (file)
@@ -7877,21 +7877,8 @@ BlueStore::TransContext *BlueStore::_txc_create(OpSequencer *osr)
 
 void BlueStore::_txc_calc_cost(TransContext *txc)
 {
-  // this is about the simplest model for transaction cost you can
-  // imagine.  there is some fixed overhead cost by saying there is a
-  // minimum of one "io".  and then we have some cost per "io" that is
-  // a configurable (with different hdd and ssd defaults), and add
-  // that to the bytes value.
-  int ios = 1;  // one "io" for the kv commit
-#ifdef HAVE_LIBAIO
-  for (auto& p : txc->ioc.pending_aios) {
-    ios += p.iov.size();
-  }
-#endif
-#ifdef HAVE_SPDK
-  ios += txc->ioc.total_nseg;
-#endif
-
+  // one "io" for the kv commit
+  auto ios = 1 + txc->ioc.get_num_ios();
   auto cost = throttle_cost_per_io.load();
   txc->cost = ios * cost + txc->bytes;
   dout(10) << __func__ << " " << txc << " cost " << txc->cost << " ("
@@ -8038,10 +8025,7 @@ void BlueStore::_txc_finish_io(TransContext *txc)
   OpSequencer *osr = txc->osr.get();
   std::lock_guard<std::mutex> l(osr->qlock);
   txc->state = TransContext::STATE_IO_DONE;
-#ifdef HAVE_LIBAIO
-  // release aio contexts (including pinned buffers).
-  txc->ioc.running_aios.clear();
-#endif
+  txc->ioc.release_running_aios();
   OpSequencer::q_list_t::iterator p = osr->q.iterator_to(*txc);
   while (p != osr->q.begin()) {
     --p;