From a6476823f1c9697762403e33808f8598cde2bbcc Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Fri, 24 May 2013 13:18:58 -0500 Subject: [PATCH] LU-3384 llite: use READ, WRITE around ll_rw_stats_tally() In vvp_io_write_start() the stats function ll_rw_stats_tally() was incorrectly called with a rw argument of 0. Correct this and use the macros READ and WRITE in and around ll_rw_stats_tally() for clarity. Signed-off-by: John L. Hammond Change-Id: Icca6cfcc102b2944761ff211f1b2c2734aae8ecf Reviewed-on: http://review.whamcloud.com/6447 Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Tested-by: Hudson Tested-by: Maloo --- lustre/llite/lproc_llite.c | 52 +++++++++++++++++++++++++--------------------- lustre/llite/vvp_io.c | 38 +++++++++++++++++---------------- 2 files changed, 48 insertions(+), 42 deletions(-) diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 64c4c2a..d63745d 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -1308,30 +1308,34 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "%3s %10s %14s %14s %17s %17s %14s\n", "R/W", "PID", "RANGE START", "RANGE END", "SMALLEST EXTENT", "LARGEST EXTENT", "OFFSET"); - /* We stored the discontiguous offsets here; print them first */ - for(i = 0; i < LL_OFFSET_HIST_MAX; i++) { - if (offset[i].rw_pid != 0) - seq_printf(seq,"%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", - offset[i].rw_op ? 'W' : 'R', - offset[i].rw_pid, - offset[i].rw_range_start, - offset[i].rw_range_end, - (unsigned long)offset[i].rw_smallest_extent, - (unsigned long)offset[i].rw_largest_extent, - offset[i].rw_offset); - } - /* Then print the current offsets for each process */ - for(i = 0; i < LL_PROCESS_HIST_MAX; i++) { - if (process[i].rw_pid != 0) - seq_printf(seq,"%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", - process[i].rw_op ? 'W' : 'R', - process[i].rw_pid, - process[i].rw_range_start, - process[i].rw_last_file_pos, - (unsigned long)process[i].rw_smallest_extent, - (unsigned long)process[i].rw_largest_extent, - process[i].rw_offset); - } + + /* We stored the discontiguous offsets here; print them first */ + for (i = 0; i < LL_OFFSET_HIST_MAX; i++) { + if (offset[i].rw_pid != 0) + seq_printf(seq, + "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + offset[i].rw_op == READ ? 'R' : 'W', + offset[i].rw_pid, + offset[i].rw_range_start, + offset[i].rw_range_end, + (unsigned long)offset[i].rw_smallest_extent, + (unsigned long)offset[i].rw_largest_extent, + offset[i].rw_offset); + } + + /* Then print the current offsets for each process */ + for (i = 0; i < LL_PROCESS_HIST_MAX; i++) { + if (process[i].rw_pid != 0) + seq_printf(seq, + "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + process[i].rw_op == READ ? 'R' : 'W', + process[i].rw_pid, + process[i].rw_range_start, + process[i].rw_last_file_pos, + (unsigned long)process[i].rw_smallest_extent, + (unsigned long)process[i].rw_largest_extent, + process[i].rw_offset); + } spin_unlock(&sbi->ll_process_lock); return 0; diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 3a64517..e7ca14e 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -542,15 +542,16 @@ static int vvp_io_read_start(const struct lu_env *env, } out: - if (result >= 0) { - if (result < cnt) - io->ci_continue = 0; - io->ci_nob += result; - ll_rw_stats_tally(ll_i2sbi(inode), current->pid, - cio->cui_fd, pos, result, 0); - result = 0; - } - return result; + if (result >= 0) { + if (result < cnt) + io->ci_continue = 0; + io->ci_nob += result; + ll_rw_stats_tally(ll_i2sbi(inode), current->pid, cio->cui_fd, + pos, result, READ); + result = 0; + } + + return result; } static void vvp_io_read_fini(const struct lu_env *env, const struct cl_io_slice *ios) @@ -599,15 +600,16 @@ static int vvp_io_write_start(const struct lu_env *env, else result = lustre_generic_file_write(file, cio, &pos); - if (result > 0) { - if (result < cnt) - io->ci_continue = 0; - io->ci_nob += result; - ll_rw_stats_tally(ll_i2sbi(inode), current->pid, - cio->cui_fd, pos, result, 0); - result = 0; - } - RETURN(result); + if (result > 0) { + if (result < cnt) + io->ci_continue = 0; + io->ci_nob += result; + ll_rw_stats_tally(ll_i2sbi(inode), current->pid, + cio->cui_fd, pos, result, WRITE); + result = 0; + } + + RETURN(result); } #ifndef HAVE_VM_OP_FAULT -- 1.8.3.1