Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1126862ybe; Wed, 11 Sep 2019 09:46:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCfDG8KvpJRg4RWmg9rPoZUcd4vAFB0oCoL2XQEsE7dqGKAdt9cbWNZJRe3tU/6+RyKlzU X-Received: by 2002:a17:906:a3d2:: with SMTP id ca18mr30516285ejb.194.1568220410365; Wed, 11 Sep 2019 09:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568220410; cv=none; d=google.com; s=arc-20160816; b=tMUtKEhL6FHXzlT5gHW2D2JQKmJlYeyriBqokj7ukCQv2LYktYt41aGbCIkxvNiskF NJJKs2Xm7Q8s5WvRiS86FsiStsuwNOJw1tcrJv8RYF3jlhdk3meCoZR1YVRxLV8jk/wJ 6n5m5fp6mLmXhCnxCccH4TpT9Y72EjHO+hTNtLVo7Msi5FXEFZYy/ZVM4yn5lQWh1nKY iUhLGPekGIRrV/MmMc8fLzKncWjwYz4HYIbQan8GvXsiryI2dEKg4LSpCVCPLNVuSQYm IeqMTMYrV0Av/pemkL/EAKtZfWzVVEzTLgnnbLIZ2dnxjndDI4hAdqTe/psqdILJXmdi iZ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=UNbLGODmhfwP3Bj0ezTOJsJxCMfCzL9Wj/fYJ0ZvBJM=; b=Gfa1rsL8uc4roQp9z0NMKHB/TjnW8jDajzpjQ7toWyCK9oCY5+9YnTnE2Vzizg+I+x WEdfKxIVkWXEUIUL3MlbaPgCY4nmZVx+6nKukf9QZK6jdSDDyDmKma38cjS1abkmMBuW YYJFOrvdsJo16yQSuhQdTJylT0vcQOWye1nmvDplHNEmHj7Etkt/OxzXNc8xcE/RjvKS kRkpT6eAI4Pf72tQVOuXv3osvTHNKW29P0oJyK+fgBr2YZlzYD8cu9wbrun9JTQjpVk9 UEqxwdst8TTsJVV+G6kfaPvvbDNtNKvD21p2vVzH5j3ra0cAAu8OT0WUhlF5FFPSH1mW n/eQ== ARC-Authentication-Results: i=1; mx.google.com; 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 b47si12204146edc.45.2019.09.11.09.46.26; Wed, 11 Sep 2019 09:46:50 -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; 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 S1729252AbfIKQpa (ORCPT + 99 others); Wed, 11 Sep 2019 12:45:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:34434 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728896AbfIKQpa (ORCPT ); Wed, 11 Sep 2019 12:45:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 146A0AF85; Wed, 11 Sep 2019 16:45:28 +0000 (UTC) From: Goldwyn Rodrigues To: linux-fsdevel@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, hch@infradead.org, andres@anarazel.de, david@fromorbit.com, riteshh@linux.ibm.com, linux-f2fs-devel@lists.sourceforge.net, Goldwyn Rodrigues Subject: [PATCH 2/3] ext4: fix inode rwsem regression Date: Wed, 11 Sep 2019 11:45:16 -0500 Message-Id: <20190911164517.16130-3-rgoldwyn@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190911164517.16130-1-rgoldwyn@suse.de> References: <20190911093926.pfkkx25mffzeuo32@alap3.anarazel.de> <20190911164517.16130-1-rgoldwyn@suse.de> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Goldwyn Rodrigues This is similar to 942491c9e6d6 ("xfs: fix AIM7 regression") Apparently our current rwsem code doesn't like doing the trylock, then lock for real scheme. So change our read/write methods to just do the trylock for the RWF_NOWAIT case. Fixes: 728fbc0e10b7 ("ext4: nowait aio support") Signed-off-by: Goldwyn Rodrigues --- fs/ext4/file.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 70b0438dbc94..d5b2d0cc325d 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -40,11 +40,13 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) struct inode *inode = file_inode(iocb->ki_filp); ssize_t ret; - if (!inode_trylock_shared(inode)) { - if (iocb->ki_flags & IOCB_NOWAIT) + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!inode_trylock_shared(inode)) return -EAGAIN; + } else { inode_lock_shared(inode); } + /* * Recheck under inode lock - at this point we are sure it cannot * change anymore @@ -190,11 +192,13 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = file_inode(iocb->ki_filp); ssize_t ret; - if (!inode_trylock(inode)) { - if (iocb->ki_flags & IOCB_NOWAIT) + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!inode_trylock(inode)) return -EAGAIN; + } else { inode_lock(inode); } + ret = ext4_write_checks(iocb, from); if (ret <= 0) goto out; @@ -233,9 +237,10 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) if (!o_direct && (iocb->ki_flags & IOCB_NOWAIT)) return -EOPNOTSUPP; - if (!inode_trylock(inode)) { - if (iocb->ki_flags & IOCB_NOWAIT) + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!inode_trylock(inode)) return -EAGAIN; + } else { inode_lock(inode); } -- 2.16.4