Skip to contentSkip to conversation

Cannot rmmod after call to add_mtd_blktrans_dev

DISCUSSION Jarkko Lavinen 2 participants 4 messages Sep 8, 2010 – Sep 28, 2010 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

I am working with mtdswap driver which uses add_mtd_blktrans_dev(). Once I call add_mtd_blktrans_dev() the driver module reference count is 1 and I cannot remove the module.

Before commit 048d871 (mtd: blktrans: Hotplug fixes) the module ref count was 0 after loading. Ref count was increased only when thedevice was opened and it was possible to remove the module if none was using it.

After the 048d871 it doesn't seem to be possible to remove drivers which use add_mtd_blktrans_dev(). Many drivers similar to ftl have ftl_remove_dev() which calls del_mtd_blktrans_dev() that would put the module but cannot be called unless the ref count is already 0.

Jarkko Lavinen

#1 lore raw
Quoted 10 lines · Jarkko Lavinen

I am working with mtdswap driver which uses add_mtd_blktrans_dev(). Once I call add_mtd_blktrans_dev() the driver module reference count is 1 and I cannot remove the module.

Before commit 048d871 (mtd: blktrans: Hotplug fixes) the module ref count was 0 after loading. Ref count was increased only when thedevice was opened and it was possible to remove the module if none was using it.

Quoted 7 lines

After the 048d871 it doesn't seem to be possible to remove drivers which use add_mtd_blktrans_dev(). Many drivers similar to ftl have ftl_remove_dev() which calls del_mtd_blktrans_dev() that would put the module but cannot be called unless the ref count is already 0.

Jarkko Lavinen

My fault, I take a good look at how to fix that differently. Best regards,
Maxim Levitsky

#2 lore raw
Quoted 17 lines · Maxim Levitsky
Quoted 16 lines · Jarkko Lavinen

I am working with mtdswap driver which uses add_mtd_blktrans_dev(). Once I call add_mtd_blktrans_dev() the driver module reference count is 1 and I cannot remove the module.

Before commit 048d871 (mtd: blktrans: Hotplug fixes) the module ref count was 0 after loading. Ref count was increased only when thedevice was opened and it was possible to remove the module if none was using it.

After the 048d871 it doesn't seem to be possible to remove drivers which use add_mtd_blktrans_dev(). Many drivers similar to ftl have ftl_remove_dev() which calls del_mtd_blktrans_dev() that would put the module but cannot be called unless the ref count is already 0.

Quoted 5 lines
Quoted 1 line

Jarkko Lavinen

My fault, I take a good look at how to fix that differently. Best regards,
Maxim Levitsky

Please test the patch I have just posted on linux-mtd.

Best regards,
Maxim Levitsky

#3 lore raw
Quoted 1 line · ext Maxim Levitsky

Please test the patch I have just posted on linux-mtd.

I tried the 1/3 patch sent on Sep 18 23:12 on top of 2.6.36-rc5. Had some email problem and to pick the patch from web archives. It didn't apply cleanly, but the merge conflict seemed minor.

The patch seems to work. I am able to remove module but now del_mtd_blktrans_dev(dev) relases my own device structure a bit too early and have to protect it with extra kref_get() and release it with blktrans_dev_put(dev).

Jarkko Lavinen