FTL诊断:resume搜索逐探测探针日志(page_read/ECC/magic/epoch/BBT全输入)
This commit is contained in:
@@ -52,6 +52,9 @@ static uint8_t s_copy_buf[FTL_PAGE_SIZE];
|
|||||||
/* 初始化状态 */
|
/* 初始化状态 */
|
||||||
static uint8_t s_initialized;
|
static uint8_t s_initialized;
|
||||||
|
|
||||||
|
/* resume 搜索探针日志窗口(诊断:逐探测记录判定输入) */
|
||||||
|
static uint8_t s_probe_log;
|
||||||
|
|
||||||
/* ======================== 私有函数声明 ======================== */
|
/* ======================== 私有函数声明 ======================== */
|
||||||
|
|
||||||
static int ftl_flush_cache(void);
|
static int ftl_flush_cache(void);
|
||||||
@@ -94,7 +97,12 @@ static int ftl_read_page(dhara_sector_t lpn) {
|
|||||||
|
|
||||||
int dhara_nand_is_bad(const struct dhara_nand *n, dhara_block_t b) {
|
int dhara_nand_is_bad(const struct dhara_nand *n, dhara_block_t b) {
|
||||||
(void)n;
|
(void)n;
|
||||||
return gd5f2gq5ue_is_block_bad(ftl_phy_block(b));
|
const int bad = gd5f2gq5ue_is_block_bad(ftl_phy_block(b));
|
||||||
|
if (s_probe_log) {
|
||||||
|
DBG_INFO("probe blk %lu: bbt_bad=%u", (unsigned long)b,
|
||||||
|
(unsigned int)bad);
|
||||||
|
}
|
||||||
|
return bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dhara_nand_mark_bad(const struct dhara_nand *n, dhara_block_t b) {
|
void dhara_nand_mark_bad(const struct dhara_nand *n, dhara_block_t b) {
|
||||||
@@ -187,18 +195,42 @@ int dhara_nand_is_free(const struct dhara_nand *n, dhara_page_t p) {
|
|||||||
int dhara_nand_read(const struct dhara_nand *n, dhara_page_t p, size_t offset, size_t length, uint8_t *data, dhara_error_t *err) {
|
int dhara_nand_read(const struct dhara_nand *n, dhara_page_t p, size_t offset, size_t length, uint8_t *data, dhara_error_t *err) {
|
||||||
(void)n;
|
(void)n;
|
||||||
uint32_t phy_pg = ftl_phy_page(p);
|
uint32_t phy_pg = ftl_phy_page(p);
|
||||||
|
int rret;
|
||||||
|
int eret;
|
||||||
|
|
||||||
if (gd5f_page_read(phy_pg) != GD5F_OK) {
|
if ((rret = gd5f_page_read(phy_pg)) != GD5F_OK) {
|
||||||
|
if (s_probe_log) {
|
||||||
|
DBG_INFO("probe pg %lu blk %lu: page_read=%d",
|
||||||
|
(unsigned long)phy_pg, (unsigned long)(p >> 6),
|
||||||
|
rret);
|
||||||
|
}
|
||||||
dhara_set_error(err, DHARA_E_ECC);
|
dhara_set_error(err, DHARA_E_ECC);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gd5f_check_ecc() != GD5F_OK) {
|
if ((eret = gd5f_check_ecc()) != GD5F_OK) {
|
||||||
|
if (s_probe_log) {
|
||||||
|
DBG_INFO("probe pg %lu blk %lu: ecc=%d",
|
||||||
|
(unsigned long)phy_pg, (unsigned long)(p >> 6),
|
||||||
|
eret);
|
||||||
|
}
|
||||||
dhara_set_error(err, DHARA_E_ECC);
|
dhara_set_error(err, DHARA_E_ECC);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gd5f_read_from_cache((uint16_t)offset, data, length);
|
gd5f_read_from_cache((uint16_t)offset, data, length);
|
||||||
|
|
||||||
|
if (s_probe_log && offset == 0 && length == FTL_PAGE_SIZE) {
|
||||||
|
/* 组末页(组内偏移 15)= checkpoint 页:记录 magic/epoch 判定 */
|
||||||
|
if ((p & 63u) == 15u) {
|
||||||
|
const uint8_t *m = data;
|
||||||
|
DBG_INFO("probe pg %lu blk %lu chk: magic=%u epoch=%u",
|
||||||
|
(unsigned long)phy_pg, (unsigned long)(p >> 6),
|
||||||
|
(unsigned int)((m[0] == 'D' && m[1] == 'h' &&
|
||||||
|
m[2] == 'a') ? 1 : 0),
|
||||||
|
(unsigned int)m[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,6 +280,7 @@ DSTATUS disk_initialize(BYTE pdrv) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
dhara_error_t err;
|
dhara_error_t err;
|
||||||
|
s_probe_log = 1;
|
||||||
if (dhara_map_resume(&s_map, &err) < 0) {
|
if (dhara_map_resume(&s_map, &err) < 0) {
|
||||||
DBG_INFO("No valid map found, creating fresh (err=%d)", err);
|
DBG_INFO("No valid map found, creating fresh (err=%d)", err);
|
||||||
dhara_map_clear(&s_map);
|
dhara_map_clear(&s_map);
|
||||||
@@ -255,6 +288,7 @@ DSTATUS disk_initialize(BYTE pdrv) {
|
|||||||
DBG_INFO("Map resumed: %lu/%lu sectors used",
|
DBG_INFO("Map resumed: %lu/%lu sectors used",
|
||||||
dhara_map_size(&s_map), dhara_map_capacity(&s_map));
|
dhara_map_size(&s_map), dhara_map_capacity(&s_map));
|
||||||
}
|
}
|
||||||
|
s_probe_log = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_initialized = 1;
|
s_initialized = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user