Whamcloud - gitweb
LU-3285 tests: style fixes in DoM tests 81/29681/3
authorMikhail Pershin <mike.pershin@intel.com>
Thu, 19 Oct 2017 13:11:45 +0000 (16:11 +0300)
committerMike Pershin <mike.pershin@intel.com>
Thu, 26 Oct 2017 18:56:42 +0000 (18:56 +0000)
Several style fixes in DoM tests and code from review debts.

Signed-off-by: Mikhail Pershin <mike.pershin@intel.com>
Change-Id: I4ee011025a008cfa474db3d1c2f86b2c250483c4
Reviewed-on: https://review.whamcloud.com/29681
Tested-by: Jenkins
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/lov/lov_object.c
lustre/mdc/lproc_mdc.c
lustre/mdc/mdc_request.c
lustre/mdt/mdt_io.c
lustre/target/tgt_grant.c
lustre/tests/conf-sanity.sh
lustre/tests/sanity-dom.sh
lustre/tests/sanity.sh
lustre/tests/sanityn.sh

index 82926a4..0b65bc7 100644 (file)
@@ -451,7 +451,7 @@ static int lov_attr_get_dom(const struct lu_env *env, struct lov_object *lov,
        cl_lvb2attr(attr, &loi->loi_lvb);
 
        /* DoM component size can be bigger than stripe size after
-        * client's setattr RPC, so do not count anything beyound
+        * client's setattr RPC, so do not count anything beyond
         * component end. Alternatively, check that limit on server
         * and do not allow size overflow there. */
        if (attr->cat_size > lle->lle_extent.e_end)
index ff148f1..cf37467 100644 (file)
@@ -420,14 +420,14 @@ LPROC_SEQ_FOPS(mdc_rpc_stats);
 
 static int mdc_stats_seq_show(struct seq_file *seq, void *v)
 {
-       struct timeval now;
+       struct timespec64 now;
        struct obd_device *dev = seq->private;
        struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
 
-       do_gettimeofday(&now);
+       ktime_get_real_ts64(&now);
 
-       seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n",
-                  now.tv_sec, now.tv_usec);
+       seq_printf(seq, "snapshot_time:         %lld.%09lu (secs.nsecs)\n",
+                  (s64)now.tv_sec, now.tv_nsec);
        seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
                   stats->os_lockless_writes);
        seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
