From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id DDCFA8045D for ; Tue, 3 Nov 2026 00:38:36 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A30bPjg030744; Tue, 3 Nov 2026 03:37:25 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A30bPjg030744 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ktyhG1y0" Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A30b7fv030685 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 3 Nov 2026 03:37:07 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A30b7fv030685 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48af5a07314so2286109f8f.2 for ; Mon, 02 Nov 2026 16:37:07 -0800 (PST) X-Gm-Message-State: APuU4Z8of5MnhE3sJ7BEAlNrmFtraF8X/59G0QiZ7oloYz06UQLLLim9 Qp51WcQ12fi6S08+mAtljDx1bSUXXsg5+budFnKkZr7GRjmddrd/HUE1r32X45c9/zHyuNUArpE S9xA5bcKfyACq6aC2QJjZhBKZaMIIoAVI45nyGFsg9oHd3YX1PlLpeg== X-Gm-Gg: AYBFou36Dlb2uDRAXFNZw+iaDE/pQ7bu7q0I9ayz/zvNHzgVHeDESxJH1Tim8HN3qvY cu5aD7cFnpE1iz6ndpcWnxZMM/Bfihzs4YAmY1AeFK8XgDfDR4+xJV9w70X6hZIfg/dwfyxwbPb FJCInqtI9/BLy2AE+Ee6YI1hlTrmm+l3a7kVXpjehPCziYaYTD3jj0tMfI3FizGESOP6CIdgbRd FGvT7UOXOSKyrmpF9YIOfwo7i3qU7KoUpYBy2yjuR1f3agrK+En0DvIhR4nHlwGxkHTy9WeGLj5 HrgD1hKn+kCSEFnWvNjnVrLQPVbcI/IHZnkMcfKfc4hm14FjGSp29VB5oviWiC7v2bMHWAgu9di huc+4t/y4iCu/aPi7lJsoZYs7U8GTBQ== X-Received: by 2002:a05:6000:2204:b0:48d:ffe8:ace6 with SMTP id ffacd0b85a97d-48e6e3004fcmr24805445f8f.42.1793666227051; Mon, 02 Nov 2026 16:37:07 -0800 (PST) X-Received: by 2002:a05:6000:2204:b0:48d:ffe8:ace6 with SMTP id ffacd0b85a97d-48e6e3004fcmr24805413f8f.42.1793666226549; Mon, 02 Nov 2026 16:37:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793666226; cv=none; d=google.com; s=arc-20260327; b=iSXnaHaM5YIBEddRwFQFPBO0XOhX/cb4wFm9JyRGOpi2UN/lEziPhkwkyHNKEiCuW4 g/2Mwxc1da2WgGDV17bpTNtRL5TxSK0OooYjJ9pJONo5aM9VTuxxCWdbeC3u1VmZEfiX J3PJujvujDiRIuqke1aOJnJFjJzdpfx6HzDHPSrpsfpDRMYZfrbo+zVgXduaPGe0F00b P1+0F1c/JF4BwNMpjsA3HiPTfoZCb8sx9qM4wfZWA6Y8uEN7tLkJ4uKb+cvhcVz01x03 24D4SjLB50g+7LC13pAow6WNbd0gsj1juaCixHRKDcpwiE8VwwFJBGqwdF9WnybI/fF2 6PaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=c3WKkwOlPFEh44bXyuqiyX2J68EV1O0dkeZnlqx1cEY=; fh=9VH7xbtOhOOwoVYPb8YgTvr+erGWPni2iwCEEh8Zz6s=; b=TzMri93NdG9JCBQqoS28mt/PuUOCZ8NScygyRoTbUKyTvAzHs4RAMdH1YV3xWNSL0f ndNLtlAV/LoxylyuBWN2FJEEWGOgIyhtgHsyOibssizk9E3rDCvgI+ybbI0o1PSSD2nu 51M3GyklbzqoiKCD6FRO88UxPdeRNeZT29hFzeM/h6VRoVdzjV3mpXj2d6CkMKhMPsqO CtVMJqulRjkIFrp7GaLhPfTWNVskHI6RgRhGhkTNeO0/VoRe0DsaVGyQ6a0s+PeLKxjG mQwzukSdE1BpMWJvWoC6NPPMdHTVEXjgGIYwg8fdBw5fVODNDP9bwFLs4Wk+VUE/vJcW C3vg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=ktyhG1y0; spf=pass (google.com: domain of andrey.zhadchenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=andrey.zhadchenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48e71baf863si21425941f8f.196.2026.11.02.16.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 16:37:06 -0800 (PST) Received-SPF: pass (google.com: domain of andrey.zhadchenko@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=ktyhG1y0; spf=pass (google.com: domain of andrey.zhadchenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=andrey.zhadchenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=c3WKkwOlPFEh44bXyuqiyX2J68EV1O0dkeZnlqx1cEY=; b=ktyhG1y03hKV K6Pg+4drkuMeWzvJ3BC8HXSGNELS5EmH8NALNwIahzJWnuCvqh9Fo+2z+NelWs/KBhUa21P37c1YS KpOojnuVxFK/l8Mpf7yfPGrInW2fM3i+NOEZ0KUKsn7A3I/Ac63Tkn+02NgS5nCugFZDPE7wqZbgh 4Abbi5tE5id0cNCkd+qjKRHSHoMqhoOetmCQ+GEBFkWivaDREwjY0RRUtZK3IMbOM6VQLrDN3g+5e Ntdq0vL/CN8w1LznNAXLQC2hxGicnZe/av3hbmDhATACVTDSSzB8Hvdp7Kd7+Nc/sigL1lD/dOl4C Px9Zr0xzcIuEwYdiJ17+xQ==; Received: from [130.117.225.5] (helo=vz9-demens-1.aci.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xO2SV-00D56q-1u; Tue, 03 Nov 2026 01:36:57 +0100 From: Andrey Zhadchenko To: alexander.ivanov@virtuozzo.com Date: Tue, 3 Nov 2026 03:32:45 +0300 Message-ID: <20261103003246.712239-6-andrey.zhadchenko@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20261103003246.712239-1-andrey.zhadchenko@virtuozzo.com> References: <20261103003246.712239-1-andrey.zhadchenko@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v2 5/6] drivers/md/push_backup: arm deadline timer under pb->lock X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org When push_backup_write acks last delayed request it sets deadline_jiffies = S64_MAX and the next fired timer uses this for mod_timer(): expiry is not set to some very distant future. Previously a later push_backup_write() would accidentally repair the expiry; since it no longer touches the timer, nothing does until stop. Make the decision and the arming atomic: call mod_timer() under pb->lock at both sites, and do not re-arm when nothing is delayed. mod_timer() and queue_work() are fine under a spinlock, and the timer base lock is dropped while the callback runs, so there is no lock inversion. As a bonus the rcu_read_lock()/synchronize_rcu() dance between postpone_if_required_for_backup() and push_backup_stop() is no longer needed: cleanup_backup() clears pb->alive under pb->lock, the timer is only armed under pb->lock while pb->alive is set, and the callback re-arming itself is handled by timer_delete_sync_try(). Drop it. https://virtuozzo.atlassian.net/browse/VSTOR-152912 Signed-off-by: Andrey Zhadchenko --- v2: new patch drivers/md/dm-push-backup.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c index b1861204f6e3e..8f2015e8e29a4 100644 --- a/drivers/md/dm-push-backup.c +++ b/drivers/md/dm-push-backup.c @@ -241,23 +241,24 @@ static void pb_timer_func(struct timer_list *timer) spin_lock_irqsave(&pb->lock, flags); deadline = pb->deadline_jiffies; - spin_unlock_irqrestore(&pb->lock, flags); - + if (deadline == S64_MAX) + goto unlock; /* Nothing is delayed, let the timer idle */ if (unlikely(time_before64(now, deadline))) mod_timer(timer, jiffies + (deadline - now) + 1); else queue_work(pb->wq, &pb->worker); +unlock: + spin_unlock_irqrestore(&pb->lock, flags); } static int postpone_if_required_for_backup(struct push_backup *pb, struct request *rq) { - bool queue_timer = false; struct pb_bio *pbio; unsigned long flags; + bool wake = false; int ret = 0; - rcu_read_lock(); /* See push_backup_stop() */ spin_lock_irqsave(&pb->lock, flags); if (!pb->alive) goto unlock; @@ -272,16 +273,13 @@ static int postpone_if_required_for_backup(struct push_backup *pb, pb->nr_delayed += 1; if (pb->nr_delayed == 1) { pb->deadline_jiffies = get_jiffies_64() + pb->timeout_in_jiffies; - queue_timer = true; + mod_timer(&pb->deadline_timer, jiffies + pb->timeout_in_jiffies + 1); + wake = true; } unlock: spin_unlock_irqrestore(&pb->lock, flags); - if (queue_timer) - mod_timer(&pb->deadline_timer, jiffies + pb->timeout_in_jiffies + 1); - rcu_read_unlock(); - - if (queue_timer) + if (wake) wake_up_interruptible(&pb->waitq); return ret; @@ -400,8 +398,6 @@ static int push_backup_stop(struct push_backup *pb, return -EBADF; cleanup_backup(pb); - /* Wait postpone_if_required_for_backup() starts timer */ - synchronize_rcu(); WARN_ON_ONCE(timer_delete_sync_try(&pb->deadline_timer) < 0); flush_workqueue(pb->wq); -- 2.43.5 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel