Skip to content

Commit 9c88ea0

Browse files
DaveWysochanskiRHamschuma-ntap
authored andcommitted
NFS: Fix /proc/PID/io read_bytes for buffered reads
Prior to commit 8786fde ("Convert NFS from readpages to readahead"), nfs_readpages() used the old mm interface read_cache_pages() which called task_io_account_read() for each NFS page read. After this commit, nfs_readpages() is converted to nfs_readahead(), which now uses the new mm interface readahead_page(). The new interface requires callers to call task_io_account_read() themselves. In addition, to nfs_readahead() task_io_account_read() should also be called from nfs_read_folio(). Fixes: 8786fde ("Convert NFS from readpages to readahead") Link: https://lore.kernel.org/linux-nfs/CAPt2mGNEYUk5u8V4abe=5MM5msZqmvzCVrtCP4Qw1n=gCHCnww@mail.gmail.com/ Signed-off-by: Dave Wysochanski <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent eeac8ed commit 9c88ea0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/nfs/read.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/stat.h>
1616
#include <linux/mm.h>
1717
#include <linux/slab.h>
18+
#include <linux/task_io_accounting_ops.h>
1819
#include <linux/pagemap.h>
1920
#include <linux/sunrpc/clnt.h>
2021
#include <linux/nfs_fs.h>
@@ -337,6 +338,7 @@ int nfs_read_folio(struct file *file, struct folio *folio)
337338

338339
trace_nfs_aop_readpage(inode, folio);
339340
nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
341+
task_io_account_read(folio_size(folio));
340342

341343
/*
342344
* Try to flush any pending writes to the file..
@@ -393,6 +395,7 @@ void nfs_readahead(struct readahead_control *ractl)
393395

394396
trace_nfs_aop_readahead(inode, readahead_pos(ractl), nr_pages);
395397
nfs_inc_stats(inode, NFSIOS_VFSREADPAGES);
398+
task_io_account_read(readahead_length(ractl));
396399

397400
ret = -ESTALE;
398401
if (NFS_STALE(inode))

0 commit comments

Comments
 (0)