Skip to content

Commit

Permalink
Did not zero the trim/unmap/discard-buffer used for emulating t/u/d.
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Oct 25, 2024
1 parent f9e89ab commit 789ac5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions microcontrollers/backend-sdcard-teensy41.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ bool backend_sdcard_teensy41::write(const uint64_t block_nr, const uint32_t n_bl
bool backend_sdcard_teensy41::trim(const uint64_t block_nr, const uint32_t n_blocks)
{
bool rc = true;
uint8_t *data = new uint8_t[get_block_size()];
uint8_t *data = new uint8_t[get_block_size()]();
for(uint32_t i=0; i<n_blocks; i++) {
if (write(block_nr + i, 1, data) == false) {
DOLOG(logging::ll_error, "backend_sdcard_teensy41::trim", "-", "Cannot trim");
Expand Down Expand Up @@ -179,7 +179,8 @@ bool backend_sdcard_teensy41::read(const uint64_t block_nr, const uint32_t n_blo

backend::cmpwrite_result_t backend_sdcard_teensy41::cmpwrite(const uint64_t block_nr, const uint32_t n_blocks, const uint8_t *const data_write, const uint8_t *const data_compare)
{
write_led(led_read, HIGH);
write_led(led_read, HIGH);
write_led(led_write, HIGH);

auto lock_list = lock_range(block_nr, n_blocks);
auto block_size = get_block_size();
Expand Down Expand Up @@ -239,7 +240,8 @@ backend::cmpwrite_result_t backend_sdcard_teensy41::cmpwrite(const uint64_t bloc

unlock_range(lock_list);

write_led(led_read, LOW);
write_led(led_read, LOW);
write_led(led_write, LOW);

return result;
}
Expand Down
10 changes: 6 additions & 4 deletions microcontrollers/backend-sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ uint64_t backend_sdcard::get_block_size() const

bool backend_sdcard::write(const uint64_t block_nr, const uint32_t n_blocks, const uint8_t *const data)
{
// Serial.printf("Write to block %" PRIu64 ", %u blocks\r\n", size_t(block_nr), n_blocks);
// DOLOG(logging::ll_debug, "backend_sdcard::write", "-", "Write to block %" PRIu64 ", %u blocks\r\n", block_nr, n_blocks);
write_led(led_write, HIGH);

uint64_t iscsi_block_size = get_block_size();
Expand Down Expand Up @@ -195,7 +195,7 @@ bool backend_sdcard::write(const uint64_t block_nr, const uint32_t n_blocks, con
bool backend_sdcard::trim(const uint64_t block_nr, const uint32_t n_blocks)
{
bool rc = true;
uint8_t *data = new uint8_t[get_block_size()];
uint8_t *data = new uint8_t[get_block_size()]();
for(uint32_t i=0; i<n_blocks; i++) {
if (write(block_nr + i, 1, data) == false) {
DOLOG(logging::ll_error, "backend_sdcard::trim", "-", "Cannot trim");
Expand Down Expand Up @@ -251,7 +251,8 @@ bool backend_sdcard::read(const uint64_t block_nr, const uint32_t n_blocks, uint

backend::cmpwrite_result_t backend_sdcard::cmpwrite(const uint64_t block_nr, const uint32_t n_blocks, const uint8_t *const data_write, const uint8_t *const data_compare)
{
write_led(led_read, HIGH);
write_led(led_read, HIGH);
write_led(led_write, HIGH);

#if defined(RP2040W)
mutex_enter_blocking(&serial_access_lock);
Expand Down Expand Up @@ -314,7 +315,8 @@ backend::cmpwrite_result_t backend_sdcard::cmpwrite(const uint64_t block_nr, con
unlock_range(lock_list);
#endif

write_led(led_read, LOW);
write_led(led_read, LOW);
write_led(led_write, LOW);

return result;
}
Expand Down

0 comments on commit 789ac5a

Please sign in to comment.