Added tracebd.py, a script for rendering block device operations

Based on a handful of local hacky variations, this sort of trace
rendering is surprisingly useful for getting an understanding of how
different filesystem operations interact with the underlying
block-device.

At some point it would probably be good to reimplement this in a
compiled language. Parsing and tracking the trace output quickly
becomes a bottleneck with the amount of trace output the tests
generate.

Note also that since tracebd.py run on trace output, it can also be
used to debug logged block-device operations post-run.
This commit is contained in:
Christopher Haster
2022-09-02 03:08:28 -05:00
parent c9a6e3a95b
commit 91200e6678
7 changed files with 878 additions and 80 deletions
+9 -9
View File
@@ -245,10 +245,10 @@ int lfs_testbd_read(const struct lfs_config *cfg, lfs_block_t block,
size);
}
if (bd->cfg->read_delay) {
if (bd->cfg->read_sleep) {
int err = nanosleep(&(struct timespec){
.tv_sec=bd->cfg->read_delay/1000000000,
.tv_nsec=bd->cfg->read_delay%1000000000},
.tv_sec=bd->cfg->read_sleep/1000000000,
.tv_nsec=bd->cfg->read_sleep%1000000000},
NULL);
if (err) {
err = -errno;
@@ -325,10 +325,10 @@ int lfs_testbd_prog(const struct lfs_config *cfg, lfs_block_t block,
}
}
if (bd->cfg->prog_delay) {
if (bd->cfg->prog_sleep) {
int err = nanosleep(&(struct timespec){
.tv_sec=bd->cfg->prog_delay/1000000000,
.tv_nsec=bd->cfg->prog_delay%1000000000},
.tv_sec=bd->cfg->prog_sleep/1000000000,
.tv_nsec=bd->cfg->prog_sleep%1000000000},
NULL);
if (err) {
err = -errno;
@@ -408,10 +408,10 @@ int lfs_testbd_erase(const struct lfs_config *cfg, lfs_block_t block) {
}
}
if (bd->cfg->erase_delay) {
if (bd->cfg->erase_sleep) {
int err = nanosleep(&(struct timespec){
.tv_sec=bd->cfg->erase_delay/1000000000,
.tv_nsec=bd->cfg->erase_delay%1000000000},
.tv_sec=bd->cfg->erase_sleep/1000000000,
.tv_nsec=bd->cfg->erase_sleep%1000000000},
NULL);
if (err) {
err = -errno;
+5 -5
View File
@@ -58,8 +58,8 @@ typedef uint32_t lfs_testbd_powercycles_t;
typedef int32_t lfs_testbd_spowercycles_t;
// Type for delays in nanoseconds
typedef uint64_t lfs_testbd_delay_t;
typedef int64_t lfs_testbd_sdelay_t;
typedef uint64_t lfs_testbd_sleep_t;
typedef int64_t lfs_testbd_ssleep_t;
// testbd config, this is required for testing
struct lfs_testbd_config {
@@ -100,15 +100,15 @@ struct lfs_testbd_config {
// Artificial delay in nanoseconds, there is no purpose for this other
// than slowing down the simulation.
lfs_testbd_delay_t read_delay;
lfs_testbd_sleep_t read_sleep;
// Artificial delay in nanoseconds, there is no purpose for this other
// than slowing down the simulation.
lfs_testbd_delay_t prog_delay;
lfs_testbd_sleep_t prog_sleep;
// Artificial delay in nanoseconds, there is no purpose for this other
// than slowing down the simulation.
lfs_testbd_delay_t erase_delay;
lfs_testbd_sleep_t erase_sleep;
};
// A reference counted block