• M
    dm io: fix I/O to multiple destinations · d73f9907
    Mikulas Patocka 提交于
    Commit 003b5c57 ("block: Convert drivers
    to immutable biovecs") broke dm-mirror due to dm-io breakage.
    
    dm-io had three possible iterators (DM_IO_PAGE_LIST, DM_IO_BVEC,
    DM_IO_VMA) that iterate over pages where the I/O should be performed.
    
    The switch to immutable biovecs changed the DM_IO_BVEC iterator to
    DM_IO_BIO.  Before this change the iterator stored the pointer to a bio
    vector in the dpages structure.  The iterator incremented the pointer in
    the dpages structure as it advanced over the pages.  After the immutable
    biovecs change, the DM_IO_BIO iterator stores a pointer to the bio in
    the dpages structure and uses bio_advance to change the bio as it
    advances.
    
    The problem is that the function dispatch_io stores the content of the
    dpages structure into the variable old_pages and restores it before
    issuing I/O to each of the devices.  Before the change, the statement
    "*dp = old_pages;" restored the iterator to its starting position.
    After the change, struct dpages holds a pointer to the bio, thus the
    statement "*dp = old_pages;" doesn't restore the iterator.
    
    Consequently, in the context of dm-mirror: only the first mirror leg is
    written correctly, the kernel locks up when trying to write the other
    mirror legs because the number of sectors to write in the where->count
    variable doesn't match the number of sectors returned by the iterator.
    
    This patch fixes the bug by partially reverting the original patch - it
    changes the code so that struct dpages holds a pointer to the bio vector,
    so that the statement "*dp = old_pages;" restores the iterator correctly.
    
    The field "context_u" holds the offset from the beginning of the current
    bio vector entry, just like the "bio->bi_iter.bi_bvec_done" field.
    Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: NMike Snitzer <snitzer@redhat.com>
    d73f9907
dm-io.c 12.9 KB