[STORE] Rename temp-files under lock to prevent metadata reads while renaming

This commit was part of the Lucene 5 upgrade but unrelated to the actual upgrade
code. Yet, Lucene 5 has more extensive checks on the segment level that uncovered
a bug where the rename failed due to open files that can't be deleted.