Skip to content

Commit

Permalink
n_reads/writes for backend
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Nov 7, 2024
1 parent cc667e8 commit 59aa2d7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend-file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ bool backend_file::write(const uint64_t block_nr, const uint32_t n_blocks, const
ts_last_acces = end;
bs.io_wait += end-start;
bs.bytes_written += n_bytes;
bs.n_writes++;
return rc == ssize_t(n_bytes);
}

Expand Down Expand Up @@ -157,6 +158,7 @@ bool backend_file::read(const uint64_t block_nr, const uint32_t n_blocks, uint8_
ts_last_acces = end;
bs.io_wait += end-start;
bs.bytes_read += n_bytes;
bs.n_reads++;
return rc == ssize_t(n_bytes);
}

Expand Down Expand Up @@ -229,6 +231,8 @@ backend::cmpwrite_result_t backend_file::cmpwrite(const uint64_t block_nr, const

auto end = get_micros();
bs.io_wait += end-start;
bs.n_reads++;
bs.n_writes++;

delete [] buffer;

Expand Down
5 changes: 5 additions & 0 deletions backend-nbd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ bool backend_nbd::write(const uint64_t block_nr, const uint32_t n_blocks, const

ts_last_acces = get_micros();
bs.bytes_written += n_bytes;
bs.n_writes++;

return rc;
}
Expand Down Expand Up @@ -304,6 +305,7 @@ bool backend_nbd::read(const uint64_t block_nr, const uint32_t n_blocks, uint8_t

ts_last_acces = get_micros();
bs.bytes_read += n_bytes;
bs.n_reads++;

return rc;
}
Expand Down Expand Up @@ -356,6 +358,9 @@ backend::cmpwrite_result_t backend_nbd::cmpwrite(const uint64_t block_nr, const

unlock_range(lock_list);

bs.n_reads++;
bs.n_writes++;

return result;
}

Expand Down
4 changes: 4 additions & 0 deletions microcontrollers/RP2040W/backend-sdcard-rp2040w.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ bool backend_sdcard_rp2040w::write(const uint64_t block_nr, const uint32_t n_blo
write_led(led_write, LOW);

bs.io_wait += end-start;
bs.n_writes++;
ts_last_acces = end;

return rc;
Expand Down Expand Up @@ -208,6 +209,7 @@ bool backend_sdcard_rp2040w::read(const uint64_t block_nr, const uint32_t n_bloc
DOLOG(logging::ll_error, "backend_sdcard_rp2040w::read", "-", "Cannot read: %d", file.error());
write_led(led_read, LOW);
bs.io_wait += end-start;
bs.n_reads++;
ts_last_acces = end;
return rc;
}
Expand Down Expand Up @@ -267,6 +269,8 @@ backend::cmpwrite_result_t backend_sdcard_rp2040w::cmpwrite(const uint64_t block
}
uint64_t end = get_micros();
bs.io_wait += end-start;
bs.n_reads++;
bs.n_writes++;

delete [] buffer;

Expand Down
4 changes: 4 additions & 0 deletions microcontrollers/backend-sdcard-teensy41.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ bool backend_sdcard_teensy41::write(const uint64_t block_nr, const uint32_t n_bl

auto end = get_micros();
bs.io_wait += end-start;
bs.n_writes++;
ts_last_acces = end;

return rc;
Expand Down Expand Up @@ -183,6 +184,7 @@ bool backend_sdcard_teensy41::read(const uint64_t block_nr, const uint32_t n_blo
DOLOG(logging::ll_error, "backend_sdcard_teensy41::read", "-", "Cannot read: %d", file.getError());
write_led(led_read, LOW);
bs.io_wait += end-start;
bs.n_reads++;
ts_last_acces = end;
return rc;
}
Expand Down Expand Up @@ -248,6 +250,8 @@ backend::cmpwrite_result_t backend_sdcard_teensy41::cmpwrite(const uint64_t bloc
}
auto end = get_micros();
bs.io_wait += end-start;
bs.n_reads++;
bs.n_writes++;

delete [] buffer;

Expand Down
4 changes: 4 additions & 0 deletions microcontrollers/backend-sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ bool backend_sdcard::write(const uint64_t block_nr, const uint32_t n_blocks, con
write_led(led_write, LOW);

bs.io_wait += end-start;
bs.n_writes++;
ts_last_acces = end;

return rc;
Expand Down Expand Up @@ -266,6 +267,7 @@ bool backend_sdcard::read(const uint64_t block_nr, const uint32_t n_blocks, uint
#endif
write_led(led_read, LOW);
bs.io_wait += end-start;
bs.n_reads++;
ts_last_acces = end;
return rc;
}
Expand Down Expand Up @@ -331,6 +333,8 @@ backend::cmpwrite_result_t backend_sdcard::cmpwrite(const uint64_t block_nr, con

auto end = get_micros();
bs.io_wait += end-start;
bs.n_reads++;
bs.n_writes++;

delete [] buffer;

Expand Down

0 comments on commit 59aa2d7

Please sign in to comment.