From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: [PATCH 09/35] ext4: Use pagevec_lookup_range() in ext4_find_unwritten_pgoff() Date: Thu, 1 Jun 2017 11:32:19 +0200 Message-ID: <20170601093245.29238-10-jack@suse.cz> References: <20170601093245.29238-1-jack@suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Ue6IxYKc+3lTjxXhXsFrf9bp4Z/BHqjm9tzTH6gpMb8=; b=NbpxS42aQSwwa3m3pBA7NKk/l14gkTeMhqORKzEEzFLUQoFMUP9tW2iv12hjl8q63QBzas8j49gf94SZVdCodcRoKEc9BdTtAvngNKamzZvACakk+E2KbMRHCrOHgn/K2L3yjETwo9WtMFx8raC3UsoJ+pbDv+UYRZszT52TxJU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=Ue6IxYKc+3lTjxXhXsFrf9bp4Z/BHqjm9tzTH6gpMb8=; b=S1tI0pKzQTAYmwZDGkFCOTxTZyyFca9bdJ91IZ4fjkPi/Qr3i29msK5KPwBWfQhyB2N7gGz4hP6aK1vIycXno2aie5JklZ+42O9R0M+i4CF30Zfqf+YoaV8W56B8N5N+xX4GB+lZV357se1lKAIl0p105cGLGzcsdfDE+h4xmHU=; In-Reply-To: <20170601093245.29238-1-jack@suse.cz> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: linux-mm@kvack.org Cc: cluster-devel@redhat.com, linux-nilfs@vger.kernel.org, tytso@mit.edu, linux-xfs@vger.kernel.org, "Yan, Zheng" , Jan Kara , "Darrick J . Wong" , Hugh Dickins , linux-f2fs-devel@lists.sourceforge.net, David Howells , David Sterba , ceph-devel@vger.kernel.org, Nadia Yvette Chambers , Ryusuke Konishi , Bob Peterson , Jaegeuk Kim , Ilya Dryomov , linux-ext4@vger.kernel.org, linux-afs@lists.infradead.org, linux-btrfs@vger.kernel.org Use pagevec_lookup_range() in ext4_find_unwritten_pgoff() since we are interested only in pages in the given range. Simplify the logic as a result of not getting pages out of range and index getting automatically advanced. CC: linux-ext4@vger.kernel.org CC: "Theodore Ts'o" Signed-off-by: Jan Kara --- fs/ext4/file.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index ddca17c7875a..6821070a388b 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -478,12 +478,11 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, pagevec_init(&pvec, 0); do { - int i, num; + int i; unsigned long nr_pages; - num = min_t(pgoff_t, end - index, PAGEVEC_SIZE); - nr_pages = pagevec_lookup(&pvec, inode->i_mapping, &index, - (pgoff_t)num); + nr_pages = pagevec_lookup_range(&pvec, inode->i_mapping, + &index, end, PAGEVEC_SIZE); if (nr_pages == 0) break; @@ -502,9 +501,6 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, goto out; } - if (page->index > end) - goto out; - lock_page(page); if (unlikely(page->mapping != inode->i_mapping)) { @@ -544,12 +540,10 @@ static int ext4_find_unwritten_pgoff(struct inode *inode, unlock_page(page); } - /* The no. of pages is less than our desired, we are done. */ - if (nr_pages < num) - break; pagevec_release(&pvec); } while (index <= end); + /* There are no pages upto endoff - that would be a hole in there. */ if (whence == SEEK_HOLE && lastoff < endoff) { found = 1; *offset = lastoff; -- 2.12.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot