Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp816280ybn; Tue, 24 Sep 2019 09:57:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJb/72GKtbpD28/49iSXGygI2K8VbZkTO1eCIrYAS6DSIZSIpDh77vBdGxvstwNAEvUu9A X-Received: by 2002:a17:906:3644:: with SMTP id r4mr153468ejb.92.1569344252053; Tue, 24 Sep 2019 09:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569344252; cv=none; d=google.com; s=arc-20160816; b=dfVQ7FE9L4CjX54kFCCIDguUoWY/Oar/Fwijxc3Vj7r3KEk9iLiSGRt12wgZTMhHEi uIn7u4+XDqy9WstrUuyyhRO9tGOwRXS7gALFxBmd+ljFCl3Uv60d4SybONFdxSSTD3wD iUyRB6Gko8qdMPXStx6Vg7lLkNFFIiSB9+STAKLNf3zOtUdcphO/hvqkPxBhZMM5JdxH 71J+Z2MY6ePVdCKiX+jAgooqBCB2V4xbvqeCQGb91W4vl/K888noiiXHTrN/EehxZzn9 lApztM8mM6h27zhw4+0GkrgLOPfnsIO3i0d8DUBTrBOHgsgrAzkwAC4gFk/aJx36BFfm aADw== 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; bh=Y/leVQOesvX/XM3KBnx/PYz9Cg0b/e+gYJOVe+q4Tjk=; b=gP5CcGV1aBNPidIJoH3gG6NHxrrfEmPAr11de+NV8nMfilFjQI1Jj6D/kwbJdiXMQ2 W3dY6afdlWkbFAlOPxpNZT7X7AKS4NajJQRkDJDdRgm1RoE/fiqRgjJvSTxG14P+UY6X lGwY45PTols3CdtQiHtkqXrgLRr8BIq3Se6tZ1H6uiLm3MnhcMB5O8/tyseXSVJofura fa2apzPCggWBdSLMgNF5DEkM4KkxR60BTMRJymToyj4p14wrOhQOLWLTfdSbnUn23Cbs nfKlNWghNtU1+FjMV9PoeuPXXNz33yngsIdAssJ3iOAKPS8KvQIBhWvFVu6z/Qis/Ki1 0pOg== 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 g23si1145063ejk.186.2019.09.24.09.57.05; Tue, 24 Sep 2019 09:57:32 -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 S1726462AbfIWKK3 (ORCPT + 99 others); Mon, 23 Sep 2019 06:10:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:47368 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405672AbfIWKK3 (ORCPT ); Mon, 23 Sep 2019 06:10:29 -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 A0A9FAF65; Mon, 23 Sep 2019 10:10:27 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 516001E4669; Mon, 23 Sep 2019 12:10:42 +0200 (CEST) Date: Mon, 23 Sep 2019 12:10:42 +0200 From: Jan Kara To: Goldwyn Rodrigues Cc: linux-fsdevel@vger.kernel.org, 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, Ted Tso , Goldwyn Rodrigues Subject: Re: [PATCH 2/3] ext4: fix inode rwsem regression Message-ID: <20190923101042.GA25332@quack2.suse.cz> References: <20190911093926.pfkkx25mffzeuo32@alap3.anarazel.de> <20190911164517.16130-1-rgoldwyn@suse.de> <20190911164517.16130-3-rgoldwyn@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190911164517.16130-3-rgoldwyn@suse.de> 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 On Wed 11-09-19 11:45:16, Goldwyn Rodrigues wrote: > 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 Thanks for fixing this! The patch looks good to me. You can add: Reviewed-by: Jan Kara BTW, I've also added Ted as ext4 maintainer to CC. Honza > --- > 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 > -- Jan Kara SUSE Labs, CR