From: John Garry john.g.garry@oracle.com
[ Upstream commit 7ef50c4c6a9c36fa3ea6f1681a80c0bf9a797345 ]
Same as done for raid0, set chunk_sectors limit to appropriately set the atomic write size limit.
Reviewed-by: Nilay Shroff nilay@linux.ibm.com Reviewed-by: Yu Kuai yukuai3@huawei.com Signed-off-by: John Garry john.g.garry@oracle.com Reviewed-by: Martin K. Petersen martin.petersen@oracle.com Link: https://lore.kernel.org/r/20250711105258.3135198-5-john.g.garry@oracle.com Signed-off-by: Jens Axboe axboe@kernel.dk Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
Based on my analysis, here's my assessment:
**Backport Status: YES**
This commit should be backported to stable kernel trees for the following reasons:
1. **Bug Fix for Correctness**: The commit fixes a missing configuration that causes incorrect atomic write size limits in RAID10. The code shows that `lim.chunk_sectors` needs to be set properly for the atomic writes feature to work correctly. Without this, the `blk_stack_atomic_writes_chunk_sectors()` function in block/blk- settings.c won't have the correct chunk size information, leading to incorrect atomic write size calculations.
3. **Small and Contained Change**: The fix is a single line addition: ```c lim.chunk_sectors = mddev->chunk_sectors; ``` This is a minimal change that only affects the RAID10 queue limits setup.
4. **No Architectural Changes**: The change doesn't introduce new features or modify existing architecture. It simply ensures an existing field is properly initialized with the correct value that's already available (`mddev->chunk_sectors`).
5. **Prevents Data Corruption Risk**: Without proper chunk_sectors limits, atomic writes may not work correctly on RAID10 arrays. This could lead to writes that are supposed to be atomic being split incorrectly, potentially causing data integrity issues.
6. **Affects Users**: Any system using RAID10 with applications that rely on atomic writes (databases, filesystems) would be affected by this missing configuration. The fix ensures that atomic write guarantees are properly honored.
7. **Low Risk**: The change has minimal risk of regression as it only sets a field that was previously uninitialized. The value being set (`mddev->chunk_sectors`) is already validated and used elsewhere in the RAID10 code.
The commit is clearly a bug fix that corrects an oversight where RAID10 wasn't setting the chunk_sectors limit while RAID0 was already fixed for the same issue. This makes it an excellent candidate for stable backporting.
drivers/md/raid10.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 6a55374a6ba3..e946abe62084 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -4019,6 +4019,7 @@ static int raid10_set_queue_limits(struct mddev *mddev) md_init_stacking_limits(&lim); lim.max_write_zeroes_sectors = 0; lim.io_min = mddev->chunk_sectors << 9; + lim.chunk_sectors = mddev->chunk_sectors; lim.io_opt = lim.io_min * raid10_nr_stripes(conf); lim.features |= BLK_FEAT_ATOMIC_WRITES; err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);