Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796406141; b=12sX05pwruay0cAOnpaCjSEHxTlYeDNOMW2j/p4qIgEbQCrtAooqAcOYLdyJ+zy5+L7N otGzD27viJRGBLOLg6wDwb7eZfdYjtz0JcopyqYw4GzPSP/jvTjA9LUWbhx/kXbp5RfFU NNfONy+knELP1mKmctca6+wa1YRo+/3DmzSiDfxhMNw1QMxq7ltFCH3LxOYmfd4ZcADFA 5a04mvE5FLNGt0+eAimRpcjHb9aHuCuGg6jfIFIPmOWbtkpK+OLVA3RT0XTz8ronAGziz bTQUzgiVMtLszoBQSiphRyyfDyr52awNNwSF1aB3svOUaPkU2YEK5StBYSWDJN6PULQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796406141; 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:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=lStHWVi1lOVH5Z4oMNbHAF5iJRY73azPOM+nfJhPH+Y=; b=a3QW4d3hQjbuChxdybBJTMaCxuCFBKQInWmvf53oqEbcc/N1F/ssvPzHqX0MZm+vlPpM SndZFp73xhSXPhFiyziXpaNb1AQkghS7oQcWXlq18EZHW61bsn4yDZbbCFg9MhqGtrd5i NiLgIAUNtW1gMKrJiVbykgGH4VL7AvxzhbrgPVcnuosgDGUlcr0nyNOh4RT0YwTgTwkJL SpLM5N4tMh0ZS2wR5HpKjVLdzkdlnv+4NKiLHJy8H/4fRG1FDjZuNesHm/hIFAr24zD0E fDypf8ToMBjwU0sYEiItB70fml2gBOgOnnb1TqmKl97/u4T1Jw2agmMZkJDaUKbLtIA== 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=mL30gXmM; arc=none smtp.remote-ip=209.85.160.47 Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (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 A4684606A335 for ; Fri, 4 Dec 2026 17:42:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A4684606A335 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) header.d=hammerspace.com header.i=@hammerspace.com header.a=rsa-sha256 header.s=google header.b=mL30gXmM Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-4ada9579947so769053fac.1 for ; Fri, 04 Dec 2026 09:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1796406140; x=1797010940; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lStHWVi1lOVH5Z4oMNbHAF5iJRY73azPOM+nfJhPH+Y=; b=mL30gXmMEyhZeQ5okvwVpW3EnKzKUJnMqBV15XfLmPfFFOaz3PJE/sEEvKvSyOEe+e PvNnVE0lR/1SeSuBInFVQvZfWoI5hrw5zRwA7sXiYxUlbzMDjFDd2vi6TeM+yWsMWkB3 rkiyF2ik90A+tGZhd08nRgwyXQxKPT5riSEzlRTt1tHJaQLirHoZFQ19AjzINZ1IGuLP qyiN8hRA1pymp1vfz2Hqjd3UJvxfwxS7/B0vV5P0O5YPdTusEcz/sTtxkg1HeXIObAv0 fOw1J/Ttr+OdeDu7waaY4UtG1N5DGykegTf1POaciL2DKvwbCpCiyLepe7OpJlm7FEAb dkoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796406140; x=1797010940; h=content-transfer-encoding:mime-version:references:in-reply-to :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=lStHWVi1lOVH5Z4oMNbHAF5iJRY73azPOM+nfJhPH+Y=; b=H142rzAfHR64SlU0yA/jsQG4J3RcWXFDSpsXopeu4OqOOhnmVrOFsD2VQIWiFS5vVJ rr064ZN8srRqY7jYMVYmyW0XW/TDcgtRd3KiRpezthdVQDjkAke0cpjtItosd5TSpmXl Md2Ec9Yk3ux4lXLgXX70Rv9z5exZb0pbl2XcgIuE4Hb5j4PSWCt5LPtTCw4oH8LAKq3q cL2bS7U+5AFjtxWquOA0Blp1Sof/mOnJKCC8ZjScbbdQQ5L9ERTX5hzaeKyPkF3V8tJt 7ytU827lU5TWM7gdeIOisYjDYi0mx8U2BQtbLiT6+aewN3n2reh5t0h7hcsyWstRgl/+ oMuQ== X-Forwarded-Encrypted: i=1; AL+hErE62GjC25cT8N6OkXPrV1B5fxr1htZoezja+sP/fYHdClVcmnMdVMthrQW5Hz18s0I4W5qMV/bmzXE=@vger.kernel.org X-Gm-Message-State: APuU4Z9h7NEDdIEKFCmiFRWx+ScLM52slRgVLzPqNRetrT/sKyYSm5Em tbV4QuHTJRA92e3h1s4VLcYDJQ59yk0oALmXlmGyn09kc5c2/YMETUhWtT+hngbos9U= X-Gm-Gg: AZFdTZdFULerDNZ20P7csTgdIazVxpmccLGOXQJjldWqGyEGzSKD4Npq20in4bQYHgI hs5TFtss673gb/AXndgIKMc+g/gEgkGlQc8XCgDALf0IWcTxwvxojFeG5/Q3IdOKAPXaxSy2CIk KG+qBjJV73vQHYnJDfCO5Z29xl+Pcu4yZix3uYaQNumVJlQbJnRGZRwLgJgq1U5ZDS4k10nPT5q Lb3dV8iuIAdju8+zCfnDtHW4jH0jxCZOOoLr5iuEh+Nyr82OR3RJk4A9gW4QkNFAhq42Y96K9+L nRzxQsuy92KfhGUMdY7NgPHEExl0ncOPPIQKw8H1uJUM246GN6MJ3LLSeMUWGdJ1JnYNWNQyGHg 9C+bmDv3ooIIgDDq5BxMha9txS8K2ufmazYULVm7lZpi3yPmY+audaYpBB1Vd9bQj/sN5mJWEHV Hs7CjxVp2aSX9+aJwrRyNP8u04HY2gbNwVdMRhS6cQdQtwpicZFqLVvOgd7KG6uIv3vnoizMFGL N3XF99YTYRlzAVqdG31nETofnOPOsW9TJcxPpb0/qlf43tn2uo66omjCzy0MdCgH30XmDiltEAe g+XWnEGSttDbE606rLnxlauojP/njio58mlD9ODT3UrU4YZ0D1pvzvflRO9Sjo85B4kOlHlDaS6 4u1aOcJ/Ad+m/J9PCKw== X-Received: by 2002:a05:6820:a28b:20b0:71a:ff41:9a1 with SMTP id 006d021491bc7-71bf22d30a8mr1777666eaf.88.1796406139461; Fri, 04 Dec 2026 09:42:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 09:42:19 -0800 (PST) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker , Mike Snitzer Cc: Olga Kornievskaia , linux-nfs@vger.kernel.org Subject: [PATCH v5 12/12] pNFS: answer a file recall with NFS4ERR_DELAY while I/O drains Date: Fri, 4 Dec 2026 12:42:03 -0500 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: 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 A layout stateid can be invalidated without a LAYOUTRETURN, for example by pnfs_destroy_layout() after an NFS4ERR_BADHANDLE, while I/O already sent to the data servers still holds its layout segments. pnfs_check_callback_stateid() then answers a CB_LAYOUTRECALL for the file with NFS4ERR_NOMATCHING_LAYOUT, so the server treats the layout as returned while that I/O can still reach the storage device. If the recall matches the invalid layout stateid and a segment within the recalled range is still in use, answer NFS4ERR_DELAY, and cancel the I/O on those segments if clora_changed is set. Fixes: bd3d16a887b0 ("NFSv4.1: Fix a potential layoutget/layoutrecall deadlock") Signed-off-by: Benjamin Coddington --- fs/nfs/callback_proc.c | 8 ++++++++ fs/nfs/pnfs.c | 35 +++++++++++++++++++++++++++++++++++ fs/nfs/pnfs.h | 3 +++ 3 files changed, 46 insertions(+) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index f9362f7409d1..fb70b2af715c 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -276,6 +276,14 @@ static u32 initiate_file_draining(struct nfs_client *clp, goto out; } pnfs_get_layout_hdr(lo); + if (!pnfs_layout_is_valid(lo) && + nfs4_stateid_match_other(&lo->plh_stateid, &args->cbl_stateid) && + pnfs_invalid_layout_busy(lo, &args->cbl_range, + be32_to_cpu(args->cbl_stateid.seqid), + args->cbl_layoutchanged)) { + rv = NFS4ERR_DELAY; + goto unlock; + } rv = pnfs_check_callback_stateid(lo, &args->cbl_stateid, cps); if (rv != NFS_OK) goto unlock; diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 694e08e4a447..d537138c1492 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -2887,6 +2887,41 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo, return -ENOENT; } +/** + * pnfs_invalid_layout_busy - check for I/O on segments of an invalid layout + * @lo: pointer to the invalid layout header + * @recall_range: range being recalled + * @seq: seqid of the recall + * @cancel_io: cancel I/O on the matching segments + * + * A recall that is answered NFS4ERR_DELAY is sent again, so with @cancel_io + * the layout driver is asked to cancel the I/O on every pass until the + * segments are freed. + * + * Context: the caller holds the inode's i_lock. + * Return: true if any segment matching the recall is still in use. + */ +bool pnfs_invalid_layout_busy(struct pnfs_layout_hdr *lo, + const struct pnfs_layout_range *recall_range, + u32 seq, bool cancel_io) +{ + struct nfs_server *server = NFS_SERVER(lo->plh_inode); + struct pnfs_layout_segment *lseg; + bool busy = false; + + assert_spin_locked(&lo->plh_inode->i_lock); + + list_for_each_entry(lseg, &lo->plh_segs, pls_list) { + if (!pnfs_match_lseg_recall(lseg, recall_range, seq)) + continue; + busy = true; + if (!cancel_io) + break; + pnfs_lseg_cancel_io(server, lseg, NULL); + } + return busy; +} + static void pnfs_mark_layout_for_return(struct inode *inode, const struct pnfs_layout_range *range, diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 6b320c379467..94bf24eaa0dc 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -335,6 +335,9 @@ int pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo, const struct pnfs_layout_range *recall_range, u32 seq, bool cancel_io, const struct nfs4_deviceid *devid); +bool pnfs_invalid_layout_busy(struct pnfs_layout_hdr *lo, + const struct pnfs_layout_range *recall_range, + u32 seq, bool cancel_io); int pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo, struct list_head *lseg_list); void pnfs_set_layout_drain(struct pnfs_layout_hdr *lo); -- 2.53.0