Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFS: Fix /proc/PID/io read_bytes for buffered reads

Prior to commit 8786fde8421c ("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: 8786fde8421c ("Convert NFS from readpages to readahead")
Link: https://lore.kernel.org/linux-nfs/CAPt2mGNEYUk5u8V4abe=5MM5msZqmvzCVrtCP4Qw1n=gCHCnww@mail.gmail.com/
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

authored by

Dave Wysochanski and committed by
Anna Schumaker
9c88ea00 eeac8ede

+3
+3
fs/nfs/read.c
··· 15 15 #include <linux/stat.h> 16 16 #include <linux/mm.h> 17 17 #include <linux/slab.h> 18 + #include <linux/task_io_accounting_ops.h> 18 19 #include <linux/pagemap.h> 19 20 #include <linux/sunrpc/clnt.h> 20 21 #include <linux/nfs_fs.h> ··· 338 337 339 338 trace_nfs_aop_readpage(inode, folio); 340 339 nfs_inc_stats(inode, NFSIOS_VFSREADPAGE); 340 + task_io_account_read(folio_size(folio)); 341 341 342 342 /* 343 343 * Try to flush any pending writes to the file.. ··· 395 393 396 394 trace_nfs_aop_readahead(inode, readahead_pos(ractl), nr_pages); 397 395 nfs_inc_stats(inode, NFSIOS_VFSREADPAGES); 396 + task_io_account_read(readahead_length(ractl)); 398 397 399 398 ret = -ESTALE; 400 399 if (NFS_STALE(inode))