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)
{
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 << " ("
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;