Merge tag 'block-5.10-2020-10-12' of git://git.kernel.dk/linux-block
[sfrench/cifs-2.6.git] / block / blk-mq-tag.h
index b1acac518c4e087d707c6440f2a2645cdbff888b..7d3e6b333a4a97b88969de12e7032f77ca4b57a0 100644 (file)
@@ -2,8 +2,6 @@
 #ifndef INT_BLK_MQ_TAG_H
 #define INT_BLK_MQ_TAG_H
 
-#include "blk-mq.h"
-
 /*
  * Tag address space map.
  */
@@ -13,17 +11,25 @@ struct blk_mq_tags {
 
        atomic_t active_queues;
 
-       struct sbitmap_queue bitmap_tags;
-       struct sbitmap_queue breserved_tags;
+       struct sbitmap_queue *bitmap_tags;
+       struct sbitmap_queue *breserved_tags;
+
+       struct sbitmap_queue __bitmap_tags;
+       struct sbitmap_queue __breserved_tags;
 
        struct request **rqs;
        struct request **static_rqs;
        struct list_head page_list;
 };
 
+extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags,
+                                       unsigned int reserved_tags,
+                                       int node, unsigned int flags);
+extern void blk_mq_free_tags(struct blk_mq_tags *tags, unsigned int flags);
 
-extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags, unsigned int reserved_tags, int node, int alloc_policy);
-extern void blk_mq_free_tags(struct blk_mq_tags *tags);
+extern int blk_mq_init_shared_sbitmap(struct blk_mq_tag_set *set,
+                                     unsigned int flags);
+extern void blk_mq_exit_shared_sbitmap(struct blk_mq_tag_set *set);
 
 extern unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data);
 extern void blk_mq_put_tag(struct blk_mq_tags *tags, struct blk_mq_ctx *ctx,
@@ -31,6 +37,9 @@ extern void blk_mq_put_tag(struct blk_mq_tags *tags, struct blk_mq_ctx *ctx,
 extern int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
                                        struct blk_mq_tags **tags,
                                        unsigned int depth, bool can_grow);
+extern void blk_mq_tag_resize_shared_sbitmap(struct blk_mq_tag_set *set,
+                                            unsigned int size);
+
 extern void blk_mq_tag_wakeup_all(struct blk_mq_tags *tags, bool);
 void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn,
                void *priv);
@@ -56,7 +65,7 @@ extern void __blk_mq_tag_idle(struct blk_mq_hw_ctx *);
 
 static inline bool blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx)
 {
-       if (!(hctx->flags & BLK_MQ_F_TAG_SHARED))
+       if (!(hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED))
                return false;
 
        return __blk_mq_tag_busy(hctx);
@@ -64,43 +73,12 @@ static inline bool blk_mq_tag_busy(struct blk_mq_hw_ctx *hctx)
 
 static inline void blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx)
 {
-       if (!(hctx->flags & BLK_MQ_F_TAG_SHARED))
+       if (!(hctx->flags & BLK_MQ_F_TAG_QUEUE_SHARED))
                return;
 
        __blk_mq_tag_idle(hctx);
 }
 
-/*
- * For shared tag users, we track the number of currently active users
- * and attempt to provide a fair share of the tag depth for each of them.
- */
-static inline bool hctx_may_queue(struct blk_mq_hw_ctx *hctx,
-                                 struct sbitmap_queue *bt)
-{
-       unsigned int depth, users;
-
-       if (!hctx || !(hctx->flags & BLK_MQ_F_TAG_SHARED))
-               return true;
-       if (!test_bit(BLK_MQ_S_TAG_ACTIVE, &hctx->state))
-               return true;
-
-       /*
-        * Don't try dividing an ant
-        */
-       if (bt->sb.depth == 1)
-               return true;
-
-       users = atomic_read(&hctx->tags->active_queues);
-       if (!users)
-               return true;
-
-       /*
-        * Allow at least some tags
-        */
-       depth = max((bt->sb.depth + users - 1) / users, 4U);
-       return atomic_read(&hctx->nr_active) < depth;
-}
-
 static inline bool blk_mq_tag_is_reserved(struct blk_mq_tags *tags,
                                          unsigned int tag)
 {