From: Peng Tao Date: Fri, 17 May 2013 15:05:46 +0000 (-0400) Subject: LU-2850 kernel: 3.8 upstream removes vmtruncate() X-Git-Tag: 2.4.51~13 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=36633944a703bbee19509f617b64f5c621768b31;hp=18456c36158a471383d039d1863d286699f92b22;p=fs%2Flustre-release.git LU-2850 kernel: 3.8 upstream removes vmtruncate() vmtruncate() is removed since upstream commit b9f61c3. Also truncate_setsize is not always available. So we just open code it and use truncate_pagecache instead. Signed-off-by: Peng Tao Signed-off-by: James Simmons Change-Id: I9d4f43a5c181f16482b4caa021ba7a09ee52b600 Reviewed-on: http://review.whamcloud.com/5613 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 562c875..7aded2e 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -358,13 +358,22 @@ static int vvp_io_setattr_lock(const struct lu_env *env, static int vvp_do_vmtruncate(struct inode *inode, size_t size) { int result; + loff_t oldsize; + /* * Only ll_inode_size_lock is taken at this level. */ ll_inode_size_lock(inode); - result = vmtruncate(inode, size); - ll_inode_size_unlock(inode); + result = inode_newsize_ok(inode, size); + if (result < 0) { + ll_inode_size_unlock(inode); + return result; + } + oldsize = inode->i_size; + i_size_write(inode, size); + truncate_pagecache(inode, oldsize, size); + ll_inode_size_unlock(inode); return result; } diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 79c4675..c9eb4eb 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1240,7 +1240,8 @@ static int osd_punch(const struct lu_env *env, struct dt_object *dt, struct inode *inode = obj->oo_inode; handle_t *h; tid_t tid; - int rc, rc2 = 0; + loff_t oldsize; + int rc = 0, rc2 = 0; ENTRY; LASSERT(end == OBD_OBJECT_EOF); @@ -1257,13 +1258,17 @@ static int osd_punch(const struct lu_env *env, struct dt_object *dt, tid = oh->ot_handle->h_transaction->t_tid; - rc = vmtruncate(inode, start); + oldsize=inode->i_size; + i_size_write(inode, start); + truncate_pagecache(inode, oldsize, start); + if (inode->i_op->truncate) + inode->i_op->truncate(inode); /* * For a partial-page truncate, flush the page to disk immediately to * avoid data corruption during direct disk write. b=17397 */ - if (rc == 0 && (start & ~CFS_PAGE_MASK) != 0) + if ((start & ~CFS_PAGE_MASK) != 0) rc = filemap_fdatawrite_range(inode->i_mapping, start, start+1); h = journal_current_handle();