From patchwork Tue Jan 26 14:09:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 8122931 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 3F6669F1C0 for ; Tue, 26 Jan 2016 14:09:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 540ED20259 for ; Tue, 26 Jan 2016 14:09:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9406520256 for ; Tue, 26 Jan 2016 14:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756112AbcAZOJe (ORCPT ); Tue, 26 Jan 2016 09:09:34 -0500 Received: from outbound-smtp07.blacknight.com ([46.22.139.12]:52774 "EHLO outbound-smtp07.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755000AbcAZOJd (ORCPT ); Tue, 26 Jan 2016 09:09:33 -0500 Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp07.blacknight.com (Postfix) with ESMTPS id B4C261C1D14 for ; Tue, 26 Jan 2016 14:09:31 +0000 (GMT) Received: (qmail 4587 invoked from network); 26 Jan 2016 14:09:31 -0000 Received: from unknown (HELO stampy.163woodhaven.lan) (mgorman@techsingularity.net@[37.228.246.231]) by 81.17.254.9 with ESMTPA; 26 Jan 2016 14:09:31 -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: Tue, 26 Jan 2016 14:09:29 +0000 Message-Id: <1453817370-10399-2-git-send-email-mgorman@techsingularity.net> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1453817370-10399-1-git-send-email-mgorman@techsingularity.net> References: <1453817370-10399-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;