From b39bab4d48937298f80a898b41f9124c506efda5 Mon Sep 17 00:00:00 2001 From: fanyong Date: Fri, 20 Mar 2009 08:52:32 +0000 Subject: [PATCH] Branch b1_8 b=17336 i=robert.read i=jinshan.xiong Do not trigger readpage when objective page index exceeds the end-of-file page index. --- lustre/liblustre/rw.c | 9 +++++++++ lustre/llite/file.c | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index 96a4b95..12e52e1 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -704,6 +704,15 @@ ssize_t llu_file_prwv(const struct iovec *iovec, int iovlen, */ if ((err = llu_glimpse_size(inode))) { GOTO(err_unlock, err); + } else { + /* If objective page index exceed end-of-file + * page index, return directly. --bug 17336 */ + size_t size = st->st_size; + unsigned long cur_index = pos >> CFS_PAGE_SHIFT; + + if ((size == 0 && cur_index != 0) || + (((size - 1) >> CFS_PAGE_SHIFT) < cur_index)) + GOTO(err_unlock, err); } } else { st->st_size = kms; diff --git a/lustre/llite/file.c b/lustre/llite/file.c index a99040a..d62d915 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1549,6 +1549,24 @@ repeat: up_read(&lli->lli_truncate_rwsem); } goto out; + } else { + /* If objective page index exceed the end-of-file page + * index, return directly. Do not expect kernel will + * check such case correctly. linux-2.6.18-128.1.1 miss + * to do that. --bug 17336 */ + size_t size = i_size_read(inode); + unsigned long cur_index = *ppos >> CFS_PAGE_SHIFT; + + if ((size == 0 && cur_index != 0) || + (((size - 1) >> CFS_PAGE_SHIFT) < cur_index)) { + if (lock_style != LL_LOCK_STYLE_NOLOCK) { + ll_file_put_lock(inode, end, lock_style, + cookie, &tree, + OBD_BRW_READ); + up_read(&lli->lli_truncate_rwsem); + } + goto out; + } } } else { /* region is within kms and, hence, within real file size (A). -- 1.8.3.1