lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210929070047.4223-2-powen.kao@mediatek.com>
Date:   Wed, 29 Sep 2021 15:00:46 +0800
From:   Po-Wen Kao <powen.kao@...iatek.com>
To:     <linux-block@...r.kernel.org>, <axboe@...nel.dk>,
        <linux-kernel@...r.kernel.org>, <stanley.chu@...iatek.com>,
        <linux-scsi@...r.kernel.org>, <martin.petersen@...cle.com>,
        <avri.altman@....com>, <alim.akhtar@...sung.com>,
        <jejb@...ux.ibm.com>
CC:     <peter.wang@...iatek.com>, <chun-hung.wu@...iatek.com>,
        <alice.chao@...iatek.com>, <jonathan.hsu@...iatek.com>,
        <powen.kao@...iatek.com>, <cc.chou@...iatek.com>,
        <chaotian.jing@...iatek.com>, <jiajie.hao@...iatek.com>,
        <wsd_upstream@...iatek.com>, <ed.tsai@...iatek.com>
Subject: [PATCH 1/2] blk-mq: new busy request iterator for driver

Driver occasionally execute allocated request directly without
dispatching to block layer, thus request never appears in tags->rqs.
To allow driver to iterate through requests in static_rqs, a new
interface blk_mq_drv_tagset_busy_iter() is introduced.

Signed-off-by: Po-Wen Kao <powen.kao@...iatek.com>
---
 block/blk-mq-tag.c     | 36 ++++++++++++++++++++++++++++++------
 include/linux/blk-mq.h |  4 ++++
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 86f87346232a..7723689e7714 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -365,6 +365,31 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
 
 /**
  * blk_mq_tagset_busy_iter - iterate over all started requests in a tag set
+ * Refer to __blk_mq_tagset_iter() for parameter details.
+ */
+void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+		busy_tag_iter_fn *fn, void *priv)
+{
+	__blk_mq_tagset_iter(tagset, fn, priv,
+			BT_TAG_ITER_STARTED);
+}
+EXPORT_SYMBOL(blk_mq_tagset_busy_iter);
+
+/**
+ * blk_mq_drv_tagset_busy_iter - iterate over all started static requests
+ * in a tag set.
+ * Refer to __blk_mq_tagset_iter() for parameter details.
+ */
+void blk_mq_drv_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+		busy_tag_iter_fn *fn, void *priv)
+{
+	__blk_mq_tagset_iter(tagset, fn, priv,
+			BT_TAG_ITER_STARTED | BT_TAG_ITER_STATIC_RQS);
+}
+EXPORT_SYMBOL(blk_mq_drv_tagset_busy_iter);
+
+/**
+ * blk_mq_tm_tagset_busy_iter - iterate over all requests in a tagset.
  * @tagset:	Tag set to iterate over.
  * @fn:		Pointer to the function that will be called for each started
  *		request. @fn will be called as follows: @fn(rq, @priv,
@@ -375,19 +400,18 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
  *
  * We grab one request reference before calling @fn and release it after
  * @fn returns.
+ * @flags: BT_TAG_ITER_*
  */
-void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
-		busy_tag_iter_fn *fn, void *priv)
+void __blk_mq_tagset_iter(struct blk_mq_tag_set *tagset,
+		busy_tag_iter_fn *fn, void *priv, unsigned int flags)
 {
 	int i;
-
 	for (i = 0; i < tagset->nr_hw_queues; i++) {
 		if (tagset->tags && tagset->tags[i])
-			__blk_mq_all_tag_iter(tagset->tags[i], fn, priv,
-					      BT_TAG_ITER_STARTED);
+			__blk_mq_all_tag_iter(tagset->tags[i], fn, priv, flags);
 	}
 }
-EXPORT_SYMBOL(blk_mq_tagset_busy_iter);
+
 
 static bool blk_mq_tagset_count_completed_rqs(struct request *rq,
 		void *data, bool reserved)
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 13ba1861e688..29c851192093 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -545,6 +545,10 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async);
 void blk_mq_delay_run_hw_queues(struct request_queue *q, unsigned long msecs);
 void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
 		busy_tag_iter_fn *fn, void *priv);
+void blk_mq_drv_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+		busy_tag_iter_fn *fn, void *priv);
+void __blk_mq_tagset_iter(struct blk_mq_tag_set *tagset,
+		busy_tag_iter_fn *fn, void *priv, unsigned int flags);
 void blk_mq_tagset_wait_completed_request(struct blk_mq_tag_set *tagset);
 void blk_mq_freeze_queue(struct request_queue *q);
 void blk_mq_unfreeze_queue(struct request_queue *q);
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