From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 047A13019A6 for ; Sun, 7 Jun 2026 07:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780817527; cv=none; b=pZq8qC0UNLac9VUABxBm+CV1L58R+Yfy3SCAK3mh/2TvPKLQfFbziFV7ElPgYK5p/pkcduGvf25rGnB6wnFajgQhyRgCGc8y0v8mbEkOYmSJiKYvJXB0BqKHFTG3R3mRrxLELqS9trHBgLxhW5IksHcKFPyRZnJXNs4EqaG3nDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780817527; c=relaxed/simple; bh=X5iwO1FACE+1+2xU8oc4DOo/3EV26eWzaAKzM8GlpEU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NuznCVJEP9IA1U+ZvNodLQ5waFZnLMFciW7aLzxVSCoAZb9etkkRsqFmczPhrYIWIae7u/lbDDxlQWGwd4gNKg43l/4NADZAz8iXlLKDO0Qes/9sIMwKPhcGNNqSekbQOe4xS8YZ+Pf9QBN0JNz0tEuXDNeCdlBQL4s68rCyg6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JeSeoNzw; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JeSeoNzw" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-45ef616daf6so2871493f8f.3 for ; Sun, 07 Jun 2026 00:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780817524; x=1781422324; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DGsP3mPndPhYcXEi6EgFHfHqDO/gbUdhLXTqxEZxCZg=; b=JeSeoNzwJH5dwinLL9rqqjEirJlPeXDYaaX3feCcHFOXrYUT0oW4zTEN4GZMcSOSxY U2DruBakXr3XDS5VjO6ReL2aVA9q2vNuEJodZI8AqOcO+DwccaJCSs4C/GgUzdnKn+ZL Udnv6TbvdKZ7GtIvKGCYaZ0S5ckaOezQahhxPH52UAGGxSxN7f7IrqfqPx5BSbJ7TVy4 tvvRo7A0I8/DZEfFEpxw0Fj8OTzul/S5PPpe9jJcB1f54jhAVmvr1cRbhOx+teFbu0jX b2ZC3KIgOKeIgrgjjCf26hZ4ydpsQbkzJtdFU22ckj0CurdtjRlJqOa3/8lkHeffucdR MqZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780817524; x=1781422324; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DGsP3mPndPhYcXEi6EgFHfHqDO/gbUdhLXTqxEZxCZg=; b=RFzHXuOxwWnm921s91a6RgVssE1J9AGVDRFjXerZIAZjq/TtnAEqVscErJQPtaU5gH MaDGBKEfK+OJUn25CtsoaqyHm/FOHaZeQZcNttzuEF57nnElHI1gil5xKd0oA3Rqa/SX Q0265gTvrNtlsT1c56eNS/Ba1C2F0TrhKRlFxP58ZgE+FO5nJcbTXfTA0BxKRU9vxL9A oyqkfaf5HePZEIM1UJxl+c4gUaa7hruW005Mk7//ryeItG/hFHIc7AlES0sfKmchQW3K mCa6PRVIxIH5E2p5h9cE2xLjNF6/5lbGeFPmGoz/SIRZcUrUl02LPEFTooELrkSJ/1sy 8TUQ== X-Forwarded-Encrypted: i=1; AFNElJ/bEuTdobbFPYFtRAxAsTS/tHrdCikxxSbqd67MuCxz9DnhpYSRYBbnWRjEqG5vfaP4DxOVAh6aTb28iwE=@vger.kernel.org X-Gm-Message-State: AOJu0YwTn9M4C0OhRvFAnxo3c+ByBHyxJar49gzvN6l+Jp+vENBBIXiP LaJ3/vA8KOXwxt+KvC80f9zaj0kBWCl9Ui4Clh2afYW9/v+VZSxDj5OI X-Gm-Gg: Acq92OF/+HoaZrqojwFBQksU+t/8dSn/e/MPAtXK2DTLgX6aiIah06/wY15utGNMcN2 4gBFbGQW8FAYBPe94C3CUMpJJxm7lH6iiwLbh0Emz7ghvr3nD+SwAzGRylU0+NnScCWMVPj8Inl IJ3AzZ0k/TleM0ovK5JlWD+PWC6C4makyBQCRw1vDpwl3FRcRcfHWaplOpaPW6w0GnDvmrb4X6C 51SA7JAPTag7I0Ys8OlQ4lXr3izmbOiRn+UMXg0hshswpmWrj1/cYRK9wf0QSJTb7LB6OzhwLx+ OE3InCK2MR9DC1ZDMY/gaenw0Jf7Rlc8XcNu6+yf9cDEH6HrU9N1rkV/HtVEVztBiGOKTPsEYqs dFT1c0VG0cMmcd0F3yu0O0j6qMEfKQxASFPepwV+1+HLIjzhU1bJcFJkPlaXg3tVxLg4wr1NtZS 08P4IuJ4mVSAHuA5D+ae5dT+qswC/M4TAlAhIQUNu8RDiedzE9FGsk X-Received: by 2002:adf:e30e:0:b0:460:1233:ecf2 with SMTP id ffacd0b85a97d-46030609798mr12570199f8f.30.1780817524257; Sun, 07 Jun 2026 00:32:04 -0700 (PDT) Received: from puck (234.243.199.146.dyn.plus.net. [146.199.243.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f351d40sm40459372f8f.26.2026.06.07.00.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2026 00:32:02 -0700 (PDT) From: Dylan Yudaken To: trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org Cc: axboe@kernel.dk, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Dylan Yudaken Subject: [PATCH v2 0/2] nfs: support FMODE_NOWAIT on O_DIRECT reads Date: Sun, 7 Jun 2026 08:31:53 +0100 Message-ID: <20260607073155.105314-1-dyudaken@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 have restricted this to read-only files initially, as the code paths are simpler. 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. v2: Suggestions from Sashiko: * Handle file flags changing * Do not use mapping_empty anymore as it was apparently racy [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 read-only files fs/nfs/direct.c | 12 ++++++++++-- fs/nfs/file.c | 16 +++++++++++++++- fs/nfs/internal.h | 1 + fs/nfs/io.c | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 3 deletions(-) base-commit: a2be31abc3fac6a20f662f6118815b9c40c371c9 -- 2.50.1