Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796063230; b=i4KRYatb6/jkX8xJNSljI3MZ5SogVK7sWRB1L5VYMKUUYjeTdsRIrj86V4ee4RtwL3d+ lnuFVA0OmwL2QFsMmPYeWYf7VK4Tw8oVylHdbdRzkdeunHZ0JNhq4fkXBxx5ZnkcKgNWs 0mU9DuiaBq2UxwaIOH/PP5Q7n6i8B71yb8SKrHaEscvbMhsaDzEnjYfRkg+wIuRDQeozp krvcllOJjbv59QM93l+OB7xt64rSzvGH6gqY+R4ewBu4GiddeV1/U2Mj26X5jPS1EL7O3 j2+pMR62HOsA5cR42i5qPnpV4q/lE4Nikl6PF84SMoz4kHZ+/yd9ZWhHG6HLJrKKP9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796063230; 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:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=SqV4Jv6wNfUGVd/YP57RFpsT3eJh+v6vOgo/2e6RqII=; b=uaBtbHIg6X/QSx5ix2xMlm2XZJDEgSU6zkDeUdjFFwkqnJBpqEgWSkGczCThl4P+6h/B CtEmKphUoMGqBJ0he7c4c5pkfwVoVr6/j8RI5u51R2DdG1hTRhLAA05hEYcQrAUs4x45m ShVe2Y3xg8jabMsJqq+S2QUY+MaqmTlkCQcNK9J93Y7zTz3oYMo3HUHkewUlQYV6k9cyS 5XGqSInobHtp5zjQvPEBv+pFDTh3AnItY6Ijt9trxCrrRGad/asG+NGNHtB7UWzvTQTXu hJKcpOLHfKwHlUlWQno8OthfjMA+1GEjTbYNXWdZzQ0RgfluCkJ5EMgzV7xtliV719A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=openvz.org; spf=pass smtp.mailfrom=openvz.org; dkim=pass header.d=openvz.org header.i=@openvz.org header.a=rsa-sha256 header.s=google header.b="o6oaRFt/"; arc=none smtp.remote-ip=209.85.128.47 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 3CE51606A684 for ; Mon, 30 Nov 2026 18:27:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3CE51606A684 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=openvz.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=openvz.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.a=rsa-sha256 header.s=google header.b=o6oaRFt/ Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4bb64ef5a14so103041295e9.1 for ; Mon, 30 Nov 2026 10:27:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1796063229; x=1796668029; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SqV4Jv6wNfUGVd/YP57RFpsT3eJh+v6vOgo/2e6RqII=; b=o6oaRFt/KNULCR3UxsBK3fWG+64nOmYCD7XpLEcSBZR8y2vGaf1tiuh+4XoZmHh8BD /eEwZU6DlriqgoVGKzc8YMZOX9aufGl2b4hzLHDetIlZ5hUMHjm1TfviNCIQZazAZ/SH QrVpGL0b8wCjxi/Tlp7d3HNMUXTJ4SCiGKkvx/wN6JiJNU7DH7bTK4PBcTX4rifAnE/0 /MdrP8NuOQwMGJ+1Er25QykXjYLcC4D238zbIEto++41DJDifiExRHoQzKClYpzstEE4 HCaN+72ZUPm9Q3eZpKadAykOUKi1zek13cofaycYmzp7Gj4Ac1XzDmJP2eHzSbPQCjbz 1mFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796063229; x=1796668029; h=content-transfer-encoding:mime-version:references:in-reply-to :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=SqV4Jv6wNfUGVd/YP57RFpsT3eJh+v6vOgo/2e6RqII=; b=DXZLpMZYoVLkNg5TykSg7XlqX5+UueBGwPDbfOdy4divMLvQNWABfyWwVJ8OAjVcBA hmv2vNpntYDtgIEBL1u4PvLILGTajIk049d25ddbLrVLH7bSbawobYx8EEXR6F76RM7n 5Im/2eEz6gjKHvrUQAb7UW9Cx5YQ1x/IjsMii02K8k9KxU59Gc9jxqoPMx3zmMOc4+HM yeCxF8vJskZbf7R/8UdYeo1YOWBDa39k+8nISEA8dITwS8AItFETCnTUGEk31UMk9l1H aIh4NOMTLr21QMd7BaZJHVqcxEF+czCthl8JV/QFk8BsFQZLdVcimV5Y7iOlinfYBfBH NT0w== X-Forwarded-Encrypted: i=1; AL+hErEqXZ6anWNTgVKjigR2WNBFLQfvNW/lCbYI7dxnWwIFWxgbfjius2YOuUHu8CrzwwL07tnq8185sQ==@lists.linux.dev X-Gm-Message-State: APuU4Z8mL2qIr6GjIOWfmKlUkaMuSsCSO+BctKIe4AgeqzR1N43dFG6B F6P1Ktok2/v8wRl5fWhNlfQRmBXqIAUuWjzqCGzsBeBKg/JapBLvXvTffKQIhiguFX4= X-Gm-Gg: AZFdTZe8MPR0aSFIHB9xLwX7bmGKqwWlbtrvPhPQSCLi9WuueZb6z2i5Kv29ulWvyEu YvEGTVnY6PPJVJaUsce/fY/lN/XEbea6yL9UNgmvinU8rXLpFTUfWomXvWhAWjatnqYaIbbIVAq Ispde7oln+QWNKw8+qOy55fZXnEbKUMDcdeYq8MqUXEGQrFAuRlXx8pKS+XxSH6A4D1nngvogJT gLxLDO3BV7z5IqA6jJ1Vxsiq3W6bSds5mgn+IsxsDXd7Trj8imEFwtJXV9DUzG/K3RPAGZJRI2L cVM6rOh+aW2ZQGMIMLoAlLXTwZ/2r5t9U6QPVYOhbryJaq7W9qzfC4ox0q73xHWt3EX/453feKO QGEoleTLcR7OVLc2TOoUSIbWfKAhkaZ0Xh6jUhI++QmASePOZyVup/yaPgUfl94IC4CdUG8KjDQ rQ+H4QAsDHf1RO/m4y632AEH0U3CggJlBKpr8ED2g+2xRN6pn1WOrMKgY7+vomp/BKDx8CS3hhd 03uwDampK8lALLsgqvKzyizwWYs93bnZyzsVvRLfaA6yFC9w+gNj0ByA3PKjrGAP+8R5Yi8bEyz EiXXaOUd5ttqAHvPqGxMESxbS2glEV9CqqggFr8a0yKGk/89 X-Received: by 2002:a05:600c:a15:b0:4b6:267a:dd6e with SMTP id 5b1f17b1804b1-4bb88938a62mr699983065e9.28.1796063228724; Mon, 30 Nov 2026 10:27:08 -0800 (PST) Received: from artemis.sw.ru ([2a06:5b06:b600:300:5748:a9a4:9c41:84f3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab65cb41f4sm63908482f8f.7.2026.11.30.10.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 10:27:08 -0800 (PST) From: "Denis V. Lunev" To: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, dm-devel@lists.linux.dev Cc: bmarzins@redhat.com, thornber@redhat.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, den@openvz.org Subject: [PATCH v3 2/3] dm era: refuse metadata rpcs once the target is suspended Date: Mon, 30 Nov 2026 19:27:02 +0100 Message-ID: <20261130182704.2728591-3-den@openvz.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130182704.2728591-1-den@openvz.org> References: <20261130182704.2728591-1-den@openvz.org> X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Denis V. Lunev An rpc reaches the worker in two steps: the caller puts it on the rpc list, then wake_worker() queues the work unless the target is suspended. stop_worker() raises that flag and drains the workqueue with no ordering against either step, so an rpc can land on both sides of the drain. An rpc queued before the flag is raised, whose wake_worker() runs after it, is never served. The caller waits for a completion that only the next resume can deliver, and it waits holding the table srcu, so a reload blocks in dm_swap_table() and the device can no longer be reloaded or removed. An rpc whose wake_worker() read the flag as clear can instead queue the work after drain_workqueue() has returned. The worker then commits the metadata beside the commit era_postsuspend() runs in its own thread. Both commits allocate from the same space map and take the same block, which corrupts it, and every commit after that fails: device-mapper: space map common: unable to decrement block device-mapper: era: metadata_commit: pre commit failed Add the rpc and queue the work under the rpc lock, take that lock to raise the flag, and refuse an rpc that arrives once it is raised. An rpc that made it onto the list is then queued before the drain waits for it. Userspace sees one change. A status query on a suspended era device used to block until the device was resumed, and now reports the target in error. Fixes: eec40579d848 ("dm: add era target") Cc: stable@vger.kernel.org Signed-off-by: Denis V. Lunev --- drivers/md/dm-era-target.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c index ea499adca4ce..29b0602e7849 100644 --- a/drivers/md/dm-era-target.c +++ b/drivers/md/dm-era-target.c @@ -1389,10 +1389,14 @@ static int perform_rpc(struct era *era, struct rpc *rpc) init_completion(&rpc->complete); spin_lock(&era->rpc_lock); + if (atomic_read(&era->suspended)) { + spin_unlock(&era->rpc_lock); + return -EBUSY; + } list_add(&rpc->list, &era->rpc_calls); + queue_work(era->wq, &era->worker); spin_unlock(&era->rpc_lock); - wake_worker(era); wait_for_completion(&rpc->complete); return rpc->result; @@ -1427,7 +1431,10 @@ static void start_worker(struct era *era) static void stop_worker(struct era *era) { + spin_lock(&era->rpc_lock); atomic_set(&era->suspended, 1); + spin_unlock(&era->rpc_lock); + drain_workqueue(era->wq); } -- 2.55.0