Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp682000ybx; Tue, 5 Nov 2019 04:00:00 -0800 (PST) X-Google-Smtp-Source: APXvYqyQ97m/fJJL0YGfus1a/NHpWWS/+jmvASMZDUWKCEqg9E8eZVzNP0CBzgTUieIwfE2E0h2T X-Received: by 2002:a50:8264:: with SMTP id 91mr35007322edf.69.1572955200697; Tue, 05 Nov 2019 04:00:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572955200; cv=none; d=google.com; s=arc-20160816; b=KBnmlqiC2ePZIUr4VgpwzgbU5gF2UZMfBumkqosX+litVEKIxWCtWjbJTDa1GcQKPX wR3I6d/jJVZIh07///pAtr6BYOTWFIxA9pTBbKb4AlbxWpoeTOQUmMzEeeairTbD/8TT ozd/8R6grhiGQRnj1gUJgVvqpBQpoI79GTIX5QlY+kDsPQwldiFcVGqzd3lNcBcDqEKe Ma3twD7jFyq5TyHx8CdlzTDdkT8M/gJPeoRndCL9Ne52X6BMvEbY+EFBOMxpzEICfCrw DOrLW42XesNidVADmhfDylpD90kidYIN6sYmzSd0ZZRoe7LCjkP2EiZkvuE9ArJNWOAs tJhg== 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=LcQBmC1CbJ1RDhTAUWqHhOSwn0GfYhx2KOpxTYNCMvg=; b=bKrOnix6pIOgY7ACTmfFqjRXP9RFGCJZ7qadE6dr2n9PWyBCxBLdT/Pky+/D/EiakV mo+u7nmgdwYD35SDNv/5Ha40A062BlNV7PErPgpqC6zWelnLXY7m9Qe2wsKV8R0C48/o n7kOSFFtOW4PtKam+ijP4Pl47edaNPJffmJKkX96TGTnTGSKkQbZJCnlDeq8n0X/VgsL WT0o7H2kVs2+OxDZFxgYWvZ0V+waHlGI0Em2pmGqC8TMyH10A/E8CfbdgkzM1WZ1hMlY iFkCLYAT4pRnjsWxpcXWCs+VrUOrGgMv7Ho/e3GxnmXzWEs15scvN3BudvOgnxSwVBqn hrpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=nPiHZ8jx; 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 f6si2297225edq.325.2019.11.05.03.59.36; Tue, 05 Nov 2019 04:00:00 -0800 (PST) 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=nPiHZ8jx; 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 S1730886AbfKEL73 (ORCPT + 99 others); Tue, 5 Nov 2019 06:59:29 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35222 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730848AbfKEL73 (ORCPT ); Tue, 5 Nov 2019 06:59:29 -0500 Received: by mail-pg1-f196.google.com with SMTP id q22so6370906pgk.2 for ; Tue, 05 Nov 2019 03:59:29 -0800 (PST) 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=LcQBmC1CbJ1RDhTAUWqHhOSwn0GfYhx2KOpxTYNCMvg=; b=nPiHZ8jxM0wm48aejSLVJS+siylmp4UzJPTDZ0tM8pI1kBrxL+mTorpO1hXya2RnU5 NDOl7ihkPddhpC3A3fGEG3HjokZgjfieDehIVEM9m4MiI2ChQrIVj089FWqqW4X24RRN j6Q/o3cARG6v3bcaDN3yWhvWounx8mVaHXMw+EQXemwL/HxMXdlw5cqLyPNdbEBNypvs D4G4YSp8+KdperEVTAD6/rrtbdBx6pnebGPBGTixbX6FvM739DVOIj1gOaG2eeVcDydF gwTmmqMs7rKp2W1yuntfL2ZKGzFtgVd4asoA6QMSyCUU4yF+K4Ialyi0JrN0Xsl0Fr6C chnA== 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=LcQBmC1CbJ1RDhTAUWqHhOSwn0GfYhx2KOpxTYNCMvg=; b=byWftw1yy49iEqkQRYkzNubruR0iQiMJzzYG8T6kRz3BnHV92Nryy2P5xkAZxNhu9F Jxb25ye7js8SD/gx7ekzMrmF+CZKymp7hBgmeGPKIC4QKWBySHUHdkwGpSjqL51b/ntx zaNvGtwQaUubiooyubUah+GpoOMHaZ1SUw9X9v8w4wHv5iZvzMmUjH6xUOd4umXmMzXQ D1eYfa09EXgl7W+Kp6v8rfyQld9vNErzX+CBzzqEJo0KJLit+zKnvzsLbGXvIZYHmeSW yBVAhJtyv/f6HpTrdXoYqA3sMWCzuuGkCaMt4emfAOnbdXHyoeDRKJNnfIbXh4s7tKhT hxZA== X-Gm-Message-State: APjAAAWv+sjjizBDoR76Oa7qIa1kELR0qc7s/0TvGpI+/kax6HSU3/5i Wo4ZqasVY0WcrFwne8Owb7lbNVh27A== X-Received: by 2002:a17:90a:6d27:: with SMTP id z36mr6215476pjj.38.1572955168558; Tue, 05 Nov 2019 03:59:28 -0800 (PST) Received: from poseidon.bobrowski.net ([114.78.226.167]) by smtp.gmail.com with ESMTPSA id k20sm13102609pgn.40.2019.11.05.03.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 03:59:27 -0800 (PST) Date: Tue, 5 Nov 2019 22:59:22 +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, riteshh@linux.ibm.com Subject: [PATCH v7 02/11] ext4: update direct I/O read lock pattern for IOCB_NOWAIT Message-ID: 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 e4b0722717b3..f33fa86fff67 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3881,7 +3881,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