[backend] use standard locking in BSFileDB

With the simple lock used before, a rewrite+rename
could lead to data loss.