Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3440149ybg; Mon, 28 Oct 2019 12:52:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxIkHvSKyNCFOjHm3TZpvQD52Rc+WXrPAcp74EyJA8g7N5uo5AQnUpQpcP7EYcbChkWYyX X-Received: by 2002:a17:907:105c:: with SMTP id oy28mr18276447ejb.299.1572292358425; Mon, 28 Oct 2019 12:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572292358; cv=none; d=google.com; s=arc-20160816; b=eAj3i3ohizaJK1xqL1bZ7zn5Tr6lYzwegiMK1IdDnWXhg2KK59QlBSn0yneb8eR9+2 uY/ylD3lWdl8P6QMjM+fOGQfDQecraxI918jmtnDlsgfb3fMEmt0cs0+FIXZvL8TS37M L+MEASTIQgEQeqelgZs+cevNpS+LpPx4vGZ6lGE329vcL9EJn3ywIAHvwkLtB/xQ+kc2 58iI6Hbm7BF/HdObg2JNounAsr+gkoc/tXQ28/T2tzuw+ppKhFzrRw4jtV1It+XJN9so Oi6EkE+dzZwz+zCT9NVMTLdiyavRdiPV3vbUCec+0/s/2u9Vd60yj1Ow10Qj+qYLz4u9 1+FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=adn4gOH9wM1yK1i3uZc/QwdCwMT/Epp1BBGQLJPWPVM=; b=EILKeq4zQE10jdlLNllBMyPpJslvn6qzP274AGSrc/0Vu6+j8v3KhS34kFTvYV3Oh/ CUdnGm3qHFQnhyZG6Qa554Tj7MO3T8DKUR1RAoNPQyQoGHL0meTc1weojBD1JrMEi10z n91cT6CkXaPIVfbMi0s+02CbLyKEj7bYDx4iBk/hvKl7Qd0scl7mN6tkd9rLF3JLhRdK hwyqp/DOUyncrNWOEsSRMdrRcb/04ewccURVm8+HIl2f3mmnKKgW76tU4UqMloR1j0+w MRxt5YrQ3nsvD7xXIcyEgAv4qkUk2sqGz+GPifEgOAeR6S6qsCk6z2Ks7g/jLWK99DR+ /zNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=G9Md5Kat; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 14si8147309edz.130.2019.10.28.12.52.12; Mon, 28 Oct 2019 12:52:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=G9Md5Kat; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388327AbfJ1KvC (ORCPT + 99 others); Mon, 28 Oct 2019 06:51:02 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41290 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388321AbfJ1KvB (ORCPT ); Mon, 28 Oct 2019 06:51:01 -0400 Received: by mail-pf1-f194.google.com with SMTP id p26so2507799pfq.8 for ; Mon, 28 Oct 2019 03:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mbobrowski-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=adn4gOH9wM1yK1i3uZc/QwdCwMT/Epp1BBGQLJPWPVM=; b=G9Md5Kat3ZszJ6WvVofzucKe1kR+H5u+O0+UtzEYZIgJOgKbina+CIMx7USP3hYliB 5f+BUq26w57DXOCHzwjIe9LuGD+6Bu2VqhuJI+K2dRDNX1FNYQ/sgBuk0wP0m1JwOaCZ vOko0PQBkDVdh5mekf6tVVelrUCXtjEhT1AHa5Z/tfHx5VlMEpRkPqD865pdlyCbxsI+ yVPyYnTzTnzlqh/2iwK7Ccm0dS2ijXW4ilvpsHClehDQw0vy5gkDM5Ha8KfdUbyEG2o4 TQG8wHL2YgziVGM83VU+gFjg7czeqAN0AhzeLaMDix+EB7Sjh85rPKeJqvNMY1zvK2EG Dduw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=adn4gOH9wM1yK1i3uZc/QwdCwMT/Epp1BBGQLJPWPVM=; b=VO9gWiIA8UFODFG1hbLD2b0FyLcJP7WcUuh4ILvaom/Q9+RYRfyb0Mfien43AZhgPY 2z0NOaecOiDQPI8j7lyXuH7DbFXtngu15GbXobNXuWSYT+sZ4GIHELnYXjeMn4HaIpNA rO2bkzUzMll1f2m7oacvc59/G8oUcg5/PsdhNI58x3Q5rpARoGCPBOJLvK6U07kSc5rU JY3hGM39QJVG7Qzivz27i+p9Bs0vXCBsBr4Map5cBOVKzTQGxslqh9CXNbruDl1Anx6Q cbuJuoacXwfSW8mktZZhURy4IWf7h8M8Z6h2N+2+liMXF5usmnGAfVcvLeztG4cw/IQ4 S2qg== X-Gm-Message-State: APjAAAWx2s8uZYS7Tel57lKLoJOP8kk7D/3H4ratLuDVWgGPe/5RbDPg 5D67kRbfaEspVYB0d9RDKvgP X-Received: by 2002:a62:5ac3:: with SMTP id o186mr19860150pfb.20.1572259861132; Mon, 28 Oct 2019 03:51:01 -0700 (PDT) Received: from poseidon.bobrowski.net (d114-78-127-22.bla803.nsw.optusnet.com.au. [114.78.127.22]) by smtp.gmail.com with ESMTPSA id 21sm2820419pfa.170.2019.10.28.03.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 03:51:00 -0700 (PDT) Date: Mon, 28 Oct 2019 21:50:54 +1100 From: Matthew Bobrowski To: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org, david@fromorbit.com, darrick.wong@oracle.com Subject: [PATCH v6 02/11] ext4: update direct I/O read lock pattern for IOCB_NOWAIT Message-ID: <17824b863511c87c3b4ea36531ca3c1430d30660.1572255425.git.mbobrowski@mbobrowski.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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 ee116344c420..0a9ea291cfab 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3837,7 +3837,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