From patchwork Thu Jan 2 22:06:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 234529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DADAC3276C for ; Thu, 2 Jan 2020 22:54:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09DEA21835 for ; Thu, 2 Jan 2020 22:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578005674; bh=pd/wt+YcBDprBLzmbtoE6qnAlsY3BlzyUlRVgKeZAZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cGOjRpwa6TLDKb5zJehkuaSR/mVkO81DjW32gBVbS/oEH5qeyMIz+dwfvMq0BKIXZ P8XVPIzcUhHIL9hOlY3d7I+Wjd/LLMnqFfB4VHNvBmt/WxVJY2KLyAO3BynOAvQQ/X /o3rmbK83+PLMA5MytwzmICwmM4q678MTCm0hT6c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728568AbgABWUb (ORCPT ); Thu, 2 Jan 2020 17:20:31 -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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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)