]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add I/O Read/Write Accounting
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 15 Nov 2013 17:59:09 +0000 (09:59 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 21 Nov 2013 16:56:24 +0000 (08:56 -0800)
Because ZFS bypasses the page cache we don't inherit per-task I/O
accounting for free.  However, the Linux kernel does provide helper
functions allow us to perform our own accounting.  These are most
commonly used for direct IO which also bypasses the page cache, but
they can be used for the common read/write call paths as well.

Signed-off-by: Pavel Snajdr <snajpa@snajpa.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #313
Closes #1275

include/sys/zpl.h
module/zfs/zpl_file.c

index d513785c411d7ef96b2669d5c2ff6a4db0a5a08c..5a7e23d46c074ad5de2287efdd4681f4392d4d8e 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/exportfs.h>
 #include <linux/writeback.h>
 #include <linux/falloc.h>
+#include <linux/task_io_accounting_ops.h>
 
 /* zpl_inode.c */
 extern void zpl_vap_init(vattr_t *vap, struct inode *dir,
index 6598c177971d46abbe6e3299f698249e70853582..8054645c1e4d2db7f7a457e4ab0cf436f61924d7 100644 (file)
@@ -170,6 +170,7 @@ zpl_read_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
      uio_seg_t segment, int flags, cred_t *cr)
 {
        int error;
+       ssize_t read;
        struct iovec iov;
        uio_t uio;
 
@@ -187,7 +188,10 @@ zpl_read_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
        if (error < 0)
                return (error);
 
-       return (len - uio.uio_resid);
+       read = len - uio.uio_resid;
+       task_io_account_read(read);
+
+       return (read);
 }
 
 static ssize_t
@@ -213,6 +217,7 @@ zpl_write_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
     uio_seg_t segment, int flags, cred_t *cr)
 {
        int error;
+       ssize_t wrote;
        struct iovec iov;
        uio_t uio;
 
@@ -230,7 +235,10 @@ zpl_write_common(struct inode *ip, const char *buf, size_t len, loff_t pos,
        if (error < 0)
                return (error);
 
-       return (len - uio.uio_resid);
+       wrote = len - uio.uio_resid;
+       task_io_account_write(wrote);
+
+       return (wrote);
 }
 
 static ssize_t