• Kirill Smelkov's avatar
    bigfile/virtmem: Do loadblk() with virtmem lock released · f49c11a3
    Kirill Smelkov authored
    loadblk() calls are potentially slow and external code that serve the cal can
    take other locks in addition to virtmem lock taken by virtmem subsystem. If
    that "other locks" are also taken before external code calls e.g.
    fileh_invalidate_page() in different codepath a deadlock can happen, e.g.
    
          T1                  T2
    
          page-access         invalidation-from-server received
          V -> loadblk
                              Z   <- ClientStorage.invalidateTransaction()
          Z -> zeo.load
                              V   <- fileh_invalidate_page
    
    The solution to avoid deadlock is to call loadblk() with virtmem lock released
    and upon loadblk() completion recheck virtmem data structures carefully.
    
    To make that happen:
    
    - new page state is introduces:
    
        PAGE_LOADING                (file content loading is  in progress)
    
    - virtmem releases virt_lock before calling loadblk() when serving pagefault
    
    - because loading is now done with virtmem lock releas...
    f49c11a3