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 4640280F25 for ; Tue, 3 Nov 2026 06:23:47 +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 6A36Ma7C001143; Tue, 3 Nov 2026 09:22:37 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A36Ma7C001143 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="jLw0DGjQ" Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A36MCoO001087 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 3 Nov 2026 09:22:12 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A36MCoO001087 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a214a5f8a1so35777075e9.0 for ; Mon, 02 Nov 2026 22:22:12 -0800 (PST) X-Gm-Message-State: APuU4Z9ZeKLCLoeve5O0AIGgJF3WinX/jHZKUy8kZSJf2W7vsmLwmIN1 qKGFkmam54o6umCgBZZKdrPvBYzBcnyE3f2oVxC5mSE3Cb4f6lSCaOIiM1gRRfTANCJk1uy5plT LtU377jdnoQNPyTezeW7pyOuI40gwcovcgKaT84Ro74/3nlQiUr4iww== X-Gm-Gg: AYBFou1zKXRU5iAuVHGegeJDql4F9ZQTQxfT7gl0C31ErhN3IJi0dIK3u5H8VqlFd8J yPPLdP9w146Jicmmtz+3iqZmt8YX4rlvCwisXzhBGQmt4I4bAr5kZzSWBCB3Z1UN4SNaXmvh3wh V53RzWZacYDUU2P6Kyums2QEqIS7PxqL9Ks1n2ShGvvT2mAUBH+Ew/zX+wF0t6mspURKZ03bgeZ AqwuSqgA0/DQWJpnz1WtYmautAnFFQA5sRJeub0O8U65RACg94qt5/blaSYkvrV2QIL4AZwJYWg P/+hg9ffEch+Ucf3e2x3boKL4FLlfEo2irA9+nRACYBwpiMuvOEndFFwZFnc9nm7dMxPsH3vqMu gD5yuk6XBOrppbngcpMuCgy4orYjefQ== X-Received: by 2002:a05:600d:82ea:b0:4a1:cfa7:e968 with SMTP id 5b1f17b1804b1-4ac17ff9be8mr295835735e9.21.1793686932199; Mon, 02 Nov 2026 22:22:12 -0800 (PST) X-Received: by 2002:a05:600d:82ea:b0:4a1:cfa7:e968 with SMTP id 5b1f17b1804b1-4ac17ff9be8mr295835535e9.21.1793686931683; Mon, 02 Nov 2026 22:22:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793686931; cv=none; d=google.com; s=arc-20260327; b=HxiKsYqzBygnULQwTlo0FDcfHt/V/aCesl3Wia+ZbyGgLzidSZVpujF/ueu9yaAvDQ s+cjmReHO1UtDcbrtu9mh+ij8XBtr1MoSEX4DQWg7kYe0AY92L1/t/1NE4rjzkR7NUbk niutvPlUGLczmOWNxrs9gbEk9YY0Zq2/268VUFgXt54geD6V+GX3O37fvaVIOL6hmCZk AM01V6aa2IYIY0r4n9I5OBqC62PgsbOh6fJeOdu8vi/hozbTy+D8HzbJb27x/6nIj2RV Vt3wE0tA/lEP/QbgkhHItD95HA0lm4BE/GVGve2/G6J4Y8EDMvbIg5EakMXLuxG3tNJY rBZg== 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=OBmJjL2QNW2J967v92NfEVLdw435kjylX4AKd9anwtI=; fh=1tuYsFJiQCT5Wkm/n4xHdwYbo1LrtdB1ozKduz9MEDE=; b=elqb+XUovakrN3k6vexHxqjPixHYy6mQ3076Xoy8hHzp/2OFHMcYUn+vmwSYL12Z9p hQ1RpTCOflbZi7zymdNLywJ93k3lHAslaq595h2qaBnr6tGYpHCLO3PSx9BK8kKfErM6 OYJNwZll1GpzDZUfwFh947Wm0+eWIJR6zgWUveMy1l2M+eJ/lmdO1XGDWKVngtiEqDl9 lXdD95qRg2g9ItphVcApMzKbOF8zv0QCWava6a3lBXXRdlxV8IR/18YUBmMIrLGw/WW2 ZAF2wMVhUoWKbJR1kg4QL/tvTCEletGrAAtu7a7+Yl6n77LKltkBVIQHhnZicY8Uw1EJ /ogA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=jLw0DGjQ; 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-48e71bbf897si21817467f8f.290.2026.11.02.22.22.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 22:22:11 -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=jLw0DGjQ; 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=OBmJjL2QNW2J967v92NfEVLdw435kjylX4AKd9anwtI=; b=jLw0DGjQMZhY d+V2Z5c3q9c7lv5Rt4VCsK24Fdq+NIUF2pJV8OBIaIPiB6V43yoPsaPX/yYu4Dl9ewsQk6KvWzV2j +RU93lyy1Q1o+PW9D9YJF5dGUdzsDXkV9ZWQDMhoiq2qmBZ8xPvhv+993Cm9smorD+kgMEjNFIx7X l41/rpJEo/q6wYurFG3MkhGl1AK6IuEaBDxsjgxip3Y0WR/eK2GGH+bCR/gOIBqkvjnY0DyhJZ+lH zgH1Z5/hzWmmfmH4iRNMOQQUVblzuxG2Os+YgY5qcI/vldYykvV3ZFOt64xZZkjREd03FK64mQQqT 5sUKNYlw0Rx2B83ZkPHeOw==; 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 1xO7qS-005EVh-1w; Tue, 03 Nov 2026 07:22:02 +0100 From: Andrey Zhadchenko To: alexander.ivanov@virtuozzo.com Date: Tue, 3 Nov 2026 09:17:51 +0300 Message-ID: <20261103061752.720813-6-andrey.zhadchenko@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20261103061752.720813-1-andrey.zhadchenko@virtuozzo.com> References: <20261103061752.720813-1-andrey.zhadchenko@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v3 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 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 or the backup is not alive. 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. The callback racing with push_backup_stop() was never handled either: timer_delete_sync_try() is try_to_del_timer_sync(), it returns -1 without waiting when the callback is running, and we only WARN on that. A callback blocked on pb->lock could thus outlive stop and re-arm the timer or queue do_pb_work() after flush_workqueue(), expiring a later session. Use timer_delete_sync() in push_backup_stop() and timer_shutdown_sync() in pb_destroy() to wait for it; the work it may have queued is flushed by flush_workqueue()/destroy_workqueue() which follow. 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 itself is waited for. Drop it. https://virtuozzo.atlassian.net/browse/VSTOR-152912 Signed-off-by: Andrey Zhadchenko --- v2: new patch v3: bail out of pb_timer_func() when !pb->alive; wait for a running callback with timer_delete_sync() in push_backup_stop() and timer_shutdown_sync() in pb_destroy() instead of WARNing on timer_delete_sync_try() < 0; fixed the commit message claim about it drivers/md/dm-push-backup.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c index b1861204f6e3e..6951e3fcdbfbf 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 (!pb->alive || deadline == S64_MAX) + goto unlock; 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,9 +398,7 @@ 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); + timer_delete_sync(&pb->deadline_timer); flush_workqueue(pb->wq); spin_lock_irq(&pb->lock); @@ -628,7 +624,7 @@ static void pb_destroy(struct push_backup *pb) { WARN_ON_ONCE(pb->nr_delayed); - WARN_ON_ONCE(timer_delete_sync_try(&pb->deadline_timer) < 0); + timer_shutdown_sync(&pb->deadline_timer); if (pb->wq) destroy_workqueue(pb->wq); kvfree(pb->map); /* Is's not zero if stop was not called */ -- 2.43.5 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel