Commit 19387f4d87f68cb8e8c7388a27c43b5e1b7a3b59
Committed by
Greg Kroah-Hartman
1 parent
203ba54a3d
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
... | ... | @@ -212,6 +212,12 @@ |
212 | 212 | */ |
213 | 213 | ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos) |
214 | 214 | { |
215 | + struct inode *inode = iocb->ki_filp->f_mapping->host; | |
216 | + | |
217 | + /* we only support swap file calling nfs_direct_IO */ | |
218 | + if (!IS_SWAPFILE(inode)) | |
219 | + return 0; | |
220 | + | |
215 | 221 | #ifndef CONFIG_NFS_SWAP |
216 | 222 | dprintk("NFS: nfs_direct_IO (%pD) off/no(%Ld/%lu) EINVAL\n", |
217 | 223 | iocb->ki_filp, (long long) pos, iter->nr_segs); |