]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nfs: new tracepoints around write handling
authorJeff Layton <jlayton@kernel.org>
Fri, 8 Aug 2025 11:40:32 +0000 (07:40 -0400)
committerAnna Schumaker <anna.schumaker@oracle.com>
Tue, 23 Sep 2025 17:28:19 +0000 (13:28 -0400)
New start and done tracepoints for:

nfs_update_folio()
nfs_write_begin()
nfs_write_end()
nfs_try_to_update_request()

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/file.c
fs/nfs/nfstrace.h
fs/nfs/write.c

index d06603ed52ece4173b17cd26ac2b1a1f58818f9d..579f2aaeca94709717ef13be89ebc2acbabd6cff 100644 (file)
@@ -388,6 +388,8 @@ static int nfs_write_begin(const struct kiocb *iocb,
        int once_thru = 0;
        int ret;
 
+       trace_nfs_write_begin(file_inode(file), pos, len);
+
        dfprintk(PAGECACHE, "NFS: write_begin(%pD2(%lu), %u@%lld)\n",
                file, mapping->host->i_ino, len, (long long) pos);
        nfs_truncate_last_folio(mapping, i_size_read(mapping->host), pos);
@@ -396,8 +398,10 @@ static int nfs_write_begin(const struct kiocb *iocb,
 start:
        folio = __filemap_get_folio(mapping, pos >> PAGE_SHIFT, fgp,
                                    mapping_gfp_mask(mapping));
-       if (IS_ERR(folio))
-               return PTR_ERR(folio);
+       if (IS_ERR(folio)) {
+               ret = PTR_ERR(folio);
+               goto out;
+       }
        *foliop = folio;
 
        ret = nfs_flush_incompatible(file, folio);
@@ -412,6 +416,8 @@ start:
                if (!ret)
                        goto start;
        }
+out:
+       trace_nfs_write_begin_done(file_inode(file), pos, len, ret);
        return ret;
 }
 
@@ -425,6 +431,7 @@ static int nfs_write_end(const struct kiocb *iocb,
        unsigned offset = offset_in_folio(folio, pos);
        int status;
 
+       trace_nfs_write_end(file_inode(file), pos, len);
        dfprintk(PAGECACHE, "NFS: write_end(%pD2(%lu), %u@%lld)\n",
                file, mapping->host->i_ino, len, (long long) pos);
 
@@ -453,13 +460,16 @@ static int nfs_write_end(const struct kiocb *iocb,
        folio_unlock(folio);
        folio_put(folio);
 
-       if (status < 0)
+       if (status < 0) {
+               trace_nfs_write_end_done(file_inode(file), pos, len, status);
                return status;
+       }
        NFS_I(mapping->host)->write_io += copied;
 
        if (nfs_ctx_key_to_expire(ctx, mapping->host))
                nfs_wb_all(mapping->host);
 
+       trace_nfs_write_end_done(file_inode(file), pos, len, copied);
        return copied;
 }
 
index 5adc2edce1350c38c3455a9a3f818ba48361c15f..8965187d428563ec91388aea357c730b6c680ad9 100644 (file)
@@ -1051,6 +1051,19 @@ DEFINE_NFS_FOLIO_EVENT_DONE(nfs_writeback_folio_done);
 DEFINE_NFS_FOLIO_EVENT(nfs_invalidate_folio);
 DEFINE_NFS_FOLIO_EVENT_DONE(nfs_launder_folio_done);
 
+DEFINE_NFS_FOLIO_EVENT(nfs_try_to_update_request);
+DEFINE_NFS_FOLIO_EVENT_DONE(nfs_try_to_update_request_done);
+
+DEFINE_NFS_FOLIO_EVENT(nfs_update_folio);
+DEFINE_NFS_FOLIO_EVENT_DONE(nfs_update_folio_done);
+
+DEFINE_NFS_FOLIO_EVENT(nfs_write_begin);
+DEFINE_NFS_FOLIO_EVENT_DONE(nfs_write_begin_done);
+
+DEFINE_NFS_FOLIO_EVENT(nfs_write_end);
+DEFINE_NFS_FOLIO_EVENT_DONE(nfs_write_end_done);
+
+
 DECLARE_EVENT_CLASS(nfs_kiocb_event,
                TP_PROTO(
                        const struct kiocb *iocb,
index 647c53d1418ae674dd3cca426d7eb6ee33238b53..18f8d7c9dbdd84a2cce79f73bb3ec81d0e203f55 100644 (file)
@@ -1017,11 +1017,12 @@ static struct nfs_page *nfs_try_to_update_request(struct folio *folio,
        unsigned int end;
        int error;
 
+       trace_nfs_try_to_update_request(folio_inode(folio), offset, bytes);
        end = offset + bytes;
 
        req = nfs_lock_and_join_requests(folio);
        if (IS_ERR_OR_NULL(req))
-               return req;
+               goto out;
 
        rqend = req->wb_offset + req->wb_bytes;
        /*
@@ -1043,6 +1044,9 @@ static struct nfs_page *nfs_try_to_update_request(struct folio *folio,
        else
                req->wb_bytes = rqend - req->wb_offset;
        req->wb_nio = 0;
+out:
+       trace_nfs_try_to_update_request_done(folio_inode(folio), offset, bytes,
+                                            PTR_ERR_OR_ZERO(req));
        return req;
 out_flushme:
        /*
@@ -1053,6 +1057,7 @@ out_flushme:
        nfs_mark_request_dirty(req);
        nfs_unlock_and_release_request(req);
        error = nfs_wb_folio(folio->mapping->host, folio);
+       trace_nfs_try_to_update_request_done(folio_inode(folio), offset, bytes, error);
        return (error < 0) ? ERR_PTR(error) : NULL;
 }
 
@@ -1290,6 +1295,8 @@ int nfs_update_folio(struct file *file, struct folio *folio,
 
        nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
 
+       trace_nfs_update_folio(inode, offset, count);
+
        dprintk("NFS:       nfs_update_folio(%pD2 %d@%lld)\n", file, count,
                (long long)(folio_pos(folio) + offset));
 
@@ -1309,6 +1316,7 @@ int nfs_update_folio(struct file *file, struct folio *folio,
        if (status < 0)
                nfs_set_pageerror(mapping);
 out:
+       trace_nfs_update_folio_done(inode, offset, count, status);
        dprintk("NFS:       nfs_update_folio returns %d (isize %lld)\n",
                        status, (long long)i_size_read(inode));
        return status;