• Jens Axboe's avatar
    [PATCH] elevator switching race · bc1c1169
    Jens Axboe authored
    There's a race between shutting down one io scheduler and firing up the
    next, in which a new io could enter and cause the io scheduler to be
    invoked with bad or NULL data.
    
    To fix this, we need to maintain the queue lock for a bit longer.
    Unfortunately we cannot do that, since the elevator init requires to be
    run without the lock held.  This isn't easily fixable, without also
    changing the mempool API.  So split the initialization into two parts,
    and alloc-init operation and an attach operation.  Then we can
    preallocate the io scheduler and related structures, and run the attach
    inside the lock after we detach the old one.
    
    This patch has survived 30 minutes of 1 second io scheduler switching
    with a very busy io load.
    Signed-off-by: default avatarJens Axboe <axboe@suse.de>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    bc1c1169
cfq-iosched.c 58.8 KB