[dm-io] Fix a race condition in the wake up code for sync_io

There's a race condition between the atomic_dec_and_test(&io->count)
in dec_count() and the waking of the sync_io() thread.  If the thread
is spuriously woken immediately after the decrement it may exit,
making the on the stack io struct invalid, yet the dec_count could
still be using it.

There are smaller fixes than the one here (eg, just take the io object
off the stack).  But I feel this code could use a clean up.

- simplify dec_count().

  - It always calls a callback fn now.
  - It always frees the io object back to the pool.

- sync_io()

  - Take the io object off the stack and allocate it from the pool the
    same as async_io.
  - Use a completion object rather than an explicit io_schedule()
    loop.  The callback triggers the completion.

Reported by: Minfei Huang
Merge branch 'thin-dev' of github.com:jthornber/linux-2.6 into thin-dev