• Andrew Morton's avatar
    [PATCH] swapcache bugfixes · 91cb02b7
    Andrew Morton authored
    Fixes a few lock ranking bugs (and deadlocks) related to
    swap_list_lock(), swap_device_lock(), mapping->page_lock and
    mapping->private_lock.
    
    - Cannot call block_flushpage->try_to_free_buffers() inside
      mapping->page_lock.  Because __set_page_dirty_buffers() takes
      ->page_lock inside ->private-lock.
    
    - Cannot call swap_free->swap_list_lock/swap_device_lock inside
      mapping->page_lock because exclusive_swap_page() takes ->page_lock
      inside swap_info_get().
    
    
    The patch also removes all the block_flushpage() calls from the swap
    code in favour of a direct call to try_to_free_buffers().
    
    The theory is that the page is locked, there is no I/O underway, nobody
    else has access to the buffers so they MUST be freeable.  A bunch of
    BUG() checks have been added, and unless someone manages to trigger
    one, the "block_flushpage() inside spinlock" problem is fixed.
    91cb02b7
swapfile.c 31.4 KB