All of lore.kernel.org
 help / color / mirror / Atom feed
* Possible event on cm_id after rdma_accept() fails?
@ 2012-01-06 20:08 Roland Dreier
       [not found] ` <CAL1RGDVhFP+yESH4pnYPA7co1WkY2HSV7vGB-eM34cgv7Tvpgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Roland Dreier @ 2012-01-06 20:08 UTC (permalink / raw)
  To: Sean Hefty; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Hi Sean,

If I get a new cm_id from a RDMA_CM_EVENT_CONNECT_REQUEST
event, and call rdma_accept(), and then rdma_accept() returns an error
for whatever reason, is it safe to assume I won't get any other events
for the cm_id I failed to accept?

ie there's no race where another thread might get a disconnect event
on that cm_id too, right?  So it's safe to just start cleaning up after
I get a failed status from rdma_accept().

Thanks,
 - R.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Possible event on cm_id after rdma_accept() fails?
       [not found] ` <CAL1RGDVhFP+yESH4pnYPA7co1WkY2HSV7vGB-eM34cgv7Tvpgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-01-06 22:23   ` Hefty, Sean
       [not found]     ` <1828884A29C6694DAF28B7E6B8A8237325675055-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Hefty, Sean @ 2012-01-06 22:23 UTC (permalink / raw)
  To: Roland Dreier; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

> If I get a new cm_id from a RDMA_CM_EVENT_CONNECT_REQUEST
> event, and call rdma_accept(), and then rdma_accept() returns an error
> for whatever reason, is it safe to assume I won't get any other events
> for the cm_id I failed to accept?
> 
> ie there's no race where another thread might get a disconnect event
> on that cm_id too, right?  So it's safe to just start cleaning up after
> I get a failed status from rdma_accept().

I typed in the response below before it occurred to me to ask whether you're asking about calling rdma_accept from user space or the kernel.  I was assuming user space. 

It looks like there is a race.

In ucma.c : ucma_event_handler(), we have:

 .. if (!ctx->uid) {
	/* ... ignore events for new connections ... */
	...
	goto out;
 }

But ucma_accept() does:

	ctx->uid = cmd.uid;
	...
	ret = rdma_accept(ctx->cm_id ...)

I believe it's possible for the remote side to issue a reject.  ucma_accept() could set ctx->uid.  The rdma_cm could process the reject, change the state of the cm_id, and call ucma_event_handler, which would queue the event.  rdma_accept() would then fail.

I think restructuring ucma_accept() like this would fix this race:

	mutex_lock(&file->mut);
	ret = rdma_accept(...)
	if (!ret)
		ctx->uid = cmd.uid;
	mutex_unlock(&file->mut);

I'll give this problem more thought.

- Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Possible event on cm_id after rdma_accept() fails?
       [not found]     ` <1828884A29C6694DAF28B7E6B8A8237325675055-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2012-01-06 22:44       ` Roland Dreier
  0 siblings, 0 replies; 3+ messages in thread
From: Roland Dreier @ 2012-01-06 22:44 UTC (permalink / raw)
  To: Hefty, Sean; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA

> I typed in the response below before it occurred to me to ask whether you're asking about calling rdma_accept from user space or the kernel.  I was assuming user space.

Yeah, userspace / librdmacm.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-06 22:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-06 20:08 Possible event on cm_id after rdma_accept() fails? Roland Dreier
     [not found] ` <CAL1RGDVhFP+yESH4pnYPA7co1WkY2HSV7vGB-eM34cgv7Tvpgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-06 22:23   ` Hefty, Sean
     [not found]     ` <1828884A29C6694DAF28B7E6B8A8237325675055-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2012-01-06 22:44       ` Roland Dreier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.