From: Dan Carpenter <dan.carpenter@oracle.com>
To: axboe@fb.com
Cc: linux-block@vger.kernel.org
Subject: [bug report] blk-mq-tag: cleanup the normal/reserved tag allocation
Date: Thu, 19 Jan 2017 13:54:49 +0300 [thread overview]
Message-ID: <20170119105449.GA18622@mwanda> (raw)
Hello Jens Axboe,
This is a semi-automatic email about new static checker warnings.
The patch 4941115bef2b: "blk-mq-tag: cleanup the normal/reserved tag
allocation" from Jan 13, 2017, leads to the following Smatch
complaint:
block/blk-mq-tag.c:142 blk_mq_get_tag()
warn: variable dereferenced before check 'data->hctx' (see line 102)
block/blk-mq-tag.c
101 {
102 struct blk_mq_tags *tags = blk_mq_tags_from_data(data);
^^^^^^^^^^^^^^^^^^^^^^^^^^^
We added a new "data->hctx" dereference here.
103 struct sbitmap_queue *bt;
104 struct sbq_wait_state *ws;
105 DEFINE_WAIT(wait);
106 unsigned int tag_offset;
107 int tag;
108
109 if (data->flags & BLK_MQ_REQ_RESERVED) {
110 if (unlikely(!tags->nr_reserved_tags)) {
111 WARN_ON_ONCE(1);
112 return BLK_MQ_TAG_FAIL;
113 }
114 bt = &tags->breserved_tags;
115 tag_offset = 0;
116 } else {
117 bt = &tags->bitmap_tags;
118 tag_offset = tags->nr_reserved_tags;
119 }
120
121 tag = __blk_mq_get_tag(data->hctx, bt);
122 if (tag != -1)
123 goto found_tag;
124
125 if (data->flags & BLK_MQ_REQ_NOWAIT)
126 return BLK_MQ_TAG_FAIL;
127
128 ws = bt_wait_ptr(bt, data->hctx);
129 do {
130 prepare_to_wait(&ws->wait, &wait, TASK_UNINTERRUPTIBLE);
131
132 tag = __blk_mq_get_tag(data->hctx, bt);
133 if (tag != -1)
134 break;
135
136 /*
137 * We're out of tags on this hardware queue, kick any
138 * pending IO submits before going to sleep waiting for
139 * some to complete. Note that hctx can be NULL here for
140 * reserved tag allocation.
141 */
142 if (data->hctx)
We're in a loop here so it's possible we don't need to check the first
item in the list, but it's kind of new so I thought I would forward the
message anyway even though it might be a false positive.
143 blk_mq_run_hw_queue(data->hctx, false);
144
regards,
dan carpenter
next reply other threads:[~2017-01-19 10:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 10:54 Dan Carpenter [this message]
2017-01-19 14:13 ` [bug report] blk-mq-tag: cleanup the normal/reserved tag allocation Jens Axboe
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=20170119105449.GA18622@mwanda \
--to=dan.carpenter@oracle.com \
--cc=axboe@fb.com \
--cc=linux-block@vger.kernel.org \
/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.