s390/pkey: fix memory leak within _copy_apqns_from_user()
[linux-2.6-microblaze.git] / fs / open.c
index a59abe3..b62f5c0 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -776,7 +776,7 @@ static int do_dentry_open(struct file *f,
                f->f_mode |= FMODE_ATOMIC_POS;
 
        f->f_op = fops_get(inode->i_fop);
-       if (unlikely(WARN_ON(!f->f_op))) {
+       if (WARN_ON(!f->f_op)) {
                error = -ENODEV;
                goto cleanup_all;
        }
@@ -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: