mem: revert to using flock and add per-segment lockfiles