From patchwork Thu Jun 1 09:32:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9758941 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8ABD76038E for ; Thu, 1 Jun 2017 09:33:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F71D284C3 for ; Thu, 1 Jun 2017 09:33:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63D07284EA; Thu, 1 Jun 2017 09:33:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B843284C3 for ; Thu, 1 Jun 2017 09:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751811AbdFAJdy (ORCPT ); Thu, 1 Jun 2017 05:33:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:50903 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751675AbdFAJdW (ORCPT ); Thu, 1 Jun 2017 05:33:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 496ACADF2; Thu, 1 Jun 2017 09:33:15 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 6128F1E35B8; Thu, 1 Jun 2017 11:33:12 +0200 (CEST) From: Jan Kara To: Cc: Hugh Dickins , David Howells , linux-afs@lists.infradead.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org, Bob Peterson , cluster-devel@redhat.com, Jaegeuk Kim , linux-f2fs-devel@lists.sourceforge.net, tytso@mit.edu, linux-ext4@vger.kernel.org, Ilya Dryomov , "Yan, Zheng" , ceph-devel@vger.kernel.org, linux-btrfs@vger.kernel.org, David Sterba , "Darrick J . Wong" , linux-xfs@vger.kernel.org, Nadia Yvette Chambers , Jan Kara Subject: [PATCH 31/35] shmem: Convert to pagevec_lookup_entries_range() Date: Thu, 1 Jun 2017 11:32:41 +0200 Message-Id: <20170601093245.29238-32-jack@suse.cz> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170601093245.29238-1-jack@suse.cz> References: <20170601093245.29238-1-jack@suse.cz> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert radix tree scanners to use pagevec_lookup_entries_range() and find_get_entries_range() since they all want only entries from given range. CC: Hugh Dickins Signed-off-by: Jan Kara --- mm/shmem.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index f9c4afbdd70c..e5ea044aae24 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -768,16 +768,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, pagevec_init(&pvec, 0); index = start; while (index < end) { - if (!pagevec_lookup_entries(&pvec, mapping, &index, - min(end - index, (pgoff_t)PAGEVEC_SIZE), - indices)) + if (!pagevec_lookup_entries_range(&pvec, mapping, &index, + end - 1, PAGEVEC_SIZE, indices)) break; for (i = 0; i < pagevec_count(&pvec); i++) { struct page *page = pvec.pages[i]; - if (indices[i] >= end) - break; - if (radix_tree_exceptional_entry(page)) { if (unfalloc) continue; @@ -860,9 +856,8 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, cond_resched(); - if (!pagevec_lookup_entries(&pvec, mapping, &index, - min(end - index, (pgoff_t)PAGEVEC_SIZE), - indices)) { + if (!pagevec_lookup_entries_range(&pvec, mapping, &index, + end - 1, PAGEVEC_SIZE, indices)) { /* If all gone or hole-punch or unfalloc, we're done */ if (lookup_start == start || end != -1) break; @@ -873,9 +868,6 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, for (i = 0; i < pagevec_count(&pvec); i++) { struct page *page = pvec.pages[i]; - if (indices[i] >= end) - break; - if (radix_tree_exceptional_entry(page)) { if (unfalloc) continue; @@ -2494,9 +2486,9 @@ static pgoff_t shmem_seek_hole_data(struct address_space *mapping, pagevec_init(&pvec, 0); pvec.nr = 1; /* start small: we may be there already */ - while (!done) { + while (!done && index < end) { last = index; - pvec.nr = find_get_entries(mapping, &index, + pvec.nr = find_get_entries_range(mapping, &index, end - 1, pvec.nr, pvec.pages, indices); if (!pvec.nr) { if (whence == SEEK_DATA) @@ -2516,8 +2508,7 @@ static pgoff_t shmem_seek_hole_data(struct address_space *mapping, if (!PageUptodate(page)) page = NULL; } - if (last >= end || - (page && whence == SEEK_DATA) || + if ((page && whence == SEEK_DATA) || (!page && whence == SEEK_HOLE)) { done = true; break;