sys/dev/disk/dm: Add a comment on race on unload
There is a minor race window in dm_modcmd() after the below
conditional on unloading dm.ko. It's possible to create a new
device after it gets beyond the conditional with 0.
if (dm_dev_counter > 0)
return EBUSY;
Running the below a.sh and then b.sh concurrently causes
kernel panic. Avoiding this race seems to be difficult using
the existing locks that are all file local ones. The panic
can be reproduced with or without the previous commit.
===== a.sh
#!/usr/local/bin/bash
while [ 1 ]; do
kldload dm
kldunload dm
done
===== b.sh
#!/usr/local/bin/bash
kldload dm
while [ 1 ]; do
dmsetup create zero1 --table '0 100 zero'
dmsetup remove /dev/mapper/zero1
done