• NeilBrown's avatar
    md/raid1: simplify the splitting of requests. · c230e7e5
    NeilBrown authored
    raid1 currently splits requests in two different ways for
    two different reasons.
    
    First, bio_split() is used to ensure the bio fits within a
    resync accounting region.
    Second, multiple r1bios are allocated for each bio to handle
    the possiblity of known bad blocks on some devices.
    
    This can be simplified to just use bio_split() once, and not
    use multiple r1bios.
    We delay the split until we know a maximum bio size that can
    be handled with a single r1bio, and then split the bio and
    queue the remainder for later handling.
    
    This avoids all loops inside raid1.c request handling.  Just
    a single read, or a single set of writes, is submitted to
    lower-level devices for each bio that comes from
    generic_make_request().
    
    When the bio needs to be split, generic_make_request() will
    do the necessary looping and call md_make_request() multiple
    times.
    
    raid1_make_request() no longer queues request for raid1 to handle,
    so we can remove that branch from the 'if'.
    
    This patch also creates a new private bio_set
    (conf->bio_split) for splitting bios.  Using fs_bio_set
    is wrong, as it is meant to be used by filesystems, not
    block devices.  Using it inside md can lead to deadlocks
    under high memory pressure.
    
    Delete unused variable in raid1_write_request() (Shaohua)
    Signed-off-by: default avatarNeilBrown <neilb@suse.com>
    Signed-off-by: default avatarShaohua Li <shli@fb.com>
    c230e7e5
raid1.h 5.64 KB