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 823EF8017D for ; Tue, 3 Nov 2026 12:44:06 +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 6A3CgmnT005223; Tue, 3 Nov 2026 15:42:48 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A3CgmnT005223 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="oZQrdPip" 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 6A3CgOFe005155 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 3 Nov 2026 15:42:24 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A3CgOFe005155 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-48e0c896d05so3510687f8f.1 for ; Tue, 03 Nov 2026 04:42:24 -0800 (PST) X-Gm-Message-State: APuU4Z/DQecaZq4QffqNS08zakQo0yTXA+goT+Lnmp37qY2f6DJHjiW4 LYp1rHuZkWtARqHKS/YMKWi28yGTRJVGHU+z+ta+DO09S/5WdPSm691OaRnju8LEhwWgbQ2lJXC +yBXzFBArYoQn6Ar12opiav1heQmGwm3Ox5Me7yYacuBI/XAyPvA8fA== X-Gm-Gg: AYBFou16uzJjJjqWnfKVOoSQMqVGjvSFMeyAeq7S8Q7iLqklS4CojmPTumef3yAuGfg Yi/nYJv6LY0ysuxNrGexSdne8zslRklxktIhGqdu//Qj/8BaqkUe99oJBS8uOEnp5ypUBS8A2zX +txMwbYjMWHwfcLvYPm/G1PZHfS6NOHN5ZmbHPIzUnBsHUh3uiH7jjolzrjrV3QWvj4WQAnyulj RCiVzAeRYSIx9lNBOO8VWu7K0gkFAHUNasBNGFxOz/EwsVnR7ZjHblHDVkLI+PqwJEZXSPuAiIU 7y2AXkF+QMdLDIgeZAw9ztTY1ZmV330axvsWVwdbFKRC60rYR1HwjEoplKm3anzxwFob7hlz/iU WwuKkvca48W6aRhAriGvacWTp44/0 X-Received: by 2002:a05:6000:4202:b0:48f:bcdf:6f83 with SMTP id ffacd0b85a97d-48fbcdf713emr554771f8f.22.1793709744100; Tue, 03 Nov 2026 04:42:24 -0800 (PST) X-Received: by 2002:a05:6000:4202:b0:48f:bcdf:6f83 with SMTP id ffacd0b85a97d-48fbcdf713emr554706f8f.22.1793709743411; Tue, 03 Nov 2026 04:42:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793709743; cv=none; d=google.com; s=arc-20260327; b=hEUb4RuSoqc0lxaIApzlm8wCHJXzHg9HBFpyubbLkcWYCnzp8hw3AZ4mW3+gIU7TMs szMKEHTahiIORX3nS9CII7NnQVzSZV2dIjjSG52we5XY/JAYoDtBERaGiyap7Zkhrzro 9zOrjDx8k0k1YJwGhaXcuWXZDxQHY9klQLVvszG/WDb9KM9XmXKPMqR0CvJdFNlddPFm zkvWPmBmLjEihhuOco+8abWQF8623hYwvjc1Zy9d0K1nFPAJKE7iSiP32IkEJ2dNosUy Nq2MSIcWkMcJSWWr/o1JGw0vGxtSS8z6WNVd5lU7VfrMWVpf6SCGlOeFFyKyFR4tfiw7 i2Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=8Gwf0pzDrVYVOjabRvbwmznOIwOyFsjcfsjFSoiYNB0=; fh=ElTTnnNtphHTCCOZ+58STyaWac7y7ytLDJZIF4HMMJ4=; b=mHhcehGj9IoNrHTCnAYzCqrtn8SCX/rYudbhn2UyI9u7dIcJ68wJkp0hk2Pammuaga j8Ok8IqTk4Kp6pQf+VfVhmjXeezNDS8aAYsraKWaR9/fmPlmg0hxnevgrvftQJ5+7Dr8 +TATYJen5xDo41FD65fT4aW27h7Kr8wp1Kp97IiDIVKsPn2MPiGOk1Ir1Miu3Fiefyoh 5iskXI3O++tmOS1dmsrBVs83TvHMqRzMzxnmFEBxqtlXvR08U1Ta6QaFi+IiaRf2GQuu y5IJVwRLq8v0OzP+6JJlYhXZ7MqJSxSPhxV2Smfvs/YfoyGLfI56GmHmD5JPMvKScxDf 3h/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=oZQrdPip; 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-48e8421f7besi10427665f8f.262.2026.11.03.04.42.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2026 04:42:23 -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=oZQrdPip; 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=8Gwf0pzDrVYVOjabRvbwmznOIwOyFsjcfsjFSoiYNB0=; b=oZQrdPipLN+/ l6hbGyy8xnrQjxmC0OT+SVus5ICLtgd3Hd94X3Fq3fG2oDW5EL8mgJJSp9DkFVZmKvsrG4GATqeRv TMrVFvU8VxeRVtONMRU3M2bfgrKWHgrRoq7Aao4rlLGQTYrpmXHUBig9YRI6U/m5sWstRJpwgiWls 3BTzsoHe0lFGj65q0gkDB4FZiU/cJOmJmjOKO4T4Ru2/i2lnwqBbcuVECGFtN7/UylbGRjXAyOtz/ vLKe1nRT8HUpCfoBtS20rrHayRZtHF55/uMAKO1TQCSi2GGFw7JW5Y4+7eVunwBVrUIhILXaBPDhu gqI2BhcexeTrDbTt7ad31A==; 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 1xODmN-00FAc4-2I; Tue, 03 Nov 2026 13:42:13 +0100 From: Andrey Zhadchenko To: khorenko@virtuozzo.com, alexander.ivanov@virtuozzo.com Date: Tue, 3 Nov 2026 15:37:55 +0300 Message-ID: <20261103123802.846676-1-andrey.zhadchenko@virtuozzo.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v5 0/7] dm/push_backup: event fd interface and fixes 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 The push_backup target currently makes the backup tool wait for the next cluster range inside the "push_backup_read" target message. dm runs target_message() under dm_get_live_table(), i.e. with md->io_barrier SRCU read-locked, so while the tool sleeps there anything that needs synchronize_srcu(&md->io_barrier) on that device is stuck: suspend, table reload/remove and dm_internal_suspend_fast() from "@stats_create". An unrelated dm-stats user hangs, and everything that later queues behind md->suspend_lock hangs with it. Patch 7 adds a file descriptor based interface instead. The tool gets an anon inode fd via the "push_backup_get_fd" message and then uses plain read()/write() of struct dm_push_backup_range to fetch the next range and to acknowledge it, without going through dm messages on the data path. The fd pins struct push_backup with a kref so it survives target removal and simply fails with ENODEV afterwards. The fd is bound to the target, not to a backup session. The legacy messages are kept for compatibility. Patches 1-6 are fixes found while working on this: 1. init the lock, waitqueue and timer before anything that can fail so pb_destroy() is safe on every error path of pb_ctr(); 2. return -ENOMEM when the workqueue allocation fails. pb_ctr() returned 0 after freeing pb, and pb_dtr() freed it again; 3. clear pb->alive under pb->lock like the other users do; 4. pass absolute expiry to mod_timer(). All callers passed a relative value, which is always in the past, so the timer fired and re-armed on every tick while a write was delayed; 5. arm the timer under pb->lock and wait for its callback properly. pb_timer_func() and postpone_if_required_for_backup() both decided under the lock and armed after dropping it, so the callback's stale S64_MAX could overwrite a fresh deadline while writes were delayed. timer_delete_sync_try() does not wait for a running callback, so a firing after the synchronize_rcu() grace period could outlive push_backup_stop() and expire a later session, or run under pb_destroy() and use pb after it is freed. With arming done under the lock, the callback checking pb->nr_delayed and stop/destroy waiting via timer_delete_sync()/timer_shutdown_sync(), the RCU dance between postpone and stop is no longer needed and is removed; 6. drop the redundant mod_timer() in push_backup_write(). The timer re-arms itself from pb->deadline_jiffies while writes are delayed, so updating the deadline under the lock is enough. The call was not under pb->lock, which matters once writes may arrive via the fd without pb->ctl_rwsem. v5: - 1/7: commit message: safe on every error path of pb_ctr(), the zeroed timer triggers an ODEBUG warning on debug kernels. - 2/7: new patch. - 4/7, 5/7, 6/7: reordered so that the timer is armed under pb->lock before push_backup_write() stops re-arming it; no bisect point has the race window. 4/7 now also fixes the mod_timer() call in push_backup_write(). - 4/7: commit message: the relative expiry is always in the past. - 5/7: pb_timer_func() checks pb->nr_delayed instead of pb->alive, so a "push_backup_stop" interrupted before taking pb->ctl_rwsem still expires the deadline. Commit message describes the race, the synchronize_rcu() window and the pb_destroy() use-after-free. Added Fixes: tag. - 6/7: dropped the "only place" claim. - 7/7: header documents that the fd survives stop/start, errno semantics, the EINTR/EFAULT/EBADMSG and write() errors, O_CLOEXEC and that "dmsetup message" is of no use. pb_destroy() NULLs the pointers it frees. checkpatch blank line. Commit message mentions the legacy u64 parsing changes and the version bump, and corrects the resubmit_pbios() rationale. Patch numbers below refer to the 6-patch v4 numbering. v4: - 3/6, 6/6: commit message typos. - 4/6: added Fixes: tag. v3: - 5/6: pb_timer_func() bails out when !pb->alive; push_backup_stop() uses timer_delete_sync() and pb_destroy() timer_shutdown_sync() instead of WARNing on timer_delete_sync_try() < 0, which never waited for a running callback. Commit message corrected accordingly. - 6/6: push_backup_get_fd() installs the fd only after its number fits into the result buffer (reserve -> emit -> check -> install), so a too small buffer no longer leaks the fd with its pb kref and module reference. pb->dead renamed to pb->destroyed. UAPI type namespaced as struct dm_push_backup_range. read() now requires exactly sizeof(range) like write(). Subject prefix aligned with the rest of the series. v2: - 2/6: reworded the commit message, dropped the KCSAN claim. - 5/6: new patch: arm the deadline timer under pb->lock and drop the rcu_read_lock()/synchronize_rcu() between postpone_if_required_for_backup() and push_backup_stop(). - 6/6: resubmit_pbios() now frees the pbio before dm_requeue_original_rq(). The requeue drops the md reference held by the in-flight request, after which __dm_destroy() may run .dtr and destroy pbio_pool under the fd writer's feet. https://virtuozzo.atlassian.net/browse/VSTOR-152912 Andrey Zhadchenko (7): drivers/md/push_backup: correct initialization drivers/md/push_backup: return error if workqueue allocation fails drivers/md/push_backup: clear pb->alive under pb->lock drivers/md/push_backup: fix mod_timer() usage drivers/md/push_backup: arm deadline timer under pb->lock drivers/md/push_backup: do not re-arm deadline timer in push_backup_write() drivers/md/push_backup: add event file descriptor interface drivers/md/dm-push-backup.c | 275 ++++++++++++++++++++++------ include/uapi/linux/dm-push-backup.h | 48 +++++ 2 files changed, 262 insertions(+), 61 deletions(-) create mode 100644 include/uapi/linux/dm-push-backup.h -- 2.43.5 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel