Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17930827ybl; Thu, 2 Jan 2020 15:03:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzqsJIx+4cJsL0U3HIEHe45eIuAAzFmzs0AfDyIVkSKYmTHWYdoJUgF+OhzyHOqd2URUjZJ X-Received: by 2002:a05:6830:109a:: with SMTP id y26mr89950665oto.227.1578006185802; Thu, 02 Jan 2020 15:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006185; cv=none; d=google.com; s=arc-20160816; b=C7x0OPPo+Lt54DbXHJGlIkOqBVJPeqhW1B4QPMg1ziq53tz10VEQYnNVt5k9ys1bNl cTN8awMxbznvCY4CarMcDAiij6LNlY6GwuEq3LnNvNZs6XsaEb3+AfOcqUPYq5zNZi8t B7ZubI+KKbhHwWMEWifLZd9QORX3XVrxo6H6eDDeyGwPcds6W13zLSdcib7MPlXY3BhA f6T5hxfdXirC1jxiNtxhv1u52MCDKxKV9az3x+U93+yiSenicDOZ+Z6KNLL9Bim13zyo Syw6xGmcCE1ErpHYv4tUFgncgwFSnh4Cglfc+WL+9gA3YX3q99mUBUGc0akQqUkO0hl3 +RYw== 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=RN5QMAiEl1TRRtXPdDgr+gvNkP1i1S6w6FgRpBpgw4Q=; b=Y2fcEu/q90r3ZIGPlxO2Q7lqZ6iveDIXPAfloHreW7Wu+e2B4imsEBOFCa9kzU2Wuw a+AzTUnMhjPahqPRXDW0uzoLemjN6E/54ROqyeBVMbGd2GWf4FimOAf3Vmbcn2IB33+p BED49nik/8sq8hbpgKlZhoY/2xRHYOqZePWaMPb/sIdSAD8FYqK0mbFGOKIbCYaqtClV gHlW2jbKWZraXo0Gqc9FCiexJ9glg0K1QNImfTTvvhPY82H/htAEpH6GnDpAxntfMwmi Ai23688RC6zm4LNg6qAHfWUjIUnlQj/76BoR8psauoX6tR6HPHN9fzhAHUBcbsIx8tdx kq/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dAJKzAZG; 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 f187si27669777oia.218.2020.01.02.15.02.54; Thu, 02 Jan 2020 15:03:05 -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=dAJKzAZG; 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 S1727960AbgABXAo (ORCPT + 99 others); Thu, 2 Jan 2020 18:00:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:51802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727498AbgABWMe (ORCPT ); Thu, 2 Jan 2020 17:12:34 -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 E005121D7D; Thu, 2 Jan 2020 22:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003153; bh=r3pZeP9IeRuVmMfAsl/FdeSCsHqM9bwXH8Ql28UUO9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dAJKzAZGZHu4XgJ0YyBk2ee/SucuOt649iHmD5j3UZ5Jut2NGyVrs4rPDaYaxRGac NYU10MHOjsH11ZVsd0n9jHIZYmEy9Q7o5zY8gtY4C0DaohZt15SxjTMvbZkrDcM4X8 Z3JIivt08GsM6Wp9NkKj70WTlJdO+RKLKF0DryDY= 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 5.4 042/191] ext4: update direct I/O read lock pattern for IOCB_NOWAIT Date: Thu, 2 Jan 2020 23:05:24 +0100 Message-Id: <20200102215834.457865761@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@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 53134e4509b8..b10aa115eade 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3836,7 +3836,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