Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2036709imm; Thu, 24 May 2018 04:55:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoLUxxBgVNJbcq/f/9STaPL1T0r3xaDtMe6wjJyx4gxOWDELWkuCwQuLnK4fv8bVWX6lYSQ X-Received: by 2002:a62:679a:: with SMTP id t26-v6mr7088774pfj.24.1527162943630; Thu, 24 May 2018 04:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527162943; cv=none; d=google.com; s=arc-20160816; b=kzuOPp0ILtmNkqtpLK4Z6HQ6bJM+jKwfCp24sKmg5yBR1mckKJ3dL3IjH1UjGhy/Au wewtLxizVYTKXfOJ8Q0b5HWNUZWr/H+qn/6kCdVuFwkykPoPYWBKo/ndvcQPVSZuoRHF JiFkZe3obF1+nyg3E9CB7YJU6odUbgJcGvss9ZiQXylt0E6y5GDALzHBIvrj/LEz5J2H UwbF2BHskdtAG+DHRE3+hqJmk3Ey4kWst7NNuPq/KKwxlzjfSQUHIiJxHRfCJ0glCAxW LKn1NjfCZE51usz+COBjFiFdVPDRD2ZuWzN1Zh595yiqECjdh/M+3g6bL80Nf25FmLGB B0Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=TGCnyIIuavAb9ps5nojjjwJXrHgjAMeEOMq0kHyZe34=; b=IVus15HO9guu0kHrTtr1Ep4FCqUG9/mWOFkBmpyFxDYZr1/wqoZCMYDxLVKJv0Q/uh 6/btmE7UPzyUY5yytAk1R7hvECvOwpC+cuP6Ua1+DjmsRNOchAq+KgkOVIuKnMdK9khA u0ZK/SGVY0/1P066naglLjAy7zpBwiIcXiOaEhCfo6pvfIX9NfpJXbpo9qdmWQ/Eq2yF a2/8Ot0sfR2lmSieyXYf1TQScXk1bsq5ie96khfFljmTH1hFD8tAHnUCgwq4tufEz1eo SegKKTABQjC/6UCdtecaQw/u7RXl90MOCJBKJ5r2fGBzkRa6phF7nDZGWc5DosZYT88a 1AVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b4uQkTV1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 e92-v6si20657624pld.601.2018.05.24.04.55.28; Thu, 24 May 2018 04:55:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=b4uQkTV1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967308AbeEXLyp (ORCPT + 99 others); Thu, 24 May 2018 07:54:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:57428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966621AbeEXJqQ (ORCPT ); Thu, 24 May 2018 05:46:16 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DDED2208D6; Thu, 24 May 2018 09:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155175; bh=7d4Fvj0JJlOTf/o9owi04KOOq1tbKrS8MsnQXExESpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b4uQkTV1XvXGLgkKx4SQCcfWn6A9n6g1tCa7431Q0N7IBj5MJobtcX/CA/IsFcRyh fkFWulP5Nn2bAi/kkG046T7+z0J0gMapPhLDAJOWTkjHWGOLWmIq+XyE8TM+XbDcMW sjiE/m2xlI7ZIubzm08Y045jQWPUR15x++1wlikY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mel Gorman , Jan Kara , Hugh Dickins , Andrew Morton , Linus Torvalds , Mel Gorman Subject: [PATCH 4.4 49/92] mm: filemap: remove redundant code in do_read_cache_page Date: Thu, 24 May 2018 11:38:26 +0200 Message-Id: <20180524093204.194122705@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mel Gorman commit 32b635298ff4e991d8d8f64dc23782b02eec29c3 upstream. do_read_cache_page and __read_cache_page duplicate page filler code when filling the page for the first time. This patch simply removes the duplicate logic. Signed-off-by: Mel Gorman Reviewed-by: Jan Kara Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Mel Gorman Signed-off-by: Greg Kroah-Hartman --- mm/filemap.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2215,7 +2215,7 @@ static struct page *wait_on_page_read(st return page; } -static struct page *__read_cache_page(struct address_space *mapping, +static struct page *do_read_cache_page(struct address_space *mapping, pgoff_t index, int (*filler)(void *, struct page *), void *data, @@ -2237,31 +2237,19 @@ repeat: /* Presumably ENOMEM for radix tree node */ return ERR_PTR(err); } + +filler: err = filler(data, page); if (err < 0) { page_cache_release(page); - page = ERR_PTR(err); - } else { - page = wait_on_page_read(page); + return ERR_PTR(err); } - } - return page; -} - -static struct page *do_read_cache_page(struct address_space *mapping, - pgoff_t index, - int (*filler)(void *, struct page *), - void *data, - gfp_t gfp) -{ - struct page *page; - int err; - -retry: - page = __read_cache_page(mapping, index, filler, data, gfp); - if (IS_ERR(page)) - return page; + page = wait_on_page_read(page); + if (IS_ERR(page)) + return page; + goto out; + } if (PageUptodate(page)) goto out; @@ -2269,21 +2257,14 @@ retry: if (!page->mapping) { unlock_page(page); page_cache_release(page); - goto retry; + goto repeat; } if (PageUptodate(page)) { unlock_page(page); goto out; } - err = filler(data, page); - if (err < 0) { - page_cache_release(page); - return ERR_PTR(err); - } else { - page = wait_on_page_read(page); - if (IS_ERR(page)) - return page; - } + goto filler; + out: mark_page_accessed(page); return page;