[Devel,RHEL7,COMMIT] mm: fix truncate_inode_pages_range() for filesystems without buffer-heads

Submitted by Konstantin Khorenko on Aug. 8, 2016, 9:51 a.m.

Details

Message ID 201608080951.u789pp6M014112@finist_cl7.x64_64.work.ct
State New
Series "mm: fix truncate_inode_pages_range() for filesystems without buffer-heads"
Headers show

Commit Message

Konstantin Khorenko Aug. 8, 2016, 9:51 a.m.
The commit is pushed to "branch-rh7-3.10.0-327.22.2.vz7.16.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.22.2.vz7.16.3
------>
commit b0847057c5f8696027e9f2a241cb1026674ad6dc
Author: Maxim Patlasov <mpatlasov@virtuozzo.com>
Date:   Mon Aug 8 13:51:51 2016 +0400

    mm: fix truncate_inode_pages_range() for filesystems without buffer-heads
    
    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@virtuozzo.com>
---
 mm/truncate.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

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);
 		}