nvme_rdma: make cm_event fd asynchronous.

This is paving the way for additional changes to enable polling for
cm_events in the initiator.

For now, just present the same blocking API on top of the now polled
file descriptor. Later, we will change this API to be more useful.

Change-Id: I174dac028720f95c30100f6dc2ed49b5bb2a7e40
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/467545
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Seth Howell 2019-09-05 12:53:18 -07:00 committed by Jim Harris
parent f54df84058
commit ad7a01bde3

View File

@ -230,10 +230,12 @@ nvme_rdma_get_event(struct rdma_event_channel *channel,
enum rdma_cm_event_type evt) enum rdma_cm_event_type evt)
{ {
struct rdma_cm_event *event; struct rdma_cm_event *event;
int rc;
rc = rdma_get_cm_event(channel, &event); while (rdma_get_cm_event(channel, &event) != 0) {
if (rc < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) {
continue;
}
SPDK_ERRLOG("Failed to get event from CM event channel. Error %d (%s)\n", SPDK_ERRLOG("Failed to get event from CM event channel. Error %d (%s)\n",
errno, spdk_strerror(errno)); errno, spdk_strerror(errno));
return NULL; return NULL;
@ -803,6 +805,7 @@ nvme_rdma_qpair_connect(struct nvme_rdma_qpair *rqpair)
int rc; int rc;
struct spdk_nvme_ctrlr *ctrlr; struct spdk_nvme_ctrlr *ctrlr;
int family; int family;
int flag;
rqpair->cm_channel = rdma_create_event_channel(); rqpair->cm_channel = rdma_create_event_channel();
if (rqpair->cm_channel == NULL) { if (rqpair->cm_channel == NULL) {
@ -810,6 +813,12 @@ nvme_rdma_qpair_connect(struct nvme_rdma_qpair *rqpair)
return -1; return -1;
} }
flag = fcntl(rqpair->cm_channel->fd, F_GETFL);
if (fcntl(rqpair->cm_channel->fd, F_SETFL, flag | O_NONBLOCK) < 0) {
SPDK_ERRLOG("Cannot set event channel to non blocking\n");
return -1;
}
ctrlr = rqpair->qpair.ctrlr; ctrlr = rqpair->qpair.ctrlr;
switch (ctrlr->trid.adrfam) { switch (ctrlr->trid.adrfam) {