Skip to contentSkip to conversation

NFSv4/flexfiles: calculate stripe boundaries from the file offset

PATCH In review Jorge Mora 3 participants 3 messages Oct 24 – Oct 28

Subsystems (2)
lore
Share & tools
lore

Jorge Mora

author
#0 lore raw

PATCH 1/1 NFSv4/flexfiles: calculate stripe boundaries from the file offset

From: Rakesh Bhargava <[email protected]>

ff_layout_pg_test() subtracted the layout segment offset when splitting I/O across stripes. Device selection in nfs4_ff_layout_calc_dss_id() uses the absolute file offset, which is also how RFC 8435 sparse layouts number stripes.

A LAYOUTGET reply that starts off a stripe boundary therefore moves the clipping point while the data server is still chosen from the file offset. After a data-server error, a direct write that crosses a stripe is joined and resent past the real boundary, and a later read of that range is not split.

Clip with the same file offset used to select the data server. The segment offset remains the covered byte range; pnfs_generic_pg_test() already limits coalescing to that range.

Fixes 4934ccbeaed3 ("NFSv4/flexfiles: Read path updates for striped layouts")
---
 fs/nfs/flexfilelayout/flexfilelayout.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +11 -7
index 7fe8b91fa47c..09d44de2676a 100644
@@ -996,7 +996,6 @@ ff_layout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
 	unsigned int size;
 	u64 p_stripe, r_stripe;
 	u32 stripe_offset;
-	u64 segment_offset = pgio->pg_lseg->pls_range.offset;
 	u32 stripe_unit = FF_LAYOUT_LSEG(pgio->pg_lseg)->stripe_unit;
 
 	/* calls nfs_generic_pg_test */
@@ -1006,10 +1005,17 @@ ff_layout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
 	else if (!ff_layout_lseg_is_striped(FF_LAYOUT_LSEG(pgio->pg_lseg)))
 		return size;
 
-	/* see if req and prev are in the same stripe */
+	/*
+	 * Sparse flexfiles stripes by logical file offset, the same value
+	 * nfs4_ff_layout_calc_dss_id() uses to choose a data server. The
+	 * layout segment offset is only the covered byte range.
+	 * pnfs_generic_pg_test() already stops coalescing at the end of it.
+	 * Subtracting that offset here shifts the stripe phase whenever a
+	 * LAYOUTGET reply starts off a stripe boundary.
+	 */
 	if (prev) {
-		p_stripe = (u64)req_offset(prev) - segment_offset;
-		r_stripe = (u64)req_offset(req) - segment_offset;
+		p_stripe = req_offset(prev);
+		r_stripe = req_offset(req);
 		do_div(p_stripe, stripe_unit);
 		do_div(r_stripe, stripe_unit);
 
@@ -1018,9 +1024,7 @@ ff_layout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
 	}
 
 	/* calculate remaining bytes in the current stripe */
-	div_u64_rem((u64)req_offset(req) - segment_offset,
-			stripe_unit,
-			&stripe_offset);
+	div_u64_rem(req_offset(req), stripe_unit, &stripe_offset);
 	WARN_ON_ONCE(stripe_offset > stripe_unit);
 	if (stripe_offset >= stripe_unit)
 		return 0;

base-commit: 18a80121193c6d19519e218434c9acf90e8d0e5c

Signature · 1 line
2.47.3
#1 lore raw
Quoted 1 line · Jorge Mora

From: Rakesh Bhargava <[email protected]>

Hi Jorge, Rakesh — this is the same change as "NFSv4/flexfiles: Bound page coalescing on the absolute stripe offset" (v4 06/24 of the flexfiles device-notification series), which Anna has in her linux-next as a84c62c4f037. Your base, 18a80121193c, is from Trond's tree and predates it.

Ben

#2 lore raw

Thank you Ben! Hope you’re doing well.

--Jorge

________________________________________
From: Benjamin Coddington <[email protected]>
Sent: Monday, October 26, 2026 5:44 PM
To: Jorge Mora
Cc: [email protected]; [email protected]; [email protected]; Bhargava, Rakesh; Kumar, Mohit; Mora, Jorge
Subject: Re: [PATCH] NFSv4/flexfiles: calculate stripe boundaries from the file offset

EXTERNAL EMAIL - USE CAUTION when clicking links or attachments

Quoted 1 line · Jorge Mora

From: Rakesh Bhargava <[email protected]>

Hi Jorge, Rakesh — this is the same change as "NFSv4/flexfiles: Bound page coalescing on the absolute stripe offset" (v4 06/24 of the flexfiles device-notification series), which Anna has in her linux-next as a84c62c4f037. Your base, 18a80121193c, is from Trond's tree and predates it.

Ben