summaryrefslogtreecommitdiffstats
path: root/fs/nfs/read.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2024-07-11 09:17:02 +0200
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2024-07-17 19:15:35 +0200
commitfada32ed6dbc748f447c8d050a961b75d946055a (patch)
tree14c49571a5db26af0fb4ad12e9648868578360c4 /fs/nfs/read.c
parentnfs: do not extend writes to the entire folio (diff)
downloadlinux-fada32ed6dbc748f447c8d050a961b75d946055a.tar.xz
linux-fada32ed6dbc748f447c8d050a961b75d946055a.zip
nfs: pass explicit offset/count to trace events
nfs_folio_length is unsafe to use without having the folio locked and a check for a NULL ->f_mapping that protects against truncations and can lead to kernel crashes. E.g. when running xfstests generic/065 with all nfs trace points enabled. Follow the model of the XFS trace points and pass in an explŃ–cit offset and length. This has the additional benefit that these values can be more accurate as some of the users touch partial folio ranges. Fixes: eb5654b3b89d ("NFS: Enable tracing of nfs_invalidate_folio() and nfs_launder_folio()") Reported-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs/read.c')
-rw-r--r--fs/nfs/read.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 036ede4875ca..6fee86a2eb42 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -333,13 +333,15 @@ out:
int nfs_read_folio(struct file *file, struct folio *folio)
{
struct inode *inode = file_inode(file);
+ loff_t pos = folio_pos(folio);
+ size_t len = folio_size(folio);
struct nfs_pageio_descriptor pgio;
struct nfs_open_context *ctx;
int ret;
- trace_nfs_aop_readpage(inode, folio);
+ trace_nfs_aop_readpage(inode, pos, len);
nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
- task_io_account_read(folio_size(folio));
+ task_io_account_read(len);
/*
* Try to flush any pending writes to the file..
@@ -383,7 +385,7 @@ int nfs_read_folio(struct file *file, struct folio *folio)
out_put:
put_nfs_open_context(ctx);
out:
- trace_nfs_aop_readpage_done(inode, folio, ret);
+ trace_nfs_aop_readpage_done(inode, pos, len, ret);
return ret;
out_unlock:
folio_unlock(folio);