Skip to contentSkip to conversation

NFSv4/flexfiles: Layouts are only available if specific stripe has a valid mirror

PATCH In review Jonathan Curley 2 participants 4 messages Dec 15, 2025 – Dec 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover NFSv4/flexfiles: Layouts are only available if specific stripe has a valid mirror

Stress tests with HA + striping discovered a deadlock with the read has_available_ds functions. Looping over all the stripes looks correct when one considers the helper functions in isolation. When considered in usage it results in a deadlock. The problem occurs because the read variant returns true if any stripe has an available DS. This means that a read for a particular dss_id can hang forever if none of the DS it needs are available while there are DS available for another dss_id.

This diff changes the helper function to consider the specific dss_id. This integrates fine with the call sites since they only work with IO for a single dss_id at a time.

I also updated the rw version of this function to consider dss_id. While this doesn't avoid a deadlock problem there may be some availability benefits of letting IO continue for stripes that have available DS even if other stripes may not.

Jonathan Curley (1):
NFSv4/flexfiles: Layouts are only available if specific stripe has a
valid mirror

 fs/nfs/flexfilelayout/flexfilelayout.c    |  6 +--
 fs/nfs/flexfilelayout/flexfilelayout.h    |  2 +-
 fs/nfs/flexfilelayout/flexfilelayoutdev.c | 55 +++++++++++------------
 3 files changed, 30 insertions(+), 33 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 NFSv4/flexfiles: Layouts are only available if specific stripe has a valid mirror

Updates ff_read_layout_has_available_ds to consider the specific dss_id to ensure that there is at least one valid mirror for the stripe to be read. Otherwise a deadlock can occur.

Also updates ff_rw_layout_has_available_ds in case there's any performance or availability benefits to considering only the stripe required for this particular write.

Fixes a1491919c880 ("NFSv4/flexfiles: Update low level helper functions to be DS stripe aware.")
---
 fs/nfs/flexfilelayout/flexfilelayout.c    |  6 +--
 fs/nfs/flexfilelayout/flexfilelayout.h    |  2 +-
 fs/nfs/flexfilelayout/flexfilelayoutdev.c | 55 +++++++++++------------
 3 files changed, 30 insertions(+), 33 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +3 -3
index b5e6985034cb..4ee1229a617d 100644
@@ -1351,7 +1351,7 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
 		rpc_wake_up(&tbl->slot_tbl_waitq);
 		fallthrough;
 	default:
