Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17935034ybl; Thu, 2 Jan 2020 15:07:15 -0800 (PST) X-Google-Smtp-Source: APXvYqzIWgAjS5aEGcVFPExT6cSCInagPn0PhtNlbvFUzE91UDGCQ9sC2m0EPUWwr61aWiOuB/LU X-Received: by 2002:a9d:3b5:: with SMTP id f50mr92212849otf.354.1578006435604; Thu, 02 Jan 2020 15:07:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006435; cv=none; d=google.com; s=arc-20160816; b=YRQDjshe54raMJXsWgEArF7RqnbXd6HuAlJILi89C3t1dTwmkfXxGS5ofS0vHTzFjp bN0p3pIp0PtoM7y1AVaRaiYb1YPfDdQct6oQTJecx8TyE3aFvGU4Kej3RSYYlic/JZYF YIk4PBl2MRC2NfMkvpYBx3wgUTC7AlwpSV428W4ta+WfY1GoMtmUiskdeBx6JQY3aixW hWm9Z/SwZow8LL00cDNQBLTMoZuaVgjvRaE8nuD44XlaR9S0nYvUk/BNKIV5Md/hBkFC nK9aRXCx5Vz6yXH7RvKpBori5UTzCtLxSipOXcFr3zaou9UlrBGmhggMzKdZLF5hyxIP 4VIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TUzTOS5G49f26XZrq99XTcXpiHCSoWX/kgXR7ym6QUc=; b=Ei1+swc1xgEyrjAQOxUst3uf2HSLXVhxcYDPVV08DqAVW3edeHtONzPEONFABNWOgb vj+iT4b1RH2fDgCpb/og4MJ7QSS6+3CmNdlZ4jxoKk0+BKZ8u1Hy4JxbzXGABD12fT2e dpxXuTNiSIwcqEBx06LfRxCzndpwHN2rBbovbvvPHpEZHDlyDYx6Hf1Cn/2gvCQYTOpC +dzye/XpyqZ1Prh1h7Eq5m42ZOYDOZPAC5OzjxSMl+0cOh6x5OU9R4p/hxznAs2lrZkw 5ZJQz57Z1DDcPYQL0/QqsZyjf1FQTHLxYks8K4osoBqI5/s33I0fZvNDdVa+mQ2zDdt1 UH5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YrBFqGCr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si29345712otq.317.2020.01.02.15.07.03; Thu, 02 Jan 2020 15:07:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YrBFqGCr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728809AbgABWUc (ORCPT + 99 others); Thu, 2 Jan 2020 17:20:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:38100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728609AbgABWUa (ORCPT ); Thu, 2 Jan 2020 17:20:30 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7DF4C24653; Thu, 2 Jan 2020 22:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003630; bh=pd/wt+YcBDprBLzmbtoE6qnAlsY3BlzyUlRVgKeZAZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YrBFqGCrzXVnE9SUxMLFGVPuzL7bNS+izcJBWpe8C5EMuXo8S234ciThkAweXmKXW MtnQbUH9RVFDm6L+UOgFLABEvilhnpQ8cTYZI9L+4WD1nDAc12pOGKUFC1xFAAqeUn JflJd2PR1XQRx/S1cqOnGA8eZ5vO8XoRbquV6UZM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Bobrowski , Jan Kara , Ritesh Harjani , Theodore Tso , Sasha Levin Subject: [PATCH 4.19 022/114] ext4: update direct I/O read lock pattern for IOCB_NOWAIT Date: Thu, 2 Jan 2020 23:06:34 +0100 Message-Id: <20200102220031.395561173@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Bobrowski [ Upstream commit 548feebec7e93e58b647dba70b3303dcb569c914 ] This patch updates the lock pattern in ext4_direct_IO_read() to not block on inode lock in cases of IOCB_NOWAIT direct I/O reads. The locking condition implemented here is similar to that of 942491c9e6d6 ("xfs: fix AIM7 regression"). Fixes: 16c54688592c ("ext4: Allow parallel DIO reads") Signed-off-by: Matthew Bobrowski Reviewed-by: Jan Kara Reviewed-by: Ritesh Harjani Link: https://lore.kernel.org/r/c5d5e759f91747359fbd2c6f9a36240cf75ad79f.1572949325.git.mbobrowski@mbobrowski.org Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/inode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 215802cbc42b..00d0c4b8fa30 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3848,7 +3848,13 @@ static ssize_t ext4_direct_IO_read(struct kiocb *iocb, struct iov_iter *iter) * writes & truncates and since we take care of writing back page cache, * we are protected against page writeback as well. */ - inode_lock_shared(inode); + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!inode_trylock_shared(inode)) + return -EAGAIN; + } else { + inode_lock_shared(inode); + } + ret = filemap_write_and_wait_range(mapping, iocb->ki_pos, iocb->ki_pos + count - 1); if (ret) -- 2.20.1