Whamcloud - gitweb
LU-2395 ofd: Maintain per-export {read,write}_bytes counters
authorJohn L. Hammond <jhammond@tacc.utexas.edu>
Tue, 27 Nov 2012 20:28:20 +0000 (14:28 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jan 2013 06:16:27 +0000 (01:16 -0500)
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 <jhammond@tacc.utexas.edu>
Change-Id: I49e237a6387b8ece1aecd63987ad4a75897b430b
Reviewed-on: http://review.whamcloud.com/4687
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/ofd/ofd_internal.h
lustre/tests/sanity.sh

index 1b17367..5b8cd32 100644 (file)
@@ -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 {
index 76d27ce..73ce8c5 100644 (file)
@@ -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"