From patchwork Mon Jan 25 10:03:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 8106031 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 31B739F440 for ; Mon, 25 Jan 2016 10:08:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59F7320279 for ; Mon, 25 Jan 2016 10:08:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C584202F8 for ; Mon, 25 Jan 2016 10:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932386AbcAYKIu (ORCPT ); Mon, 25 Jan 2016 05:08:50 -0500 Received: from outbound-smtp03.blacknight.com ([81.17.249.16]:58509 "EHLO outbound-smtp03.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932385AbcAYKIs (ORCPT ); Mon, 25 Jan 2016 05:08:48 -0500 X-Greylist: delayed 321 seconds by postgrey-1.27 at vger.kernel.org; Mon, 25 Jan 2016 05:08:48 EST Received: from mail.blacknight.com (pemlinmail03.blacknight.ie [81.17.254.16]) by outbound-smtp03.blacknight.com (Postfix) with ESMTPS id 4EC4F987B7 for ; Mon, 25 Jan 2016 10:03:25 +0000 (UTC) Received: (qmail 9532 invoked from network); 25 Jan 2016 10:03:25 -0000 Received: from unknown (HELO stampy.163woodhaven.lan) (mgorman@techsingularity.net@[37.228.246.231]) by 81.17.254.9 with ESMTPA; 25 Jan 2016 10:03:25 -0000 From: Mel Gorman To: Andrew Morton Cc: Hugh Dickins , Jan Kara , Linux-FSDevel , Linux-MM , LKML , Mel Gorman Subject: [PATCH 1/2] mm: filemap: Remove redundant code in do_read_cache_page Date: Mon, 25 Jan 2016 10:03:23 +0000 Message-Id: <1453716204-20409-2-git-send-email-mgorman@techsingularity.net> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1453716204-20409-1-git-send-email-mgorman@techsingularity.net> References: <1453716204-20409-1-git-send-email-mgorman@techsingularity.net> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP do_read_cache_page and __read_cache_page duplicates 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 --- mm/filemap.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index bc943867d68c..aa38593d0cd5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2283,7 +2283,7 @@ static struct page *wait_on_page_read(struct page *page) 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, @@ -2305,31 +2305,19 @@ static struct page *__read_cache_page(struct address_space *mapping, /* 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; @@ -2337,21 +2325,14 @@ static struct page *do_read_cache_page(struct address_space *mapping, 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;