Whamcloud - gitweb
b=22312 write_bytes are missing in obdfilter stats
authorNicolas Williams <Nicolas.Williams@sun.com>
Thu, 1 Apr 2010 22:40:40 +0000 (15:40 -0700)
committerRobert Read <rread@sun.com>
Thu, 1 Apr 2010 22:40:40 +0000 (15:40 -0700)
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
lustre/tests/sanity.sh [changed mode: 0644->0755]
lustre/tests/test-framework.sh
lustre/utils/llobdstat [changed mode: 0644->0755]

index 3e7fee2..485560c 100644 (file)
@@ -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);
old mode 100644 (file)
new mode 100755 (executable)
index 1f22dc0..d2ebdea
@@ -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
index 5f2634d..4893f7f 100644 (file)
@@ -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
 
old mode 100644 (file)
new mode 100755 (executable)
index 9c9cf5a..733cb4b
@@ -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";