Linux Documentation
 help / color / mirror / Atom feed
* [PATCH v2 0/2] dm thin: complete writes only after the metadata commit
@ 2026-12-01  7:25 Peng Yu
  2026-12-01  7:25 ` [PATCH v2 1/2] dm thin metadata: keep the changed flags until the commit succeeds Peng Yu
  2026-12-01  7:25 ` [PATCH v2 2/2] dm thin: add wait_for_commit pool feature Peng Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Yu @ 2026-12-01  7:25 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski
  Cc: Joe Thornber, dm-devel, linux-doc, linux-kernel, Peng Yu

This series adds a new option to the dm thin pool: wait_for_commit. When
wait_for_commit is enabled, a write or a discard will return after the
metadata is committed. By default, wait_for_commit is disabled, and the
option changes nothing for the thin pool.

Patch 1 is a bug fix that does not depend on the option. After a failed
metadata commit, a FLUSH or FUA write could succeed although the thin
device had lost changes. Sashiko's review of v1 pointed to it. Patch 2
relies on it for what happens after a failed commit.

Why we need wait_for_commit:

Assume there is a server A, and the underlying device of its thin pool
is an NVMe-oF device. Server A creates a thin device and exports the
thin device to a remote host via NVMe-oF too. When server A fails, a
control plane will rebuild the pool and thin device on a standby
server B, and server B will export the thin device to the same remote
host. When the remote host issues a FLUSH, server A fails, so the
metadata are not committed to the pool. The thin pool fails over to
server B, and then the NVMe-oF multipath resends the FLUSH to B.
B receives the command and finds nothing to flush. In this case, some
uncommitted data are lost, but the remote host can't get any error.

As the dm thin pool doc says: "the thin-provisioning target behaves like
a physical disk that has a volatile write cache". If the underlying disk
of a thin pool is a remote disk and we want to fail over the thin pool
from server A to server B, the "volatile write cache" is only on
server A, and server B doesn't know about it, so we will get a
consistency issue. The wait_for_commit option could fix this issue with
a performance penalty.

Below is a performance test on my laptop. We got the results in a VM on
loop devices. The numbers are the ones of v1. I did not measure them
again, because v2 does not change the write paths that they exercise.

1 MiB sequential first writes (no zero fill)
|                      | 1 job, depth 1           | 8 jobs, depth 8          |
|                      | MiB/s | mean ms | p99 ms | MiB/s | mean ms | p99 ms |
| no wait_for_commit   | 1307  | 0.65    | 1.59   | 1596  | 39.7    | 276    |
| with wait_for_commit | 131   | 7.57    | 17.7   | 776   | 78.2    | 148    |

4 KiB random writes, mostly to new blocks (allocation and zero fill)
|                      | 1 job, depth 1, 2000 writes | 8 jobs, depth 2, 10000 writes |
|                      | s       | IOPS   | p99 ms   | s       | IOPS    | p99 ms    |
| no wait_for_commit   | 1.16    | 1723   | 0.97     | 4.96    | 2066    | 15.3      |
| with wait_for_commit | 10.5    | 195    | 11.6     | 15.1    | 673     | 49.5      |

4 KiB random overwrites of mapped blocks, 4 jobs, depth 16
|                      | IOPS   | mean ms | p99 ms |
| no wait_for_commit   | 202095 | 0.31    | 1.12   |
| with wait_for_commit | 203293 | 0.31    | 1.13   |

Changes since v1:
* New patch 1: keep the changed flags of the thin devices until the
  commit has succeeded. It replaces v1's patch 1, whose commit_failed
  flag worked around the same problem for plain writes only.
* Patch 2: a plain write is now tested exactly like a FUA write, a
  discard keeps its cell until the commit, and the worker is woken after
  the waiting discards are completed. The notes of patch 2 have the
  reasons for the findings of Sashiko's review that did not lead to a
  change.
* Rebased on the for-next branch of linux-dm.git.

v1: https://lore.kernel.org/all/20261125043325.138351-1-yupeng0921@gmail.com/
Sashiko's review of v1 patch 1: https://lore.kernel.org/all/sashiko-outbox-232598@kernel.org/
Sashiko's review of v1 patch 2: https://lore.kernel.org/all/sashiko-outbox-232600@kernel.org/

Peng Yu (2):
  dm thin metadata: keep the changed flags until the commit succeeds
  dm thin: add wait_for_commit pool feature

 .../device-mapper/thin-provisioning.rst       |  18 ++-
 drivers/md/dm-thin-metadata.c                 |  32 +++-
 drivers/md/dm-thin-metadata.h                 |   6 +
 drivers/md/dm-thin.c                          | 153 +++++++++++++++---
 4 files changed, 182 insertions(+), 27 deletions(-)


base-commit: 5feb56b402e9827d599b4076da9ad71c374b9ef5
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01  7:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  7:25 [PATCH v2 0/2] dm thin: complete writes only after the metadata commit Peng Yu
2026-12-01  7:25 ` [PATCH v2 1/2] dm thin metadata: keep the changed flags until the commit succeeds Peng Yu
2026-12-01  7:25 ` [PATCH v2 2/2] dm thin: add wait_for_commit pool feature Peng Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox