Commit dca33729 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] tmpfs: shmem_file_write EFAULT

From: Hugh Dickins <hugh@veritas.com>

generic_file_aio_write_nolock has recently been corrected for when partial
writes hit -EFAULT: now bring shmem_file_write into line.
parent 9001a6cb
......@@ -1186,30 +1186,32 @@ shmem_file_write(struct file *file, const char __user *buf, size_t count, loff_t
left = __copy_from_user(kaddr + offset, buf, bytes);
kunmap(page);
}
written += bytes;
count -= bytes;
pos += bytes;
buf += bytes;
if (pos > inode->i_size)
inode->i_size = pos;
flush_dcache_page(page);
if (left) {
set_page_dirty(page);
if (!PageReferenced(page))
SetPageReferenced(page);
page_cache_release(page);
if (left) {
pos -= left;
written -= left;
err = -EFAULT;
break;
}
if (!PageReferenced(page))
SetPageReferenced(page);
set_page_dirty(page);
page_cache_release(page);
/*
* Our dirty pages are not counted in nr_dirty,
* and we do not attempt to balance dirty pages.
*/
written += bytes;
count -= bytes;
pos += bytes;
buf += bytes;
if (pos > inode->i_size)
inode->i_size = pos;
cond_resched();
} while (count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment