sys/dev/disk/dm: Don't let targets implement deps [2/2]
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 24 Oct 2015 10:38:56 +0000 (19:38 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 25 Oct 2015 10:25:46 +0000 (19:25 +0900)
commitd471f1f91f48d72fc2e9bbb8d461753054d745d6
treecfee97e69dcc0d05d924429047836ddfe5e587a4
parent49784e7dc51eeb3484ff250260a9a924e15ca965
sys/dev/disk/dm: Don't let targets implement deps [2/2]

This commit gets rid of target's deps handler by introducing
a new structure struct dm_mapping which embeds struct dm_pdev*
and a tailq structure for the next entry whose tailq head is
embedded within struct dm_table_entry.

=====(A) before this commit
table
    |                                     [dm core]
-------------------------------------------------------
    |           pdev      pdev      pdev  [dm targets]
    v          ^         ^         ^
    target----/---------/---------/
    (void*)

=====(B) this commit
table---->mapping-->mapping-->mapping-->...
    |           |         |         |
    |           v         v         v     [dm core]
-------------------------------------------------------
    |           pdev      pdev      pdev  [dm targets]
    v          ^         ^         ^
    target----/---------/---------/
    (void*)

Each target's init() now calls dm_table_add_deps(table, pdev)
to add a new dm_mapping (that points to pdev) to table. This
allows dm table structure to refer to underlying devices that
the target is dependent on (by following this tailq) without
using target specific deps handler.

dmsetup(8)'s deps subcommand is now handled by a newly added
dm core function dm_table_deps() that is common among targets.
This greatly reduces complexity and size of targets plus make
code less error prone. Targets only need to call dm_table_add
_deps() as mentioned above whenever they allocate underlying
device(s) via dm_pdev_insert().
sys/dev/disk/dm/dm.h
sys/dev/disk/dm/dm_ioctl.c
sys/dev/disk/dm/dm_pdev.c
sys/dev/disk/dm/dm_table.c
sys/dev/disk/dm/dm_target_error.c
sys/dev/disk/dm/dm_target_zero.c
sys/dev/disk/dm/targets/crypt/dm_target_crypt.c
sys/dev/disk/dm/targets/delay/dm_target_delay.c
sys/dev/disk/dm/targets/linear/dm_target_linear.c
sys/dev/disk/dm/targets/snapshot/dm_target_snapshot.c
sys/dev/disk/dm/targets/striped/dm_target_striped.c