sys/dev/disk/dm: Fix dm-delay deps behavior for compatibility with Linux
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 17 Oct 2015 18:17:38 +0000 (03:17 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 17 Oct 2015 19:18:50 +0000 (04:18 +0900)
commit66fee7cc1080d3f2889ac6f6ea3e0eeeb15f2fec
treeb579e4734d2584f596150b35aaedb19d3e3a1e00
parent037a33c5852ff57fb122c5fbceba87a6c1df81f2
sys/dev/disk/dm: Fix dm-delay deps behavior for compatibility with Linux

dmsetup(8)'s deps subcommand should not show two underlying
devices for both read and write if those are the same devices.
This is how Linux dm-delay behaves.

Also note that DragonFly and NetBSD's deps implementation is
inefficient in the sense that each target needs to implement
deps ioctl. dm core should be able to tell dependencies without
using target specific ioctl code. dm core in Linux kernel is
implemented this way and this is better plus less error prone.

===== using the existing code
  # kldload dm
  # dmsetup create delay1 --table '0 1000 delay /dev/da3 0 10'
  # dmsetup deps /dev/mapper/delay1
  1 dependencies  : (0, 504430623)
  # dmsetup create delay2 --table '0 1000 delay /dev/da3 0 10 /dev/da3 0 10'
  # dmsetup deps /dev/mapper/delay2
  2 dependencies  : (0, 504430623) (0, 504430623)
  # dmsetup create delay3 --table '0 1000 delay /dev/da3 0 10 /dev/da4 0 10'
  # dmsetup deps /dev/mapper/delay3
  2 dependencies  : (0, 504430623) (0, 504430631)

===== using this commit, deps for delay2 differs
  # kldload dm
  # dmsetup create delay1 --table '0 1000 delay /dev/da3 0 10'
  # dmsetup deps /dev/mapper/delay1
  1 dependencies  : (0, 504430623)
  # dmsetup create delay2 --table '0 1000 delay /dev/da3 0 10 /dev/da3 0 10'
  # dmsetup deps /dev/mapper/delay2
  1 dependencies  : (0, 504430623)
  # dmsetup create delay3 --table '0 1000 delay /dev/da3 0 10 /dev/da4 0 10'
  # dmsetup deps /dev/mapper/delay3
  2 dependencies  : (0, 504430623) (0, 504430631)
sys/dev/disk/dm/targets/delay/dm_target_delay.c