[Devel] [PATCH rh7 2/4] tcache: invalidate page on unsuccessful put
Vladimir Davydov
vdavydov at parallels.com
Thu Jul 16 02:03:30 PDT 2015
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>
---
mm/tcache.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/mm/tcache.c b/mm/tcache.c
index 8de333905f81..6c1e9e7e047c 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,
--
2.1.4
More information about the Devel
mailing list