From 0b72da3f303132ec09d80c65156c7a20fa03c721 Mon Sep 17 00:00:00 2001 From: Vladimir Saveliev Date: Tue, 16 Feb 2010 19:30:28 +0300 Subject: [PATCH] b=21982 long file truncate problem fix (use loff_t for truncate size instead of size_t) and unit test i=jinshan.xiong i=adilger --- lustre/include/cl_object.h | 2 +- lustre/llite/vvp_io.c | 6 +++--- lustre/lov/lov_io.c | 2 +- lustre/tests/sanity.sh | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 26e6553..5081a74 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -2272,7 +2272,7 @@ struct cl_io { struct cl_io_rw_common ci_rw; struct cl_truncate_io { /** new size to which file is truncated */ - size_t tr_size; + loff_t tr_size; struct obd_capa *tr_capa; } ci_truncate; struct cl_fault_io { diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index a601017..89bb048 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -293,7 +293,7 @@ static int vvp_io_trunc_lock(const struct lu_env *env, { struct ccc_io *vio = cl2ccc_io(env, ios); struct cl_io *io = ios->cis_io; - size_t new_size = io->u.ci_truncate.tr_size; + loff_t new_size = io->u.ci_truncate.tr_size; __u32 enqflags = new_size == 0 ? CEF_DISCARD_DATA : 0; int result; @@ -327,7 +327,7 @@ static int vvp_io_trunc_start(const struct lu_env *env, struct cl_io *io = ios->cis_io; struct inode *inode = ccc_object_inode(io->ci_obj); struct cl_object *obj = ios->cis_obj; - size_t size = io->u.ci_truncate.tr_size; + loff_t size = io->u.ci_truncate.tr_size; pgoff_t start = cl_index(obj, size); int result; @@ -375,7 +375,7 @@ static void vvp_io_trunc_end(const struct lu_env *env, struct vvp_io *vio = cl2vvp_io(env, ios); struct cl_io *io = ios->cis_io; struct inode *inode = ccc_object_inode(io->ci_obj); - size_t size = io->u.ci_truncate.tr_size; + loff_t size = io->u.ci_truncate.tr_size; if (vio->cui_partpage != NULL) { cl_page_disown(env, ios->cis_io, vio->cui_partpage); diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 8b71f49..b21fd94 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -100,7 +100,7 @@ static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio, switch(io->ci_type) { case CIT_TRUNC: { - size_t new_size = parent->u.ci_truncate.tr_size; + loff_t new_size = parent->u.ci_truncate.tr_size; new_size = lov_size_to_stripe(lsm, new_size, stripe); io->u.ci_truncate.tr_capa = parent->u.ci_truncate.tr_capa; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d3b5408..2d93a0e 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -1785,6 +1785,23 @@ test_34f() { # bug 6242, 6243 } run_test 34f "read from a file with no objects until EOF =======" +test_34g() { + dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error + $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error + $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed" + cancel_lru_locks osc + $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \ + error "wrong size after lock cancel" + + $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error + $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \ + error "expanding truncate failed" + cancel_lru_locks osc + $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \ + error "wrong expanded size after lock cancel" +} +run_test 34g "truncate long file ===============================" + test_35a() { cp /bin/sh $DIR/f35a chmod 444 $DIR/f35a -- 1.8.3.1