diff options
author | Peng Tao <tao.peng@primarydata.com> | 2015-01-20 07:44:29 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-02-05 22:36:05 -0800 |
commit | 19387f4d87f68cb8e8c7388a27c43b5e1b7a3b59 (patch) | |
tree | dc774c0278f77c01fd477c4d4e56f9f32981b7d3 | |
parent | 203ba54a3d85ed962f96421f78afe61016bdf514 (diff) | |
download | linux-stable-19387f4d87f68cb8e8c7388a27c43b5e1b7a3b59.tar.gz linux-stable-19387f4d87f68cb8e8c7388a27c43b5e1b7a3b59.tar.bz2 linux-stable-19387f4d87f68cb8e8c7388a27c43b5e1b7a3b59.zip |
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>
-rw-r--r-- | fs/nfs/direct.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 10bf07280f4a..294692ff83b1 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -212,6 +212,12 @@ static int nfs_direct_cmp_commit_data_verf(struct nfs_direct_req *dreq, */ ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos) { + struct inode *inode = iocb->ki_filp->f_mapping->host; + + /* we only support swap file calling nfs_direct_IO */ + if (!IS_SWAPFILE(inode)) + return 0; + #ifndef CONFIG_NFS_SWAP dprintk("NFS: nfs_direct_IO (%pD) off/no(%Ld/%lu) EINVAL\n", iocb->ki_filp, (long long) pos, iter->nr_segs); |