Use proper locking for node allocation

save is refactored to accept a code block that needs to be
protected with the role lock. Make use of that in allocate
and convert usages of previous allocate functions accordingly.