Commit 55313e92 authored by Mike Christie's avatar Mike Christie Committed by Jens Axboe

nbd: add set cmd timeout helper

Add a helper to set the cmd timeout. It does not really do a lot now,
but will be more useful in the next patches.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 238bdcdf
...@@ -1246,6 +1246,12 @@ static bool nbd_is_valid_blksize(unsigned long blksize) ...@@ -1246,6 +1246,12 @@ static bool nbd_is_valid_blksize(unsigned long blksize)
return true; return true;
} }
static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout)
{
nbd->tag_set.timeout = timeout * HZ;
blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
}
/* Must be called with config_lock held */ /* Must be called with config_lock held */
static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
...@@ -1276,10 +1282,8 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, ...@@ -1276,10 +1282,8 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
nbd_size_set(nbd, config->blksize, arg); nbd_size_set(nbd, config->blksize, arg);
return 0; return 0;
case NBD_SET_TIMEOUT: case NBD_SET_TIMEOUT:
if (arg) { if (arg)
nbd->tag_set.timeout = arg * HZ; nbd_set_cmd_timeout(nbd, arg);
blk_queue_rq_timeout(nbd->disk->queue, arg * HZ);
}
return 0; return 0;
case NBD_SET_FLAGS: case NBD_SET_FLAGS:
...@@ -1799,11 +1803,9 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info) ...@@ -1799,11 +1803,9 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
if (ret) if (ret)
goto out; goto out;
if (info->attrs[NBD_ATTR_TIMEOUT]) { if (info->attrs[NBD_ATTR_TIMEOUT])
u64 timeout = nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]); nbd_set_cmd_timeout(nbd,
nbd->tag_set.timeout = timeout * HZ; nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
}
if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) { if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
config->dead_conn_timeout = config->dead_conn_timeout =
nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]); nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]);
...@@ -1971,11 +1973,9 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) ...@@ -1971,11 +1973,9 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
if (ret) if (ret)
goto out; goto out;
if (info->attrs[NBD_ATTR_TIMEOUT]) { if (info->attrs[NBD_ATTR_TIMEOUT])
u64 timeout = nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]); nbd_set_cmd_timeout(nbd,
nbd->tag_set.timeout = timeout * HZ; nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]));
blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
}
if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) { if (info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]) {
config->dead_conn_timeout = config->dead_conn_timeout =
nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]); nla_get_u64(info->attrs[NBD_ATTR_DEAD_CONN_TIMEOUT]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment