git: sys/dev/disk/dm: Don't let targets implement deps [2/2]

Tomohiro Kusumi tkusumi at crater.dragonflybsd.org
Sun Oct 25 07:57:22 PDT 2015


commit d471f1f91f48d72fc2e9bbb8d461753054d745d6
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date:   Sat Oct 24 19:38:56 2015 +0900

    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().

Summary of changes:
 sys/dev/disk/dm/dm.h                               | 13 ++++-
 sys/dev/disk/dm/dm_ioctl.c                         | 34 +++++++++++-
 sys/dev/disk/dm/dm_pdev.c                          | 18 +++++++
 sys/dev/disk/dm/dm_table.c                         | 54 +++++++++++++++++++
 sys/dev/disk/dm/dm_target_error.c                  |  8 ---
 sys/dev/disk/dm/dm_target_zero.c                   |  7 ---
 sys/dev/disk/dm/targets/crypt/dm_target_crypt.c    | 25 +--------
 sys/dev/disk/dm/targets/delay/dm_target_delay.c    | 39 ++------------
 sys/dev/disk/dm/targets/linear/dm_target_linear.c  | 24 +--------
 .../disk/dm/targets/snapshot/dm_target_snapshot.c  | 61 ++--------------------
 .../disk/dm/targets/striped/dm_target_striped.c    | 28 +---------
 11 files changed, 130 insertions(+), 181 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/d471f1f91f48d72fc2e9bbb8d461753054d745d6


-- 
DragonFly BSD source repository



More information about the Commits mailing list