Whamcloud - gitweb
LU-17481 mdt: count all opens in mdt.*.md_stats 80/53880/5
authorYang Sheng <ys@whamcloud.com>
Thu, 1 Feb 2024 16:31:13 +0000 (00:31 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Feb 2024 07:15:04 +0000 (07:15 +0000)
Count all of opens for mdt. Also add a test case to
verify it.

Signed-off-by: Yang Sheng <ys@whamcloud.com>
Change-Id: I2fa90cc2b4ce8d7d039736a5f40a70cbeb04bf8c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53880
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_open.c
lustre/tests/sanity.sh

index 85f78fe..de0cce2 100644 (file)
@@ -1719,9 +1719,6 @@ again_pw:
         */
        result = mdt_refetch_lovea(info, child, ma, ibits);
 
-       mdt_counter_incr(req, LPROC_MDT_OPEN,
-                        ktime_us_delta(ktime_get(), kstart));
-
        GOTO(out_child_unlock, result);
 
 out_child_unlock:
@@ -1740,6 +1737,10 @@ out_parent:
 out:
        if (result)
                lustre_msg_set_transno(req->rq_repmsg, 0);
+       else
+               mdt_counter_incr(req, LPROC_MDT_OPEN,
+                                ktime_us_delta(ktime_get(), kstart));
+
        return result;
 }
 
index 56d7dbf..7073096 100755 (executable)
@@ -15784,7 +15784,7 @@ test_133a() {
 
        local testdir=$DIR/${tdir}/stats_testdir
 
-       mkdir -p $DIR/${tdir}
+       mkdir_on_mdt0 $DIR/${tdir}
 
        # clear stats.
        do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
@@ -15799,6 +15799,10 @@ test_133a() {
        touch ${testdir}/${tfile} || error "touch failed"
        check_stats $SINGLEMDS "open" 1
        check_stats $SINGLEMDS "close" 1
+       # open should match close
+       ls -lR ${testdir}
+       check_stats $SINGLEMDS "open" 2
+       check_stats $SINGLEMDS "close" 2
        [ $MDS1_VERSION -ge $(version_code 2.8.54) ] && {
                mknod ${testdir}/${tfile}-pipe p || error "mknod failed"
                check_stats $SINGLEMDS "mknod" 2
@@ -15813,8 +15817,8 @@ test_133a() {
        check_stats $SINGLEMDS "rmdir" 1
 
        local testdir1=$DIR/${tdir}/stats_testdir1
-       mkdir_on_mdt0 -p ${testdir}
-       mkdir_on_mdt0 -p ${testdir1}
+       mkdir_on_mdt0 ${testdir}
+       mkdir_on_mdt0 ${testdir1}
        touch ${testdir1}/test1
        mv ${testdir1}/test1 ${testdir} || error "file crossdir rename"
        check_stats $SINGLEMDS "crossdir_rename" 1