Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1577935pxb; Thu, 4 Mar 2021 15:19:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwoypZmjzkz2IYnWbmMOeObsJPVS82ekqC1DoSU0KLASfQrM3nCMC6OjKz/xZC+wq4uj0Ar X-Received: by 2002:a05:6602:2348:: with SMTP id r8mr5658056iot.77.1614899977914; Thu, 04 Mar 2021 15:19:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614899977; cv=none; d=google.com; s=arc-20160816; b=JGHDFKEcP8/UebH9b9rDoXnBfrp9pgoIxuJrIOgXeR0BKdnn32f8qW8YcuP5yp0BUs iZ2U1lgQH3pY2/J7b4L6jU+bYObX+udMxUUjMG60nH85udCEFmzipFNUMvudBlpJHTYi iGWsMDPOUGm49H3BgIaDLEgL45McW/O9zhvcXLopFrxywOPpQRuRWLOXQ8f5WIoio8u1 gWL3qJVyKXjYOGWe3Pib8nmz4L7TBMx6NvCraHOpX+KNmUCeZkAF4bAw4gw6xx6Gm/Fe EaBnJKGQ4b4MkKz7IleKsSod4y4C7KT5ZcpOTTdb2jmi1PTQR7L0DKVhG6a5YGPI1mIm svvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9UO+0TRDaYLGApIoEWyRHalqxcm04zGOsOOw64BwIcE=; b=JsnYXTIrj5a+p9uNtlB+k/ZL/FZ7sQgmam/kOx8QIELt8IuO6CF0VoBpZCaz6WUbSM dBS6oq1geOJw2KNlpGQ97RLd8YAiXubs90jpG2uSSk7/yimBipkC2WZF2Jh0Zr6gPhVD ZFsudx/+OAddG4mwIiI1g69xR9ZTxnYkewXT0N5hEUWSHbd50Ex7Fcxz0OCUTveOxW6w SKk3anV1JdNKrpsjpaIudfc3d2Q7scmEUuNywpXHCJUFycoFttJ4KbhAGR/a5Z6NwTbg pi4PuTGvISQe4YYlP7Ks04j0wBgHU0H8owQE871u6xPqN1vvYTyYBIMn9tQbo5C43fd2 ZlPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@veeam.com header.s=mx2 header.b=XMT6SbIq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=veeam.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si633231iod.102.2021.03.04.15.19.25; Thu, 04 Mar 2021 15:19:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@veeam.com header.s=mx2 header.b=XMT6SbIq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=veeam.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1452935AbhCCQ6a (ORCPT + 99 others); Wed, 3 Mar 2021 11:58:30 -0500 Received: from mx2.veeam.com ([64.129.123.6]:50842 "EHLO mx2.veeam.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379309AbhCCMb0 (ORCPT ); Wed, 3 Mar 2021 07:31:26 -0500 Received: from mail.veeam.com (prgmbx01.amust.local [172.24.0.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.veeam.com (Postfix) with ESMTPS id 42C0E41501; Wed, 3 Mar 2021 07:30:38 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=veeam.com; s=mx2; t=1614774638; bh=9UO+0TRDaYLGApIoEWyRHalqxcm04zGOsOOw64BwIcE=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=XMT6SbIqMH9aXWanq8Gd6dEC4dR3Iyc3Qz78Xobcs4aj4rlpUOj0a6Wq8PzwNwidh 2aTdd7EIDsDeHflPS565JGQPuoOPvL7VS3n2+JmENV31pZnxB48IdLkW96T/nLnjpg LQFGkeYUDeeJSkjU+cEbAneE6V7nKcFpxwHjiH2M= Received: from prgdevlinuxpatch01.amust.local (172.24.14.5) by prgmbx01.amust.local (172.24.0.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.721.2; Wed, 3 Mar 2021 13:30:36 +0100 From: Sergei Shtepa To: , , , , , , , , , CC: , Subject: [PATCH v6 1/4] block: add blk_mq_is_queue_frozen() Date: Wed, 3 Mar 2021 15:30:15 +0300 Message-ID: <1614774618-22410-2-git-send-email-sergei.shtepa@veeam.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614774618-22410-1-git-send-email-sergei.shtepa@veeam.com> References: <1614774618-22410-1-git-send-email-sergei.shtepa@veeam.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.24.14.5] X-ClientProxiedBy: prgmbx01.amust.local (172.24.0.171) To prgmbx01.amust.local (172.24.0.171) X-EsetResult: clean, is OK X-EsetId: 37303A29C604D265637363 X-Veeam-MMEX: True Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org blk_mq_is_queue_frozen() allow to assert that the queue is frozen. Signed-off-by: Sergei Shtepa --- block/blk-mq.c | 12 ++++++++++++ include/linux/blk-mq.h | 1 + 2 files changed, 13 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index d4d7c1caa439..d5e7122789fc 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -161,6 +161,18 @@ int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, } EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait_timeout); +bool blk_mq_is_queue_frozen(struct request_queue *q) +{ + bool ret; + + mutex_lock(&q->mq_freeze_lock); + ret = percpu_ref_is_dying(&q->q_usage_counter) && percpu_ref_is_zero(&q->q_usage_counter); + mutex_unlock(&q->mq_freeze_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(blk_mq_is_queue_frozen); + /* * Guarantee no request is in use, so we can change any data structure of * the queue afterward. diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 2c473c9b8990..6f01971abf7b 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -533,6 +533,7 @@ void blk_freeze_queue_start(struct request_queue *q); void blk_mq_freeze_queue_wait(struct request_queue *q); int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, unsigned long timeout); +bool blk_mq_is_queue_frozen(struct request_queue *q); int blk_mq_map_queues(struct blk_mq_queue_map *qmap); void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues); -- 2.20.1