From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796109947; b=huIeHDfoGllN4K1SobvZ3Pp8N24xdA1po8n8TRRWaB9SoBhYqc8S7ztFVoVSnQ9nQ3HM ptJ+dLYXEwqJZIMwZWdm1SIVpCaUprklodR/irHAJqVJMC+wtqV8kziQtGMGtxJXA+0Tj tClI+CdjhTZHzNNSVj+V7MPbLF6fDbXWQzFdFIc8rihHter7zSZOn1+GVhksX3MrLhOQp zBs3WYdVk0QsR6uWHOmgllUOqPtVywcmSWPqgu+EeSBPbYs3A3f5zKQCBq8uVp3q0BK/o 6GMhIdz+uaKrszL9ejoU7RX10TjZ9/K13PTGbWYwgeIZ8EgKXYusAe7oswA/s4oAQzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796109947; 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=DpFn057xbOhwrQ7qqOZPNtsFKgDvLKPJMr0HzGgV8cGTIouccEt/AB0S/12PzTQKSc4s I+S7FqnG20fYpjV2oWqb01DCer8cEe4Gh1jC8odFK0tY4byA+vVAtksm9fGS3uCXousSz wEsPpFSRC6tFLL47OAzu+vvMKMjst5aKlwvdB3qqdxTbZjY1tFWb24++bgC4GFkqEhQmd hMOOiQx10cuP3OMqibHiHMQzFLmU6/6kQ6KOXq8g+DxcHoNVeop5uEhXRx23vM7Da9peI VqgVITUQgaEfsUHtnzLSnTxsNS/4b7gyvRYPChvV3R4SKcfgDQnMkF4K60HutNra7Zw== 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.175 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 81ACC606A68F for ; Tue, 1 Dec 2026 07:25:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81ACC606A68F 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-f175.google.com with SMTP id 41be03b00d2f7-cddac941ed1so5118027a12.2 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=u589GEMbtAhWBGUeNIL4fuDfM2qUs0diVR/lFU99yXtHfkIBj3i46YxHj5kIpMhrVJ 4ReByR5jOuw5gcZoaby45A6MFkZlxU3Af2clm8mFzabsmpBYzI2HSR5WlZGdEQ8n34mB Wz4d/3aX/SOp7BPbJgUjoIjgpcNAzZ22XnXcFQDweVNgP1KpcEJyTppe73hi2/lEOO5m RxbV9IbR2QQG9ehvbN9mi++o3YBChjheCj0KvyD+b/WWvTEVH2NwLb3fNAbTFPOeHyUR dgd4SLZZbifUbv+ytQsEVHVHzhSl61xymMOyKDfIWK2l0j8GobIU34E2wenXel7AsyIY 6qYQ== X-Forwarded-Encrypted: i=1; AL+hErGWwSCukbYlIb3R2Cn2SKzs/RQG0x1cuIDW7WH5iKKS8YbfGKW5fTG0SPykzy/ei5+oLr4rlxX830x9J/U=@vger.kernel.org X-Gm-Message-State: APuU4Z+05275nqtj3rQH6fI3YjpBveQaoiMsQ3okwzcq47Hnm3y9ymb2 C+2pXhJ5hfR4295lPP+vBUMhSZs5BSd3XykUq70I/786XU9F+uWisv/C X-Gm-Gg: AZFdTZekD/n58rrxp5uDT1Uu+e1bwSCIh5Uh1avK3FA+RwN1yqW8+f9cZ44f7keZX7F qmDhL86DpQqykA0xIbQxa1+BTDjqhEBFO8HM1B2rKyMA5l/2fKu5GPuJjd1+cCNalBaKE39giyB Gxk0Er+QeNKwukDkDFVcJ0WDg5ZEeKoI50Tlncf1jqcwf2sVhAC6YHdqNBgo8cI+/SIoljQebi0 Kd8rye69mWWqZXN/NkDa08/mHXgtLXhXo0vToN+nz5aO05I+krRZGDYLVPMK2qr+1s7XTNATj82 dibO2uB4gZ63E8sI63mqLCXpykKP3jEDn/JviTUUphgVTJ99mRpd8EpC6eEz3piq1uKKCt3ebnu y+1v4aWIwLPwp5ErpNEs6aQs5ksul2eCXobH0zb/m3Gs+UXj29LzQkUx4RnBOiP1TBkJiL+zXaH wxqNtgrQFOqOtKPp3B6+850Cqvzdibnpq0pE5tUy0XbWDJ9JWTCiJzndNa/+sR8YsmBDDCeT2rx oiByrXx/IFkowk2WLaY4Tq2V2aSkT3AUfoJvm3nE8Fuv7q1dnzw49yYjLCTFIZZO+r3V/fCnlkh RDy62yaP8Qdo44L8/s5AQREqojMEEnwqPEyfMGVEYJMdAYP5uBwkqMfa54aE4vZDol4mq5fXOLF G7pFnDfS4sJLLgHu9e1jQmKLnJT7GzPYZ7ZG+4VUafFUwvDjlZ+fUSAUFZpsWBW6/br68wwgEOu FPtzYiYQfwvqHDyweBuFg2hzJArvQ5BhdcMqxNIvXDOC+pz3bQEi+kI9zgmOrUDAAHxdWnmVVnO gbs6mN6Vs+nAdP17nGKhAjwipC+Zki/KAU= 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-kernel@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