[Devel] [PATCH RHEL7 COMMIT] tcache: invalidate page on unsuccessful put

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jul 17 06:53:06 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.25
------>
commit 34d63b9f7899ff2872f60b0941e814aaefc4d301
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Fri Jul 17 17:53:06 2015 +0400

    tcache: invalidate page on unsuccessful put
    
    If cleancache_put fails, the backend must invalidate the page at the
    given offset, otherwise the following cleancache_get will receive stale
    data resulting in data corruption.
    
    This patch makes tcache_cleancache_put_page meet this requirement.
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    Reviewed-by: Kirill Tkhai <ktkhai at odin.com>
---
 mm/tcache.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/mm/tcache.c b/mm/tcache.c
index 8de3339..6c1e9e7 100644
--- a/mm/tcache.c
+++ b/mm/tcache.c
@@ -834,25 +834,23 @@ static void tcache_cleancache_put_page(int pool_id,
 				       pgoff_t index, struct page *page)
 {
 	struct tcache_node *node;
-	struct page *cache_page;
-
-	if (!tcache_active)
-		return;
-
-	cache_page = tcache_alloc_page();
-	if (!cache_page)
-		return;
-
-	copy_highpage(cache_page, page);
+	struct page *cache_page = NULL;
 
 	node = tcache_get_node_and_pool(pool_id, &key, true);
 	if (node) {
-		/* cleancache does not care about failures */
-		(void)tcache_attach_page(node, index, cache_page);
+		if (tcache_active)
+			cache_page = tcache_alloc_page();
+		if (cache_page) {
+			copy_highpage(cache_page, page);
+			/* cleancache does not care about failures */
+			(void)tcache_attach_page(node, index, cache_page);
+		} else
+			cache_page = tcache_detach_page(node, index);
 		tcache_put_node_and_pool(node);
 	}
 
-	put_page(cache_page);
+	if (cache_page)
+		put_page(cache_page);
 }
 
 static int tcache_cleancache_get_page(int pool_id,



More information about the Devel mailing list