summaryrefslogtreecommitdiffstats
path: root/src/kernel/mq.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/mq.c')
-rw-r--r--src/kernel/mq.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/kernel/mq.c b/src/kernel/mq.c
index 946e395..b1c1e99 100644
--- a/src/kernel/mq.c
+++ b/src/kernel/mq.c
@@ -32,21 +32,24 @@
*/
static void dnbd3_busy_iter(struct request *req, void *priv, bool arg2)
{
- bool *is_busy = (bool *) priv;
- *is_busy = true;
+ struct dnbd3_cmd *cmd = blk_mq_rq_to_pdu(req);
+ unsigned long *busy = (unsigned long *) priv;
+ set_bit(cmd->index, busy);
}
/**
* dnbd3_is_mq_busy - check if mq is busy
* @dev: the device
+ *
+ * sets bit to 1, where socket is busy
*/
-bool dnbd3_is_mq_busy(struct dnbd3_device *dev)
+unsigned long dnbd3_is_mq_busy(struct dnbd3_device *dev)
{
struct blk_mq_tag_set *set = &dev->tag_set;
- bool is_busy = false;
+ unsigned long busy = 0;
- blk_mq_tagset_busy_iter(set, dnbd3_busy_iter, &is_busy);
+ blk_mq_tagset_busy_iter(set, dnbd3_busy_iter, &busy);
/*
* just for demonstration
@@ -64,7 +67,7 @@ bool dnbd3_is_mq_busy(struct dnbd3_device *dev)
}
*/
- return is_busy;
+ return busy;
}
@@ -92,20 +95,6 @@ void dnbd3_end_cmd(struct dnbd3_cmd *cmd, blk_status_t error)
blk_mq_end_request(req, error);
}
-/**
- * dnbd3_is_any_sock_alive - check if any socket is alive
- * @cmd: the command
- */
-static bool dnbd3_is_any_sock_alive(struct dnbd3_cmd *cmd) {
- int i;
- for (i = 0; i < NUMBER_CONNECTIONS; i++) {
- if (dnbd3_is_sock_alive(cmd->dnbd3->socks[i]) &&
- !cmd->dnbd3->socks->panic) {
- return true;
- }
- }
- return false;
-}
/**
* dnbd3_handle_cmd - handles a mq command
@@ -140,8 +129,6 @@ static int dnbd3_handle_cmd(struct dnbd3_cmd *cmd, int index)
}
}
- cmd->status = BLK_STS_OK;
-
mutex_lock(&sock->tx_lock);
if (unlikely(!sock->sock)) {
mutex_unlock(&sock->tx_lock);
@@ -181,6 +168,7 @@ static blk_status_t dnbd3_queue_rq(struct blk_mq_hw_ctx *hctx,
mutex_lock(&cmd->lock);
cmd->requed = false;
+ cmd->index = hctx->queue_num;
ret = dnbd3_handle_cmd(cmd, hctx->queue_num);
if (ret < 0) {
@@ -234,8 +222,6 @@ static enum blk_eh_timer_return dnbd3_xmit_timeout(struct request *req,
}
error_dev(dev, "connection timed out");
- cmd->status = BLK_STS_IOERR;
-// blk_mq_complete_request(req);
dnbd3_end_cmd(cmd, BLK_STS_TIMEOUT);
mutex_unlock(&cmd->lock);
return BLK_EH_DONE;