mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 02:36:11 +08:00
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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user