The patch from comment 5 (which is basically equivalent to my patch) fixes the ioctl error but not the fact that partitions aren't deleted on non-dm devices such as loop devices. Getting this right is a bit more involved, and there are corner cases to look at. I have a patch series almost ready, please wait a bit.