I had noticed that io_uring always punts O_DIRECT NFS reads to a background thread
since the file does not advertise FMODE_NOWAIT.
I am not very familiar with the NFS codebase, but looking around suggests a simple change
to nfs_start_io_direct is all that is required to properly support this functionality.
On the request issue side, it seems everything in NFS is actually run in the background
(post this lock change), and the completion codepaths all look to have no similar locking
semantics.
I unfortunately do not have the means to test the performance improvement, since even
without this change my local network is the bottleneck here.
However I do suspect that there are people that would want this fix ([1]).
Applying a similar patch on that GitHub issue did give performance gains.
To convince myself this works at all I did trace io_uring events through with and
without the patch.
Using a test app ([2]) to issue O_DIRECT io_uring reads calls io_uring_queue_async_work
without this patch, while with it the call is skipped and the completion is queued into
io_uring directly from nfs_direct_read_completion.
Patch 1 here adds an unused nfs_start_io_direct_nowait which patch 2 uses in order to safely
advertise FMODE_NOWAIT.
[1]: https://github.com/axboe/liburing/issues/1499
[2]: https://github.com/DylanZA/liburing/commit/264c06f1939dfd6b6bc4c967ada5960c4f4f2db3
Dylan Yudaken (2):
nfs: add nowait version of nfs_start_io_direct
nfs: expose FMODE_NOWAIT for O_DIRECT read files
fs/nfs/direct.c | 5 ++++-
fs/nfs/file.c | 13 ++++++++++++-
fs/nfs/internal.h | 1 +
fs/nfs/io.c | 38 ++++++++++++++++++++++++++++++++++++--
4 files changed, 53 insertions(+), 4 deletions(-)
base-commit: 670b77dfebe7257adc0defbc48a4c43cfdf6c8f6
--
2.50.1