From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796406127; b=CojcVd9i6iKeGnEyttK0oKtz6I3x8tuw823yQ3+GL/OiSnqH9JzBFFcq9euFUPhlMp+C SJu/z2wWIW7Oh5BNWmnNU/qX4b4oNuC2l9MyjxpLxYdpekJlDfgWWgseU0jWq9XGwhl27 638d8TD1xynex+HmNvDreeJUErimVzJvZqu3Xqe+QFyQYeUnPQgpSMrD2kGsfwp3cb1hx lRCAjCSJQ0iK7QIPKAonZCJwskI2gZQOUBbHbLezqI2rZjEPwZGWMYx5QgzE11LA/4Gy/ IevzBfzljDgf+oI/VgacEIjxyanDQWL1zdxvSe2SRVFRrt92PxIUnXGQMY919IZW7LQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796406127; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=J73HjT+Z5O9G/J7I1RntPwjaF5NgQ70dM5kxPE7gKEE=; b=BPF31PD0qCSlAeJtzQAnZHMc71NNz3CE353TVNKSQ93YBX6UO85FiathSC7JtZ5FaWwy 9kGNegMAGFJYnMBP0fXd4Gb03XNpg7Mqd7wn/E3q7zOu7z/8/wZJfJzOGPu3rNgDUXGKM UAcdwDMQ1UVWLxqAVGcV2Tju8IXzyPsuL77+JFL3yD4leijSnE7ajllCFMdCFaxVBZ52m i8PnB1LzVsX63+B4uffwRgvnVUK9DKS5DVUwv/CcXKiJS2eOZ67S6IsQbiB+jjXXLN1Ra hi+kdWa6zVcZKb6lwvW/ZitkgUsDIvB4vp3qTSpwFJjfpfmMm3RW3bSRmGfsCjYGwug== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=hammerspace.com; spf=pass smtp.mailfrom=hammerspace.com; dkim=pass header.d=hammerspace.com header.i=@hammerspace.com header.a=rsa-sha256 header.s=google header.b=pgFJMjFc; arc=none smtp.remote-ip=209.85.210.43 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 472D8606A32D for ; Fri, 4 Dec 2026 17:42:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 472D8606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hammerspace.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hammerspace.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=hammerspace.com header.i=@hammerspace.com header.a=rsa-sha256 header.s=google header.b=pgFJMjFc Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-86156cf8a7eso1751649a34.1 for ; Fri, 04 Dec 2026 09:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1796406126; x=1797010926; 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:content-type; bh=J73HjT+Z5O9G/J7I1RntPwjaF5NgQ70dM5kxPE7gKEE=; b=pgFJMjFcYqTVkFf5BRYWYHCAuc/yTrYGIfcquXIO066ImYBYoXLUiA5mZnvhtznqeV zVijoH1XxN5SmVHzbLlW/eduJogvfbCJ8BC10OYqZjTP5nvq54xo9c9bnPYSZf4M1oS9 jpdwnA/FCGhu5R1XHGIgHHeRdHMj2z4z/hP1WXODPG4okU7kB1uNgIVuxezTQvWnSrFV 3kgJ4vd9UxeinfshpZwrTzARKfBRmD3BNGUsK8tQkvkFvyJFSM7854T2Ghag0efQ+MO+ Gu9o8s2RkgZs+4jkEZDTcjwju3r/ixSP3ZjaVYflD57Ph2aNuuOReaaFggD4+ute5s4J 5LZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796406126; x=1797010926; 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:content-type; bh=J73HjT+Z5O9G/J7I1RntPwjaF5NgQ70dM5kxPE7gKEE=; b=T4LLycLpo6bd5kSUn/xDZXhN2bMZEPGRUQoAnZydAYOSIqjdYgdlMI5Vesjs0Zr3oc dsQYKJHoZkO5p7uq8UHsxpfotaGf/MJ+Ampb3jZnKrK1VMfWuPrXW89Xh62CzFJmo2Y4 RbGZQP1drev0rhZagTq3OgphcDq2P6z1Q/kRIl+xnvV5gcxs+phuhQ7hEslxDdvCWRoU O8dUHvENkablcZ6NAkQTwI0G5VmJjYGNAFI/d5Oqj69k/IeRq7g1zW+BCNyEJlHIDzTj VaapFOVsm0OJKNGiutIMb4e1ms1zIsq1iVbuU7WHMsfs2WpCpiOrQlW43fjvmkXxDxo+ ouYg== X-Forwarded-Encrypted: i=1; AL+hErFDALAbvs4qIn1V6OOVTzz0mB6mFrFuJQnwZHPb4bsaLfra86lYwLV0TLdQnQ0NzfeuaFzlaVoobP8=@vger.kernel.org X-Gm-Message-State: APuU4Z/aPnzElsx/Xk8erldjsH0jz0doc7BtV6PxdEffmwplrOxTDmPJ Wvu9m+AJ6XE7ow/LdbihH35nqPirnAYYjYx8B7aGbsZF+RD77PsorweYIOtKOV9ti1Y= X-Gm-Gg: AZFdTZeRv4mMDDItS0k2ZbI15u0bqTZ8FvzpF4V93MffAdvmf+069+bof3GNMgctToa 3P91I90yYK6xA7I0uJv0HxacveEeWWhXuFi49vXclq81K9mf36ZLv138gJyyade1eioCUkU+BYe 9H7vmvQHRRigYSCkiiMiAMEUhCNa345zBCYMu1dUxJ7r0/t2ySgbDwDotI7g9qwMOffQQpSuyXo xv5hVPnopQ0+9Grnn4LWXiTjwpzoyLgqmKlF7wQaMgarFBDdhil615/yM9XGHG0km4Fml6DFAuS RJXk2z56RRhwl2T8mXrpmqidTJEGYTf3G3Xm037hzdG+1EILcBnWyrXE5AkSB4aeh0ynTtXFD1a Bm8J/QTdDb1G2C4kPRtvv2Zd+HP/o4YPnOF/YUuuPVQ5moxPDJk+7rniXeunnplgEJplKIP1FGh vRraEksmLdNQ/DybUCCUuQECl2tyV3L/VpRqI8sPLiGHjofxg7nnZJHJRCmqzdZDz9kvqZyuVHI PnsaMPK4Vd+tO9T1aQ4DWGGaOb8jZBD1WKOBWukgq9SrbYJt7nlIL800EOmGOxjs9ZwmAW+Yfdk 8tHZtNDnohXBzKoZqxqkT4dPn2GvAAbUC9ylMtLp+DesdoxdkgJWw24vNqeFGNSc19JvEs9b X-Received: by 2002:a05:6820:3511:10b0:71a:fec1:da65 with SMTP id 006d021491bc7-71bf21ad7c2mr1221455eaf.46.1796406125829; Fri, 04 Dec 2026 09:42:05 -0800 (PST) Received: from bcodding.csb.hammerspace.com ([66.97.168.37]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-71bef0cd34asm3035398eaf.3.2026.12.04.09.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 09:42:05 -0800 (PST) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker , Mike Snitzer Cc: Olga Kornievskaia , linux-nfs@vger.kernel.org Subject: [PATCH v5 00/12] pNFS: layout recalls and writes that have to be resent Date: Fri, 4 Dec 2026 12:41:51 -0500 Message-ID: X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Benjamin Coddington v3 answered a CB_LAYOUTRECALL with NFS4ERR_DELAY while I/O on the layout drains. Trond pointed out on 5/6 that a layout segment reference does not mean I/O is in flight: a pageio descriptor keeps its segment while it waits for a folio lock or faults in an O_DIRECT buffer, and a commit bucket keeps one until the COMMIT is sent. Those holders keep a recall from completing, and what they wait for can be waiting for the layout the recall holds back. Two cases deadlock, with or without v3: - An O_DIRECT write whose buffer is an mmap of the same file. The writer faults the buffer in with its descriptor and its commit buckets holding segments, and the fault's read waits for a layout. - Writeback that has queued one folio and waits for the lock on the next, while the task holding that lock is in nfs_wb_folio() or nfs_read_folio() waiting for a layout. This version stops those holders from keeping the layout in use. Patch 8 adds a second count on the layout segment, pls_hold, which keeps the segment allocated without keeping it on the layout. Patches 9 and 10 move the pageio descriptor and the commit buckets to it. They take a reference only when they put I/O or a COMMIT on the wire, and if the segment has been invalidated by then the requests are sent again with a new one. Patch 12 is v3's file recall patch without the flag that blocked LAYOUTGET: it answers NFS4ERR_DELAY only while a segment in the recalled range is in use. A held segment keeps its mirrors on the flexfiles layout header's list after the segment has been returned, so patch 7 has the lookup for a deleted deviceid walk the segments that are on the layout. That resend path is the one the mirrored write fallback series fixes, and the recall tests don't pass without it, so its remaining three patches are here as patches 1, 3 and 4, and that series ends: https://lore.kernel.org/linux-nfs/cover.1795148523.git.bcodding@hammerspace.com/ With patches 8 to 10 and without patch 1, an O_DIRECT write under recalls returns success with mirrors left holding old data. Without patch 4, KASAN reports a use-after-free of the mirror array. Patch 2 returns the error from an O_DIRECT read whose requests were all dropped, and ends the read's count at the first request dropped. Patches 5 and 6 pace the O_DIRECT write resend, which otherwise runs without a pause until a layout is available. Patch 5 is 2/5 of the FF_FLAGS_NO_IO_THRU_MDS series unchanged: https://lore.kernel.org/linux-nfs/cover.1795122899.git.bcodding@hammerspace.com/ Splitting the references also solves the nfs_wb_folio() problem I asked about on 1/5 of the FF_FLAGS_NO_IO_THRU_MDS series. With patch 9 a task can wait for a layout with the folio locked, so patch 11 has nfs_wb_folio() wait and resend a folio that the layout driver refuses with -EAGAIN. That replaces 1/5. The rest of that series is posted on top of v4 of this one, and I'll rebase it on this version. v3's 6/6 (write through the MDS while a recalled layout drains) is dropped. Tested on a KASAN kernel against a reffs MDS that hands out six-way mirrored flexfiles layouts with FF_FLAGS_NO_IO_THRU_MDS, with knfsd as the NFSv3 data server so that writes are UNSTABLE and need a COMMIT: - Buffered and O_DIRECT readers and writers on three files while FSID, ALL and FILE recalls, with clora_changed set and clear, run in a loop. The files and each of the six mirrors match the data written. On the base, a buffered write(2) in this test fails with EAGAIN in some runs. With patch 11 it doesn't. - The O_DIRECT write from an mmap of the same file, with an FSID recall sent while the writer is between chunks. On the base the writer stays in ff_layout_pg_retry_wait() until it is killed. With the series the write completes and the recall gets NFS4ERR_NOMATCHING_LAYOUT. - Writeback stopped after queueing its first folio, with a test-only delay, while a FILE recall is outstanding and a second task reads or writes the next dirty folio. On the base both tasks hang. With the series both finish and the data is correct. - Buffered data written UNSTABLE and not yet committed when an FSID or FILE recall arrives. The data is written again with the new layout and reads back correctly. Not tested: layouts with a single mirror, the files layout driver, and the block layout drivers. The changes since v4 are for cases these tests don't reach, and were made from the review alone. The series is based on Trond's testing branch at 3e1999173432, which has 1/6 to 4/6 of v3 and 2/4 of the mirrored write fallback series. Changes since v4, from the sashiko review: https://lore.kernel.org/linux-nfs/cover.1796306148.git.bcodding@hammerspace.com/ - New patch 7: the flexfiles lookup for a deleted deviceid walks the layout's segments. - Patch 9 (was 8): a LAYOUTERROR takes its segment reference only if the segment still has one. A descriptor's segment may have left the layout by then, and v4 took the reference from zero. - Patch 9: a write that is rescheduled from the submitter drops its open context reference through nfsiod, as writeback must. - Patch 9: the reference for I/O is taken without the inode's i_lock. - Patch 10 (was 9): pnfs_generic_commit_pagelist() keeps the layout header while it goes through the commit lists. In v4 a commit bucket's hold could be the last reference on the header that the lists are part of. - Patch 11 (was 10): nfs_launder_folio() doesn't resend from an exiting task or a kernel thread, where no signal ends the wait, and a fatal signal is checked after every wait. - Patch 4: a failure to create the DS RPC client returns the layout unless the write goes to the MDS. v4 retried at once on the same layout. - Patch 2: the read's count ends at the first request dropped. A pNFS read that is resent can drop requests from the middle. - Patch 3: an O_DIRECT write that fails with a hard error ends its count at the request that was refused, whose copy another mirror may have sent. - Patches 3 and 4: the stable tag is v6.6+, where patch 1 applies. - Changelogs of patches 10 and 11 corrected (LOCALIO commit, nfs_update_folio()). Changes since v3: https://lore.kernel.org/linux-nfs/cover.1793627813.git.bcodding@hammerspace.com/ - 1/6 to 4/6 are in Trond's testing branch and are not reposted. - New patches 8 to 10: the pageio descriptor and the commit buckets don't keep a layout in use. - Patch 12 (was 5/6): doesn't set NFS_LAYOUT_BULK_RECALL, so LAYOUTGET is not blocked after the recall completes and a partial recall only waits for segments in its range. I/O is cancelled on every recall with clora_changed set. - 6/6 dropped. - New patches 2, 6 and 11. Patch 5 is from the FF_FLAGS_NO_IO_THRU_MDS series. Changes to patches 1, 3 and 4 since v2 of the mirrored write fallback series: - Patch 3: when the current mirror asks for a retry, the other mirrors are not sent until it has been coalesced again. The changelog no longer says the mirrors stay in step when their wsize differs. - Patch 4: a fatal error preparing the DS no longer returns the layout under FF_FLAGS_NO_IO_THRU_MDS. - Patch 1: unchanged. Benjamin Coddington (12): NFS: resend O_DIRECT write requests that error cleanup gets with -EAGAIN NFS: report the error when an O_DIRECT read's requests are never sent NFS: send every mirror when one of them can take no more pNFS/flexfiles: don't switch a busy mirrored write descriptor to the MDS NFS: make the O_DIRECT write work a delayed_work NFS: wait before resending an O_DIRECT write that was refused again pNFS/flexfiles: look for a deviceid in the layout's segments pNFS: add a layout segment hold that doesn't keep the layout in use pNFS: don't keep a layout in use from an idle pageio descriptor pNFS: don't keep a layout in use from a commit bucket NFS: wait and resend a folio refused with -EAGAIN in nfs_wb_folio() pNFS: answer a file recall with NFS4ERR_DELAY while I/O drains fs/nfs/callback_proc.c | 8 + fs/nfs/direct.c | 74 +++++--- fs/nfs/file.c | 6 +- fs/nfs/filelayout/filelayout.c | 2 +- fs/nfs/flexfilelayout/flexfilelayout.c | 117 ++++++++----- fs/nfs/inode.c | 1 + fs/nfs/internal.h | 3 +- fs/nfs/nfs42proc.c | 6 +- fs/nfs/pagelist.c | 46 ++++- fs/nfs/pnfs.c | 233 +++++++++++++++++++++---- fs/nfs/pnfs.h | 12 ++ fs/nfs/pnfs_nfs.c | 74 +++++--- fs/nfs/read.c | 3 +- fs/nfs/write.c | 49 ++++-- include/linux/nfs_fs.h | 1 + include/linux/nfs_xdr.h | 3 +- 16 files changed, 499 insertions(+), 139 deletions(-) base-commit: 3e19991734326332c736e24c9b47b2cffb8f9e42 -- 2.53.0