From: John Hammond Date: Thu, 14 Jul 2011 00:48:40 +0000 (-0500) Subject: LU-333: Make read_bytes in llite/*/stats report bytes read. X-Git-Tag: 2.1.0-RC0~27 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=37eeb0ffd0325c5a3c426d6ab0e72ef6da84db99;ds=sidebyside LU-333: Make read_bytes in llite/*/stats report bytes read. Move ll_stats_ops_tally(..., LPROC_LL_{READ,WRITE}_BYTES, ...) from vvp_io_init() to the end of ll_file_io_generic(), and tally by the actual number of bytes read rather than the number requested. Test 127b, client stats are correctly tallied with this patch. Change-Id: Icad0bc09630b8c1775f2ec59326902aa88215498 Signed-off-by: John Hammond Signed-off-by: Richard Henwood Reviewed-on: http://review.whamcloud.com/1094 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 4ca1911..93d4f47 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -891,8 +891,21 @@ static ssize_t ll_file_io_generic(const struct lu_env *env, GOTO(out, result); out: cl_io_fini(env, io); - if (iot == CIT_WRITE) - lli->lli_write_rc = result < 0 ? : 0; + + if (iot == CIT_READ) { + if (result >= 0) + ll_stats_ops_tally(ll_i2sbi(file->f_dentry->d_inode), + LPROC_LL_READ_BYTES, result); + } else if (iot == CIT_WRITE) { + if (result >= 0) { + ll_stats_ops_tally(ll_i2sbi(file->f_dentry->d_inode), + LPROC_LL_WRITE_BYTES, result); + lli->lli_write_rc = 0; + } else { + lli->lli_write_rc = result; + } + } + return result; } diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 62b0072..32a8905 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -1076,12 +1076,9 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, vio->cui_ra_window_set = 0; result = 0; if (io->ci_type == CIT_READ || io->ci_type == CIT_WRITE) { - int op; size_t count; count = io->u.ci_rw.crw_count; - op = io->ci_type == CIT_READ ? - LPROC_LL_READ_BYTES : LPROC_LL_WRITE_BYTES; /* "If nbyte is 0, read() will return 0 and have no other * results." -- Single Unix Spec */ if (count == 0) @@ -1089,7 +1086,6 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, else { cio->cui_tot_count = count; cio->cui_tot_nrsegs = 0; - ll_stats_ops_tally(sbi, op, count); } } else if (io->ci_type == CIT_SETATTR) { if (cl_io_is_trunc(io)) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 750a825..38fcd12 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6258,7 +6258,7 @@ test_126() { # bug 12829/13455 } run_test 126 "check that the fsgid provided by the client is taken into account" -test_127() { # bug 15521 +test_127a() { # bug 15521 $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed" $LCTL set_param osc.*.stats=0 FSIZE=$((2048 * 1024)) @@ -6294,7 +6294,47 @@ test_127() { # bug 15521 [ "$read_bytes" != 0 ] || error "no read done" [ "$write_bytes" != 0 ] || error "no write done" } -run_test 127 "verify the client stats are sane" +run_test 127a "verify the client stats are sane" + +test_127b() { # bug LU-333 + $LCTL set_param llite.*.stats=0 + FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients + # perform 2 reads and writes so MAX is different from SUM. + dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1 + dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1 + cancel_lru_locks osc + dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1 + dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1 + + $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp + while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do + echo "got $COUNT $NAME" + eval $NAME=$COUNT || error "Wrong proc format" + + case $NAME in + read_bytes) + [ $COUNT -ne 2 ] && error "count is not 2: $COUNT" + [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN" + [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX" + [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM" + ;; + write_bytes) + [ $COUNT -ne 2 ] && error "count is not 2: $COUNT" + [ $MIN -ne $FSIZE ] && error "min is not $FSIZE: $MIN" + [ $MAX -ne $FSIZE ] && error "max is incorrect: $MAX" + [ $SUM -ne $((FSIZE * 2)) ] && error "sum is wrong: $SUM" + ;; + *) ;; + esac + done < $TMP/${tfile}.tmp + + #check that we actually got some stats + [ "$read_bytes" ] || error "Missing read_bytes stats" + [ "$write_bytes" ] || error "Missing write_bytes stats" + [ "$read_bytes" != 0 ] || error "no read done" + [ "$write_bytes" != 0 ] || error "no write done" +} +run_test 127b "verify the llite client stats are sane" test_128() { # bug 15212 touch $DIR/$tfile