From 3e87874d4e2e40e5f6218c35d72efa79dc234beb Mon Sep 17 00:00:00 2001 From: Xu Wang <59418106+xwang1498@users.noreply.github.com> Date: Sat, 18 Jan 2025 17:44:27 -0500 Subject: [PATCH 1/2] store random seed for later recovery --- disk-filltest.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/disk-filltest.c b/disk-filltest.c index 56c1c8c..e1747f9 100644 --- a/disk-filltest.c +++ b/disk-filltest.c @@ -260,6 +260,8 @@ void unlink_randfiles(void) if (filenum > 0) printf(" total: %u.\n", filenum); + + unlink("random-seed"); } /* fill disk */ @@ -288,6 +290,14 @@ void write_randfiles(void) printf("Writing files random-######## with seed %u\n", g_seed); + if (!gopt_unlink_immediate) { + FILE *fp = fopen("random-seed", "w"); + if (fp != NULL) { + fprintf(fp, "%u", g_seed); + fclose(fp); + } + } + while (!done && filenum < gopt_file_limit) { char filename[32], eta[64]; From 5cda1d6b34b33cc8b9cd11fab4cbc4040e201577 Mon Sep 17 00:00:00 2001 From: Xu Wang <59418106+xwang1498@users.noreply.github.com> Date: Sat, 18 Jan 2025 17:44:59 -0500 Subject: [PATCH 2/2] read random seed from file when in readonly/verify mode --- disk-filltest.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/disk-filltest.c b/disk-filltest.c index e1747f9..cd945f5 100644 --- a/disk-filltest.c +++ b/disk-filltest.c @@ -49,7 +49,7 @@ #endif /* random seed used */ -unsigned int g_seed; +unsigned int g_seed = 0; /* only perform read operation */ int gopt_readonly = 0; @@ -526,10 +526,20 @@ int main(int argc, char* argv[]) { int r; - g_seed = time(NULL); - parse_commandline(argc, argv); + if (gopt_readonly && !g_seed) { + FILE *fp = fopen("random-seed", "r"); + if (fp != NULL) { + fscanf(fp, "%u", &g_seed); + fclose(fp); + } + } + + if (!g_seed) { + g_seed = time(NULL); + } + for (r = 0; r < gopt_repeat; ++r) { if (gopt_readonly)