• Vivek Goyal's avatar
    virtiofs: schedule blocking async replies in separate worker · bb737bbe
    Vivek Goyal authored
    In virtiofs (unlike in regular fuse) processing of async replies is
    serialized.  This can result in a deadlock in rare corner cases when
    there's a circular dependency between the completion of two or more async
    replies.
    
    Such a deadlock can be reproduced with xfstests:generic/503 if TEST_DIR ==
    SCRATCH_MNT (which is a misconfiguration):
    
     - Process A is waiting for page lock in worker thread context and blocked
       (virtio_fs_requests_done_work()).
     - Process B is holding page lock and waiting for pending writes to
       finish (fuse_wait_on_page_writeback()).
     - Write requests are waiting in virtqueue and can't complete because
       worker thread is blocked on page lock (process A).
    
    Fix this by creating a unique work_struct for each async reply that can
    block (O_DIRECT read).
    
    Fixes: a62a8ef9 ("virtio-fs: add virtiofs filesystem")
    Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    bb737bbe
file.c 82.6 KB