Don't pay for a bunch of timechecks and not do anything

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Clean up and document the Thread Fridge

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Improve fridge initialization/destruction

Previously, the caller allocated a thread fridge, stuck some values in
it, and called the initialization function, which set some other
values in it.  Separate out a fridge parameters structure that gets
passed to the initializer.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Remove test_rpctools.c

It doesn't do anything useful, and it does it on an interface that
hasn't existed since last Spring.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Fix types

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Implment thr_max

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Un-camelcase flags

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Remove the stacksize parameter from the threadfridge

Nobody was using it, it wasn't even supported in the code, and it
breaks things if you try to set it.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Use clock_gettime rather than time in fridgethr

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
State machine for start, stop, and pause

Stop has been tested and works, pause may not work yet.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Implement new deferment styles for the thread fridge

 * Queue: What we had before, stick the job on a queue and immediately
          exit.

 * Block: Wait (with timeout) for a thread to become available.

 * Fail: Error on any submission when the fridge is full.

Switch request processing over to use blocking deferment.

A simple test (set the max to two, hammer it with three machines, and
insert prints on blocking and scheduling) shows that blocking
deferment works.  I'm not sure how to induce a timeout in request
processing, so as yet the behaviour of rearming the transport on
timeout isn't tested.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Rename fridgethr_get to fridgethr_submit

The name fridgethr_get did not make the function's purpose apparent.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Add per-task cleanup to thread fridge

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Fix up formatting of FSAL_UP

It was a rewrite anyway, so there's nothing we can foreport from 1.5.
It's not that busy an area in the code.
And I'm about to make lots of changes anyway by stuffing it in the fridge.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Put FSAL UPcall thread in the fridge

And if we find ourselves with lots of upcall traffic, we can trivially
increase the size of the fridge.

Also take the opportunity to simplify upcall dispatch and get rid of
the gigantic switch statements.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Pull out stat thread launches

According to Jim Lieb they don't even compile.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Swallow up state async request thread

This is not tested beyond making sure it comes up and shuts down.  I
do not yet have an FSAL that supports asynchronous blocking locks, so
someone with one will need to go over this.

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Add support for looper fridges

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Add 'woke' entry to fridgethr_context

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>
Support changing the wait time of a running fridge

Signed-off-by: Adam C. Emerson <aemerson@linuxbox.com>