• Lars Ellenberg's avatar
    drbd: add missing spinlock to bitmap receive · 829c6087
    Lars Ellenberg authored
    During bitmap exchange, when using the RLE bitmap compression scheme,
    we have a code path that can set the whole bitmap at once.
    
    To avoid holding spin_lock_irq() for too long, we used to lock out other
    bitmap modifications during bitmap exchange by other means, and then,
    knowing we have exclusive access to the bitmap, modify it without
    the spinlock, and with IRQs enabled.
    
    Since we now allow local IO to continue, potentially setting additional
    bits during the bitmap receive phase, this is no longer true, and we get
    uncoordinated updates of bitmap members, causing bm_set to no longer
    accurately reflect the total number of set bits.
    
    To actually see this, you'd need to have a large bitmap, use RLE bitmap
    compression, and have busy IO during sync handshake and bitmap exchange.
    
    Fix this by taking the spin_lock_irq() in this code path as well, but
    calling cond_resched_lock() after each page worth of bits processed.
    Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
    Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
    829c6087
drbd_bitmap.c 44.3 KB