index 18eb9ba..61ed623 100644 (file)
@@ -2613,7 +2613,7 @@ static struct obd_ops mdc_obd_ops = {
         .o_del_conn         = client_import_del_conn,
         .o_connect          = client_connect_import,
        .o_reconnect        = osc_reconnect,
-       .o_disconnect       = osc_disconnect,
+       .o_disconnect       = osc_disconnect,
         .o_iocontrol        = mdc_iocontrol,
         .o_set_info_async   = mdc_set_info_async,
         .o_statfs           = mdc_statfs,
index 6924296..abe7bab 100644 (file)
@@ -550,9 +550,18 @@ int mdt_punch_hdl(struct tgt_session_info *tsi)
        if (IS_ERR(mo))
                GOTO(out_unlock, rc = PTR_ERR(mo));
 
+       /* Shouldn't happen on dirs */
+       if (S_ISDIR(lu_object_attr(&mo->mot_obj))) {
+               rc = -EPERM;
+               CERROR("%s: Truncate on dir "DFID": rc = %d\n",
+                      exp->exp_obd->obd_name, PFID(&tsi->tsi_fid), rc);
+               GOTO(out_put, rc);
+       }
+
        mdt_dom_write_lock(mo);
        if (!mdt_object_exists(mo))
                GOTO(out_put, rc = -ENOENT);
+
        dob = mdt_obj2dt(mo);
 
        la_from_obdo(la, oa, OBD_MD_FLMTIME | OBD_MD_FLATIME | OBD_MD_FLCTIME);
index e3264a5..62da5c9 100644 (file)
@@ -1505,7 +1505,6 @@ int tgt_grant_commit_cb_add(struct thandle *th, struct obd_export *exp,
 }
 EXPORT_SYMBOL(tgt_grant_commit_cb_add);
 
-
 /**
  * Show estimate of total amount of dirty data on clients.
  *
@@ -1632,4 +1631,3 @@ ssize_t tgt_grant_compat_disable_seq_write(struct file *file,
        return count;
 }
 EXPORT_SYMBOL(tgt_grant_compat_disable_seq_write);
-
index a678edc..13c1857 100644 (file)
@@ -2077,11 +2077,11 @@ t32_test() {
 
                if [ "$dom_upgrade" != "no" ]; then
                        echo "Check DoM file can be created"
-                       $SETSTRIPE -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
+                       $LFS setstripe -E 1M -L mdt -E EOF $tmp/mnt/lustre/dom || {
                                error_noexit "Verify DoM creation"
                                return 1
                        }
-                       [ $($GETSTRIPE -L $tmp/mnt/lustre/dom) == 100 ] || {
+                       [ $($LFS getstripe -L $tmp/mnt/lustre/dom) == 100 ] || {
                                error_noexit "Verify a DoM file"
                                return 1
                        }
index 7c47479..6df949b 100644 (file)
@@ -84,17 +84,14 @@ test_3() {
 }
 run_test 3 "Truncate over DoM size on different nodes"
 
-# TODO: tests below are from sanityn but their adapted version should be
-# put here: 31 32 34 71 75
-
-test_sn16() {
+test_fsx() {
        local file1=$DIR1/$tfile
        local file2=$DIR2/$tfile
 
        touch $file1
-       fsx -c 50 -p 1 -N 1000 -l $(($DOM_SIZE*2)) -S 0 -d -d $file1 $file2
+       fsx -c 50 -p 100 -N 1000 -l $((DOM_SIZE*2)) -S 0 -d -d $file1 $file2
 }
-run_test sn16 "$FSXNUM iterations of dual-mount fsx"
+run_test fsx "Dual-mount fsx with DoM files"
 
 test_sanity()
 {
index 770f148..929fdc4 100755 (executable)
@@ -15006,18 +15006,18 @@ test_270a() {
        mkdir -p $DIR/$tdir
 
        # basic checks for DoM component creation
-       $SETSTRIPE -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
+       $LFS setstripe -E 1024K -E 1024K -L mdt $dom 2>/dev/null &&
                error "Can set MDT layout to non-first entry"
 
-       $SETSTRIPE -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
+       $LFS setstripe -E 1024K -L mdt -E 1024K -L mdt $dom 2>/dev/null &&
                error "Can define multiple entries as MDT layout"
 
-       $SETSTRIPE -E 1M -L mdt $dom ||
+       $LFS setstripe -E 1M -L mdt $dom ||
                error "Can't create DoM layout"
 
-       [ $($GETSTRIPE -L $dom) == 100 ] || error "bad pattern"
-       [ $($GETSTRIPE -c $dom) == 0 ] || error "bad stripe count"
-       [ $($GETSTRIPE -S $dom) == 1048576 ] || error "bad stripe size"
+       [ $($LFS getstripe -L $dom) == 100 ] || error "bad pattern"
+       [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
+       [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
 
        local mdtidx=$($GETSTRIPE -M $dom)
        local mdtname=MDT$(printf %04x $mdtidx)
@@ -15077,7 +15077,7 @@ test_270a() {
        fi
 
        # combined striping
-       $SETSTRIPE -E 1024K -L mdt -E EOF $dom ||
+       $LFS setstripe -E 1024K -L mdt -E EOF $dom ||
                error "Can't create DoM + OST striping"
 
        dd if=/dev/urandom of=$tmp bs=1024 count=2000
@@ -15098,7 +15098,7 @@ test_270b() {
        local max_size=1048576
 
        mkdir -p $DIR/$tdir
-       $SETSTRIPE -E $max_size -L mdt $dom
+       $LFS setstripe -E $max_size -L mdt $dom
 
        # truncate over the limit
        $TRUNCATE $dom $(($max_size + 1)) &&
@@ -15117,25 +15117,25 @@ run_test 270b "DoM: maximum size overflow checks for DoM-only file"
 
 test_270c() {
        mkdir -p $DIR/$tdir
-       $SETSTRIPE -E 1024K -L mdt $DIR/$tdir
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
 
        # check files inherit DoM EA
        touch $DIR/$tdir/first
        [ $($GETSTRIPE -L $DIR/$tdir/first) == 100 ] ||
                error "bad pattern"
-       [ $($GETSTRIPE -c $DIR/$tdir/first) == 0 ] ||
+       [ $($LFS getstripe -c $DIR/$tdir/first) == 0 ] ||
                error "bad stripe count"
-       [ $($GETSTRIPE -S $DIR/$tdir/first) == 1048576 ] ||
+       [ $($LFS getstripe -S $DIR/$tdir/first) == 1048576 ] ||
                error "bad stripe size"
 
        # check directory inherits DoM EA and uses it as default
        mkdir $DIR/$tdir/subdir
        touch $DIR/$tdir/subdir/second
-       [ $($GETSTRIPE -L $DIR/$tdir/subdir/second) == 100 ] ||
+       [ $($LFS getstripe -L $DIR/$tdir/subdir/second) == 100 ] ||
                error "bad pattern in sub-directory"
-       [ $($GETSTRIPE -c $DIR/$tdir/subdir/second) == 0 ] ||
+       [ $($LFS getstripe -c $DIR/$tdir/subdir/second) == 0 ] ||
                error "bad stripe count in sub-directory"
-       [ $($GETSTRIPE -S $DIR/$tdir/subdir/second) == 1048576 ] ||
+       [ $($LFS getstripe -S $DIR/$tdir/subdir/second) == 1048576 ] ||
                error "bad stripe size in sub-directory"
        return 0
 }
@@ -15143,18 +15143,18 @@ run_test 270c "DoM: DoM EA inheritance tests"
 
 test_270d() {
        mkdir -p $DIR/$tdir
-       $SETSTRIPE -E 1024K -L mdt $DIR/$tdir
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
 
        # inherit default DoM striping
        mkdir $DIR/$tdir/subdir
        touch $DIR/$tdir/subdir/f1
 
        # change default directory striping
-       $SETSTRIPE -c 1 $DIR/$tdir/subdir
+       $LFS setstripe -c 1 $DIR/$tdir/subdir
        touch $DIR/$tdir/subdir/f2
-       [ $($GETSTRIPE -c $DIR/$tdir/subdir/f2) == 1 ] ||
+       [ $($LFS getstripe -c $DIR/$tdir/subdir/f2) == 1 ] ||
                error "wrong default striping in file 2"
-       [ $($GETSTRIPE -L $DIR/$tdir/subdir/f2) == 1 ] ||
+       [ $($LFS getstripe -L $DIR/$tdir/subdir/f2) == 1 ] ||
                error "bad pattern in file 2"
        return 0
 }
@@ -15165,8 +15165,8 @@ test_270e() {
        mkdir -p $DIR/$tdir/norm
        DOMFILES=20
        NORMFILES=10
-       $SETSTRIPE -E 1M -L mdt $DIR/$tdir/dom
-       $SETSTRIPE -i 0 -S 2M $DIR/$tdir/norm
+       $LFS setstripe -E 1M -L mdt $DIR/$tdir/dom
+       $LFS setstripe -i 0 -S 2M $DIR/$tdir/norm
 
        createmany -o $DIR/$tdir/dom/dom- $DOMFILES
        createmany -o $DIR/$tdir/norm/norm- $NORMFILES
@@ -15212,12 +15212,12 @@ test_270f() {
                error "Cannot change per-MDT DoM stripe limit to $dom_limit"
 
        $LFS mkdir -i 0 -c 1 $DIR/$tdir
-       $SETSTRIPE -d $DIR/$tdir
-       $SETSTRIPE -E $dom_limit -L mdt $DIR/$tdir ||
+       $LFS setstripe -d $DIR/$tdir
+       $LFS setstripe -E $dom_limit -L mdt $DIR/$tdir ||
                error "Can't set directory default striping"
 
        # exceed maximum stripe size
-       $SETSTRIPE -E $(($dom_limit * 2)) -L mdt $dom &&
+       $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
                error "Able to create DoM component size more than LOD limit"
 
        do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
@@ -15242,11 +15242,11 @@ test_270f() {
 
        do_facet mds1 $LCTL set_param -n \
                                lod.$mdtname.dom_stripesize=$((dom_limit * 2))
-       $SETSTRIPE -E $((dom_limit * 2)) -L mdt $dom ||
+       $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
                error "Can't create DoM component size after limit change"
        do_facet mds1 $LCTL set_param -n \
                                lod.$mdtname.dom_stripesize=$((dom_limit / 2))
-       $SETSTRIPE -E $dom_limit -L mdt ${dom}_big &&
+       $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
                error "Can create big DoM component after limit decrease"
        touch ${dom}_def ||
                error "Can't create file with old default layout"
index 173f039..835e3b9 100755 (executable)
@@ -4017,22 +4017,21 @@ test_100a() {
        skip "Reserved for glimpse-ahead" && return
        mkdir -p $DIR/$tdir
 
-       $SETSTRIPE -E 1024K -L mdt -E EOF $DIR/$tdir/dom
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
 
        lctl set_param -n mdc.*.stats=clear
        dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
 
        $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
        # first stat from server should return size data and save glimpse
-       local reads=$(lctl get_param -n mdc.*.stats | \
+       local gls=$(lctl get_param -n mdc.*.stats | \
                awk '/ldlm_glimpse/ {print $2}')
-       [ -z $reads ] || error "Unexpected $reads glimpse RPCs"
+       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
        # second stat to check size is NOT cached on client without IO lock
        $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
 
-       local reads=$(lctl get_param -n mdc.*.stats | \
-               awk '/ldlm_glimpse/ {print $2}')
-       [ "1" == "$reads" ] || error "Expect 1 glimpse RPCs but got $reads"
+       local gls=$(lctl get_param -n mdc.*.stats | grep ldlm_glimpse | wc -l)
+       [ "1" == "$gls" ] || error "Expect 1 glimpse RPCs but got $gls"
        rm -f $dom
 }
 run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
@@ -4040,7 +4039,7 @@ run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
 test_100b() {
        mkdir -p $DIR/$tdir
 
-       $SETSTRIPE -E 1024K -L mdt -E EOF $DIR/$tdir/dom
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
 
        lctl set_param -n mdc.*.stats=clear
        dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
@@ -4050,10 +4049,10 @@ test_100b() {
        # second stat to check size is cached on client
        $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
 
-       local reads=$(lctl get_param -n mdc.*.stats | \
-               awk '/ldlm_glimpse/ {print $2}')
+       local gls=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_glimpse/ {print $2}')
        # both stats should cause no glimpse requests
-       [ -z $reads ] || error "Unexpected $reads glimpse RPCs"
+       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
        rm -f $dom
 }
 run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
@@ -4061,7 +4060,7 @@ run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
 test_100c() {
        mkdir -p $DIR/$tdir
 
-       $SETSTRIPE -E 1024K -L mdt -E EOF $DIR/$tdir/dom
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
 
        lctl set_param -n mdc.*.stats=clear
        lctl set_param -n osc.*.stats=clear
@@ -4071,8 +4070,8 @@ test_100c() {
        $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
                error "Wrong size from stat #1"
 
-       local reads=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
-       [ $reads -eq 0 ] && error "Expect OST glimpse RPCs but got none"
+       local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
+       [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
 
        rm -f $dom
 }
@@ -4081,7 +4080,7 @@ run_test 100c "DoM: write vs stat without IO lock (combined file)"
 test_100d() {
        mkdir -p $DIR/$tdir
 
-       $SETSTRIPE -E 1024K -L mdt -E EOF $DIR/$tdir/dom
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
 
 
        dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
@@ -4093,8 +4092,8 @@ test_100d() {
        $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
                error "Wrong size from stat #1"
 
-       local reads=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
-       [ $reads -eq 0 ] && error "Expect OST glimpse but got none"
+       local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
+       [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
 
        rm -f $dom
 }