Whamcloud - gitweb
b=21982 long file truncate problem
authorVladimir Saveliev <Vladimir.Saveliev@sun.com>
Tue, 16 Feb 2010 16:30:28 +0000 (19:30 +0300)
committerMikhail Pershin <tappro@sun.com>
Tue, 16 Feb 2010 21:15:18 +0000 (00:15 +0300)
fix (use loff_t for truncate size instead of size_t) and unit test

i=jinshan.xiong
i=adilger

lustre/include/cl_object.h
lustre/llite/vvp_io.c
lustre/lov/lov_io.c
lustre/tests/sanity.sh

index 26e6553..5081a74 100644 (file)
@@ -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 {
index a601017..89bb048 100644 (file)
@@ -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);
index 8b71f49..b21fd94 100644 (file)
@@ -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;
index d3b5408..2d93a0e 100644 (file)
@@ -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