[0/2] Simplify handling of credits in compound_send_recv()
mbox series

Message ID 20190220061145.28241-1-lsahlber@redhat.com
Headers show
Series
  • Simplify handling of credits in compound_send_recv()
Related show

Message

Ronnie Sahlberg Feb. 20, 2019, 6:11 a.m. UTC
Pavel, Steve,

I think we can simplify the credits handling in compound_send_recv() a bit.

The first patch adds an extra argument to wait_for_free_request() and
allows us to atomically wait for n (n >= 1) requests/credits instead of just a
single one.
All callsites pass 1 as number of requests so no behaviour should be changed.

The second patch uses this new feature to now atomically wait for num_rqst
requests/credits in one single call.
This makes the code much simpler, since we no longer need to return
the credits if we only got a partial number of requests (can no longer happen).
It also solves a potential deadlock if we have many concurrent threads
trying to allocate requests/credits at the same time. I.e.
each one grabs one or two requests but then block on the final request.


We still have the issue that if we we do not have enough credits for the compound,
and the server will not grant us any additional credits in any responses yet to be received,  and the client is not doing any other I/O which might bump the number of requests, then we might block indefinitely, or until the session is reconnected.
That is unchanged but should be a lot rarer since we no longer have the deadlock between many concurrent threads.