Messages in this thread | | | Date | Fri, 02 Oct 2009 15:44:47 +0200 | From | tomerma1@post ... | Subject | How to tell when a gendisk has been freed? |
| |
Hi,
Im writing a block device that does asynchronous mirroring. The user creates a device by giving a local device and connecting to a remote device (on the net), mirroring writes to both.
When the user is done with the device i would like to give him the option of deleting the device. To do that, i first stop taking requests (i disallow opens by looking at a variable i allocated for that device (a custom struct)), next wait until there are no more active make_requests, and finally i free everything... However, theres a problem with open - when i free the device, the open dereferences a variable i allocated for that device, but i have already freed the device.
The only safe way to free the device is when i know for sure no more opens or make_requests can be called... To do that i have to know when the gendisk is gone (even if i del_gendisk it, and wait until the opener counter drops to zero, i cant be sure that another open isnt being executed at the moment)... However, i didnt see any way to do it, so i was wondering what is the right way to do it?
Thanks, Tomer
| |