7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benjamin Coddington commit a84c62c4f03706b2c2f01dcc5fe614a4233ee75d upstream. ff_layout_pg_test() was copied from the files layout, which partitions data servers relative to pattern_offset and bounds coalescing with a segment-relative offset. Flexfiles has no pattern_offset: nfs4_ff_layout_calc_dss_id() partitions on the absolute file offset (RFC 8435 Section 6). So when a layout segment's offset is not stripe-unit-aligned, the segment-relative coalescing window is shifted off the absolute stripe grid and a coalesced I/O can straddle a stripe boundary, sending the bytes past it to the wrong data server. Bound coalescing on the absolute offset to match calc_dss_id(). Aligned segments, including all whole-file layouts, are unchanged. Fixes: 4934ccbeaed3 ("NFSv4/flexfiles: Read path updates for striped layouts") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Benjamin Coddington Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- fs/nfs/flexfilelayout/flexfilelayout.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -996,7 +996,6 @@ ff_layout_pg_test(struct nfs_pageio_desc unsigned int size; u64 p_stripe, r_stripe; u64 stripe_offset; - u64 segment_offset = pgio->pg_lseg->pls_range.offset; u64 stripe_unit = FF_LAYOUT_LSEG(pgio->pg_lseg)->stripe_unit; /* calls nfs_generic_pg_test */ @@ -1008,8 +1007,8 @@ ff_layout_pg_test(struct nfs_pageio_desc /* see if req and prev are in the same stripe */ if (prev) { - p_stripe = (u64)req_offset(prev) - segment_offset; - r_stripe = (u64)req_offset(req) - segment_offset; + p_stripe = (u64)req_offset(prev); + r_stripe = (u64)req_offset(req); p_stripe = div64_u64(p_stripe, stripe_unit); r_stripe = div64_u64(r_stripe, stripe_unit); @@ -1018,7 +1017,7 @@ ff_layout_pg_test(struct nfs_pageio_desc } /* calculate remaining bytes in the current stripe */ - div64_u64_rem((u64)req_offset(req) - segment_offset, + div64_u64_rem((u64)req_offset(req), stripe_unit, &stripe_offset); WARN_ON_ONCE(stripe_offset > stripe_unit);