nfs: don't reuse partially completed requests in nfs_lock_and_join_requests
authorChristoph Hellwig <hch@lst.de>
Mon, 1 Jul 2024 05:26:54 +0000 (07:26 +0200)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 8 Jul 2024 17:47:51 +0000 (13:47 -0400)
commitb571cfcb9dcac187c6d967987792d37cb0688610
tree248b65e74247c21002e66549a3d1852daa6c8a5c
parentf1b7c7552cbcf89e56b15ff481f3d19b53046291
nfs: don't reuse partially completed requests in nfs_lock_and_join_requests

When NFS requests are split into sub-requests, nfs_inode_remove_request
calls nfs_page_group_sync_on_bit to set PG_REMOVE on this sub-request and
only completes the head requests once PG_REMOVE is set on all requests.
This means that when nfs_lock_and_join_requests sees a PG_REMOVE bit, I/O
on the request is in progress and has partially completed.   If such a
request is returned to nfs_try_to_update_request, it could be extended
with the newly dirtied region and I/O for the combined range will be
re-scheduled, leading to extra I/O.

Change the logic to instead restart the search for a request when any
PG_REMOVE bit is set, as the completion handler will remove the request
as soon as it can take the page group lock.  This not only avoid
extending the I/O but also does the right thing for the callers that
want to cancel or flush the request.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/write.c