Commit 1066a175c7ef86259ea07f796c9a66dd26f28f5f
Committed by
Greg Kroah-Hartman
1 parent
907fe767f3
Exists in
smarc-ti-linux-3.14.y
and in
1 other branch
nfs: fix dio deadlock when O_DIRECT flag is flipped
commit ee8a1a8b160a87dc3a9c81a86796aa4db85ea815 upstream. We only support swap file calling nfs_direct_IO. However, application might be able to get to nfs_direct_IO if it toggles O_DIRECT flag during IO and it can deadlock because we grab inode->i_mutex in nfs_file_direct_write(). So return 0 for such case. Then the generic layer will fall back to buffer IO. Signed-off-by: Peng Tao <tao.peng@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 1 changed file with 6 additions and 0 deletions Side-by-side Diff
fs/nfs/direct.c
... | ... | @@ -123,6 +123,12 @@ |
123 | 123 | */ |
124 | 124 | ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t pos, unsigned long nr_segs) |
125 | 125 | { |
126 | + struct inode *inode = iocb->ki_filp->f_mapping->host; | |
127 | + | |
128 | + /* we only support swap file calling nfs_direct_IO */ | |
129 | + if (!IS_SWAPFILE(inode)) | |
130 | + return 0; | |
131 | + | |
126 | 132 | #ifndef CONFIG_NFS_SWAP |
127 | 133 | dprintk("NFS: nfs_direct_IO (%pD) off/no(%Ld/%lu) EINVAL\n", |
128 | 134 | iocb->ki_filp, (long long) pos, nr_segs); |