Skip to content

Commit

Permalink
Merge pull request #27574 from iotcg/iwarp_rocev2
Browse files Browse the repository at this point in the history
msg/async/rdma: fix memory leak

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Apr 25, 2019
2 parents 49117a0 + d775a46 commit 878e488
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions src/msg/async/rdma/Infiniband.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Port::Port(CephContext *cct, struct ibv_context* ictxt, uint8_t ipn): ctxt(ictxt


Device::Device(CephContext *cct, ibv_device* d, struct ibv_context *dc)
: device(d), device_attr(new ibv_device_attr), active_port(nullptr)
: device(d), active_port(nullptr)
{
if (device == NULL) {
lderr(cct) << __func__ << " device == NULL" << cpp_strerror(errno) << dendl;
Expand All @@ -126,15 +126,15 @@ Device::Device(CephContext *cct, ibv_device* d, struct ibv_context *dc)
lderr(cct) << __func__ << " open rdma device failed. " << cpp_strerror(errno) << dendl;
ceph_abort();
}
int r = ibv_query_device(ctxt, device_attr);
if (r == -1) {
int r = ibv_query_device(ctxt, &device_attr);
if (r) {
lderr(cct) << __func__ << " failed to query rdma device. " << cpp_strerror(errno) << dendl;
ceph_abort();
}
}

void Device::binding_port(CephContext *cct, int port_num) {
port_cnt = device_attr->phys_port_cnt;
port_cnt = device_attr.phys_port_cnt;
for (uint8_t i = 0; i < port_cnt; ++i) {
Port *port = new Port(cct, ctxt, i+1);
if (i + 1 == port_num && port->get_port_attr()->state == IBV_PORT_ACTIVE) {
Expand Down Expand Up @@ -915,9 +915,9 @@ void Infiniband::init()

support_srq = cct->_conf->ms_async_rdma_support_srq;
if (support_srq)
rx_queue_len = device->device_attr->max_srq_wr;
rx_queue_len = device->device_attr.max_srq_wr;
else
rx_queue_len = device->device_attr->max_qp_wr;
rx_queue_len = device->device_attr.max_qp_wr;
if (rx_queue_len > cct->_conf->ms_async_rdma_receive_queue_len) {
rx_queue_len = cct->_conf->ms_async_rdma_receive_queue_len;
ldout(cct, 1) << __func__ << " receive queue length is " << rx_queue_len << " receive buffers" << dendl;
Expand All @@ -936,15 +936,15 @@ void Infiniband::init()
ceph_abort();
}

tx_queue_len = device->device_attr->max_qp_wr;
tx_queue_len = device->device_attr.max_qp_wr;
if (tx_queue_len > cct->_conf->ms_async_rdma_send_buffers) {
tx_queue_len = cct->_conf->ms_async_rdma_send_buffers;
ldout(cct, 1) << __func__ << " assigning: " << tx_queue_len << " send buffers" << dendl;
} else {
ldout(cct, 0) << __func__ << " using the max allowed send buffers: " << tx_queue_len << dendl;
}

ldout(cct, 1) << __func__ << " device allow " << device->device_attr->max_cqe
ldout(cct, 1) << __func__ << " device allow " << device->device_attr.max_cqe
<< " completion entries" << dendl;

memory_manager = new MemoryManager(cct, device, pd);
Expand All @@ -964,6 +964,7 @@ Infiniband::~Infiniband()
ibv_destroy_srq(srq);
delete memory_manager;
delete pd;
delete device_list;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/msg/async/rdma/Infiniband.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Device {
int get_gid_idx() { return active_port->get_gid_idx(); }
void binding_port(CephContext *c, int port_num);
struct ibv_context *ctxt;
ibv_device_attr *device_attr;
ibv_device_attr device_attr;
Port* active_port;
};

Expand Down Expand Up @@ -117,10 +117,10 @@ class DeviceList {
}
delete []devices;
ibv_free_device_list(device_list);
rdma_free_devices(device_context_list);
}

Device* get_device(const char* device_name) {
ceph_assert(devices);
for (int i = 0; i < num; ++i) {
if (!strlen(device_name) || !strcmp(device_name, devices[i]->get_name())) {
return devices[i];
Expand Down

0 comments on commit 878e488

Please sign in to comment.