bch: add BIOC_DISCARD ioctl that discards cached sector

This forces the bch layer to read the sector from the physical device
instead of using the cached values. It is necessary to call when the
device is updated from the different source than bch, for example
erased by the MTD ioctl command.

It also has to invalidate readahead buffer from FTL if option
CONFIG_DRVR_READAHEAD is set.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc
2025-01-22 11:35:52 +01:00
committed by Xiang Xiao
parent 4050c79505
commit d9270f9ea8
5 changed files with 52 additions and 1 deletions
+26
View File
@@ -1279,4 +1279,30 @@ int rwb_flush(FAR struct rwbuffer_s *rwb)
}
#endif
/****************************************************************************
* Name: rwb_flush
*
* Description:
* Flush the write buffer
*
****************************************************************************/
#ifdef CONFIG_DRVR_READAHEAD
int rwb_discard(FAR struct rwbuffer_s *rwb)
{
int ret;
ret = rwb_lock(&rwb->rhlock);
if (ret < 0)
{
return ret;
}
rwb_resetrhbuffer(rwb);
rwb_unlock(&rwb->rhlock);
return ret;
}
#endif
#endif /* CONFIG_DRVR_WRITEBUFFER || CONFIG_DRVR_READAHEAD */