All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtepa <sergei.shtepa@veeam.com>
To: Christoph Hellwig <hch@infradead.org>,
	Mike Snitzer <snitzer@redhat.com>,
	Alasdair Kergon <agk@redhat.com>, Hannes Reinecke <hare@suse.de>,
	Jens Axboe <axboe@kernel.dk>, <dm-devel@redhat.com>,
	<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-api@vger.kernel.org>
Cc: <sergei.shtepa@veeam.com>, <pavel.tide@veeam.com>
Subject: [PATCH v7 1/3] block: add blk_mq_is_queue_frozen()
Date: Fri, 12 Mar 2021 18:44:53 +0300	[thread overview]
Message-ID: <1615563895-28565-2-git-send-email-sergei.shtepa@veeam.com> (raw)
In-Reply-To: <1615563895-28565-1-git-send-email-sergei.shtepa@veeam.com>

blk_mq_is_queue_frozen() allow to assert that the queue is frozen.

Signed-off-by: Sergei Shtepa <sergei.shtepa@veeam.com>
---
 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);
+
 /*
  * 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


WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtepa <sergei.shtepa@veeam.com>
To: Christoph Hellwig <hch@infradead.org>,
	Mike Snitzer <snitzer@redhat.com>,
	 Alasdair Kergon <agk@redhat.com>, Hannes Reinecke <hare@suse.de>,
	Jens Axboe <axboe@kernel.dk>, <dm-devel@redhat.com>,
	<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-api@vger.kernel.org>
Cc: pavel.tide@veeam.com, sergei.shtepa@veeam.com
Subject: [dm-devel] [PATCH v7 1/3] block: add blk_mq_is_queue_frozen()
Date: Fri, 12 Mar 2021 18:44:53 +0300	[thread overview]
Message-ID: <1615563895-28565-2-git-send-email-sergei.shtepa@veeam.com> (raw)
In-Reply-To: <1615563895-28565-1-git-send-email-sergei.shtepa@veeam.com>

blk_mq_is_queue_frozen() allow to assert that the queue is frozen.

Signed-off-by: Sergei Shtepa <sergei.shtepa@veeam.com>
---
 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);
+
 /*
  * 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


  reply	other threads:[~2021-03-12 15:46 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 15:44 [PATCH v7 0/3] block device interposer Sergei Shtepa
2021-03-12 15:44 ` [dm-devel] " Sergei Shtepa
2021-03-12 15:44 ` Sergei Shtepa [this message]
2021-03-12 15:44   ` [dm-devel] [PATCH v7 1/3] block: add blk_mq_is_queue_frozen() Sergei Shtepa
2021-03-12 19:06   ` Mike Snitzer
2021-03-12 19:06     ` [dm-devel] " Mike Snitzer
2021-03-14  9:14     ` Christoph Hellwig
2021-03-14  9:14       ` [dm-devel] " Christoph Hellwig
2021-03-15 12:06       ` Sergei Shtepa
2021-03-15 12:06         ` [dm-devel] " Sergei Shtepa
2021-03-12 15:44 ` [PATCH v7 2/3] block: add bdev_interposer Sergei Shtepa
2021-03-12 15:44   ` [dm-devel] " Sergei Shtepa
2021-03-14  9:28   ` Christoph Hellwig
2021-03-14  9:28     ` [dm-devel] " Christoph Hellwig
2021-03-15 13:06     ` Sergei Shtepa
2021-03-15 13:06       ` [dm-devel] " Sergei Shtepa
2021-03-16  8:09   ` Ming Lei
2021-03-16  8:09     ` [dm-devel] " Ming Lei
2021-03-16 16:35     ` Sergei Shtepa
2021-03-16 16:35       ` [dm-devel] " Sergei Shtepa
2021-03-17  3:03       ` Ming Lei
2021-03-17  3:03         ` [dm-devel] " Ming Lei
2021-03-17 12:22         ` Sergei Shtepa
2021-03-17 12:22           ` [dm-devel] " Sergei Shtepa
2021-03-17 15:04           ` Mike Snitzer
2021-03-17 15:04             ` [dm-devel] " Mike Snitzer
2021-03-17 18:14             ` Sergei Shtepa
2021-03-17 18:14               ` [dm-devel] " Sergei Shtepa
2021-03-17 19:13               ` Mike Snitzer
2021-03-17 19:13                 ` [dm-devel] " Mike Snitzer
2021-03-18 14:56                 ` Sergei Shtepa
2021-03-18 14:56                   ` [dm-devel] " Sergei Shtepa
2021-03-17 14:58         ` Mike Snitzer
2021-03-17 14:58           ` [dm-devel] " Mike Snitzer
2021-03-12 15:44 ` [PATCH v7 3/3] dm: add DM_INTERPOSED_FLAG Sergei Shtepa
2021-03-12 15:44   ` [dm-devel] " Sergei Shtepa
2021-03-12 19:00   ` Mike Snitzer
2021-03-12 19:00     ` [dm-devel] " Mike Snitzer
2021-03-15 12:29     ` Sergei Shtepa
2021-03-15 12:29       ` [dm-devel] " Sergei Shtepa
2021-03-14  9:30   ` Christoph Hellwig
2021-03-14  9:30     ` [dm-devel] " Christoph Hellwig
2021-03-15 13:25     ` Sergei Shtepa
2021-03-15 13:25       ` [dm-devel] " Sergei Shtepa
2021-03-16 15:23       ` Christoph Hellwig
2021-03-16 15:23         ` [dm-devel] " Christoph Hellwig
2021-03-16 15:25         ` Christoph Hellwig
2021-03-16 15:25           ` [dm-devel] " Christoph Hellwig
2021-03-16 16:20           ` Sergei Shtepa
2021-03-16 16:20             ` [dm-devel] " Sergei Shtepa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1615563895-28565-2-git-send-email-sergei.shtepa@veeam.com \
    --to=sergei.shtepa@veeam.com \
    --cc=agk@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel.tide@veeam.com \
    --cc=snitzer@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.