From 20f7890945db5147ae214deb0f23b09175515edf Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Thu, 1 Apr 2010 15:40:40 -0700 Subject: [PATCH] b=22312 write_bytes are missing in obdfilter stats There's a missing lprocfs_counter_add() for LPROC_FILTER_WRITE_BYTES in filter_io.c:filter_preprw_write(). A test is also delivered. i=robert.read@sun.com --- lustre/obdfilter/filter_io.c | 3 +++ lustre/tests/sanity.sh | 54 ++++++++++++++++++++++++++++++++++++++++++ lustre/tests/test-framework.sh | 9 +++++++ lustre/utils/llobdstat | 9 ++++--- 4 files changed, 70 insertions(+), 5 deletions(-) mode change 100644 => 100755 lustre/tests/sanity.sh mode change 100644 => 100755 lustre/utils/llobdstat diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c index 3e7fee20..485560c 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -823,6 +823,9 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa, fsfilt_check_slow(obd, now, "start_page_write"); + lprocfs_counter_add(obd->obd_stats, LPROC_FILTER_WRITE_BYTES, + tot_bytes); + if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats) lprocfs_counter_add(exp->exp_nid_stats->nid_stats, LPROC_FILTER_WRITE_BYTES, tot_bytes); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh old mode 100644 new mode 100755 index 1f22dc0..d2ebdea --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -1723,6 +1723,60 @@ test_33b() { } run_test 33b "test open file with malformed flags (No panic and return error)" +test_33c() { + local ostnum + local ostname + local write_bytes + local all_zeros + + all_zeros=: + rm -fr $DIR/d33 + mkdir -p $DIR/d33 + # Read: 0, Write: 4, create/destroy: 2/0, stat: 1, punch: 0 + + sync + for ostnum in $(seq $OSTCOUNT); do + # test-framework's OST numbering is one-based, while Lustre's + # is zero-based + ostname=$(printf "lustre-OST%.4d" $((ostnum - 1))) + # Parsing llobdstat's output sucks; we could grep the /proc + # path, but that's likely to not be as portable as using the + # llobdstat utility. Besides, this way we also test that + # utility. + write_bytes=$(do_facet ost$ostnum $LLOBDSTAT $ostname | + sed -e 's/^.*, Write: \([0-9][0-9]*\),.*$/\1/' | + grep '^[0-9]*$') + if (( ${write_bytes:-0} > 0 )) + then + all_zeros=false + break; + fi + done + + $all_zeros || return 0 + + # Write four bytes + echo foo > $DIR/d33/bar + # Really write them + sync + + # Total up write_bytes after writing. We'd better find non-zeros. + for ostnum in $(seq $OSTCOUNT); do + ostname=$(printf "lustre-OST%.4d" $ostnum) + write_bytes=$(do_facet ost$ostnum $LLOBDSTAT $ostname | + sed -e 's/^.*, Write: \([0-9][0-9]*\),.*$/\1/' | + grep '^[0-9]*$') + if (( ${write_bytes:-0} > 0 )) + then + all_zeros=false + break; + fi + done + + $all_zeros && error "OST not keeping write_bytes stats (b22312)" +} +run_test 33c "test llobdstat and write_bytes" + TEST_34_SIZE=${TEST_34_SIZE:-2000000000000} test_34a() { rm -f $DIR/f34 diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 5f2634d..4893f7f 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -34,6 +34,15 @@ if [ -f "$EXCEPT_LIST_FILE" ]; then . $EXCEPT_LIST_FILE fi +if [[ -x $LUSTRE/utils/llobdstat ]]; then + LLOBDSTAT=$LUSTRE/utils/llobdstat +elif [[ -x /usr/bin/llobdstat ]]; then + LLOBDSTAT=/usr/bin/llobdstat +else + # Good luck + LLOBDSTAT=llobdstat +fi + [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre diff --git a/lustre/utils/llobdstat b/lustre/utils/llobdstat old mode 100644 new mode 100755 index 9c9cf5a..733cb4b --- a/lustre/utils/llobdstat +++ b/lustre/utils/llobdstat @@ -33,11 +33,10 @@ if (($#ARGV < 0) || ($#ARGV > 2)) { } elsif ( -f "$ARGV[0]/$obdstats" ) { $statspath = "$ARGV[0]/$obdstats"; } else { - my $st = `ls $defaultpath/obdfilter/$ARGV[0]/$obdstats 2> /dev/null`; - chop $st; - if ( -f "$st" ) { - $statspath = $st; - } + my $st = "$defaultpath/obdfilter/$ARGV[0]/$obdstats"; + if ( -f "$st" ) { + $statspath = $st; + } } if ( $statspath =~ /^None$/ ) { die "Cannot locate stat file for: $ARGV[0]\n"; -- 1.8.3.1