diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-02-20 15:19:47 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-02-20 15:19:47 -0500 |
commit | 39791dc0bda8c5a995e307e6306b79cd0fded644 (patch) | |
tree | c5e2e514231183763982f69a1622a69a4c7f66eb /misc | |
parent | 468d82f430dfdf270b738e14345b879560c2cd9e (diff) | |
download | e2fsprogs-39791dc0bda8c5a995e307e6306b79cd0fded644.tar.gz |
badblocks: Fix up recover_block handling in badblocks
If there was a bad block for block #0, badblocks would never switch
back testing blocks more efficiently. In addition, we were
double-incrementing the blocks to be tested in the read/write test due
to failure to remove code.
Thanks to Ragnar Kjørstad for pointing these problems out.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'misc')
-rw-r--r-- | misc/badblocks.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/misc/badblocks.c b/misc/badblocks.c index 84e84748..f2965417 100644 --- a/misc/badblocks.c +++ b/misc/badblocks.c @@ -571,7 +571,7 @@ static unsigned int test_rw (int dev, blk_t last_block, const unsigned int *pattern; int i, try, got, nr_pattern, pat_idx; unsigned int bb_count = 0; - blk_t recover_block = 0; + blk_t recover_block = ~0; /* set up abend handler */ capture_terminate(NULL); @@ -681,17 +681,6 @@ static unsigned int test_rw (int dev, blk_t last_block, block_size)) bb_count += bb_output(currently_testing+i); } - currently_testing += got; - if (got != try) { - try = 1; - if (!recover_block) - recover_block = currently_testing - - got + blocks_at_once; - continue; - } else if (currently_testing == recover_block) { - try = blocks_at_once; - recover_block = 0; - } if (v_flag > 1) print_status(); } @@ -732,7 +721,7 @@ static unsigned int test_nd (int dev, blk_t last_block, unsigned long buf_used; static unsigned int bb_count; int granularity = blocks_at_once; - blk_t recover_block = 0; + blk_t recover_block = ~0; bb_count = 0; errcode = ext2fs_badblocks_list_iterate_begin(bb_list,&bb_iter); @@ -831,8 +820,7 @@ static unsigned int test_nd (int dev, blk_t last_block, got = do_read (dev, save_ptr, try, block_size, currently_testing); if (got == 0) { - if ((currently_testing == 0) || - (recover_block == 0)) + if (recover_block == ~0) recover_block = currently_testing + blocks_at_once; if (granularity != 1) { @@ -867,7 +855,7 @@ static unsigned int test_nd (int dev, blk_t last_block, currently_testing += got; if (got != try) { try = 1; - if (!recover_block) + if (recover_block == ~0) recover_block = currently_testing - got + blocks_at_once; continue; @@ -885,7 +873,7 @@ static unsigned int test_nd (int dev, blk_t last_block, if (currently_testing >= recover_block) { granularity = blocks_at_once; - recover_block = 0; + recover_block = ~0; } flush_bufs(); @@ -1298,4 +1286,3 @@ int main (int argc, char ** argv) free(t_patts); return 0; } - |