aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-09-20 16:41:09 +0200
committerMattias Andrée <maandree@kth.se>2024-09-20 16:41:09 +0200
commitb3c256c43b7357f3e6ac1696e6b1cb3db5c9428a (patch)
tree2119181fcbc8a433b3dfebd7c21fcd6978ace139
parentm (diff)
downloaddeadshred-b3c256c43b7357f3e6ac1696e6b1cb3db5c9428a.tar.gz
deadshred-b3c256c43b7357f3e6ac1696e6b1cb3db5c9428a.tar.bz2
deadshred-b3c256c43b7357f3e6ac1696e6b1cb3db5c9428a.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--TODO1
-rw-r--r--deadshred.c6
2 files changed, 5 insertions, 2 deletions
diff --git a/TODO b/TODO
index 7edc9d8..6d59925 100644
--- a/TODO
+++ b/TODO
@@ -1,2 +1,3 @@
Add shred map operand
Test direction alternation
+Verify that aborting does not cause sections to be lost in the shred map
diff --git a/deadshred.c b/deadshred.c
index 6557a02..c471982 100644
--- a/deadshred.c
+++ b/deadshred.c
@@ -252,7 +252,7 @@ shredspan(int fd, struct span *span, const char *fname)
goto pwrite_again;
}
if (errno != EIO)
- weprintf("pwrite %s <buffer> %zu %ji:", fname, (size_t)n, (intmax_t)off);
+ eprintf("pwrite %s <buffer> %zu %ji:", fname, (size_t)n, (intmax_t)off);
add_span(off, n, span->blocksize == 1U ? 1U : span->blocksize >> 1, !first_fail);
first_fail = 0;
if (status.direction == FORWARDS)
@@ -443,7 +443,7 @@ main(int argc, char *argv[])
if (errno)
eprintf("pthread_create NULL:");
- while (nspans) {
+ for (;;) {
size_t old_nspans = nspans;
for (i = 0; i < old_nspans && !exiting; i++)
shredspan(fd, &spans[i], argv[0]);
@@ -453,6 +453,8 @@ main(int argc, char *argv[])
}
for (i = 0, j = nspans, nspans -= old_nspans; i < nspans;)
spans[i++] = spans[--j];
+ if (!nspans)
+ break;
status.direction ^= 1;
status.pass_nr += 1U;
}