ocfs2: make __ocfs2_page_mkwrite handle file end properly.
__ocfs2_page_mkwrite now is broken in handling file end. 1. the last page should be the page contains i_size - 1. 2. the len in the last page is also calculated wrong. So change them accordingly. Acked-by: Mark Fasheh <mfasheh@suse.com> Signed-off-by: Tao Ma <tao.ma@oracle.com>
This commit is contained in:
@@ -74,9 +74,11 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh,
|
|||||||
/*
|
/*
|
||||||
* Another node might have truncated while we were waiting on
|
* Another node might have truncated while we were waiting on
|
||||||
* cluster locks.
|
* cluster locks.
|
||||||
|
* We don't check size == 0 before the shift. This is borrowed
|
||||||
|
* from do_generic_file_read.
|
||||||
*/
|
*/
|
||||||
last_index = size >> PAGE_CACHE_SHIFT;
|
last_index = (size - 1) >> PAGE_CACHE_SHIFT;
|
||||||
if (page->index > last_index) {
|
if (unlikely(!size || page->index > last_index)) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -107,7 +109,7 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh,
|
|||||||
* because the "write" would invalidate their data.
|
* because the "write" would invalidate their data.
|
||||||
*/
|
*/
|
||||||
if (page->index == last_index)
|
if (page->index == last_index)
|
||||||
len = size & ~PAGE_CACHE_MASK;
|
len = ((size - 1) & ~PAGE_CACHE_MASK) + 1;
|
||||||
|
|
||||||
ret = ocfs2_write_begin_nolock(mapping, pos, len, 0, &locked_page,
|
ret = ocfs2_write_begin_nolock(mapping, pos, len, 0, &locked_page,
|
||||||
&fsdata, di_bh, page);
|
&fsdata, di_bh, page);
|
||||||
|
Reference in New Issue
Block a user