All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jorge Mora <jmora1300@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: trondmy@kernel.org, anna@kernel.org, Rakesh.Bhargava@netapp.com,
	Mohit.Kumar@netapp.com, mora@netapp.com
Subject: [PATCH] NFSv4/flexfiles: calculate stripe boundaries from the file offset
Date: Sat, 24 Oct 2026 08:08:11 -0600	[thread overview]
Message-ID: <20261024140811.51694-1-mora@netapp.com> (raw)

From: Rakesh Bhargava <Rakesh.Bhargava@netapp.com>

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")

Signed-off-by: Rakesh Bhargava <Rakesh.Bhargava@netapp.com>
Signed-off-by: Jorge Mora <mora@netapp.com>
---
 fs/nfs/flexfilelayout/flexfilelayout.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 7fe8b91fa47c..09d44de2676a 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -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
-- 
2.47.3


             reply	other threads:[~2026-10-24 14:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24 14:08 Jorge Mora [this message]
2026-10-26 23:44 ` [PATCH] NFSv4/flexfiles: calculate stripe boundaries from the file offset Benjamin Coddington
2026-10-28  0:48   ` Mora, Jorge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261024140811.51694-1-mora@netapp.com \
    --to=jmora1300@gmail.com \
    --cc=Mohit.Kumar@netapp.com \
    --cc=Rakesh.Bhargava@netapp.com \
    --cc=anna@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mora@netapp.com \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.