Whamcloud - gitweb
LU-618 llite: IO accounting of page read 70/30570/3
authorHongchao Zhang <hongchao.zhang@intel.com>
Thu, 30 Nov 2017 10:10:52 +0000 (18:10 +0800)
committerJohn L. Hammond <john.hammond@intel.com>
Mon, 8 Jan 2018 16:31:52 +0000 (16:31 +0000)
When CONFIG_TASK_IO_ACCOUNTING is used with Lustre, writes are
accounted for but not read.

The accounting is normally done in the kernel for page writeback
and readahead functionlity, Therefore, as Lustre implements its
own readahead, it must also maintain its own accounting on read
(but not for write)

Lustre-change: https://review.whamcloud.com/1636
Lustre-commit: 48de9b195d71cb57ee50636d75c59d78ee068cee

Change-Id: I19f330be65324a8da002f9d61cb9262345ecb012
Signed-off-by: Hongchao Zhang <hongchao.zhang@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-on: https://review.whamcloud.com/30570
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/llite/rw.c
lustre/tests/sanity.sh

index 9dc99f6..a00ccef 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/pagemap.h>
 /* current_is_kswapd() */
 #include <linux/swap.h>
+#include <linux/task_io_accounting_ops.h>
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
@@ -1121,8 +1122,12 @@ static int ll_io_read_page(const struct lu_env *env, struct cl_io *io,
                       PFID(ll_inode2fid(inode)), rc2, vvp_index(vpg));
        }
 
-       if (queue->c2_qin.pl_nr > 0)
+       if (queue->c2_qin.pl_nr > 0) {
+               int count = queue->c2_qin.pl_nr;
                rc = cl_io_submit_rw(env, io, CRT_READ, queue);
+               if (rc == 0)
+                       task_io_account_read(PAGE_SIZE * count);
+       }
 
        /*
         * Unlock unsent pages in case of error.
index c3d8752..d325723 100755 (executable)
@@ -16090,6 +16090,24 @@ test_313() {
 }
 run_test 313 "io should fail after last_rcvd update fail"
 
+test_315() { # LU-618
+       local file=$DIR/$tfile
+       rm -f $file
+
+       $MULTIOP $file oO_CREAT:O_DIRECT:O_RDWR:w4096000c
+       $MULTIOP $file oO_RDONLY:r4096000_c &
+       PID=$!
+
+       sleep 2
+
+       local rbytes=$(awk '/read_bytes/ { print $2 }' /proc/$PID/io)
+       kill -USR1 $PID
+
+       [ $rbytes -gt 4000000 ] || error "read is not accounted ($rbytes)"
+       rm -f $file
+}
+run_test 315 "read should be accounted"
+
 test_fake_rw() {
        local read_write=$1
        if [ "$read_write" = "write" ]; then