block: Fix QCOW cluster leak after a failed write
A write that allocates a data cluster and then fails before the cluster
is mapped leaves that cluster allocated: refcount 1, no L2 entry
pointing at it. At allocator exhaustion this is the common case, since
get_new_cluster() returns ENOSPC for the L2 table the same write still
needs, so every retried write burns one more cluster exactly when the
allocator has none to spare. Only an offline repair gets the space
back.
Return the cluster to the allocator on the failure path, the same way a
cluster freed from a live mapping is returned, and do the same for a
new L2 table whose refcount could not be raised. Best effort: the
caller is already returning an error.
The double allocation this write path used to cause, an L1 entry left
pointing at a refcount-zero table that the free-list rebuild handed to
the next writer, is fixed by 8192880. This covers the space leak that
remains on the same path.
Signed-off-by: doge <me@crackerben.com>
Signed-off-by: CMGS <ilskdw@gmail.com>