• Jan Kara's avatar
    direct-io: Fix sleep in atomic due to sync AIO · 93e1f7fc
    Jan Kara authored
    commit d9c10e5b8863cfb6886d1640386455075c6e979d upstream.
    Commit e864f395 "fs: add RWF_DSYNC aand RWF_SYNC" added additional
    way for direct IO to become synchronous and thus trigger fsync from the
    IO completion handler. Then commit 9830f4be "fs: Use RWF_* flags for
    AIO operations" allowed these flags to be set for AIO as well. However
    that commit forgot to update the condition checking whether the IO
    completion handling should be defered to a workqueue and thus AIO DIO
    with RWF_[D]SYNC set will call fsync() from IRQ context resulting in
    sleep in atomic.
    Fix the problem by checking directly iocb flags (the same way as it is
    done in dio_complete()) instead of checking all conditions that could
    lead to IO being synchronous.
    CC: Christoph Hellwig <hch@lst.de>
    CC: Goldwyn Rodrigues <rgoldwyn@suse.com>
    CC: stable@vger.kernel.org
    Reported-by: 's avatarMark Rutland <mark.rutland@arm.com>
    Tested-by: 's avatarMark Rutland <mark.rutland@arm.com>
    Fixes: 9830f4beSigned-off-by: 's avatarJan Kara <jack@suse.cz>
    Signed-off-by: 's avatarJens Axboe <axboe@kernel.dk>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>