Hello,
free_dev() releases minor number before unregistering gendisk.
It creates a window where two registered gendisk with same number
exist, which will cause problem.
Typically, if you run the following script,
you will hit WARN_ON() in kref_get().
#!/bin/sh
(while dmsetup create a --notable; do dmsetup remove a; done) &
(while dmsetup create b --notable; do dmsetup remove b; done) &
Attached patch fixes this problem.
--
Jun'ichi Nomura, NEC Solutions (America), Inc.