From: John L. Hammond Date: Tue, 27 Nov 2012 20:28:20 +0000 (-0600) Subject: LU-2395 ofd: Maintain per-export {read,write}_bytes counters X-Git-Tag: 2.3.59~47 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=99be593f3966e487f78526ca48f6b39b99f83414;ds=sidebyside LU-2395 ofd: Maintain per-export {read,write}_bytes counters Add handling of these counters to ofd_counter_incr() and add a test to sanity to ensure that they work as intended. Signed-off-by: John L. Hammond Change-Id: I49e237a6387b8ece1aecd63987ad4a75897b430b Reviewed-on: http://review.whamcloud.com/4687 Reviewed-by: Andreas Dilger Reviewed-by: Emoly Liu Tested-by: Hudson Tested-by: Maloo --- diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 1b17367..5b8cd32 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -94,6 +94,16 @@ static inline void ofd_counter_incr(struct obd_export *exp, int opcode, if (exp->exp_obd && exp->exp_obd->u.obt.obt_jobstats.ojs_hash && (exp->exp_connect_flags & OBD_CONNECT_JOBSTATS)) lprocfs_job_stats_log(exp->exp_obd, jobid, opcode, amount); + + if (exp->exp_nid_stats != NULL && + exp->exp_nid_stats->nid_stats != NULL) { + if (opcode == LPROC_OFD_STATS_READ) + lprocfs_counter_add(exp->exp_nid_stats->nid_stats, + LPROC_OFD_READ_BYTES, amount); + else if (opcode == LPROC_OFD_STATS_WRITE) + lprocfs_counter_add(exp->exp_nid_stats->nid_stats, + LPROC_OFD_WRITE_BYTES, amount); + } } struct ofd_device { diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 76d27ce..73ce8c5 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8011,6 +8011,51 @@ test_133d() { } run_test 133d "Verifying rename_stats ========================================" +test_133e() { + local testdir=$DIR/${tdir}/stats_testdir + local ctr f0 f1 bs=32768 count=42 sum + + remote_ost_nodsh && skip "remote OST with nodsh" && return + mkdir -p ${testdir} || error "mkdir failed" + + $SETSTRIPE -c 1 -i 0 ${testdir}/${tfile} + + for ctr in {write,read}_bytes; do + sync + cancel_lru_locks osc + + do_facet ost1 $LCTL set_param -n \ + "obdfilter.*.exports.clear=clear" + + if [ $ctr = write_bytes ]; then + f0=/dev/zero + f1=${testdir}/${tfile} + else + f0=${testdir}/${tfile} + f1=/dev/null + fi + + dd if=$f0 of=$f1 conv=notrunc bs=$bs count=$count || \ + error "dd failed" + sync + cancel_lru_locks osc + + sum=$(do_facet ost1 $LCTL get_param \ + "obdfilter.*.exports.*.stats" | \ + awk -v ctr=$ctr '\ + BEGIN { sum = 0 } + $1 == ctr { sum += $7 } + END { print sum }') + + if ((sum != bs * count)); then + error "Bad $ctr sum, expected $((bs * count)), got $sum" + fi + done + + rm -rf $DIR/${tdir} +} +run_test 133e "Verifying OST {read,write}_bytes nid stats =================" + test_140() { #bug-17379 test_mkdir -p $DIR/$tdir || error "Creating dir $DIR/$tdir" cd $DIR/$tdir || error "Changing to $DIR/$tdir"