diff options
| author | Christoph Hellwig <hch@lst.de> | 2024-07-11 09:17:02 +0200 |
|---|---|---|
| committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2024-07-17 13:15:35 -0400 |
| commit | fada32ed6dbc748f447c8d050a961b75d946055a (patch) | |
| tree | 14c49571a5db26af0fb4ad12e9648868578360c4 /fs/nfs/write.c | |
| parent | 39c910a430370fd25d5b5e4b2f4b24581a705499 (diff) | |
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/write.c')
| -rw-r--r-- | fs/nfs/write.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index acf2d942d78f..b297833a4514 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -2063,17 +2063,17 @@ int nfs_wb_folio_cancel(struct inode *inode, struct folio *folio) */ int nfs_wb_folio(struct inode *inode, struct folio *folio) { - loff_t range_start = folio_file_pos(folio); - loff_t range_end = range_start + (loff_t)folio_size(folio) - 1; + loff_t range_start = folio_pos(folio); + size_t len = folio_size(folio); struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, .nr_to_write = 0, .range_start = range_start, - .range_end = range_end, + .range_end = range_start + len - 1, }; int ret; - trace_nfs_writeback_folio(inode, folio); + trace_nfs_writeback_folio(inode, range_start, len); for (;;) { folio_wait_writeback(folio); @@ -2091,7 +2091,7 @@ int nfs_wb_folio(struct inode *inode, struct folio *folio) goto out_error; } out_error: - trace_nfs_writeback_folio_done(inode, folio, ret); + trace_nfs_writeback_folio_done(inode, range_start, len, ret); return ret; } |