Commit ee8a1a8b160a87dc3a9c81a86796aa4db85ea815
Committed by
Trond Myklebust
1 parent
ec6f34e5b5
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
nfs: fix dio deadlock when O_DIRECT flag is flipped
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> Cc: stable@vger.kernel.org Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
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); |