Change the temporary_write_lock api, so that it always returns a lock object,
and a flag indicating whether it was able to grab a write lock.
This is because callers don't know whether it had to unlock the original lock, so it
should always return something that lets callers maintain proper state.