From: John Garry <john.g.ga...@oracle.com>

[ Upstream commit 5fb9d4341b782a80eefa0dc1664d131ac3c8885d ]

Same as done for raid0, set chunk_sectors limit to appropriately set the
atomic write size limit.

Setting chunk_sectors limit in this way overrides the stacked limit
already calculated based on the bottom device limits. This is ok, as
when any bios are sent to the bottom devices, the block layer will still
respect the bottom device chunk_sectors.

Reviewed-by: Nilay Shroff <ni...@linux.ibm.com>
Reviewed-by: Mikulas Patocka <mpato...@redhat.com>
Signed-off-by: John Garry <john.g.ga...@oracle.com>
Reviewed-by: Martin K. Petersen <martin.peter...@oracle.com>
Link: https://lore.kernel.org/r/20250711105258.3135198-6-john.g.ga...@oracle.com
Signed-off-by: Jens Axboe <ax...@kernel.dk>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---

LLM Generated explanations, may be completely bogus:

Based on my analysis of the commit and the kernel repository context,
here is my assessment:

**Backport Status: YES**

This commit should be backported to stable kernel trees for the
following reasons:

1. **Bug Fix**: This commit fixes a correctness issue where dm-stripe
   was not properly setting the `chunk_sectors` limit. The commit
   message explains that this is needed to "appropriately set the atomic
   write size limit." Without this fix, atomic writes on dm-stripe
   devices may not work correctly or may have incorrect size limits.


3. **Small and Contained**: The change is minimal - just a single line
   addition:
  ```c
  limits->chunk_sectors = sc->chunk_size;
  ```
  This sets the chunk_sectors field in the io_hints function, which is a
  straightforward fix with minimal risk.

4. **Fixes Regression/Incorrect Behavior**: The block layer commit
   `add194b01e4a` shows that the stacking code now relies on
   `chunk_sectors` instead of `io_min` to determine atomic write limits.
   Without this dm-stripe fix, atomic writes would be incorrectly
   limited or potentially fail on dm-stripe devices because the
   chunk_sectors field would be unset.

5. **No New Features**: This doesn't add new functionality - it simply
   ensures that an existing feature (atomic writes, enabled by commit
   `30b88ed06f80`) works correctly by providing the required
   chunk_sectors information.

6. **Clear Dependencies**: The commit is self-contained and only depends
   on the atomic writes infrastructure already being present
   (DM_TARGET_ATOMIC_WRITES flag), which was added earlier.

The fix addresses a real issue where atomic write operations on dm-
stripe devices would have incorrect size limits because the block layer
stacking code expects chunk_sectors to be set but dm-stripe wasn't
providing this value. This is exactly the type of bug fix that stable
kernels should receive - it's small, fixes incorrect behavior, and has
minimal risk of introducing regressions.

 drivers/md/dm-stripe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index 4112071de0be..c68dc1653cfd 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -459,6 +459,7 @@ static void stripe_io_hints(struct dm_target *ti,
        struct stripe_c *sc = ti->private;
        unsigned int chunk_size = sc->chunk_size << SECTOR_SHIFT;
 
+       limits->chunk_sectors = sc->chunk_size;
        limits->io_min = chunk_size;
        limits->io_opt = chunk_size * sc->stripes;
 }
-- 
2.39.5


Reply via email to