From 055f939979b20eb769803ecffd0caa53c440ad7d 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. Signed-off-by: Yang Sheng Change-Id: I2fa90cc2b4ce8d7d039736a5f40a70cbeb04bf8c Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53880 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_open.c | 7 ++++--- lustre/tests/sanity.sh | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 85f78fe..de0cce2 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -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; } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 56d7dbf..7073096 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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 -- 1.8.3.1