From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796306230; b=KsP6SBMH5doVxgdBUJv+OfqN1s1CakkoM6PmV4V3ocyQ+dedFlEwlBe1EjoTtT3lTlWb ISr7N1KpFPI7xf6amBDXjdhq+mBPJSg7T+U0E8i2imRhFyZ6Pz8LsqZ/QCvfSWYMohkwR hGxxCxWTPiz0zurTu8kMO94JzMWJMo0mrpUqpd3T/3pgI3T2pqIr6hy6i1iem74F35X1f 3Gf5GSVUoLIYFo83PwykxVKdaWrJ41905/YTtUTBXZomwFBJturjp4TR35Okh0JL9Ljat ZNuRw9eFa9O9GDy9H5fuxm7TZ/6sLs1UjxQ1PMnkk2pJBlIlbS82do3ZBg4pLva8CJw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796306230; 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=ynMNupnXcjP9rTLiJVLXfpLsPVKR9nOtYU25CEmJ6Js=; b=J+u9+eUhLai2bi4EnB/qRHvboTNP2frlD/phcdoNqrNuKTbwSPKR4bqXp3f5obwitpa8 mQCuhXpOLkpPkCL2D+oWDjWIQ8ZPckKB/Qf5sB3b3I2Scm62Hzd6x1+CgczVa7NgnEXfY qlt7iUHpgSlA7unHrI2AfXA/rF4PEKTcdMSm2ycNbDpEVIqSpVbhEmeiriTzdR4X3ukk7 QSxfjceVXOnlmFOZ8kDPJGFXC+ECPdQe4qOROr2EiDtW72sWm0QrgAqq4EZRLlrP2RqdO G1FqrlOhern91e6cbnnfK9lH0JveJd/5t88njIOOYzff/cbq9i7hBHcO1feW3Scp9Bg== 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=j++m38Ae; arc=none smtp.remote-ip=209.85.167.178 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 9BB38606A322 for ; Thu, 3 Dec 2026 13:57:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9BB38606A322 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=j++m38Ae Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-57e47de950fso5381052b6e.0 for ; Thu, 03 Dec 2026 05:57:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1796306228; x=1796911028; 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=ynMNupnXcjP9rTLiJVLXfpLsPVKR9nOtYU25CEmJ6Js=; b=j++m38Ae04LcIOtWQflhpRkZUxQRRJo2ZJRL9p/+ZupoLUZjghg2iWTlXuRonX8938 lMxg6Ds5xbJT46VSNzpkuyDHhBQtWiAbnoV57WTz1IC7LGUR0tGjpDhdh1hF/F62zNVO 4GCImrRmux4hZEr3eSBIeuRUSlGoAvvbKsqhZn0U0+K1dK2bG+QjqBaYOPWriOor5xYF bVdhqMielcUU41pTJ/xuUw8gQwjAk+oV3M5pRcZ7HwjviavinGkSlSCbGW1k9y0LcXyk 7mqUxw46IRQbIAj6PLGhOSa4Fz6AyjEQPXMehalnA3gePG9bw2XeuDf3e6/XRsWuv313 Y/rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796306228; x=1796911028; 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=ynMNupnXcjP9rTLiJVLXfpLsPVKR9nOtYU25CEmJ6Js=; b=ngn4F/wMBqiXOCbpNjRreEwsorr4j6N2a6UUQOOvsI5y7Qz5RopNoSqy32rfpBZjO2 lZoz/zX8F6+6P/SZb5swJf9GS3kgfqsKTwWaXv04C2bI2NercY5pZfgDI5Z+eDCqRrbm z91TNQq5MkieBwbJ/swcnv/AM1LfyranzyORljMnZbwd0XULjJFGM2Z1JY4D6bsJgQm4 y3yDoGqH8uoTn1xyWIefJCHszNzafT+JANP1uVzZsXWCJNCyIWChEPMDsqxu+EPis6j6 h161gkw14Lip8SxdAgdf6naeM3JP9kXu1HGVnzHNEX65uEXi4Nc8O/PNzlaY6fAWRw6Y QGkg== X-Forwarded-Encrypted: i=1; AL+hErGvUNX8Er4Kf4UBsRKklCk8yHsB93TUqOntIV66yLUNOkOIzntDcamF5gPfEIheGyIdqxRagSqJ33k=@vger.kernel.org X-Gm-Message-State: APuU4Z8Nj5mKS+A7FKDvYfUknqdVM3BTTvqEEHyPl3XuAgTpmEb3YNXT dU6/y+35fIlPIpXvYlUJUw3lAmeuKwuBhTSLdKTUSILrRuZOKi8WslQMbDmLK5WyHFA= X-Gm-Gg: AZFdTZfemL1yGAxDS3PhaXZWV0sauBDeLWJ8oaLgwdm64DcM+1aDbszZq8CU00T6hFf DRodvsRUK71vzc5NmfeKopbySA1kgAQZM6E92ZW7fwL+wtSXbxLTDDv7PZh+yRO8Yhl5SKUq3oT suk3M/Dy606GUMzU/qk7FKMu9/MulkhfWE2rxiH+ji17yQGuAQeRx3JT3yhW18vH3dCy7h0WDfH /aDJZTh2+7qKAVFAjoFi57gggewsdIpyKqttEzVeS/KWn0+Npvrg6u9LVyuzxtb7aYcuJZD652P vXOvbVrAv0V3++n7YYTcKDYl/M6urCU0BkCPT9xgaUE/k9kWPhOblZSDkjuwwIcnK3ERLzHj7sK 1F7A0z2M1uCT2CLPwX3f2jRm9OtxPDD2FTBREbdRBFOZowkIjnTWhMIADxuJxQF6ImYgYcCswzr rETN4ZlWNou8aHM2j4ZMEjl4qb7EcKzkW4li00yxEKkD3w4ZqFd0SzogxxbGMwwVeng3asQD+2E 8U6o8BxF7rHEuT7CHf6OEPqIVu0Y8R320MIlrJrOAUychqo2lAmgfVi868QwDtvI6bbELQTnAS2 M0a9w6Uee4pzYIEkJvk2d6vH8kc2Rhzj8Si1bDVOS34Tx5NeOcgPYaTT6mItVJGxQSwq8cQ7 X-Received: by 2002:a05:6808:1a1f:b0:571:75b2:5ee6 with SMTP id 5614622812f47-57a0d0eb0d2mr44380278b6e.63.1796306228338; Thu, 03 Dec 2026 05:57:08 -0800 (PST) Received: from bcodding.csb.hammerspace.com ([66.97.168.37]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57a350548ffsm30973955b6e.11.2026.12.03.05.57.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 05:57:08 -0800 (PST) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker , Mike Snitzer Cc: Olga Kornievskaia , linux-nfs@vger.kernel.org Subject: [PATCH v4 00/11] pNFS: layout recalls and writes that have to be resent Date: Thu, 3 Dec 2026 08:56:55 -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 7 adds a second count on the layout segment, pls_hold, which keeps the segment allocated without keeping it on the layout. Patches 8 and 9 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 11 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. 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 7 to 9 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. Patches 3 and 4 have changes from the sashiko review of that posting, listed below. Patch 2 returns the error from an O_DIRECT read whose requests were all 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 8 a task can wait for a layout with the folio locked, so patch 10 has nfs_wb_folio() wait and resend a folio that the layout driver refuses with -EAGAIN. That replaces 1/5, and I'll repost the rest of that series on top of this one. 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 10 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 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 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 7 to 9: the pageio descriptor and the commit buckets don't keep a layout in use. - Patch 11 (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 10. 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: failing to create the DS RPC client is treated like a fatal error preparing the DS, and a fatal error no longer returns the layout under FF_FLAGS_NO_IO_THRU_MDS. - Patch 1: unchanged. Benjamin Coddington (11): 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: 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 | 68 +++++--- fs/nfs/filelayout/filelayout.c | 2 +- fs/nfs/flexfilelayout/flexfilelayout.c | 81 +++++---- fs/nfs/internal.h | 3 +- fs/nfs/pagelist.c | 45 ++++- fs/nfs/pnfs.c | 226 +++++++++++++++++++++---- fs/nfs/pnfs.h | 12 ++ fs/nfs/pnfs_nfs.c | 61 ++++--- fs/nfs/read.c | 3 +- fs/nfs/write.c | 42 +++-- include/linux/nfs_xdr.h | 3 +- 12 files changed, 425 insertions(+), 129 deletions(-) base-commit: 3e19991734326332c736e24c9b47b2cffb8f9e42 -- 2.53.0