From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: [PATCH v5 27/78] page cache: Convert page deletion to XArray Date: Fri, 15 Dec 2017 14:03:59 -0800 Message-ID: <20171215220450.7899-28-willy@infradead.org> References: <20171215220450.7899-1-willy@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ePy7G-0002vt-Rx for linux-f2fs-devel@lists.sourceforge.net; Fri, 15 Dec 2017 22:06:02 +0000 Received: from bombadil.infradead.org ([65.50.211.133]) by sfi-mx-2.v28.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) id 1ePy7F-0007Dh-Rj for linux-f2fs-devel@lists.sourceforge.net; Fri, 15 Dec 2017 22:06:02 +0000 In-Reply-To: <20171215220450.7899-1-willy@infradead.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: linux-kernel@vger.kernel.org Cc: Jens Axboe , linux-xfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-raid@vger.kernel.org, Matthew Wilcox , Marc Zyngier , linux-usb@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, David Howells , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ross Zwisler , Rehas Sachdeva , Shaohua Li , linux-btrfs@vger.kernel.org From: Matthew Wilcox The code is slightly shorter and simpler. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 91df92f5c96d..c9bc0dee0154 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -115,27 +115,25 @@ static void page_cache_tree_delete(struct address_space *mapping, struct page *page, void *shadow) { - int i, nr; + XA_STATE(xas, &mapping->pages, page->index); + unsigned int i, nr; - /* hugetlb pages are represented by one entry in the radix tree */ + xas_set_update(&xas, workingset_lookup_update(mapping)); + + /* hugetlb pages are represented by a single entry in the xarray */ nr = PageHuge(page) ? 1 : hpage_nr_pages(page); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageTail(page), page); VM_BUG_ON_PAGE(nr != 1 && shadow, page); - for (i = 0; i < nr; i++) { - struct radix_tree_node *node; - void **slot; - - __radix_tree_lookup(&mapping->pages, page->index + i, - &node, &slot); - - VM_BUG_ON_PAGE(!node && nr != 1, page); - - radix_tree_clear_tags(&mapping->pages, node, slot); - __radix_tree_replace(&mapping->pages, node, slot, shadow, - workingset_lookup_update(mapping)); + i = nr; +repeat: + xas_store(&xas, shadow); + xas_init_tags(&xas); + if (--i) { + xas_next(&xas); + goto repeat; } page->mapping = NULL; -- 2.15.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot