From 010eab88fb23fa030a5bd03be817e0e62d805491 Mon Sep 17 00:00:00 2001 From: Arne Coucheron Date: Thu, 3 Oct 2019 04:04:47 +0200 Subject: [PATCH] Revert "shmem: fix splicing from a hole while it's punched" This reverts commit 21618a8f0f46ff327acd6a079bc05c065561e4c0. Change-Id: I1da9a6dbb1cb829c3964c3c29210872920a15898 --- mm/shmem.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 374f845652a7..b7cc0c72bade 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -501,19 +501,22 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) } index = start; - while (index <= end) { + for ( ; ; ) { cond_resched(); pvec.nr = shmem_find_get_pages_and_swap(mapping, index, min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1, pvec.pages, indices); if (!pvec.nr) { - /* If all gone or hole-punch, we're done */ - if (index == start || end != -1) + if (index == start) break; - /* But if truncating, restart to make sure all gone */ index = start; continue; } + if (index == start && indices[0] > end) { + shmem_deswap_pagevec(&pvec); + pagevec_release(&pvec); + break; + } mem_cgroup_uncharge_start(); for (i = 0; i < pagevec_count(&pvec); i++) { struct page *page = pvec.pages[i]; @@ -523,12 +526,8 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) break; if (radix_tree_exceptional_entry(page)) { - if (shmem_free_swap(mapping, index, page)) { - /* Swap was replaced by page: retry */ - index--; - break; - } - nr_swaps_freed++; + nr_swaps_freed += !shmem_free_swap(mapping, + index, page); continue; } @@ -536,11 +535,6 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) if (page->mapping == mapping) { VM_BUG_ON(PageWriteback(page)); truncate_inode_page(mapping, page); - } else { - /* Page was replaced by swap: retry */ - unlock_page(page); - index--; - break; } unlock_page(page); }