Revert "shmem: fix splicing from a hole while it's punched"

This reverts commit 21618a8f0f.

Change-Id: I1da9a6dbb1cb829c3964c3c29210872920a15898
This commit is contained in:
Arne Coucheron 2019-10-03 04:04:47 +02:00 committed by surblazer
parent c9f76626c3
commit 010eab88fb

View file

@ -501,19 +501,22 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
} }
index = start; index = start;
while (index <= end) { for ( ; ; ) {
cond_resched(); cond_resched();
pvec.nr = shmem_find_get_pages_and_swap(mapping, index, pvec.nr = shmem_find_get_pages_and_swap(mapping, index,
min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1, min(end - index, (pgoff_t)PAGEVEC_SIZE - 1) + 1,
pvec.pages, indices); pvec.pages, indices);
if (!pvec.nr) { if (!pvec.nr) {
/* If all gone or hole-punch, we're done */ if (index == start)
if (index == start || end != -1)
break; break;
/* But if truncating, restart to make sure all gone */
index = start; index = start;
continue; continue;
} }
if (index == start && indices[0] > end) {
shmem_deswap_pagevec(&pvec);
pagevec_release(&pvec);
break;
}
mem_cgroup_uncharge_start(); mem_cgroup_uncharge_start();
for (i = 0; i < pagevec_count(&pvec); i++) { for (i = 0; i < pagevec_count(&pvec); i++) {
struct page *page = pvec.pages[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; break;
if (radix_tree_exceptional_entry(page)) { if (radix_tree_exceptional_entry(page)) {
if (shmem_free_swap(mapping, index, page)) { nr_swaps_freed += !shmem_free_swap(mapping,
/* Swap was replaced by page: retry */ index, page);
index--;
break;
}
nr_swaps_freed++;
continue; continue;
} }
@ -536,11 +535,6 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
if (page->mapping == mapping) { if (page->mapping == mapping) {
VM_BUG_ON(PageWriteback(page)); VM_BUG_ON(PageWriteback(page));
truncate_inode_page(mapping, page); truncate_inode_page(mapping, page);
} else {
/* Page was replaced by swap: retry */
unlock_page(page);
index--;
break;
} }
unlock_page(page); unlock_page(page);
} }