Stale cached data in bdbuf creates problems

ali nasir supremenasir at yahoo.com
Mon Apr 30 11:39:30 UTC 2012


Hi,

I face a problem in the bdbuf which results in the in the Master Boot Record not been getting read from the physical device. What happens is as follows:
RTEMS version 4.10.1
1. An SD card is already present in the system and mounted.
2. The SD card is unmounted by the following calls in sequence:
unmount("/mnt/sdcard")
rmdir("/mnt/sdcard")
rtems_bdbuf_syncdev(dev)    //dev is created using the rtems_filesystem_make_dev_t(major, minor)
rtems_disk_delete(dev)
rtems_bdbuf_purge_dev(dev)
rtems_io_unregister_driver(major)
3. When another device is inserted and rtems_bdpart_register_from_disk() is called, the OS tries to read the Master Boot Record(MBR) of the device via the call rtems_bdpart_read_record( disk, 0, &block); from function rtems_bdpart_read(). This eventually calls the rtems_bdbuf_read() and the rtems_bdbuf_create_read_request(). In rtems_bdbuf_create_read_request(), it finds the BDBUF state (bd->state) as RTEMS_BDBUF_STATE_CACHED and returns. But this cached data is of the card which was just unmounted in step 2. Hence the MBR of the current SD card is not read at all. I see that the low level Sd card read block is never called during the above process. 

Does anyone know what could be reason or i miss something more in the unmount?

Regards,
Ali



More information about the users mailing list