[Devel,RHEL7,COMMIT] cleancache: avoid pointless cleancache_invalidate_inode() calls.

Submitted by Konstantin Khorenko on April 13, 2017, 10:41 a.m.

Details

Message ID 201704131041.v3DAf5EN005213@finist_cl7.x64_64.work.ct
State New
Series "fs/cleancache: fix data invalidation in the cleancache during direct_io"
Headers show

Commit Message

Konstantin Khorenko April 13, 2017, 10:41 a.m.
The commit is pushed to "branch-rh7-3.10.0-514.10.2.vz7.29.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.10.2.vz7.29.15
------>
commit 456aa581f3cd05b156995b2b03a498133733b25f
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Thu Apr 13 14:41:05 2017 +0400

    cleancache: avoid pointless cleancache_invalidate_inode() calls.
    
    Per Alexey: there is no point in invalidation of cleancache on entry to
    truncate_inode_pages_range/invalidate_inode_pages2_range routines.
    It is waste of time, cleancache will be repopulated by invalidation
    (which it stupid, of course). It is enough to do this once at exit.
    
    https://jira.sw.ru/browse/PSBM-63908
    
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/truncate.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/mm/truncate.c b/mm/truncate.c
index ce4b1d8..1db0425 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -285,9 +285,8 @@  void truncate_inode_pages_range(struct address_space *mapping,
 	int		i;
 	int		bug_if_page_has_bh = 0;
 
-	cleancache_invalidate_inode(mapping);
 	if (mapping->nrpages == 0 && mapping->nrexceptional == 0)
-		return;
+		goto out;
 
 	/* Offsets within partial pages */
 	partial_start = lstart & (PAGE_CACHE_SIZE - 1);
@@ -390,7 +389,7 @@  void truncate_inode_pages_range(struct address_space *mapping,
 	 * will be released, just zeroed, so we can bail out now.
 	 */
 	if (start >= end)
-		return;
+		goto out;
 
 	index = start;
 	for ( ; ; ) {
@@ -431,6 +430,8 @@  void truncate_inode_pages_range(struct address_space *mapping,
 		pagevec_release(&pvec);
 		index++;
 	}
+
+out:
 	cleancache_invalidate_inode(mapping);
 }
 EXPORT_SYMBOL(truncate_inode_pages_range);
@@ -627,10 +628,8 @@  int invalidate_inode_pages2_range(struct address_space *mapping,
 	int ret2 = 0;
 	int did_range_unmap = 0;
 
-	cleancache_invalidate_inode(mapping);
-
 	if (mapping->nrpages == 0 && mapping->nrexceptional == 0)
-		return 0;
+		goto out;
 
 	pagevec_init(&pvec, 0);
 	index = start;
@@ -692,6 +691,8 @@  int invalidate_inode_pages2_range(struct address_space *mapping,
 		cond_resched();
 		index++;
 	}
+
+out:
 	cleancache_invalidate_inode(mapping);
 	return ret;
 }