Support opportunistic lock allocation
Support opportunistic lock allocation

Add a function to opportunistically allocate as many locks of a given
set as possible. This is equivalent to sequentially try the locks in
increasing lock order after restricting to those locks where the
required owner state is higher than the currently held one.

Signed-off-by: Klaus Aehlig <4ce51de36d9068cd7db2eec1151e0f3f95419008@google.com>
Reviewed-by: Petr Pudlak <9d19625f8ee825a2c398462ed335cbcf98f79c32@google.com>

onponomarev/ganeti,dimara/ganeti,andir/ganeti,yiannist/ganeti,mbakke/ganeti,grnet/snf-ganeti,bitemyapp/ganeti,yiannist/ganeti,ganeti/ganeti,leshchevds/ganeti,onponomarev/ganeti,ganeti/ganeti,yiannist/ganeti,ganeti/ganeti,leshchevds/ganeti,dimara/ganeti,bitemyapp/ganeti,grnet/snf-ganeti,mbakke/ganeti,mbakke/ganeti,andir/ganeti,apyrgio/ganeti,ganeti-github-testing/ganeti-test-1,andir/ganeti,ganeti-github-testing/ganeti-test-1,apyrgio/ganeti,leshchevds/ganeti