From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62DB8C433E0 for ; Fri, 12 Mar 2021 19:06:55 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C66A664F80 for ; Fri, 12 Mar 2021 19:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C66A664F80 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615576013; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wRgVq6j/NyN8ATAr2lqP9jz94aQVB20YwkodUsPTV9U=; b=SpZJhSRHagy5DKrf7vwDcJOjhxGCPZ2mm7VIR/2NZhW3XtmF7HoFY+VVl9pTcwXdCFoppI e9WeNnMktCO8Wo8y+6V2K0w8wvkNooBMWpph5jp0zrRYWjAqepROzLtsp7kwSpctBx+OVf q/gWJbLTAoM08IB+t3f1g9u+aBDFscg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-331-FNjjYA4_PP6Vs0h2Hv15Ew-1; Fri, 12 Mar 2021 14:06:51 -0500 X-MC-Unique: FNjjYA4_PP6Vs0h2Hv15Ew-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2BAF760CD; Fri, 12 Mar 2021 19:06:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DBA660636; Fri, 12 Mar 2021 19:06:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DBF424A717; Fri, 12 Mar 2021 19:06:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12CJ6g6b007895 for ; Fri, 12 Mar 2021 14:06:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 85D8760918; Fri, 12 Mar 2021 19:06:42 +0000 (UTC) Received: from localhost (unknown [10.18.25.174]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 497E660C9B; Fri, 12 Mar 2021 19:06:42 +0000 (UTC) Date: Fri, 12 Mar 2021 14:06:41 -0500 From: Mike Snitzer To: Sergei Shtepa Message-ID: <20210312190641.GA2550@redhat.com> References: <1615563895-28565-1-git-send-email-sergei.shtepa@veeam.com> <1615563895-28565-2-git-send-email-sergei.shtepa@veeam.com> MIME-Version: 1.0 In-Reply-To: <1615563895-28565-2-git-send-email-sergei.shtepa@veeam.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: Jens Axboe , linux-block@vger.kernel.org, linux-api@vger.kernel.org, pavel.tide@veeam.com, linux-kernel@vger.kernel.org, Christoph Hellwig , dm-devel@redhat.com, Alasdair Kergon Subject: Re: [dm-devel] [PATCH v7 1/3] block: add blk_mq_is_queue_frozen() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Fri, Mar 12 2021 at 10:44am -0500, Sergei Shtepa wrote: > blk_mq_is_queue_frozen() allow to assert that the queue is frozen. > > Signed-off-by: Sergei Shtepa > --- > block/blk-mq.c | 13 +++++++++++++ > include/linux/blk-mq.h | 1 + > 2 files changed, 14 insertions(+) > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index d4d7c1caa439..2f188a865024 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -161,6 +161,19 @@ 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 frozen; > + > + mutex_lock(&q->mq_freeze_lock); > + frozen = percpu_ref_is_dying(&q->q_usage_counter) && > + percpu_ref_is_zero(&q->q_usage_counter); > + mutex_unlock(&q->mq_freeze_lock); > + > + return frozen; > +} > +EXPORT_SYMBOL_GPL(blk_mq_is_queue_frozen); > + This is returning a frozen state that is immediately stale. I don't think any code calling this is providing the guarantees you think it does due to the racey nature of this state once the mutex is dropped. > /* > * 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 > -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE251C433DB for ; Fri, 12 Mar 2021 19:07:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A834D64F77 for ; Fri, 12 Mar 2021 19:07:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234062AbhCLTHE (ORCPT ); Fri, 12 Mar 2021 14:07:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52756 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234159AbhCLTGs (ORCPT ); Fri, 12 Mar 2021 14:06:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615576007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pWyz36koqRQcLJypWgN3Jo6QKc24/Z5WKte5SZjr3Xs=; b=KADNAK9QXxQMVHsCVspxDWKrEdtR9na6Tz5vx0nyRUiLeJSILuwdqaNf0Mm8FrKprIx8ix 1xSH6tZMhB88XdMrJAzGsfxUJDFzGsghD7X1TL58TkTO445/86LzxhpSNb27L8zhdDmCMP zn+6PrV5RJm6rWTKqRpQIVVGUYbPwHM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-OmSAVjrKPZ61QqTHc0WCxA-1; Fri, 12 Mar 2021 14:06:44 -0500 X-MC-Unique: OmSAVjrKPZ61QqTHc0WCxA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DD55101872B; Fri, 12 Mar 2021 19:06:42 +0000 (UTC) Received: from localhost (unknown [10.18.25.174]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 497E660C9B; Fri, 12 Mar 2021 19:06:42 +0000 (UTC) Date: Fri, 12 Mar 2021 14:06:41 -0500 From: Mike Snitzer To: Sergei Shtepa Cc: Christoph Hellwig , Alasdair Kergon , Hannes Reinecke , Jens Axboe , dm-devel@redhat.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, pavel.tide@veeam.com Subject: Re: [PATCH v7 1/3] block: add blk_mq_is_queue_frozen() Message-ID: <20210312190641.GA2550@redhat.com> References: <1615563895-28565-1-git-send-email-sergei.shtepa@veeam.com> <1615563895-28565-2-git-send-email-sergei.shtepa@veeam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1615563895-28565-2-git-send-email-sergei.shtepa@veeam.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org On Fri, Mar 12 2021 at 10:44am -0500, Sergei Shtepa wrote: > blk_mq_is_queue_frozen() allow to assert that the queue is frozen. > > Signed-off-by: Sergei Shtepa > --- > block/blk-mq.c | 13 +++++++++++++ > include/linux/blk-mq.h | 1 + > 2 files changed, 14 insertions(+) > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index d4d7c1caa439..2f188a865024 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -161,6 +161,19 @@ 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 frozen; > + > + mutex_lock(&q->mq_freeze_lock); > + frozen = percpu_ref_is_dying(&q->q_usage_counter) && > + percpu_ref_is_zero(&q->q_usage_counter); > + mutex_unlock(&q->mq_freeze_lock); > + > + return frozen; > +} > +EXPORT_SYMBOL_GPL(blk_mq_is_queue_frozen); > + This is returning a frozen state that is immediately stale. I don't think any code calling this is providing the guarantees you think it does due to the racey nature of this state once the mutex is dropped. > /* > * 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 >