From 011e1561518b471da799e052dee91c82e2f6e55a Mon Sep 17 00:00:00 2001 From: Tao Ma Date: Sat, 17 Jul 2010 21:45:49 +0800 Subject: [PATCH] --- yaml --- r: 210383 b: refs/heads/master c: f63afdb2c32db850fa1bfccf84643a8885cbeb61 h: refs/heads/master i: 210381: f0c58e2fb953f9f04ee1af3290b26dee8f730c81 210379: ddd070fc3374c123146ccf34e45db045a41543b8 210375: 2917e0e5be41d732ab12be4871c66b5f38196fbb 210367: 66b40c41df84fb34774cb68bc3fd8b4301a4516d v: v3 --- [refs] | 2 +- trunk/fs/ocfs2/mmap.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 4b44f19c3993..af799c00b43c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f5ce5a08a40f2086435858ddc80cb40394b082eb +refs/heads/master: f63afdb2c32db850fa1bfccf84643a8885cbeb61 diff --git a/trunk/fs/ocfs2/mmap.c b/trunk/fs/ocfs2/mmap.c index af2b8fe1f139..4c18f4ad93b4 100644 --- a/trunk/fs/ocfs2/mmap.c +++ b/trunk/fs/ocfs2/mmap.c @@ -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 * 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; - if (page->index > last_index) { + last_index = (size - 1) >> PAGE_CACHE_SHIFT; + if (unlikely(!size || page->index > last_index)) { ret = -EINVAL; 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. */ 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, &fsdata, di_bh, page);