From b3c256c43b7357f3e6ac1696e6b1cb3db5c9428a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 20 Sep 2024 16:41:09 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- deadshred.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'deadshred.c') 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 %zu %ji:", fname, (size_t)n, (intmax_t)off); + eprintf("pwrite %s %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; } -- cgit v1.2.3-70-g09d2