[PATCH mtd-utils] mtd-tests/flash_stress: allow picking any erase block

Dominique Martinet dominique.martinet at atmark-techno.com
Fri Aug 14 00:36:53 PDT 2026


unlike the kernel module mtd_stresstest, the read and write operations
in this test program only ever span a single erase block, so we can pick
any erase block in rand_eb()
---
Noticed this while looking at the code (to get a rough idea of how many
erase cycles I'm going through on average for each erase block with this)

 tests/mtd-tests/flash_stress.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/mtd-tests/flash_stress.c b/tests/mtd-tests/flash_stress.c
index da39e1408ed3..ada8596382e9 100644
--- a/tests/mtd-tests/flash_stress.c
+++ b/tests/mtd-tests/flash_stress.c
@@ -150,9 +150,8 @@ static int rand_eb(void)
 {
 	unsigned int eb;
 
-	/* Read or write up 2 eraseblocks at a time - hence 'mtd.eb_cnt - 1' */
 	do {
-		eb = rand() % (mtd.eb_cnt - 1);
+		eb = rand() % mtd.eb_cnt;
 	} while (bbt[eb]);
 
 	return eb;
-- 
2.55.0.dirty





More information about the linux-mtd mailing list