[Devel] [PATCH rh7] mm: fix truncate_inode_pages_range() for filesystems without buffer-heads

Maxim Patlasov mpatlasov at virtuozzo.com
Wed Aug 3 16:46:07 PDT 2016


File systems who don't use buffer-heads must not suffer from
the lack of ->invalidatepage_range() adress_space operation.
The logic of partial start/end truncation already implemented
in truncate_inode_pages_range() must suffice for them.

https://jira.sw.ru/browse/PSBM-50629

Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 mm/truncate.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mm/truncate.c b/mm/truncate.c
index 8dcfe94..cc852aa 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -274,6 +274,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
 	pgoff_t		indices[PAGEVEC_SIZE];
 	pgoff_t		index;
 	int		i;
+	int		bug_if_page_has_bh = 0;
 
 	cleancache_invalidate_inode(mapping);
 	if (mapping->nrpages == 0 && mapping->nrshadows == 0)
@@ -283,7 +284,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
 	partial_start = lstart & (PAGE_CACHE_SIZE - 1);
 	partial_end = (lend + 1) & (PAGE_CACHE_SIZE - 1);
 	if (!inode_has_invalidate_range(mapping->host))
-		BUG_ON(partial_end);
+		bug_if_page_has_bh = 1;
 
 	/*
 	 * 'start' and 'end' always covers the range of pages to be fully
@@ -368,9 +369,11 @@ void truncate_inode_pages_range(struct address_space *mapping,
 			wait_on_page_writeback(page);
 			zero_user_segment(page, 0, partial_end);
 			cleancache_invalidate_page(mapping, page);
-			if (page_has_private(page))
+			if (page_has_private(page)) {
+				BUG_ON(bug_if_page_has_bh);
 				do_invalidatepage_range(page, 0,
 							partial_end);
+			}
 			unlock_page(page);
 			page_cache_release(page);
 		}



More information about the Devel mailing list