bdbuf: Disk I/O buffering

Kirspel, Kevin {Engineering - Osmetech CCD} kevin.kirspel at
Fri Jul 1 20:28:37 UTC 2005

I have built an rtems 4.6.0 release and it has worked beautifully for 2
years.  I added compact flash support to my build by using the IDE
interface in rtems.  Every thing works great as long as I keep the
compact flash card in the system. I wanted to add support to rtems so
that I may remove and insert the compact flash card whenever I want. I
now probe() the compact flash device to make sure it is in place before
I perform any ata_ioctl() commands. If the device is not in place, I
return -1 with errno = ENODEV. This causes the bdbuf_swapout_task()
function to enter an indefinite loop because it keeps on trying to call
the ata_ioctl() routine with no success.

The following code is taken from the bdbuf_swapout_task() function in

/* transfer_sema initialized when bd_buf inserted in the mod chain
   first time */
result = dd->ioctl(dd->phys_dev->dev, BLKIO_REQUEST, &req);


if (result == -1)
  bd_buf->status = RTEMS_IO_ERROR;
  bd_buf->error = errno;
  /* Release tasks waiting on syncing this buffer */
  _CORE_mutex_Flush(&bd_buf->transfer_sema, NULL,
  if (bd_buf->in_progress)
    _CORE_mutex_Seize(&bd_buf->transfer_sema, 0, TRUE, 0, level);

I am not a disk buffering guru, but what can I do to the
bdbuf_swapout_task() ( or other functions ) to make it process the error
so that at the higher levels and error code is returned.

My current scenario is this:

1. I boot the system with the compact flash card in place.
2. After task initialization, my main task initializes the ide
partitions, mounts the drive, opens a file, writes data to the file,
closes the file, and unmounts the drive. This works great.
3. I then remove the compact flash and repeat the process.
4. During the mount process, the system hangs in bdbuf_swapout_task() do
to the fact that the dd->ioctl() returns -1;

Kevin Kirspel
235 Hembree Park Drive
Roswell GA, 30076
770-510-4444 x568

More information about the users mailing list