mm: fix data corruption due to stale mmap reads
[sfrench/cifs-2.6.git] / mm / truncate.c
index 706cff171a15323aaba9e7ebc502273e0145c4ed..6479ed2afc53fb9dd8d9719051ea77e7a5b200af 100644 (file)
@@ -686,7 +686,17 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
                cond_resched();
                index++;
        }
-
+       /*
+        * For DAX we invalidate page tables after invalidating radix tree.  We
+        * could invalidate page tables while invalidating each entry however
+        * that would be expensive. And doing range unmapping before doesn't
+        * work as we have no cheap way to find whether radix tree entry didn't
+        * get remapped later.
+        */
+       if (dax_mapping(mapping)) {
+               unmap_mapping_range(mapping, (loff_t)start << PAGE_SHIFT,
+                                   (loff_t)(end - start + 1) << PAGE_SHIFT, 0);
+       }
 out:
        cleancache_invalidate_inode(mapping);
        return ret;