• Sachin Prabhu's avatar
    Complete oplock break jobs before closing file handle · 058f35e3
    Sachin Prabhu authored
    commit ca7df8e0 upstream.
    
    Commit
    c11f1df5
    requires writers to wait for any pending oplock break handler to
    complete before proceeding to write. This is done by waiting on bit
    CIFS_INODE_PENDING_OPLOCK_BREAK in cifsFileInfo->flags. This bit is
    cleared by the oplock break handler job queued on the workqueue once it
    has completed handling the oplock break allowing writers to proceed with
    writing to the file.
    
    While testing, it was noticed that the filehandle could be closed while
    there is a pending oplock break which results in the oplock break
    handler on the cifsiod workqueue being cancelled before it has had a
    chance to execute and clear the CIFS_INODE_PENDING_OPLOCK_BREAK bit.
    Any subsequent attempt to write to this file hangs waiting for the
    CIFS_INODE_PENDING_OPLOCK_BREAK bit to be cleared.
    
    We fix this by ensuring that we also clear the bit
    CIFS_INODE_PENDING_OPLOCK_BREAK when we remove the oplock break handler
    from the workqueue.
    
    The bug was found by Red Hat QA while testing using ltp's fsstress
    command.
    Signed-off-by: default avatarSachin Prabhu <sprabhu@redhat.com>
    Acked-by: default avatarShirish Pargaonkar <shirishpargaonkar@gmail.com>
    Signed-off-by: default avatarJeff Layton <jlayton@samba.org>
    Signed-off-by: default avatarSteve French <steve.french@primarydata.com>
    Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
    058f35e3
file.c 96 KB