From: Christoph Hellwig <[email protected]>

[ Upstream commit 499cbe0f2fb0641cf07a1a8ac9f7317674295fea ]

Mark dm error as DM_TARGET_PASSES_INTEGRITY so that it can be stacked on
top of PI capable devices.  The claim is strictly speaking as lie as dm
error fails all I/O and doesn't pass anything on, but doing the same for
integrity I/O work just fine :)

This helps to make about two dozen xfstests test cases pass on PI capable
devices.

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Mikulas Patocka <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---

LLM Generated explanations, may be completely bogus:

YES

- What changes: The patch adds `DM_TARGET_PASSES_INTEGRITY` to the error
  target’s feature bits, so the `error` target advertises that it
  “passes integrity” (even though it kills all I/O). In the upstream
  diff this is the sole functional change: `drivers/md/dm-target.c`
  updates `.features` to include `DM_TARGET_PASSES_INTEGRITY` alongside
  existing flags.
  - Upstream change site: drivers/md/dm-target.c (error target
    `.features` line).
  - In stable trees like v5.4, the analogous site is `drivers/md/dm-
    target.c:150`, where `.features = DM_TARGET_WILDCARD` currently
    lacks the integrity pass-through bit.

- Why it matters: Device-mapper only allows integrity-enabled I/O to be
  cloned/mapped through a target if it either implements integrity
  itself or passes integrity through:
  - Clone-path gate: drivers/md/dm.c:1369–1376. If a bio has integrity
    and the target does not have `DM_TARGET_INTEGRITY` or
    `DM_TARGET_PASSES_INTEGRITY`, `clone_bio()` returns `-EIO`, failing
    the I/O.
  - Table registration gate: drivers/md/dm-table.c:1207 requires all
    targets in the table to pass integrity for the DM device to register
    an integrity profile; otherwise integrity stacking is disabled for
    the mapped device.
  - As a result, today stacking `dm-error` atop a PI-capable device can
    fail or silently disable integrity, which breaks real workloads and,
    as the commit notes, about two dozen xfstests on PI devices.

- Correctness and safety: Marking the `error` target as “passes
  integrity” unblocks the two integrity gates above without changing the
  target’s behavior for data:
  - `io_err_map()` still returns `DM_MAPIO_KILL` (drivers/md/dm-
    target.c), so the request never reaches lower devices.
  - When integrity is present, the DM core will clone the integrity
    payload (drivers/md/dm.c:1369–1398) and then, because the target
    kills the I/O, `free_tio()` will `bio_put()` the clone, freeing the
    integrity payload (drivers/md/dm.c:633–647). No leaks, no functional
    change in outcomes (I/O still fails with error), only removal of
    spurious integrity gating.
  - Other simple pass-through targets already set this flag (e.g., `dm-
    linear`, `dm-mpath`, `dm-stripe`, `dm-delay`): drivers/md/dm-
    linear.c:220, drivers/md/dm-mpath.c:2009, drivers/md/dm-
    stripe.c:490, drivers/md/dm-delay.c:362. Aligning `dm-error`
    improves consistency.

- Scope and risk:
  - Minimal, single-bit feature change, confined to the `dm-error`
    target.
  - No architectural changes; no user-visible behavior change except
    allowing integrity-enabled stacking where it previously errored or
    disabled integrity.
  - Security neutral; performance impact negligible (a short-lived
    integrity clone that is immediately freed on kill).

- Backport notes:
  - The feature bit `DM_TARGET_PASSES_INTEGRITY` exists in stable series
    (include/linux/device-mapper.h:241–242), and the `error` target
    currently lacks it (drivers/md/dm-target.c:150 in v5.4).
  - Upstream diff also shows a `.version` bump and additional callbacks
    in newer kernels; for stable backports you can keep the version as-
    is and only add the feature bit. The functional fix is just the
    feature addition.
  - No dependencies on other recent changes.

Given it fixes real failures with PI-capable devices, is tiny and self-
contained, and aligns `dm-error` with other DM targets’ integrity
behavior, this is a good candidate for stable backport.

 drivers/md/dm-target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 2af5a9514c05e..8fede41adec00 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -263,7 +263,8 @@ static long io_err_dax_direct_access(struct dm_target *ti, 
pgoff_t pgoff,
 static struct target_type error_target = {
        .name = "error",
        .version = {1, 7, 0},
-       .features = DM_TARGET_WILDCARD | DM_TARGET_ZONED_HM,
+       .features = DM_TARGET_WILDCARD | DM_TARGET_ZONED_HM |
+               DM_TARGET_PASSES_INTEGRITY,
        .ctr  = io_err_ctr,
        .dtr  = io_err_dtr,
        .map  = io_err_map,
-- 
2.51.0


Reply via email to