-		if (ff_layout_avoid_mds_available_ds(lseg))
+		if (ff_layout_avoid_mds_available_ds(lseg, dss_id))
 			return -NFS4ERR_RESET_TO_PNFS;
 reset:
 		dprintk("%s Retry through MDS. Error %d\n", __func__,
@@ -2113,7 +2113,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
 	return PNFS_ATTEMPTED;
 
 out_failed:
-	if (ff_layout_avoid_mds_available_ds(lseg))
+	if (ff_layout_avoid_mds_available_ds(lseg, dss_id))
 		return PNFS_TRY_AGAIN;
 	trace_pnfs_mds_fallback_read_pagelist(hdr->inode,
 			hdr->args.offset, hdr->args.count,
@@ -2195,7 +2195,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
 	return PNFS_ATTEMPTED;
 
 out_failed:
-	if (ff_layout_avoid_mds_available_ds(lseg))
+	if (ff_layout_avoid_mds_available_ds(lseg, dss_id))
 		return PNFS_TRY_AGAIN;
 	trace_pnfs_mds_fallback_write_pagelist(hdr->inode,
 			hdr->args.offset, hdr->args.count,
fs/nfs/flexfilelayout/flexfilelayout.h +1 -1
index 17a008c8e97c..4378ce48f75b 100644
@@ -247,7 +247,7 @@ const struct cred *ff_layout_get_ds_cred(struct nfs4_ff_layout_mirror *mirror,
 					 const struct pnfs_layout_range *range,
 					 const struct cred *mdscred,
 					 u32 dss_id);
-bool ff_layout_avoid_mds_available_ds(struct pnfs_layout_segment *lseg);
+bool ff_layout_avoid_mds_available_ds(struct pnfs_layout_segment *lseg, u32 dss_id);
 bool ff_layout_avoid_read_on_rw(struct pnfs_layout_segment *lseg);
 
 #endif /* FS_NFS_NFS4FLEXFILELAYOUT_H */
fs/nfs/flexfilelayout/flexfilelayoutdev.c +26 -29

106 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#2 lore raw
Quoted 88 lines · Jonathan Curley

Updates ff_read_layout_has_available_ds to consider the specific dss_id to ensure that there is at least one valid mirror for the stripe to be read. Otherwise a deadlock can occur.

Also updates ff_rw_layout_has_available_ds in case there's any performance or availability benefits to considering only the stripe required for this particular write.

Fixes a1491919c880 ("NFSv4/flexfiles: Update low level helper

functions to be DS stripe aware.")

---
 fs/nfs/flexfilelayout/flexfilelayout.c    |  6 +-- fs/nfs/flexfilelayout/flexfilelayout.h    |  2 +- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 55 +++++++++++---------- --

 3 files changed, 30 insertions(+), 33 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +0 -0
index b5e6985034cb..4ee1229a617d 100644
@@ -1351,7 +1351,7 @@ static int
 ff_layout_async_handle_error_v4(struct rpc_task *task,
   rpc_wake_up(&tbl->slot_tbl_waitq);
   fallthrough;

  default:
- if (ff_layout_avoid_mds_available_ds(lseg))
+ if (ff_layout_avoid_mds_available_ds(lseg, dss_id)) return -NFS4ERR_RESET_TO_PNFS;
 reset:
  dprintk("%s Retry through MDS. Error %d\n", __func__,

fs/nfs/flexfilelayout/flexfilelayout.c +0 -0
@@ -2113,7 +2113,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header
 *hdr)
   return PNFS_ATTEMPTED;


 out_failed:
- if (ff_layout_avoid_mds_available_ds(lseg))
+ if (ff_layout_avoid_mds_available_ds(lseg, dss_id)) return PNFS_TRY_AGAIN; trace_pnfs_mds_fallback_read_pagelist(hdr->inode, hdr->args.offset, hdr->args.count,

fs/nfs/flexfilelayout/flexfilelayout.c +0 -0
@@ -2195,7 +2195,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header
 *hdr, int sync)
   return PNFS_ATTEMPTED;


 out_failed:
- if (ff_layout_avoid_mds_available_ds(lseg))
+ if (ff_layout_avoid_mds_available_ds(lseg, dss_id)) return PNFS_TRY_AGAIN; trace_pnfs_mds_fallback_write_pagelist(hdr->inode, hdr->args.offset, hdr->args.count,

fs/nfs/flexfilelayout/flexfilelayout.h +1 -1
index 17a008c8e97c..4378ce48f75b 100644
@@ -247,7 +247,7 @@ const struct cred *ff_layout_get_ds_cred(struct
 nfs4_ff_layout_mirror *mirror,
   const struct pnfs_layout_range *range,
   const struct cred *mdscred,
   u32 dss_id);
-bool ff_layout_avoid_mds_available_ds(struct pnfs_layout_segment
 *lseg);
+bool ff_layout_avoid_mds_available_ds(struct pnfs_layout_segment
 *lseg, u32 dss_id);

 bool ff_layout_avoid_read_on_rw(struct pnfs_layout_segment *lseg);
 #endif /* FS_NFS_NFS4FLEXFILELAYOUT_H */

fs/nfs/flexfilelayout/flexfilelayoutdev.c +0 -0
index d25bac36dbd9..7d8c56b84ba6 100644
@@ -21,7 +21,7 @@
  static unsigned int dataserver_timeo = NFS_DEF_TCP_TIMEO;
  static unsigned int dataserver_retrans;


-static bool ff_layout_has_available_ds(struct pnfs_layout_segment *lseg);
+static bool ff_layout_has_available_ds(struct pnfs_layout_segment *lseg, u32 dss_id);

 void nfs4_ff_layout_put_deviceid(struct nfs4_ff_layout_ds *mirror_ds)
 {

fs/nfs/flexfilelayout/flexfilelayoutdev.c nfs4_ff_layout_prepare_ds(struct · line 426

Quoted 8 lines
fs/nfs/flexfilelayout/flexfilelayoutdev.c +1 -1
@@ -420,7 +420,7 @@ nfs4_ff_layout_prepare_ds(struct
 pnfs_layout_segment *lseg,
   lseg->pls_range.length, NFS4ERR_NXIO,
   OP_ILLEGAL, GFP_NOIO);
   ff_layout_send_layouterror(lseg);
- if (fail_return || !ff_layout_has_available_ds(lseg))
+ if (fail_return || !ff_layout_has_available_ds(lseg, dss_id))
   pnfs_error_mark_layout_for_return(ino, lseg);
   ds = NULL;

NACK. We must not conflate unavailability of a stripe with an inability to process striped layouts. The former is a server problem. The latter is a client problem.

The correct way to handle the unavailability of a stripe is to
1. When reading, look for a mirror, and just report the data server as being unavailable using LAYOUTERROR.
2. When writing, or if there are no mirrors available to read from, return the layout, and report the error as part of the flexfiles layoutreturn.

If the server has no way to fix the issue, it can signal that by refusing to hand out a layout when the client asks for a new one for the same stripe.

Signature · 2 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace
[email protected], [email protected]
author
#3 lore raw
Quoted 3 lines

The correct way to handle the unavailability of a stripe is to
1. When reading, look for a mirror, and just report the data server as being unavailable using LAYOUTERROR.

That's the way I'm trying to handle it with this diff? When the client is trying to read from a particular dss_id, I'm looking for whether there's an available mirror for that dss_id. The client needs an available mirror for that dss_id in order to continue. The problem I'm trying to fix is to get the client to report unavailability of the dss_id it needs to continue. A DS for dss_id+1 or any other dss_id being alive doesn't allow a client to continue against dss_id. That's why I'm getting rid of the loop.

I didn't make any changes to the layout validity checks, only the DS availability check. I may have made a mistake in the diff title by using the word "valid" when I meant "available". Would making the change to the title and description resolve your concern?

Quoted 3 lines

2. When writing, or if there are no mirrors available to read from, return the layout, and report the error as part of the flexfiles layoutreturn.

The write case I can revert. It just seemed like an improvement to allow the client to continue against the mirrors for one dss_id while another dss_id that is not relevant to the write that the client is performing is unavailable.

Quoted 3 lines

If the server has no way to fix the issue, it can signal that by refusing to hand out a layout when the client asks for a new one for the same stripe.

Understood, I can handle that at the server. This diff is fixing it so that the client reaches out to the server for the corrected layout when the DS it needs to continue is unavailable.