Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee8a1a8b authored by Peng Tao's avatar Peng Tao Committed by Trond Myklebust
Browse files

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: default avatarPeng Tao <tao.peng@primarydata.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent ec6f34e5
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -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)
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
#ifndef CONFIG_NFS_SWAP
	dprintk("NFS: nfs_direct_IO (%pD) off/no(%Ld/%lu) EINVAL\n",
	dprintk("NFS: nfs_direct_IO (%pD) off/no(%Ld/%lu) EINVAL\n",
			iocb->ki_filp, (long long) pos, iter->nr_segs);
			iocb->ki_filp, (long long) pos, iter->nr_segs);