locks: ensure lock directory exists

Fixes #17326.