mm,thp: avoid writes to file with THP in pagecache
[linux-block.git] / fs / open.c
index a59abe3c669ae13ac7f3fa68bc0fb5f54a781ee4..c60cd22cc052a41d2e0b2b1f954051268ae10bf8 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -818,6 +818,14 @@ static int do_dentry_open(struct file *f,
                if (!f->f_mapping->a_ops || !f->f_mapping->a_ops->direct_IO)
                        return -EINVAL;
        }
+
+       /*
+        * XXX: Huge page cache doesn't support writing yet. Drop all page
+        * cache for this file before processing writes.
+        */
+       if ((f->f_mode & FMODE_WRITE) && filemap_nr_thps(inode->i_mapping))
+               truncate_pagecache(inode, 0);
+
        return 0;
 
 cleanup_all: