• Ming Lei's avatar
    dm: improve bio splitting and associated IO accounting · 7dd76d1f
    Ming Lei authored
    The current DM code (ab)uses late assignment of dm_io->orig_bio (after
    __map_bio() returns and any bio splitting is complete) to indicate the
    FS bio has been processed and can be accounted. This results in
    awkward waiting until ->orig_bio is set in dm_submit_bio_remap().
    
    Also the bio splitting was implemented using bio_split()+bio_chain()
    -- a well-worn pattern but it requires bio cloning purely for the
    benefit of more natural IO accounting.  The bio_split() result was
    stored in ->orig_bio to represent the mapped part of the original FS
    bio.
    
    DM has switched to the bdev based IO accounting interface.  DM's IO
    accounting can be implemented in terms of the original FS bio (now
    stored early in ->orig_bio) via access to its sectors/bio_op. And
    if/when splitting is needed, set a new DM_IO_WAS_SPLIT flag and use
    new dm_io fields of .sector_offset & .sectors to allow IO accounting
    for split bios _without_ needing to clone a new bio to store in
    ->orig_bio.
    Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
    Co-developed-by: default avatarMike Snitzer <snitzer@kernel.org>
    Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
    7dd76d1f
dm.c 74.9 KB