Skip to content

Commit

Permalink
fs/mnemofs: Fix journal log rw issue, read size issue
Browse files Browse the repository at this point in the history
Fixes the journal log read and write size and overlap issues, along with read return value issue.

Signed-off-by: Saurav Pal <[email protected]>
  • Loading branch information
resyfer authored and acassis committed Aug 17, 2024
1 parent 9d396bf commit daa3168
Show file tree
Hide file tree
Showing 11 changed files with 1,178 additions and 369 deletions.
18 changes: 9 additions & 9 deletions drivers/mtd/mtd_nandram.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ int nand_ram_eraseblock(FAR struct nand_raw_s *raw, off_t block)
for (i = start_page; i < end_page; i++)
{
nand_ram_flash_spare[i].n_erase++;
nand_ram_flash_spare[i].free = 1;
nand_ram_flash_spare[i].free = NAND_RAM_PAGE_FREE;
}

NAND_RAM_LOG("[LOWER %lu | %s] Done\n", nand_ram_ins_i, "eraseblock");
Expand Down Expand Up @@ -331,12 +331,11 @@ int nand_ram_rawread(FAR struct nand_raw_s *raw, off_t block,
struct nand_ram_data_s *read_page_data;
struct nand_ram_spare_s *read_page_spare;

ret = OK;
read_page = (block << NAND_RAM_LOG_PAGES_PER_BLOCK) + page;
read_page_data = nand_ram_flash_data + read_page;
read_page_spare = nand_ram_flash_spare + read_page;

ret = OK;

nxmutex_lock(&nand_ram_dev_mut);
nand_ram_ins_i++;

Expand All @@ -362,7 +361,8 @@ int nand_ram_rawread(FAR struct nand_raw_s *raw, off_t block,
}
else
{
memcpy(data, (const void *)read_page_data, NAND_RAM_PAGE_SIZE);
memcpy(data, (const void *)read_page_data->page,
NAND_RAM_PAGE_SIZE);
}
}

Expand Down Expand Up @@ -407,12 +407,11 @@ int nand_ram_rawwrite(FAR struct nand_raw_s *raw, off_t block,
struct nand_ram_data_s *write_page_data;
struct nand_ram_spare_s *write_page_spare;

ret = OK;
write_page = (block << NAND_RAM_LOG_PAGES_PER_BLOCK) + page;
write_page_data = nand_ram_flash_data + write_page;
write_page_spare = nand_ram_flash_spare + write_page;

ret = OK;

nxmutex_lock(&nand_ram_dev_mut);
nand_ram_ins_i++;

Expand All @@ -429,16 +428,17 @@ int nand_ram_rawwrite(FAR struct nand_raw_s *raw, off_t block,
}

nand_ram_flash_spare[write_page].n_write++;
nand_ram_flash_spare[write_page].free = NAND_RAM_PAGE_WRITTEN;

memset((void *)write_page_data, 0, NAND_RAM_PAGE_SIZE);
memset((void *)write_page_data->page, 0, NAND_RAM_PAGE_SIZE);
if (data != NULL)
{
memcpy((void *)write_page_data, data, NAND_RAM_PAGE_SIZE);
memcpy((void *)write_page_data->page, data, NAND_RAM_PAGE_SIZE);
}

if (spare != NULL)
{
memcpy((void *)write_page_spare, data, NAND_RAM_PAGE_SIZE);
memcpy((void *)write_page_spare, data, NAND_RAM_SPARE_SIZE);
}

NAND_RAM_LOG("[LOWER %lu | %s] Done\n", nand_ram_ins_i, "rawwrite");
Expand Down
Loading

0 comments on commit daa3168

Please sign in to comment.