diff --git a/WHATS_NEW b/WHATS_NEW index e55f7a7a7..5e9e8ae92 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.74 - ================================== + Add random suffix to archive file names to prevent races when being created. Reinitialize archive and backup handling on toolcontext refresh. Fix opprobriously slow I/O to cluster mirrors created with --nosync. Make poll_mirror_progress report PROGRESS_CHECK_FAILED if LV is not a mirror. diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c index 95ac49d64..bf16da573 100644 --- a/lib/format_text/archive.c +++ b/lib/format_text/archive.c @@ -226,7 +226,7 @@ int archive_vg(struct volume_group *vg, const char *dir, const char *desc, uint32_t retain_days, uint32_t min_archive) { - int i, fd, renamed = 0; + int i, fd, rnum, renamed = 0; uint32_t ix = 0; struct archive_file *last; FILE *fp = NULL; @@ -271,9 +271,12 @@ int archive_vg(struct volume_group *vg, ix = last->index + 1; } + rnum = rand_r(&vg->cmd->rand_seed); + for (i = 0; i < 10; i++) { if (dm_snprintf(archive_name, sizeof(archive_name), - "%s/%s_%05u.vg", dir, vg->name, ix) < 0) { + "%s/%s_%05u-%d.vg", + dir, vg->name, ix, rnum) < 0) { log_error("Archive file name too long."); return 0; }