From: Jorge Mora <jmora1300@gmail.com>
To: Jorge.Mora@netapp.com, jorge_luis_mora@yahoo.com
Cc: Jorge Mora <mora@netapp.com>, stable@vger.kernel.org
Subject: [PATCH 1/2] NFSv4/flexfiles: calculate stripe boundaries from the file offset
Date: Thu, 22 Oct 2026 10:48:25 -0600 [thread overview]
Message-ID: <20261022164826.38125-2-mora@netapp.com> (raw)
In-Reply-To: <20261022164826.38125-1-mora@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")
Cc: stable@vger.kernel.org
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 7fe8b91fa..09d44de26 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;
--
2.52.0
next parent reply other threads:[~2026-10-22 16:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261022164826.38125-1-mora@netapp.com>
2026-10-22 16:48 ` Jorge Mora [this message]
2026-10-22 17:11 ` [PATCH 1/2] NFSv4/flexfiles: calculate stripe boundaries from the file offset Mora, Jorge
[not found] <20261022164046.38079-1-mora@netapp.com>
2026-10-22 16:40 ` Jorge Mora
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=20261022164826.38125-2-mora@netapp.com \
--to=jmora1300@gmail.com \
--cc=Jorge.Mora@netapp.com \
--cc=jorge_luis_mora@yahoo.com \
--cc=mora@netapp.com \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox