logalloc: make sure blocked requests memory allocations are served from the standar allocator
logalloc: make sure blocked requests memory allocations are served from the standar allocator

Issue 1510 describes a scenario in which, under load, we allocate memory within
release_requests() leading to a reentry into an invalid state in our
blocked requests' shared_promise.

This is not easy to trigger since not all allocations will actually get to the
point in which they need a new segment, let alone have that happening during
another allocator call.

Having those kinds of reentry is something we have always sought to avoid with
release_requests(): this is the reason why most of the actual routine is
deferred after a call to later().

However, that is a trick we cannot use for updating the state of the blocked
requests' shared_promise: we can't guarantee when is that going to run, and we
always need a valid shared_promise, in a valid state, waiting for new requests
to hook into.

The solution employed by this patch is to make sure that no allocation
operations whatsoever happen during the initial part of release_requests on
behalf of the shared promise.  Allocation is now deferred to first use, which
relieves release_requests() from all allocation duties. All it needs to do is
free the old object and signal to the its user that an allocation is needed (by
storing {} into the shared_promise).

Fixes #1510

Signed-off-by: Glauber Costa <7ba9037b0dd006f9408bd45b94707becd5cd4e87@scylladb.com>
Message-Id: <49771e51426f972ddbd4f3eeea3cdeef9cc3b3c6.1470238168.git.7ba9037b0dd006f9408bd45b94707becd5cd4e87@scylladb.com>

avikivity/scylla,raphaelsc/scylla,avikivity/scylla,scylladb/scylla,kjniemi/scylla,duarten/scylla,avikivity/scylla,scylladb/scylla,raphaelsc/scylla,kjniemi/scylla,scylladb/scylla,scylladb/scylla,duarten/scylla,kjniemi/scylla,duarten/scylla,raphaelsc/scylla