Skip to content

Commit

Permalink
Add I/O Read/Write Accounting
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs#313
Closes openzfs#1275
  • Loading branch information
behlendorf committed Nov 21, 2013
1 parent 2971457 commit e3dc14b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/sys/zpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 10 additions & 2 deletions module/zfs/zpl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit e3dc14b

Please sign in to comment.