From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 15F6E802A5 for ; Thu, 8 Oct 2026 14:04:58 +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 698E3dup024488; Thu, 8 Oct 2026 17:03:40 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 698E3dup024488 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="lV2qRhas" Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 698E3dXT024482 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 8 Oct 2026 17:03:39 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 698E3dXT024482 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48c7fe9736eso642514f8f.0 for ; Thu, 08 Oct 2026 07:03:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBzxB4h3z+ycao6bahMQyp3G6zn+aQV4V8NyjQVSNRVgCAyDdglq2uZJHjJGeOupj4CpwqklpQ==@openvz.org X-Gm-Message-State: AFq9FYLaZ2RL22TkKoZx7TAKixWebt7+0YTAWzB4mgICr4ZatkBWfjAN D9rCkVslrYrKR4RkVx4jNHtpKUYS7PZL1YZQqRFU8X8hxgWALcmSlszq8igrOaeS+wOOdEehaW3 8lGoQjhdu+L+ip1R717jHEej2SSKj8hl5EexUlOzztcCScMsaf6Y+uQ== X-Gm-Gg: AYBFou0KLP0o4t6CeNp24aOeJDXXMOrmQTV3qAK4I/VMsvTwWmK80TF85va0e4DRko+ cD7yMAq8m0IFDLTNTFAlfkbykP2yQJlTvutezdFqfpqvzZOwVE+NyXzdJBfPyNU7VrVkOyXXgXE mCKB3v4g9KzA/6Bg99v5z9cktqdVysOAXNoZUwNLbZWpxwY5Iy4Rq6z2fl6gZHt0trOav2Go/0n go2mrI7cAdQUfkHE8jExJ9x9yOpX2C2a/7H8eSMf1xXAHov7iJATVhB8ODYJx9/ScfWQC4IBkb8 NkcuCzdESMiW1T6AxcjufuN6UYc92amDLom/FoYbFOapAiFmD+D0DQGSIr33rK0ISW20k5iSr1C +9/5Xxf4n3zhiFQaOjvZagWLjvD4= X-Received: by 2002:a05:6000:603:b0:48a:f62c:61e2 with SMTP id ffacd0b85a97d-48c726ed164mr11961018f8f.6.1791468218765; Thu, 08 Oct 2026 07:03:38 -0700 (PDT) X-Received: by 2002:a05:6000:603:b0:48a:f62c:61e2 with SMTP id ffacd0b85a97d-48c726ed164mr11960922f8f.6.1791468217950; Thu, 08 Oct 2026 07:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791468217; cv=none; d=google.com; s=arc-20260327; b=Wlogp6d1cNYwZvZ0kvryA8GCVsmbIOdh+b7A9qXCtuWRkbzHLI7AjTHDxGLgo9wK5Y ytDXGl+jYmW7FXS3Tsx5IB5sBrC7ZnNuhJ+xIRhfW2aNFYxV7DzFXuXf2K8eHAVRVHG3 D2zjvnfxxCExkH/LjRuiGeC+HOApqbQ7JlKrG7w5Es+3nRArQjA+bxPFGZzt2+DAxIWW zIwQq86EvCGZDptHNs+nllQI7fvQFcNrnKgXneRZy+xfezoqH+eH4qLWSAPfRkPYMp/P SJZDOtVLHp2Z156D4x/d5h8wCIVb8IIVQM7bwgXLbhYgQbCfCDX79PRYnwKgzBkG8OH+ Loww== 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=Z80e8F2pEKmQtE1IZnihSPu3agyoFwsnf+0VppKm9/k=; fh=jiFD8gjZllyls1UFJ+1kA4uyOnjRU7bVpV3P+S6CTV8=; b=ofzSjk+zAGz1ccMw/ZKT+QmD9p9/HGSNZmpGxkzY7at+gZL6a7hQcF24Lf55Pe5Ymf /GsyettcDPRwR/UcWk4f1KDNTtJcX3McZgCDBLfD4n5L++uWYvIvJ4caVi4OeIgX48uZ yLy/SWzmqj5Eqwm0WR4e4o4G/H8OMU1yPdGsLy4PuL28vup22fOM42I04a6rleiekSDl ohP5DmyYAz5oqHaYvesgcXB4H/BVltFVvstX1sBlWD2aVxty2n6B5eJglulvAvAF04IL M9BwZBoKOQEN/RtQ7KOkFU1iOKSHavBKZqsNrXjFHBg1pONTka5PaYLnj/ip4FAyX3Sq 6i7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=lV2qRhas; spf=pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=alexander.ivanov@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-48c72467a19si10351694f8f.79.2026.10.08.07.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Oct 2026 07:03:37 -0700 (PDT) Received-SPF: pass (google.com: domain of alexander.ivanov@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=lV2qRhas; spf=pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=alexander.ivanov@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=Z80e8F2pEKmQtE1IZnihSPu3agyoFwsnf+0VppKm9/k=; b=lV2qRhaspyQF RQDU5tZkf7rxv1YM/S7WQQEXuSxkGFa4WhJfKzO4+nKznbqcceug63ejY3Qv07sDpb+BCVwUOHYBD bHuB3C6hmN+oGP5vpBaeWJoPrKtXSx6WxmmEJmA8TzgjkELRug4ksMGa4hPfCRaohEtCGzAKvzPev IkTapbl0UMHYk86/riRHKlqS56WdN+kksIsxA0pcoKOQ8F+0GZs4K2HskdJ4I0gTpuyVK4nN92OQk geJCPGl+/CoSJjq3YWoPvN2qAAW2rJbOX7K9vzNvtzkyvW7bC2f7eaF3l4QGu/NyaXIoQfWOZqudp OGEii8Yja99ksPXpXnwaJw==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=sky) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xEofN-00FAkW-1M; Thu, 08 Oct 2026 16:03:35 +0200 From: Alexander Ivanov To: den@openvz.org Date: Thu, 8 Oct 2026 16:03:29 +0200 Message-ID: <20261008140333.614909-2-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261008140333.614909-1-alexander.ivanov@virtuozzo.com> References: <20261008140333.614909-1-alexander.ivanov@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v3 1/5] dm-ploop: fix lost wakeup in ploop_allocator() 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 ploop_allocator() checks prealloc_size and kthread_should_stop() before setting TASK_INTERRUPTIBLE. If ploop_req_prealloc() sets prealloc_size and calls wake_up_process() in between, the wakeup finds the task running and is lost, so the allocator goes to sleep with a pending preallocation request. Later requests for the same size return early without waking it up, so the request may stay pending forever and waiters on dispatcher_wq_prealloc hang. The same applies to kthread_stop(). Set the task state before checking the conditions, as the canonical kthread loop does. set_current_state() implies a full barrier, which pairs with the one in try_to_wake_up(). https://virtuozzo.atlassian.net/browse/VSTOR-148171 Feature: dm-ploop: ploop target driver Signed-off-by: Alexander Ivanov --- drivers/md/dm-ploop-map.c | 49 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c index 48466435dd19..a3a5393e533d 100644 --- a/drivers/md/dm-ploop-map.c +++ b/drivers/md/dm-ploop-map.c @@ -2347,31 +2347,38 @@ int ploop_allocator(void *data) struct file *file; for (;;) { - /* we do not care about exact number here - risk one extra schedule wrt taking the lock */ - if (ploop->prealloc_size) { - __set_current_state(TASK_RUNNING); - file = ploop_top_delta(ploop)->file; - current->flags |= PLOOP_PFLAGS; - ret = ploop_preallocate_cluster(ploop, file); - if (ret) { - /* - * threads requesting prealloc must check - * if size actually changed - */ - /* ENOSPC is only for fallocate */ - pr_err_ratelimited( - PL_FMT("failed to allocate space: %d\n"), - ploop_device_name(ploop), ret); - } - wake_up_interruptible(&ploop->dispatcher_wq_prealloc); - current_restore_flags(old_flags, PLOOP_PFLAGS); - } + /* + * Set the state before checking the conditions, otherwise + * wake_up_process() from ploop_req_prealloc() or + * kthread_stop() may come in between and get lost. + */ + set_current_state(TASK_INTERRUPTIBLE); if (kthread_should_stop()) { __set_current_state(TASK_RUNNING); break; } - set_current_state(TASK_INTERRUPTIBLE); - schedule(); + /* we do not care about exact number here - risk one extra schedule wrt taking the lock */ + if (!READ_ONCE(ploop->prealloc_size)) { + schedule(); + continue; + } + __set_current_state(TASK_RUNNING); + + file = ploop_top_delta(ploop)->file; + current->flags |= PLOOP_PFLAGS; + ret = ploop_preallocate_cluster(ploop, file); + if (ret) { + /* + * threads requesting prealloc must check + * if size actually changed + */ + /* ENOSPC is only for fallocate */ + pr_err_ratelimited( + PL_FMT("failed to allocate space: %d\n"), + ploop_device_name(ploop), ret); + } + wake_up_interruptible(&ploop->dispatcher_wq_prealloc); + current_restore_flags(old_flags, PLOOP_PFLAGS); } return 0; -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel