Device mapper does not find dev in list

Leon Gross leon.gross at rub.de
Fri Apr 29 05:58:32 EDT 2022


Hello everyone,

I am having trouble debugging a custom device mapper driver.
Creation and operating on it work just fine, but the removal using 
'dmsetup remove' causes and error (kernel version 5.17.4).
I tracked it down to 'dm-table.c:434'. The comparison fails and the 
warning in line 440 is thrown.

I attached GDB to the kernel and created breakpoints at 'dm_put_device' 
and 'dm_get_dev' aswell.
I create the mapped device and  'dm_get_dev' is hit once, and the values 
match the expected ones, observed in the user space.

After mounting and performing some operations on the device, I unmount 
it an call 'dmsetup remove'  in the user land on it.
The breakpoint 'dm_put_device' triggers, and the devices 'dd->dm_dev' 
and 'd' are compared to each other.
The loop is run exactly one time.
When I inspect the contents of 'dd->dm_dev' and 'd', I observes odd 
values for ''dd->dm_dev'.

inspection of 'd':
$6 = {
     bdev = 0xffff888100480600,
     dax_dev = 0x0 <fixed_percpu_data>,
     mode = 0x3,
     name = "8:16\000\001\306\001\201\210\377\377\217\001\306\001"
}

inspection of 'dd->dm_dev':
$7 = {
   bdev = 0xffff8881019a1418,
   dax_dev = 0xffff8881019dcea8,
   mode = 0x19dcea8,
   name = "\201\210\377\377\000\006H\000\201\210\377\377\001\000\000"
}

The values in the first object are equivalent to the device appearing in 
the user space (dmsetup ls --tree).
The values of 'dd->dm_dev' are odd and I cannot find out where this 
should originate from.
How can there be two different values in the list? And why is my device 
not inside of it?

Thanks in advance,
Leon Gross





More information about the Kernelnewbies mailing list