I have block driver for a hot-pluggable PCI storage device. if the device is removed during IO, I never seem to get a call to release (i.e. mydev_blk_release(struct gendisk *gd, fmode_t mode)), which I think is preventing del_gendisk() from completing, thus hanging the cleanup of the driver. I am ending all requests on the queue once an eject happens, but it still doesn’t seem to cause a release. What is the right way to terminate requests and delete the gendisk in the case of vanished media?
I have block driver for a hot-pluggable PCI storage device. if the device is
Share
This is caused by not ending the request that is broken by the device removal. In my driver, I had the folowing
request_fn:This will prevent the requests entering the driver’s workqueue when the device disappears (signified by the loss of
mydev). However this hung because the last request was not actually completed, causingq->rq->elvpriv(now calledq->nr_rqs_elvpriv) to remain at 1, which causedblk_drain_queue()to spin forever, which hungblk_cleanup_queue()and prevented the driver being able to remove the device.The solution looks like this (in the workqueue callback function in my driver, but this depends on how you structure the IO work):