From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796109948; b=moOX2KWbd71W5fkXfk6mS776lUoM3mESH1dQ4CiKPS8pYJrft6xyFRR+buExvs1xtHyO obysCLmilAEpJoem1VFpxNcJl4z/e92otYNGEYdKLydvNBdFfKlxU4cHuOMECntpuaE6x hTLMvv/avpaqVeCBbh1mr4QkpPXIeLClmYaBRpH6dLMV0DoPM0NN1ZuymbWA2TtCbk2mY 10KJBW+E+kJd/GXKrvyIfhCKLFayxzFJlUbgQm9M7V42dALdLvDKRxgF0dbQ1KobGy230 IGkp01ZYqUdkPXBdnu/YuuRFonpYdjfZc05nTbPXTOosL84y3qs6GJgbDjSf10M4slA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796109948; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=d4eYHofutZhlgZG6YwZmo4UQKF6PgzIGT0Us1p0TH84=; b=UbrYm+HsxAgakEvb0QssKxcum4rdc990dXzgkzosQEZ4bcIhxoNXyOfc3fiWr30xKKrw 5Qvn/TLMZS2sk7M2sgG3W+6GWb+LqJ1NwmpfOhLwaf69YC6vw95Mp0wIGAOHCN/8NtyE5 F0jQDFnSUVXUtj7zf2GnJkQy/TLhY2su+89MZsYs1NT+BpK1BeFaAxsMKhrxSY2CXeN6F ipCwseAUdbt+M3MNLSgJGawZsfCYjimb7tbeGe7owIoMO8RDHIW6jcKdvB0wtO948H5Am PrdF+wloU3+P+Bi21mGUJ9g+2IqoxIG0ewcuXYeinVqU9ZKQlc+0F9eXryPU0ZV2dFQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ujWvj5Kf; arc=none smtp.remote-ip=209.85.215.180 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9955B606A685 for ; Tue, 1 Dec 2026 07:25:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9955B606A685 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ujWvj5Kf Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-cdb2e0062bbso4213914a12.1 for ; Mon, 30 Nov 2026 23:25:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796109947; x=1796714747; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=d4eYHofutZhlgZG6YwZmo4UQKF6PgzIGT0Us1p0TH84=; b=ujWvj5KfJfuaXw9opTRk679JpaRDrZVZrMrRCA1VGS147FHE3bHMmCrkKnfJCyKWOf 1Ps8dxYJ9siTb+jWv2cXF7LF4q7OUNCULpw89txNv1b2lZVN/l6hAEj5do44II+oagG+ zufECCw1CqvboJYx7xhghSg4qfk2BbAIHEZEQk4lJhn8vgM3oK2S3neCOGvhc8p7oIX4 4OEX9LqhaFgyqiDhqw1mE1gvmL8Hx3rNg8+tqWKSHylmopcpmpmwEtOMU3QsQbhnRcV3 IMeRNcIm0V5NrwSYlQ00C4p3YZ3y5tjK8cY/VFmliNDYXvCzQRFbPzO3Kih+uje3DDQT WuNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796109947; x=1796714747; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=d4eYHofutZhlgZG6YwZmo4UQKF6PgzIGT0Us1p0TH84=; b=hj+SO9XKdNKGt4RAFnxqqfWWN96XnhbbaOiX2nU4H3JS7A2z4mP2Ry0e0+vvG237Dg YjmuReBcKq/q/Ynn6cweeSlDmN5pWP+9ATureV8i1luZIY0rn/0L46nmD39+9BiDcIRB kW+IDvjedNFCj6mkV9QrkwiSzkgU+9VZvUUbEO4ZrCuqEURAKrZ5gJhMbl2X5b5s0Gqo +XUiRBSINmQr8XzTzQJUdO7Iu8q+UHx5oFO0t5x0uP5hjQzZ+DFO9ud4jDQjmRG7NL83 exR7QkfP528svZ0+x6mXpBm/zZJO+ehS0Qw2cOHFurTe3nu3+3vXvFhtbsLIn5cg5iuJ eBbQ== X-Forwarded-Encrypted: i=1; AL+hErGK+4nHei1JI4yfYpC84ekq53GWBa9l0SVFj3jy6y2Z3Lddzp36PjSBCLu55pi4GKhc7MVnzNaFb0o=@vger.kernel.org X-Gm-Message-State: APuU4Z9dVqPCT32ZbCPYJT6fYyWJj8fpsp5zDGFeh2wc4km7cF1K6m6V Ppc3j35UDaSlM4oZS+dzVJzuYrNfSOg+Ilew2viLgdMcxS4PfMoKeyB4 X-Gm-Gg: AZFdTZe5TiY9GH+QPbhvfe7eTNaMTJcg5+UPbTIPLZR2Op1S7r6B/GVohBnSHAEfkHo QD6hVfoX4+JyDxpgFw164/nDtYJifMKKvNWZdf0lgGva5DM5NfooRii/qvXGgVqvi7YTADGrisT DM8indKTIWjLLsrKSwFPzEqhU751KKp+vwZNqne5wJLT6Z4XdTo3r7C8B6wJwcjh0ib2l/YnCgm N55FKhuRthPfJN2vzrjYcG+JcF6hN/9QBLq6EPwG8i0PfMUB2HmiUAx7d+YgzU8RxaawWEI0iG+ CNeDUvjZQ/6Ya2+6TDeuS3AlGKMqq8gcdVfs78gxiiDtvGGIWifH0cyza2gibKRVHe9+EyX+6X4 MdcYZfpR6K4/2lDQe/bOVSsvgdVW3NE27aZLwQLMeq+whzzzAYB1R/kEBH1W2q/qR2k3T5dv0Vs rwzUa2ZbIOHzecujkv7pWf6QzRo85V8f1XIT6J0H+NsooFOYCllF3hmD0osm1MYWRTh/TdaQgTw 8fnUPoKPDSDYfhZCEys/3/E80LrSQGQppRm6tjjwz7oNQfMnYjyxtZ6HR/5k5W54PdyyWzyS4+h ZQOpHUXmFTdohkRdv2+U5W34Xlt4bbySZse9a2YibcAB6fcrB6Gk7IVwPtnmoFWhwHlrapV7FnT w0eMRN+HbYWOsXQrFNcFAnXi/vDGocNvlnOXVy0pIAk84kAgTjsaEDcK4/hqD75nhY7lwYjpGWa 3dwcod/6sg3+xr8Pl/FwLvUcdmjfKluaP28baxe4rEw9CTg6hKRpkgSqY6dt+U7SNhV/7Enogxt IXiN75nolRvo3IUvCiP8qwEmz32WTnVCYM= X-Received: by 2002:a17:90b:2701:b0:3b4:184c:c20e with SMTP id 98e67ed59e1d1-3b41c7b6809mr32583663a91.4.1796109946834; Mon, 30 Nov 2026 23:25:46 -0800 (PST) Received: from yupeng-Desktop-AMD-Ryzen-AI-Max-300-Series.. (c-73-169-192-12.hsd1.wa.comcast.net. [73.169.192.12]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b53479b149sm22660472a91.6.2026.11.30.23.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 23:25:46 -0800 (PST) From: Peng Yu To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka , Benjamin Marzinski Cc: Joe Thornber , dm-devel@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Peng Yu Subject: [PATCH v2 0/2] dm thin: complete writes only after the metadata commit Date: Mon, 30 Nov 2026 23:25:30 -0800 Message-ID: <20261201072532.68398-1-yupeng0921@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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