From: Pan Liu Date: Fri, 18 Aug 2017 13:31:46 +0000 (+0800) Subject: os/bluestore: support calculate cost when using spdk. X-Git-Tag: v13.0.1~1156^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2b9113a25e549f3947bb82e324a729d3bcf821ce;p=ceph.git os/bluestore: support calculate cost when using spdk. Signed-off-by: Pan Liu Signed-off-by: Ziye Yang --- diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index a90cedeb854..37e65ff3ec0 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -39,6 +39,7 @@ public: #ifdef HAVE_SPDK void *nvme_task_first = nullptr; void *nvme_task_last = nullptr; + std::atomic_int total_nseg = {0}; #endif diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 1e2d2631978..5da13aa2b5b 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7657,6 +7657,11 @@ void BlueStore::_txc_calc_cost(TransContext *txc) for (auto& p : txc->ioc.pending_aios) { ios += p.iov.size(); } + +#ifdef HAVE_SPDK + ios += txc->ioc.total_nseg; +#endif + auto cost = throttle_cost_per_io.load(); txc->cost = ios * cost + txc->bytes; dout(10) << __func__ << " " << txc << " cost " << txc->cost << " (" diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 2ff5dac3357..5660540ce08 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -320,6 +320,7 @@ struct Task { for (uint16_t i = 0; i < io_request.nseg; i++) queue_data->data_buf_mempool.push_back(io_request.inline_segs[i]); } + ctx->total_nseg -= io_request.nseg; io_request.nseg = 0; } @@ -423,6 +424,7 @@ int SharedDriverQueueData::alloc_buf_from_pool(Task *t, bool write) data_buf_mempool.pop_back(); } t->io_request.nseg = count; + t->ctx->total_nseg += count; if (write) { auto blp = t->write_bl.begin(); uint32_t len = 0;