Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796316883; b=yNCF7e7Gx4oqpPLCPyCzLoHfhJ4tdfE5kW0nrYPieT6N6zfZW6v33v8KHdqeAgJC1dk7 N+JRNm7fHX0cBLe9McH4PnTM2N6K65Px8ST7u3x0tTadie+kiMEL2KXZObxf54sDmJkaB JTwzi/d/79egH/zGd8lNLsx1Cbn+8W7ft4v5A4kW1vCypyV9AAODTOlo2wIqs2+ObuGSS I/8Quc+CHke22qn37F+371jGzq6QHIABWkA7hv6f6uL5iM4i/33JcNnyhoD7QPZN3v37g jU8hKmFla1U6yXZR97jLekNcK4IqJWgWpa1Br1K0DQOJQaDwqIXnOfcih85wA8+GC3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796316883; 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=eVY8bd3s1v9o/BG5QbgsvH0CkqdgH1LaW/JcF7AZf00=; b=24VeydWbW2MsyKJQJftlA1Uvcl2YM7uEP4rwKbsi980/iPQeAF8Q8yTRQPejeTpGDaWT 6UdorBRJJ3Kin4u/2tEKqggMbQ1iRoaVt0hWkir81UfRo5SED6RDTUvxi8D5p0UyERrwF zg78jO8h1EMyQAtRJyZJ6B667k1fYzhhWmc566b73VqqNVFKogdsHzUJ2IBL0t/96aXQ0 Bjsk/sf/N8C2NL3CmiKfFOTwT4bp9ASee25zDYuKvn52jZMqKMwtuAMuLBJfrI63/09AI qHbgxG8SeF2CsPT7A/5hS8p8VAkp+EgPKAa8Y9qCPtvKTsPZsHTfQLwjt8ZQheLIUiw== 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=lIoIeG2A; arc=none smtp.remote-ip=209.85.210.48 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 39C9A606A32F for ; Thu, 3 Dec 2026 16:54:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 39C9A606A32F 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=lIoIeG2A Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-862b3a39d0dso34862a34.3 for ; Thu, 03 Dec 2026 08:54:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1796316882; x=1796921682; 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=eVY8bd3s1v9o/BG5QbgsvH0CkqdgH1LaW/JcF7AZf00=; b=lIoIeG2A9fnCoihhjUrgUB7FT0a8xMaG1x/qrbPwqu5H/nwFfijmbHyNZ77NiqyaV7 3nuuCb7ReB6IQPCpY8sn2C0CSdtZ6bGf1whaCWYvb5IReR2bevDXi/ySrZcOJHcKcNI6 4nlW1WQ1TBoidE4K59RhJboIka7qKRytuxR4Oa1qzc71dUCPUhd1Phlmv5i5wp6lgVYY voVyAcTTDNldCsfXTw9MBIdqe+MeISvEi82z+TKQM/fq3m/oU+qhokE5w0BoSssY6hD9 Bex1qTo4LjYYsEL1/8tlJuzpFsHmJoK6Jj1OVSwycTNaBeGTTWrWIpiuXsgboR01vUA8 LgBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796316882; x=1796921682; 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=eVY8bd3s1v9o/BG5QbgsvH0CkqdgH1LaW/JcF7AZf00=; b=K4brfjuFJXfXCDDOWDUYg4bbrAlyIyh/4Z3Ap3ykxc31SHEROPA3+BIxjQ6/97FFiP 7zFkjNFWWaeeBU7Yd++9Mi4KE9M+rnezIxe3EQytLS8CZB3y/46fXRzXmAevgPzD/Kj6 SW39euZ7i8MCBPhbqpdZoa3eKjtWed8MeflAD3jZDIYA/fXvHEJkkeC7JMNvCeq3nh2D ZeebP/5uQyFy/A5OqorI0g3At/dyKewKBFsemMU0bz0uDrfBwqjGaZiDawvEwRA80j4/ Okd2QeRUFpNiQS1oK2+xDJRkdJSmsI/NgkeF58DPsdMkk6VTXGxiMXZEayEEdf6XNk0z fB0A== X-Forwarded-Encrypted: i=1; AL+hErHNy4u4XEYsLeOAKWsFvleW+9YXKoctcwSxQupD5TnLHyEw1DSSKZlCwQ7jhlx5mc+NkX2r56VC1sE=@vger.kernel.org X-Gm-Message-State: APuU4Z9xUg7NC2JlPepuxIg6adzDzYDZxctbisvhEuNhwDAdnBrLVRAx SddQaYRc76OHj4wylUMEUIZYOSV8DInRcXLPE3u2JuRjS/G8jDAx1aSRr2gK+ZR2Q0Y= X-Gm-Gg: AZFdTZccjpAgioZydKrO1opkE1OEJIgur5QImGNWecsFyNo9Y50AUGhe/SikMxdw4eP CFGFcpUqL1laoLN0fWfB6wn9VLlHejVg3Tz+Bpj304t1tiNSx2n24dXl/AqWHySlGXcNHRzNKkb U0v1MiXE30gwDTHiQXqCF19V9rIXg/6eOypHFFqdHG3mcvDBKdbZRDislq5GY96sZ7TYSgRgDi4 /RBE2jZDlyD6B1oMO3HgrqJ6Bh9raHOFh6FosKdcdKnGG8O0Sa+9RydcRsiF0FPP/BikKs3hlRz FLY8I5m4xT1qO95FbZE7HR7ZE11TyGZl+hxmgRGTN9SpQwLSVCTx7EsD1p/gorcdEFWVubAU1a7 mRXm1pCjtxRfcVP5yVUb34/vlm8l5priHe4uOAl07BCEP1i0OldPK9+JWnypfrrnqOzkz3+sNJZ PRnuULW+Qi5F64QxpqIxCllxoOtsuwMWMjJm3EnW9isD35fxnboihRoRQjk0z+fUUtvdXbeQO9c XVFFC8TFtw2YpEVN2M/wDtjURPKjHMkLyAqj2BFYP0wmW68G2AusOinMgdo8TEwEgF/4IJtjDpO 8I58CSHhEiAOLAxL8urBWTRfNnCtglmGYGd5guI40AcHPgaW8OmsvndzQTqyBWr3GkbGZaMddbD Cbhi8RrdwRFUxcRyAnw== X-Received: by 2002:a05:6830:44a2:b0:7fa:5c49:523e with SMTP id 46e09a7af769-86315a29c1cmr45207606a34.23.1796316882042; Thu, 03 Dec 2026 08:54:42 -0800 (PST) Received: from bcodding.csb.hammerspace.com ([66.97.168.37]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863168dcf38sm31827030a34.9.2026.12.03.08.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 08:54:41 -0800 (PST) From: Benjamin Coddington To: Trond Myklebust , Anna Schumaker , Mike Snitzer Cc: Olga Kornievskaia , linux-nfs@vger.kernel.org Subject: [PATCH v4 3/4] pNFS/flexfiles: use the MDS when the server has no layout to give Date: Thu, 3 Dec 2026 11:54:36 -0500 Message-ID: <25b501aa9e13477faefe0dbd25b1d745b5228d34.1796315321.git.bcodding@hammerspace.com> 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 When LAYOUTGET fails with NFS4ERR_LAYOUTUNAVAILABLE, or with NFS4ERR_TOOSMALL after the retry at the session's maximum reply size, pnfs_update_layout() sets the layout's fail bit for that iomode and returns no layout without sending another LAYOUTGET for the next 120 seconds. If the file's layouts carried FF_FLAGS_NO_IO_THRU_MDS, reads and writes wait for a layout the whole time, and then send a LAYOUTGET that can fail the same way. On a hard mount that repeats for as long as the server keeps answering that way. RFC 8435 says that after NFS4ERR_LAYOUTUNAVAILABLE "the I/O is to go to the metadata server" (section 5.1.1), and that FF_FLAGS_NO_IO_THRU_MDS is a hint (section 5.1.2). Send the I/O through the MDS while the fail bit is set, in ff_layout_inode_no_fallback_to_mds(), which reads, writes and the resend after a data server error share. This also lets a server deal with a data server the client can't use: the client reports the failure with LAYOUTERROR (or in LAYOUTRETURN) and returns the layout, and the server can answer the next LAYOUTGET with NFS4ERR_LAYOUTUNAVAILABLE. Fixes: 2f007ba074ad ("pNFS/flexfiles: don't read through MDS when previous layout forbid it") Fixes: 1d62e659c0bf ("NFSv4/flexfiles: honor FF_FLAGS_NO_IO_THRU_MDS in pg_get_mirror_count_write") Fixes: ec906cf7bee6 ("pNFS/flexfiles: don't reset to MDS for v4 error when previous layout forbid it") Signed-off-by: Benjamin Coddington --- fs/nfs/flexfilelayout/flexfilelayout.c | 40 +++++++++++++++----------- fs/nfs/internal.h | 6 ++-- fs/nfs/pnfs.c | 22 ++++++++++++++ fs/nfs/pnfs.h | 1 + 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 2b9ca3cac73c..0402725a84a6 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -997,10 +997,14 @@ static bool ff_layout_pg_retry_wait(struct nfs_pageio_descriptor *pgio) /* * Returns true if the inode's layouts forbid I/O through the MDS. + * FF_FLAGS_NO_IO_THRU_MDS is a hint (RFC 8435, section 5.1.2), so set it + * aside while a failed LAYOUTGET for @iomode (NFS4ERR_LAYOUTUNAVAILABLE or + * NFS4ERR_TOOSMALL) keeps pnfs_update_layout() from sending another. */ static bool ff_layout_inode_no_fallback_to_mds(struct inode *inode, u32 iomode) { - return nfs_no_io_thru_mds(inode); + return nfs_no_io_thru_mds(inode) && + !pnfs_layout_get_failed(inode, iomode); } /* @@ -1151,13 +1155,12 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio, } /* * No segment, and no error to report either: pnfs_update_layout() - * simply has nothing to give (NFS_LAYOUT_BULK_RECALL, a failed - * pnfs_layout_io_test, blocked LAYOUTGETs, a layout being - * returned). If the server forbids reading this file through the - * MDS there is no fallback to take, so wait for a layout on the - * same terms as the -EAGAIN above. The layout hdr that carried - * FF_FLAGS_NO_IO_THRU_MDS may itself be gone by now, which is why - * the flag is kept on the inode. + * simply has nothing to give (NFS_LAYOUT_BULK_RECALL, blocked + * LAYOUTGETs, a layout being returned). If the server forbids + * reading this file through the MDS there is no fallback to take, + * so wait for a layout on the same terms as the -EAGAIN above. The + * layout hdr that carried FF_FLAGS_NO_IO_THRU_MDS may itself be + * gone by now, which is why the flag is kept on the inode. */ if (!ff_layout_inode_no_fallback_to_mds(pgio->pg_inode, IOMODE_READ)) goto out_mds; @@ -1445,7 +1448,8 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task, struct nfs4_state *state, struct nfs_client *clp, struct pnfs_layout_segment *lseg, - struct nfs4_deviceid_node *devid) + struct nfs4_deviceid_node *devid, + u32 iomode) { struct pnfs_layout_hdr *lo = lseg->pls_layout; struct inode *inode = lo->plh_inode; @@ -1534,8 +1538,9 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task, return -NFS4ERR_RESET_TO_PNFS; reset: /* - * FF_FLAGS_NO_IO_THRU_MDS: never resend through the MDS. The - * caller would do so with force_mds set (ff_layout_reset_read(), + * FF_FLAGS_NO_IO_THRU_MDS: don't resend through the MDS (see + * ff_layout_inode_no_fallback_to_mds()). The caller would do so + * with force_mds set (ff_layout_reset_read(), * ff_layout_reset_write(hdr, false) -> pnfs_*_done_resend_to_mds()), * which builds a descriptor out of the plain MDS page ops and so * consults no layout at all -- this is the last point at which the @@ -1545,7 +1550,7 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task, * pnfs_destroy_layout(). Having done so they can no longer ask the * layout hdr about the flag, hence the inode. */ - if (nfs_no_io_thru_mds(inode)) { + if (ff_layout_inode_no_fallback_to_mds(inode, iomode)) { dprintk("%s Retry through pNFS, no MDS fallback. Error %d\n", __func__, task->tk_status); return -NFS4ERR_RESET_TO_PNFS; @@ -1630,7 +1635,8 @@ static int ff_layout_async_handle_error(struct rpc_task *task, struct nfs4_state *state, struct nfs_client *clp, struct pnfs_layout_segment *lseg, - struct nfs4_deviceid_node *devid) + struct nfs4_deviceid_node *devid, + u32 iomode) { int vers = clp->cl_nfs_mod->rpc_vers->number; @@ -1650,7 +1656,7 @@ static int ff_layout_async_handle_error(struct rpc_task *task, lseg, devid); case 4: return ff_layout_async_handle_error_v4(task, op_status, state, - clp, lseg, devid); + clp, lseg, devid, iomode); default: /* should never happen */ WARN_ON_ONCE(1); @@ -1784,7 +1790,7 @@ static int ff_layout_read_done_cb(struct rpc_task *task, err = ff_layout_async_handle_error(task, hdr->res.op_status, hdr->args.context->state, hdr->ds_clp, hdr->lseg, - hdr->ds_dev); + hdr->ds_dev, IOMODE_READ); trace_nfs4_pnfs_read(hdr, err); clear_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags); @@ -1994,7 +2000,7 @@ static int ff_layout_write_done_cb(struct rpc_task *task, err = ff_layout_async_handle_error(task, hdr->res.op_status, hdr->args.context->state, hdr->ds_clp, hdr->lseg, - hdr->ds_dev); + hdr->ds_dev, IOMODE_RW); trace_nfs4_pnfs_write(hdr, err); clear_bit(NFS_IOHDR_RESEND_PNFS, &hdr->flags); @@ -2045,7 +2051,7 @@ static int ff_layout_commit_done_cb(struct rpc_task *task, err = ff_layout_async_handle_error(task, data->res.op_status, NULL, data->ds_clp, data->lseg, - data->ds_dev); + data->ds_dev, IOMODE_RW); trace_nfs4_pnfs_commit_ds(data, err); switch (err) { diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 208c83cc1d99..ee79d522de9a 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -558,8 +558,10 @@ static inline bool nfs_file_io_is_buffered(struct nfs_inode *nfsi) * mdsthreshold hint must not be acted on for such a file, since the only * thing pnfs_within_mdsthreshold() can ask for is the one thing the * layout forbids. Flexfiles also retries reads and writes that have no - * layout segment instead of sending them through the MDS. Servers are - * assumed to be consistent in their no-fallback policy per file. + * layout segment instead of sending them through the MDS, unless a + * LAYOUTGET for that iomode has failed with NFS4ERR_LAYOUTUNAVAILABLE or + * NFS4ERR_TOOSMALL. Servers are assumed to be consistent in their + * no-fallback policy per file. */ #define NFS_INO_NO_IO_THRU_MDS (30) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 78cd101b7485..7fc55abb1e19 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -586,6 +586,28 @@ pnfs_layout_io_test_failed(struct pnfs_layout_hdr *lo, u32 iomode) return true; } +/* + * Returns true if a LAYOUTGET for @iomode failed with an error, such as + * NFS4ERR_LAYOUTUNAVAILABLE, in the last PNFS_LAYOUTGET_RETRY_TIMEOUT. + * pnfs_layout_io_test_failed() clears an expired fail bit only when + * pnfs_update_layout() gets that far, so check the time here too. + */ +bool pnfs_layout_get_failed(struct inode *inode, u32 iomode) +{ + struct pnfs_layout_hdr *lo; + unsigned long now = jiffies; + bool ret = false; + + spin_lock(&inode->i_lock); + lo = NFS_I(inode)->layout; + if (lo && test_bit(pnfs_iomode_to_fail_bit(iomode), &lo->plh_flags)) + ret = time_in_range(lo->plh_retry_timestamp, + now - PNFS_LAYOUTGET_RETRY_TIMEOUT, now); + spin_unlock(&inode->i_lock); + return ret; +} +EXPORT_SYMBOL_GPL(pnfs_layout_get_failed); + static void pnfs_init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg, const struct pnfs_layout_range *range, diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 94bf24eaa0dc..bb66c637d287 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -308,6 +308,7 @@ int pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc); size_t pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req); void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg); +bool pnfs_layout_get_failed(struct inode *inode, u32 iomode); struct pnfs_layout_segment *pnfs_layout_process(struct nfs4_layoutget *lgp); void pnfs_layoutget_free(struct nfs4_layoutget *lgp); void pnfs_free_lseg_list(struct list_head *tmp_list); -- 2.53.0