Adopted erase_size config changes in block devices and test runners
This ended up needing a bit of API rework since littlefs no longer needs to know the actual erase_count. We can no longer rely on lfs_config to contain all the information necessary to configure the block devices. Changing the lfs_bd_config structs to be required is probably a good idea anyways as it moves us more towards separating the bds from littlefs, though we can't quite get rid of the lfs_config parameter because of the block-device API in lfs_config. Eventually it would be nice to get rid of it, but that would require API breakage.
This commit is contained in:
+17
-12
@@ -1271,9 +1271,9 @@ static void list_geometries(void) {
|
||||
builtin_geometries[g].name,
|
||||
READ_SIZE,
|
||||
PROG_SIZE,
|
||||
BLOCK_SIZE,
|
||||
BLOCK_COUNT,
|
||||
BLOCK_SIZE*BLOCK_COUNT);
|
||||
ERASE_SIZE,
|
||||
ERASE_COUNT,
|
||||
ERASE_SIZE*ERASE_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1316,6 +1316,7 @@ void perm_run(
|
||||
.sync = lfs_emubd_sync,
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.block_size = BLOCK_SIZE,
|
||||
.block_count = BLOCK_COUNT,
|
||||
.block_cycles = BLOCK_CYCLES,
|
||||
@@ -1324,6 +1325,10 @@ void perm_run(
|
||||
};
|
||||
|
||||
struct lfs_emubd_config bdcfg = {
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.erase_count = ERASE_COUNT,
|
||||
.erase_value = ERASE_VALUE,
|
||||
.erase_cycles = ERASE_CYCLES,
|
||||
.badblock_behavior = BADBLOCK_BEHAVIOR,
|
||||
@@ -1333,7 +1338,7 @@ void perm_run(
|
||||
.erase_sleep = bench_erase_sleep,
|
||||
};
|
||||
|
||||
int err = lfs_emubd_createcfg(&cfg, bench_disk_path, &bdcfg);
|
||||
int err = lfs_emubd_create(&cfg, &bdcfg);
|
||||
if (err) {
|
||||
fprintf(stderr, "error: could not create block device: %d\n", err);
|
||||
exit(-1);
|
||||
@@ -1761,19 +1766,19 @@ invalid_define:
|
||||
= BENCH_LIT(sizes[0]);
|
||||
geometry->defines[PROG_SIZE_i]
|
||||
= BENCH_LIT(sizes[1]);
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= BENCH_LIT(sizes[2]);
|
||||
} else if (count >= 2) {
|
||||
geometry->defines[PROG_SIZE_i]
|
||||
= BENCH_LIT(sizes[0]);
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= BENCH_LIT(sizes[1]);
|
||||
} else {
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= BENCH_LIT(sizes[0]);
|
||||
}
|
||||
if (count >= 4) {
|
||||
geometry->defines[BLOCK_COUNT_i]
|
||||
geometry->defines[ERASE_COUNT_i]
|
||||
= BENCH_LIT(sizes[3]);
|
||||
}
|
||||
optarg = s;
|
||||
@@ -1805,19 +1810,19 @@ invalid_define:
|
||||
= BENCH_LIT(sizes[0]);
|
||||
geometry->defines[PROG_SIZE_i]
|
||||
= BENCH_LIT(sizes[1]);
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= BENCH_LIT(sizes[2]);
|
||||
} else if (count >= 2) {
|
||||
geometry->defines[PROG_SIZE_i]
|
||||
= BENCH_LIT(sizes[0]);
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= BENCH_LIT(sizes[1]);
|
||||
} else {
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= BENCH_LIT(sizes[0]);
|
||||
}
|
||||
if (count >= 4) {
|
||||
geometry->defines[BLOCK_COUNT_i]
|
||||
geometry->defines[ERASE_COUNT_i]
|
||||
= BENCH_LIT(sizes[3]);
|
||||
}
|
||||
optarg = s;
|
||||
|
||||
+19
-13
@@ -89,18 +89,22 @@ intmax_t bench_define(size_t define);
|
||||
|
||||
#define READ_SIZE_i 0
|
||||
#define PROG_SIZE_i 1
|
||||
#define BLOCK_SIZE_i 2
|
||||
#define BLOCK_COUNT_i 3
|
||||
#define CACHE_SIZE_i 4
|
||||
#define LOOKAHEAD_SIZE_i 5
|
||||
#define BLOCK_CYCLES_i 6
|
||||
#define ERASE_VALUE_i 7
|
||||
#define ERASE_CYCLES_i 8
|
||||
#define BADBLOCK_BEHAVIOR_i 9
|
||||
#define POWERLOSS_BEHAVIOR_i 10
|
||||
#define ERASE_SIZE_i 2
|
||||
#define ERASE_COUNT_i 3
|
||||
#define BLOCK_SIZE_i 4
|
||||
#define BLOCK_COUNT_i 5
|
||||
#define CACHE_SIZE_i 6
|
||||
#define LOOKAHEAD_SIZE_i 7
|
||||
#define BLOCK_CYCLES_i 8
|
||||
#define ERASE_VALUE_i 9
|
||||
#define ERASE_CYCLES_i 10
|
||||
#define BADBLOCK_BEHAVIOR_i 11
|
||||
#define POWERLOSS_BEHAVIOR_i 12
|
||||
|
||||
#define READ_SIZE bench_define(READ_SIZE_i)
|
||||
#define PROG_SIZE bench_define(PROG_SIZE_i)
|
||||
#define ERASE_SIZE bench_define(ERASE_SIZE_i)
|
||||
#define ERASE_COUNT bench_define(ERASE_COUNT_i)
|
||||
#define BLOCK_SIZE bench_define(BLOCK_SIZE_i)
|
||||
#define BLOCK_COUNT bench_define(BLOCK_COUNT_i)
|
||||
#define CACHE_SIZE bench_define(CACHE_SIZE_i)
|
||||
@@ -113,9 +117,11 @@ intmax_t bench_define(size_t define);
|
||||
|
||||
#define BENCH_IMPLICIT_DEFINES \
|
||||
BENCH_DEF(READ_SIZE, PROG_SIZE) \
|
||||
BENCH_DEF(PROG_SIZE, BLOCK_SIZE) \
|
||||
BENCH_DEF(BLOCK_SIZE, 0) \
|
||||
BENCH_DEF(BLOCK_COUNT, (1024*1024)/BLOCK_SIZE) \
|
||||
BENCH_DEF(PROG_SIZE, ERASE_SIZE) \
|
||||
BENCH_DEF(ERASE_SIZE, 0) \
|
||||
BENCH_DEF(ERASE_COUNT, (1024*1024)/BLOCK_SIZE) \
|
||||
BENCH_DEF(BLOCK_SIZE, ERASE_SIZE) \
|
||||
BENCH_DEF(BLOCK_COUNT, ERASE_COUNT/lfs_max(BLOCK_SIZE/ERASE_SIZE,1))\
|
||||
BENCH_DEF(CACHE_SIZE, lfs_max(64,lfs_max(READ_SIZE,PROG_SIZE))) \
|
||||
BENCH_DEF(LOOKAHEAD_SIZE, 16) \
|
||||
BENCH_DEF(BLOCK_CYCLES, -1) \
|
||||
@@ -125,7 +131,7 @@ intmax_t bench_define(size_t define);
|
||||
BENCH_DEF(POWERLOSS_BEHAVIOR, LFS_EMUBD_POWERLOSS_NOOP)
|
||||
|
||||
#define BENCH_GEOMETRY_DEFINE_COUNT 4
|
||||
#define BENCH_IMPLICIT_DEFINE_COUNT 11
|
||||
#define BENCH_IMPLICIT_DEFINE_COUNT 13
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+41
-16
@@ -1312,9 +1312,9 @@ static void list_geometries(void) {
|
||||
builtin_geometries[g].name,
|
||||
READ_SIZE,
|
||||
PROG_SIZE,
|
||||
BLOCK_SIZE,
|
||||
BLOCK_COUNT,
|
||||
BLOCK_SIZE*BLOCK_COUNT);
|
||||
ERASE_SIZE,
|
||||
ERASE_COUNT,
|
||||
ERASE_SIZE*ERASE_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1341,6 +1341,7 @@ static void run_powerloss_none(
|
||||
.sync = lfs_emubd_sync,
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.block_size = BLOCK_SIZE,
|
||||
.block_count = BLOCK_COUNT,
|
||||
.block_cycles = BLOCK_CYCLES,
|
||||
@@ -1349,6 +1350,10 @@ static void run_powerloss_none(
|
||||
};
|
||||
|
||||
struct lfs_emubd_config bdcfg = {
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.erase_count = ERASE_COUNT,
|
||||
.erase_value = ERASE_VALUE,
|
||||
.erase_cycles = ERASE_CYCLES,
|
||||
.badblock_behavior = BADBLOCK_BEHAVIOR,
|
||||
@@ -1358,7 +1363,7 @@ static void run_powerloss_none(
|
||||
.erase_sleep = test_erase_sleep,
|
||||
};
|
||||
|
||||
int err = lfs_emubd_createcfg(&cfg, test_disk_path, &bdcfg);
|
||||
int err = lfs_emubd_create(&cfg, &bdcfg);
|
||||
if (err) {
|
||||
fprintf(stderr, "error: could not create block device: %d\n", err);
|
||||
exit(-1);
|
||||
@@ -1410,6 +1415,7 @@ static void run_powerloss_linear(
|
||||
.sync = lfs_emubd_sync,
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.block_size = BLOCK_SIZE,
|
||||
.block_count = BLOCK_COUNT,
|
||||
.block_cycles = BLOCK_CYCLES,
|
||||
@@ -1418,6 +1424,10 @@ static void run_powerloss_linear(
|
||||
};
|
||||
|
||||
struct lfs_emubd_config bdcfg = {
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.erase_count = ERASE_COUNT,
|
||||
.erase_value = ERASE_VALUE,
|
||||
.erase_cycles = ERASE_CYCLES,
|
||||
.badblock_behavior = BADBLOCK_BEHAVIOR,
|
||||
@@ -1431,7 +1441,7 @@ static void run_powerloss_linear(
|
||||
.powerloss_data = &powerloss_jmp,
|
||||
};
|
||||
|
||||
int err = lfs_emubd_createcfg(&cfg, test_disk_path, &bdcfg);
|
||||
int err = lfs_emubd_create(&cfg, &bdcfg);
|
||||
if (err) {
|
||||
fprintf(stderr, "error: could not create block device: %d\n", err);
|
||||
exit(-1);
|
||||
@@ -1496,6 +1506,7 @@ static void run_powerloss_log(
|
||||
.sync = lfs_emubd_sync,
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.block_size = BLOCK_SIZE,
|
||||
.block_count = BLOCK_COUNT,
|
||||
.block_cycles = BLOCK_CYCLES,
|
||||
@@ -1504,6 +1515,10 @@ static void run_powerloss_log(
|
||||
};
|
||||
|
||||
struct lfs_emubd_config bdcfg = {
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.erase_count = ERASE_COUNT,
|
||||
.erase_value = ERASE_VALUE,
|
||||
.erase_cycles = ERASE_CYCLES,
|
||||
.badblock_behavior = BADBLOCK_BEHAVIOR,
|
||||
@@ -1517,7 +1532,7 @@ static void run_powerloss_log(
|
||||
.powerloss_data = &powerloss_jmp,
|
||||
};
|
||||
|
||||
int err = lfs_emubd_createcfg(&cfg, test_disk_path, &bdcfg);
|
||||
int err = lfs_emubd_create(&cfg, &bdcfg);
|
||||
if (err) {
|
||||
fprintf(stderr, "error: could not create block device: %d\n", err);
|
||||
exit(-1);
|
||||
@@ -1580,6 +1595,7 @@ static void run_powerloss_cycles(
|
||||
.sync = lfs_emubd_sync,
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.block_size = BLOCK_SIZE,
|
||||
.block_count = BLOCK_COUNT,
|
||||
.block_cycles = BLOCK_CYCLES,
|
||||
@@ -1588,6 +1604,10 @@ static void run_powerloss_cycles(
|
||||
};
|
||||
|
||||
struct lfs_emubd_config bdcfg = {
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.erase_count = ERASE_COUNT,
|
||||
.erase_value = ERASE_VALUE,
|
||||
.erase_cycles = ERASE_CYCLES,
|
||||
.badblock_behavior = BADBLOCK_BEHAVIOR,
|
||||
@@ -1601,7 +1621,7 @@ static void run_powerloss_cycles(
|
||||
.powerloss_data = &powerloss_jmp,
|
||||
};
|
||||
|
||||
int err = lfs_emubd_createcfg(&cfg, test_disk_path, &bdcfg);
|
||||
int err = lfs_emubd_create(&cfg, &bdcfg);
|
||||
if (err) {
|
||||
fprintf(stderr, "error: could not create block device: %d\n", err);
|
||||
exit(-1);
|
||||
@@ -1762,6 +1782,7 @@ static void run_powerloss_exhaustive(
|
||||
.sync = lfs_emubd_sync,
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.block_size = BLOCK_SIZE,
|
||||
.block_count = BLOCK_COUNT,
|
||||
.block_cycles = BLOCK_CYCLES,
|
||||
@@ -1770,6 +1791,10 @@ static void run_powerloss_exhaustive(
|
||||
};
|
||||
|
||||
struct lfs_emubd_config bdcfg = {
|
||||
.read_size = READ_SIZE,
|
||||
.prog_size = PROG_SIZE,
|
||||
.erase_size = ERASE_SIZE,
|
||||
.erase_count = ERASE_COUNT,
|
||||
.erase_value = ERASE_VALUE,
|
||||
.erase_cycles = ERASE_CYCLES,
|
||||
.badblock_behavior = BADBLOCK_BEHAVIOR,
|
||||
@@ -1782,7 +1807,7 @@ static void run_powerloss_exhaustive(
|
||||
.powerloss_data = NULL,
|
||||
};
|
||||
|
||||
int err = lfs_emubd_createcfg(&cfg, test_disk_path, &bdcfg);
|
||||
int err = lfs_emubd_create(&cfg, &bdcfg);
|
||||
if (err) {
|
||||
fprintf(stderr, "error: could not create block device: %d\n", err);
|
||||
exit(-1);
|
||||
@@ -2299,19 +2324,19 @@ invalid_define:
|
||||
= TEST_LIT(sizes[0]);
|
||||
geometry->defines[PROG_SIZE_i]
|
||||
= TEST_LIT(sizes[1]);
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= TEST_LIT(sizes[2]);
|
||||
} else if (count >= 2) {
|
||||
geometry->defines[PROG_SIZE_i]
|
||||
= TEST_LIT(sizes[0]);
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= TEST_LIT(sizes[1]);
|
||||
} else {
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= TEST_LIT(sizes[0]);
|
||||
}
|
||||
if (count >= 4) {
|
||||
geometry->defines[BLOCK_COUNT_i]
|
||||
geometry->defines[ERASE_COUNT_i]
|
||||
= TEST_LIT(sizes[3]);
|
||||
}
|
||||
optarg = s;
|
||||
@@ -2343,19 +2368,19 @@ invalid_define:
|
||||
= TEST_LIT(sizes[0]);
|
||||
geometry->defines[PROG_SIZE_i]
|
||||
= TEST_LIT(sizes[1]);
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= TEST_LIT(sizes[2]);
|
||||
} else if (count >= 2) {
|
||||
geometry->defines[PROG_SIZE_i]
|
||||
= TEST_LIT(sizes[0]);
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= TEST_LIT(sizes[1]);
|
||||
} else {
|
||||
geometry->defines[BLOCK_SIZE_i]
|
||||
geometry->defines[ERASE_SIZE_i]
|
||||
= TEST_LIT(sizes[0]);
|
||||
}
|
||||
if (count >= 4) {
|
||||
geometry->defines[BLOCK_COUNT_i]
|
||||
geometry->defines[ERASE_COUNT_i]
|
||||
= TEST_LIT(sizes[3]);
|
||||
}
|
||||
optarg = s;
|
||||
|
||||
+19
-13
@@ -82,18 +82,22 @@ intmax_t test_define(size_t define);
|
||||
|
||||
#define READ_SIZE_i 0
|
||||
#define PROG_SIZE_i 1
|
||||
#define BLOCK_SIZE_i 2
|
||||
#define BLOCK_COUNT_i 3
|
||||
#define CACHE_SIZE_i 4
|
||||
#define LOOKAHEAD_SIZE_i 5
|
||||
#define BLOCK_CYCLES_i 6
|
||||
#define ERASE_VALUE_i 7
|
||||
#define ERASE_CYCLES_i 8
|
||||
#define BADBLOCK_BEHAVIOR_i 9
|
||||
#define POWERLOSS_BEHAVIOR_i 10
|
||||
#define ERASE_SIZE_i 2
|
||||
#define ERASE_COUNT_i 3
|
||||
#define BLOCK_SIZE_i 4
|
||||
#define BLOCK_COUNT_i 5
|
||||
#define CACHE_SIZE_i 6
|
||||
#define LOOKAHEAD_SIZE_i 7
|
||||
#define BLOCK_CYCLES_i 8
|
||||
#define ERASE_VALUE_i 9
|
||||
#define ERASE_CYCLES_i 10
|
||||
#define BADBLOCK_BEHAVIOR_i 11
|
||||
#define POWERLOSS_BEHAVIOR_i 12
|
||||
|
||||
#define READ_SIZE TEST_DEFINE(READ_SIZE_i)
|
||||
#define PROG_SIZE TEST_DEFINE(PROG_SIZE_i)
|
||||
#define ERASE_SIZE TEST_DEFINE(ERASE_SIZE_i)
|
||||
#define ERASE_COUNT TEST_DEFINE(ERASE_COUNT_i)
|
||||
#define BLOCK_SIZE TEST_DEFINE(BLOCK_SIZE_i)
|
||||
#define BLOCK_COUNT TEST_DEFINE(BLOCK_COUNT_i)
|
||||
#define CACHE_SIZE TEST_DEFINE(CACHE_SIZE_i)
|
||||
@@ -106,9 +110,11 @@ intmax_t test_define(size_t define);
|
||||
|
||||
#define TEST_IMPLICIT_DEFINES \
|
||||
TEST_DEF(READ_SIZE, PROG_SIZE) \
|
||||
TEST_DEF(PROG_SIZE, BLOCK_SIZE) \
|
||||
TEST_DEF(BLOCK_SIZE, 0) \
|
||||
TEST_DEF(BLOCK_COUNT, (1024*1024)/BLOCK_SIZE) \
|
||||
TEST_DEF(PROG_SIZE, ERASE_SIZE) \
|
||||
TEST_DEF(ERASE_SIZE, 0) \
|
||||
TEST_DEF(ERASE_COUNT, (1024*1024)/ERASE_SIZE) \
|
||||
TEST_DEF(BLOCK_SIZE, ERASE_SIZE) \
|
||||
TEST_DEF(BLOCK_COUNT, ERASE_COUNT/lfs_max(BLOCK_SIZE/ERASE_SIZE,1)) \
|
||||
TEST_DEF(CACHE_SIZE, lfs_max(64,lfs_max(READ_SIZE,PROG_SIZE))) \
|
||||
TEST_DEF(LOOKAHEAD_SIZE, 16) \
|
||||
TEST_DEF(BLOCK_CYCLES, -1) \
|
||||
@@ -117,8 +123,8 @@ intmax_t test_define(size_t define);
|
||||
TEST_DEF(BADBLOCK_BEHAVIOR, LFS_EMUBD_BADBLOCK_PROGERROR) \
|
||||
TEST_DEF(POWERLOSS_BEHAVIOR, LFS_EMUBD_POWERLOSS_NOOP)
|
||||
|
||||
#define TEST_IMPLICIT_DEFINE_COUNT 11
|
||||
#define TEST_GEOMETRY_DEFINE_COUNT 4
|
||||
#define TEST_IMPLICIT_DEFINE_COUNT 13
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user