aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/vfs_compat.h
diff options
context:
space:
mode:
authorPrasad Joshi <[email protected]>2011-06-25 13:30:29 +0100
committerBrian Behlendorf <[email protected]>2011-06-27 09:59:19 -0700
commitb312979252c5b566d2f59febcda67f309637e18c (patch)
tree7a9950357582ef20835f99fb565da1cef12fd135 /include/linux/vfs_compat.h
parent560bcf9d14a63e2cef4dd49d61399c8a865c1348 (diff)
Tear down and flush the mmap region
The inode eviction should unmap the pages associated with the inode. These pages should also be flushed to disk to avoid the data loss. Therefore, use truncate_setsize() in evict_inode() to release the pagecache. The API truncate_setsize() was added in 2.6.35 kernel. To ensure compatibility with the old kernel, the patch defines its own truncate_setsize function. Signed-off-by: Prasad Joshi <[email protected]> Closes #255
Diffstat (limited to 'include/linux/vfs_compat.h')
-rw-r--r--include/linux/vfs_compat.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h
index dce2b6f28..1d8a523cd 100644
--- a/include/linux/vfs_compat.h
+++ b/include/linux/vfs_compat.h
@@ -41,4 +41,25 @@ insert_inode_locked(struct inode *ip)
}
#endif /* HAVE_INSERT_INODE_LOCKED */
+/*
+ * 2.6.35 API change,
+ * Add truncate_setsize() if it is not exported by the Linux kernel.
+ *
+ * Truncate the inode and pages associated with the inode. The pages are
+ * unmapped and removed from cache.
+ */
+#ifndef HAVE_TRUNCATE_SETSIZE
+static inline void
+truncate_setsize(struct inode *ip, loff_t new)
+{
+ struct address_space *mapping = ip->i_mapping;
+
+ i_size_write(ip, new);
+
+ unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
+ truncate_inode_pages(mapping, new);
+ unmap_mapping_range(mapping, new + PAGE_SIZE - 1, 0, 1);
+}
+#endif /* HAVE_TRUNCATE_SETSIZE */
+
#endif /* _ZFS_VFS_H */