From patchwork Thu Jun 1 09:32:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9759065 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 0E9A560390 for ; Thu, 1 Jun 2017 09:37:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E40A9284F1 for ; Thu, 1 Jun 2017 09:37:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8307284FF; Thu, 1 Jun 2017 09:37:24 +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 5192A284F1 for ; Thu, 1 Jun 2017 09:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751978AbdFAJhX (ORCPT ); Thu, 1 Jun 2017 05:37:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:50783 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751629AbdFAJdT (ORCPT ); Thu, 1 Jun 2017 05:33:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5F89DADB5; Thu, 1 Jun 2017 09:33:14 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 323CA1E3576; 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 12/35] xfs: Use pagevec_lookup_range() in xfs_find_get_desired_pgoff() Date: Thu, 1 Jun 2017 11:32:22 +0200 Message-Id: <20170601093245.29238-13-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 We want only pages from given range in xfs_find_get_desired_pgoff(). Use pagevec_lookup_range() instead of pagevec_lookup() and remove unnecessary code. Note that the check for getting less pages than desired can be removed because index gets updated by pagevec_lookup_range(). CC: Darrick J. Wong CC: linux-xfs@vger.kernel.org Signed-off-by: Jan Kara --- fs/xfs/xfs_file.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 487342078fc7..f9343dac7ff9 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1045,13 +1045,11 @@ xfs_find_get_desired_pgoff( endoff = XFS_FSB_TO_B(mp, map->br_startoff + map->br_blockcount); end = (endoff - 1) >> PAGE_SHIFT; do { - int want; unsigned nr_pages; unsigned int i; - want = min_t(pgoff_t, end - index, PAGEVEC_SIZE - 1) + 1; - nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &index, - want); + nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping, + &index, end, PAGEVEC_SIZE); if (nr_pages == 0) break; @@ -1075,9 +1073,6 @@ xfs_find_get_desired_pgoff( *offset = lastoff; goto out; } - /* Searching done if the page index is out of range. */ - if (page->index > end) - goto out; lock_page(page); /* @@ -1117,13 +1112,6 @@ xfs_find_get_desired_pgoff( unlock_page(page); } - /* - * The number of returned pages less than our desired, search - * done. - */ - if (nr_pages < want) - break; - pagevec_release(&pvec); } while (index <= end);