From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 4E143C4741F for ; Sat, 31 Oct 2020 09:26:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD99E20756 for ; Sat, 31 Oct 2020 09:26:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="qE5NYOKM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD99E20756 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 32A3E6B005C; Sat, 31 Oct 2020 05:26:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3006B6B006E; Sat, 31 Oct 2020 05:26:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23CF06B0070; Sat, 31 Oct 2020 05:26:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EBA3B6B005C for ; Sat, 31 Oct 2020 05:26:22 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 919F03623 for ; Sat, 31 Oct 2020 09:26:22 +0000 (UTC) X-FDA: 77431689804.16.net03_360af512729d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 6E5AD100E690B for ; Sat, 31 Oct 2020 09:26:22 +0000 (UTC) X-HE-Tag: net03_360af512729d X-Filterd-Recvd-Size: 4380 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Sat, 31 Oct 2020 09:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=MWaMneU7BhzODsMhJkl5CJM+zMKEb8OgtLKiOZosoCk=; b=qE5NYOKMbe4XeE8BYN8fFNEy9q DViNDofJVNr1FC64B8Kea7D3I4Jd9NJjh4+0FlckN5mLaPnpU3S0gEGuYcYJd5qopVCnLHNy1/PCT o7KGBEOJ3wcURPs38tRliRa76rn8KRo6Pz5n2eOXpA/nz111btt8WiqFA+0LC1hvnYBWxNpp8hIwB cc790NyWsudCExvSHRC83ut/sX7RbKGLZzUJviU6ZhOSG7RQl4Ej4AmKby3XUn7Xt6cSc/vNzaFhq wu/gbeiGAsgpvmjoRehH03O1Dmu7yUm9v0kOtoiyB0LYVnkUXIQdXwZagffzPmCq82egBvBIpf/GN CTPWPNug==; Received: from 089144193201.atnat0002.highway.a1.net ([89.144.193.201] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYn9O-00004x-Fg; Sat, 31 Oct 2020 09:26:19 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Kent Overstreet , Matthew Wilcox , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 11/13] mm: streamline the partially uptodate checks in filemap_make_page_uptodate Date: Sat, 31 Oct 2020 10:00:02 +0100 Message-Id: <20201031090004.452516-12-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201031090004.452516-1-hch@lst.de> References: <20201031090004.452516-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Unwind the goto mess a bit. Signed-off-by: Christoph Hellwig --- mm/filemap.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 000f75cd359d1c..904b0a4fb9e008 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2218,7 +2218,6 @@ static int filemap_make_page_uptodate(struct kiocb = *iocb, struct iov_iter *iter, struct address_space *mapping =3D file->f_mapping; loff_t last =3D iocb->ki_pos + iter->count; pgoff_t last_index =3D (last + PAGE_SIZE - 1) >> PAGE_SHIFT; - loff_t pos =3D max(iocb->ki_pos, (loff_t)pg_index << PAGE_SHIFT); int error; =20 if (PageReadahead(page)) { @@ -2251,32 +2250,22 @@ static int filemap_make_page_uptodate(struct kioc= b *iocb, struct iov_iter *iter, if (PageUptodate(page)) return 0; =20 - if (mapping->host->i_blkbits =3D=3D PAGE_SHIFT || - !mapping->a_ops->is_partially_uptodate) - goto page_not_up_to_date; - /* pipes can't handle partially uptodate pages */ - if (unlikely(iov_iter_is_pipe(iter))) - goto page_not_up_to_date; - if (!trylock_page(page)) - goto page_not_up_to_date; - /* Did it get truncated before we got the lock? */ - if (!page->mapping) - goto page_not_up_to_date_locked; - if (!mapping->a_ops->is_partially_uptodate(page, pos & ~PAGE_MASK, - last - pos)) - goto page_not_up_to_date_locked; - -unlock_page: - unlock_page(page); - return 0; + if (mapping->host->i_blkbits <=3D PAGE_SHIFT && + mapping->a_ops->is_partially_uptodate && + !iov_iter_is_pipe(iter) && + trylock_page(page)) { + loff_t pos =3D max(iocb->ki_pos, (loff_t)pg_index << PAGE_SHIFT); =20 -page_not_up_to_date: - /* Get exclusive access to the page ... */ - error =3D lock_page_for_iocb(iocb, page); - if (unlikely(error)) - return error; + if (page->mapping && + mapping->a_ops->is_partially_uptodate(page, + pos & ~PAGE_MASK, last - pos)) + goto unlock_page; + } else { + error =3D lock_page_for_iocb(iocb, page); + if (unlikely(error)) + return error; + } =20 -page_not_up_to_date_locked: /* Did it get truncated before we got the lock? */ if (!page->mapping) { unlock_page(page); @@ -2287,6 +2276,9 @@ static int filemap_make_page_uptodate(struct kiocb = *iocb, struct iov_iter *iter, if (PageUptodate(page)) goto unlock_page; return filemap_readpage(iocb, page); +unlock_page: + unlock_page(page); + return 0; } =20 static int filemap_new_page(struct kiocb *iocb, struct iov_iter *iter, --=20 2.28.0