]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
fs/ocfs2: remove page cache for converted direct write
authorWengang Wang <wen.gang.wang@oracle.com>
Tue, 23 Jan 2018 17:17:39 +0000 (09:17 -0800)
committerJack Vogel <jack.vogel@oracle.com>
Wed, 24 Jan 2018 22:44:50 +0000 (14:44 -0800)
Remove the page cache range for the writes converted from direct IO to
buffered IO.

orabug: 27431376
Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: Ashish Samant <ashish.samant@oracle.com>
fs/ocfs2/file.c

index 53e71d2e0958e7955eb4bce3db4dc71e06a7094d..52b36b44ac890b5aae0a3a44ebdc5fb8e8fc1e75 100644 (file)
@@ -2322,7 +2322,7 @@ static ssize_t ocfs2_file_write_iter(struct kiocb *iocb,
        ssize_t written = 0;
        ssize_t ret;
        size_t count = iov_iter_count(from), orig_count;
-       loff_t old_size;
+       loff_t old_size, orig_pos;
        u32 old_clusters;
        struct file *file = iocb->ki_filp;
        struct inode *inode = file_inode(file);
@@ -2343,6 +2343,7 @@ static ssize_t ocfs2_file_write_iter(struct kiocb *iocb,
 
        appending = iocb->ki_flags & IOCB_APPEND ? 1 : 0;
        direct_io = iocb->ki_flags & IOCB_DIRECT ? 1 : 0;
+       orig_pos = iocb->ki_pos;
 
        mutex_lock(&inode->i_mutex);
 
@@ -2526,6 +2527,13 @@ out_sems:
        if (have_alloc_sem)
                ocfs2_iocb_clear_sem_locked(iocb);
 
+       if (dropped_dio) {
+               loff_t end = orig_pos + orig_count - 1;
+
+               invalidate_inode_pages2_range(file->f_mapping,
+                                             orig_pos >> PAGE_CACHE_SHIFT,
+                                             end >> PAGE_CACHE_SHIFT);
+       }
        mutex_unlock(&inode->i_mutex);
 
        if (written)