NFSv4/flexfiles: calculate stripe boundaries from the file offset
Subsystems (2)
PATCH 1/2 NFSv4/flexfiles: calculate stripe boundaries from the file offset
In reply to a message not in the archiveff_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.
--- fs/nfs/flexfilelayout/flexfilelayout.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +11 -7
@@ -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 ;
Signature · 1 line
2.52.0
Please disregard this message.
I was testing my git sendmail configuration and it automatically send it to [email protected] even though I did not add it to --to or --cc list. Also, this is no my patch and the author will re-send it soon.
________________________________________
From: Jorge Mora <[email protected]>
Sent: Thursday, October 22, 2026 10:48 AM
To: Mora, Jorge; [email protected]
Cc: Mora, Jorge; [email protected]
Subject: [PATCH 1/2] NFSv4/flexfiles: calculate stripe boundaries from the file offset
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
EXTERNAL EMAIL - USE CAUTION when clicking links or attachments
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.
--- fs/nfs/flexfilelayout/flexfilelayout.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
fs/nfs/flexfilelayout/flexfilelayout.c +11 -7
@@ -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