Stale cached data in bdbuf creates problems

Sebastian Huber sebastian.huber at embedded-brains.de
Wed May 2 07:56:05 UTC 2012


On 05/02/2012 08:48 AM, ali nasir wrote:
>
> Hello,
>
> I have the following set up.
> /dev/sdc01 is mounted succesfully on /mnt/sdcard. This is the first and only partition on the device. For the time being, i use a disk with only one partition. While mounting the same, /dev/sdc0 is passed as arguments to the create_phys and to the bdpart_register_from_disk. The fstab_entry table has the first entry as /dev/sdc01 and the second one as /dev/sdc0. The first entry is always mounted succesfully.
>
> Now, during the unmount, i now do the following:
>
>      rv = unmount("/mnt/sdcard");
>      rv = rmdir ("/mnt/sdcard");
>      dev_t dev = 0;
>
>      rv = rtems_media_get_device_identifier("/dev/sdc01",&dev); //SYNC the first partition
>      rv = rtems_bdbuf_syncdev(dev);
>      rtems_bdbuf_purge_dev(dev);
>      rv = rtems_disk_delete(dev);
>
>      rv = rtems_media_get_device_identifier("/dev/sdc0",&dev);   //SYNC the physical device
>      rv = rtems_bdbuf_syncdev(dev);
>      rtems_bdbuf_purge_dev(dev);
>      rv = rtems_disk_delete(dev);
>      rv = rtems_io_unregister_driver(sd_card_disk_major);

This sequence looks ok, but you should place the

rtems_io_unregister_driver(sd_card_disk_major)

into the RTEMS_BLKIO_DELETED IO control handler.  The disk management will call 
this driver IO control once the disk is actually deleted.

>
> All the above calls return RTEMS_SUCCESFULL. I verified it with printfs (not shown in the above code).
> But still, when i insert a different size card, after the unmount of the first one, the MBR is not read from the physical device. The bdbuf determines that the data is cached and starts using this cached data, which is actually the data of the previous card.

Please set a break point to rtems_bdbuf_read() line 1911

bd = rtems_bdbuf_get_buffer_for_access (dev, media_block, bds_per_group);

after the steps above.  Is this bd really in the RTEMS_BDBUF_STATE_CACHED or 
RTEMS_BDBUF_STATE_MODIFIED state if you read the MBR?

-- 
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the users mailing list