From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 1B9B23264FF for ; Tue, 16 Jun 2026 13:40:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781617205; cv=none; b=UtUaqR1YhqUOqU15tvr2VE3mUrtrIdPGeg5o7HzRlzeAp39M+WsxQl42RBFkQci580kNb3XB/hWC4s5JGX8eaoLQ6cY3Zy1YIDtjT/l1UQbniVf3MIOvdZTxj553NCpjMHzWgwmhCOqJ9vasibzmOZIOmocOlIIgUFw8qyNVn/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781617205; c=relaxed/simple; bh=tUxT1zI1BNmrmL6C8tiQenB5TPmL4oGqhjOnjcJ2vRA=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=eOsp+LKzgZgoBva4MiQ2LBiT/ZZd3//GKG4ks3onJtN8gcagg3Q0dKsTJHAz0hC6xlEUs2Zoi8BE6hy4Qfl6zprdjg0rbiQxLntW32qxnOIU/gGswTvdJ8vTE4TpeqeJWUGwkDYQ/ohT57YULwxO8+voODf9UyPh6t5UwtpRug4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--praan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TOgAkWPi; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--praan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TOgAkWPi" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2bf55c3f44aso41526465ad.0 for ; Tue, 16 Jun 2026 06:40:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781617203; x=1782222003; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=KfmNEms9WT8BM1m0vGOF8Pag7VQCxRcR85ufJLQG+hY=; b=TOgAkWPiq/QW0GEaM/vnvJmevCn2old5uJgtVfgtHE1pva/2y7H9ZbJ3yEmQcgiwj2 4CEZf+XoIGeYdQkxTXh3p7oqSx+3ypWYj0GqCPHjYz5dWks9L3loR2ze/JJySSTxoqZL s38pBvio9kCTfwaSpN1sKTSXfoIQE9GvVcoqFb++Utp4rLhP7jR1SVzJH0Fah0edDuQU 9t7ugYeLpwmptmT+320tuLt9l1f38qcPpV8tyD148lz12omyToySpMaLu8qE54r6593A Zlbv1d7F4et5jyk4OG9HU4tlYWH6OEZrcEcLerYHmLRml3z2OI1lI+PuunKn6VbmiZrw quCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781617203; x=1782222003; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=KfmNEms9WT8BM1m0vGOF8Pag7VQCxRcR85ufJLQG+hY=; b=AR9NBVIo/NFaEZt6fwTBOUFVSDCaXjB6pamuJ4ZhhEKpSlWEjk+SfzJHGC0AYChpe7 nFT5eaecFvqQL1Dox8lUqkjDJXUpUrDCBs45qM5ftj/RF+lbXsGesgaiG5u/fPixcyQz +ujtDc1zXZmNk8hFVHAtqZDCQ5U2OBL7yqVBPFCfsKooc40TXLGLJ6Ue98B7D9MadFMY 1OZc/+grWVE0IEO/xb3K+DdnACeE919aB7v2oAsI5h8/ZWzyDQwz0AQCZS97GT7J1y+g IbUhJvK9Dy1TxEFGglhpdeLFTuXCNzUqwbJJJvujpLzHULw7IDJIDFZDl+ennW8PxUYu nATQ== X-Forwarded-Encrypted: i=1; AFNElJ8XNVkZllAcU1RY9FDkHlSoq5llic86Sr8rbGTlBn8EWoXxxw6WagBMmJ1416X7Be54tuPSEw65cXpzfdc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5fkKvIor38hYElMujBak8Z+OwDuX3zCi4N657hZ+IcHeEIIW0 MnPC8fs5VrmeSD0Uv0WhvtvSgTlL6ga4U0VtbssvZAF9MWAaGs0Fk3CzWmU+c/FNrpY631ReXfL H1w== X-Received: from plbay2.prod.google.com ([2002:a17:902:8b82:b0:2be:b2c1:9921]) (user=praan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1a2d:b0:2bf:22ac:a7d8 with SMTP id d9443c01a7336-2c699a8d1fcmr29977185ad.5.1781617202996; Tue, 16 Jun 2026 06:40:02 -0700 (PDT) Date: Tue, 16 Jun 2026 13:39:53 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.1136.gdb2ca164c4-goog Message-ID: <20260616134000.2733403-1-praan@google.com> Subject: [PATCH v2 0/7] nfs: Modernize Direct I/O path From: Pranjal Shrivastava To: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Trond Myklebust , Anna Schumaker , Christoph Hellwig , Christoph Hellwig , Shivaji Kant , Pranjal Shrivastava Content-Type: text/plain; charset="UTF-8" Modernize the NFS Direct I/O path as a preparatory step to enable PCI Peer-to-Peer DMA (P2PDMA) support. Following feedback on the initial RFC [1], the modernization and architectural changes are split into this standalone series. Currently, NFS O_DIRECT relies on the legacy iov_iter_get_pages_alloc2() API which does not support the pinning requirements for P2P memory. The implementation moves NFS to the modern iov_iter_extract_pages() API and migrates NFS direct I/O away from pages to use folios. Design ====== 1. Pin-Awareness Standard NFS requests use get_page() and put_page() for memory management. However, memory extracted via iov_iter_extract_pages() requires explicit pinning. Introduce a PG_PINNED flag and a wb_nr_pinned count to struct nfs_page. This allows the request lifecycle to track ownership of physical pins and ensure that unpinning is performed only when the I/O is complete. 2. API Migration Migrate the Direct I/O path to the modern iov_iter_extract_pages() API. This aligns NFS with the modern extraction model and serves as the foundation for passing ITER_ALLOW_P2PDMA in a follow-up series. 3. Extraction Helper and Folio Support Introduce a new extraction helper in direct.c to group contiguous pages from the same folio into a single struct nfs_page. This effectively migrates the Direct I/O path from being page-based to being folio-based. Note: zone_device_pages_have_same_pgmap() checks are intentionally omitted in the extraction helper since P2PDMA enablement will be introduced in a follow-up series. Bisectability ============= The series attempts to remain bisectable. [Patches 1-2] Introduce pin-aware infrastructure and accounting. [Patch 3] Adds a centralized request release helper. [Patch 4] Migrates the Direct I/O path to iov_iter_extract_pages(). [Patches 5-6] Implement the extraction helper and folio-based grouping. [Patch 7] Removes orphaned page-based helpers. Testing ======= This series has been tested with xfstests [2] on RDMA & TCP transports: ./check generic/091 generic/130 generic/139 generic/143 generic/154 \ generic/155 generic/183 generic/188 generic/190 generic/196 \ generic/198 generic/203 generic/214 generic/240 generic/263 \ generic/287 generic/290 generic/292 generic/330 generic/444 \ generic/450 generic/451 generic/586 generic/647 generic/708 \ generic/729 generic/760 The following summary was tabulated via a custom script [3] (on github). python3 display.py results/*/check.log +--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+ | testcase | rdma-sys-3 | rdma-sys-4.0 | rdma-sys-4.1 | rdma-sys-4.2 | tcp-sys-3 | tcp-sys-4.0 | tcp-sys-4.1 | tcp-sys-4.2 | +--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+ | generic/091 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/130 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/139 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/143 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/154 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/155 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/183 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/188 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/190 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/196 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/198 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/203 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/214 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/240 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/263 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/287 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/290 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/292 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/330 | skipped | skipped | skipped | pass | skipped | skipped | skipped | pass | | generic/444 | skipped | skipped | skipped | skipped | skipped | skipped | skipped | skipped | | generic/450 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/451 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/586 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/647 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/708 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/729 | pass | pass | pass | pass | pass | pass | pass | pass | | generic/760 | pass | pass | pass | pass | pass | pass | pass | pass | +--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+--------------+ Thanks, Praan [1] https://lore.kernel.org/all/20260401194501.2269200-1-praan@google.com/ [2] https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git [v2] - Fix data corruption in nfs_direct_extract_pages() by correctly calculating intra-page offsets using offset_in_page(). - Fix requested_bytes accounting in direct read/write paths to only increment after successful RPC scheduling. - Add missing kernel-doc descriptions for the @pinned parameter in nfs_page_create_from_page() and nfs_page_create_from_folio(). - Rebase on fs-next/ [v1] https://lore.kernel.org/all/20260603053033.3300318-1-praan@google.com/ Pranjal Shrivastava (7): nfs: make nfs_page pin-aware nfs: Track number of pinned pages in nfs_page nfs: Introduce nfs_release_request_list helper nfs: migrate direct I/O to iov_iter_extract_pages nfs: introduce nfs_direct_extract_pages helper nfs: Optimize direct I/O to use folios for requests nfs: Cleanup the nfs_page_create_from_page helper fs/nfs/direct.c | 165 +++++++++++++++++++++++---------------- fs/nfs/pagelist.c | 87 +++++++++++---------- fs/nfs/read.c | 2 +- fs/nfs/write.c | 2 +- include/linux/nfs_page.h | 12 ++- 5 files changed, 150 insertions(+), 118 deletions(-) base-commit: 389bb4a76905771adfa86d21ee0b865247148e9d -- 2.54.0.1136.gdb2ca164c4-goog