aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/mmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/mmap.c')
-rw-r--r--fs/ocfs2/mmap.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index af2b8fe1f139..4c18f4ad93b4 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -74,9 +74,11 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh,
74 /* 74 /*
75 * Another node might have truncated while we were waiting on 75 * Another node might have truncated while we were waiting on
76 * cluster locks. 76 * cluster locks.
77 * We don't check size == 0 before the shift. This is borrowed
78 * from do_generic_file_read.
77 */ 79 */
78 last_index = size >> PAGE_CACHE_SHIFT; 80 last_index = (size - 1) >> PAGE_CACHE_SHIFT;
79 if (page->index > last_index) { 81 if (unlikely(!size || page->index > last_index)) {
80 ret = -EINVAL; 82 ret = -EINVAL;
81 goto out; 83 goto out;
82 } 84 }
@@ -107,7 +109,7 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh,
107 * because the "write" would invalidate their data. 109 * because the "write" would invalidate their data.
108 */ 110 */
109 if (page->index == last_index) 111 if (page->index == last_index)
110 len = size & ~PAGE_CACHE_MASK; 112 len = ((size - 1) & ~PAGE_CACHE_MASK) + 1;
111 113
112 ret = ocfs2_write_begin_nolock(mapping, pos, len, 0, &locked_page, 114 ret = ocfs2_write_begin_nolock(mapping, pos, len, 0, &locked_page,
113 &fsdata, di_bh, page); 115 &fsdata, di_bh, page);