diff --git a/mm/filemap.c b/mm/filemap.c index 7b84dc8..bf7cf6c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2041,6 +2041,14 @@ generic_file_direct_write(struct kiocb * mark_inode_dirty(inode); } *ppos = end; + } else if (written < 0) { + loff_t isize = i_size_read(inode); + /* + * generic_file_direct_IO() may have instantiated a few blocks + * outside i_size. Trim these off again. + */ + if (pos + count > isize) + vmtruncate(inode, isize); } /*