From e300d72a9d1a0871f9f7ed51ce5019730c0e5447 Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Fri, 2 Feb 2024 00:31:13 +0800 Subject: [PATCH] LU-17481 mdt: count all opens in mdt.*.md_stats Count all of opens for mdt. Also add a test case to verify it. Lustre-change: https://review.whamcloud.com/53880 Lustre-commit: 055f939979b20eb769803ecffd0caa53c440ad7d Signed-off-by: Yang Sheng Change-Id: I2fa90cc2b4ce8d7d039736a5f40a70cbeb04bf8c Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54181 Tested-by: jenkins Tested-by: Maloo --- lustre/mdt/mdt_open.c | 7 ++++--- lustre/tests/sanity.sh | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 0e96455..d020e7e 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -1763,9 +1763,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: @@ -1784,6 +1781,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; } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 05b8b51..fd9cd77 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -14461,7 +14461,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 @@ -14476,6 +14476,12 @@ test_133a() { touch ${testdir}/${tfile} || error "touch failed" check_stats $SINGLEMDS "open" 1 check_stats $SINGLEMDS "close" 1 + (( $MDS1_VERSION >= $(version_code 2.14.0.136) )) && { + # 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 @@ -14490,8 +14496,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 -- 1.8.3.1