提交 eaba83b5 编写于 作者: J John Garry 提交者: Martin K. Petersen

scsi: core: Fix sbitmap depth in scsi_realloc_sdev_budget_map()

In commit edb854a3 ("scsi: core: Reallocate device's budget map on
queue depth change"), the sbitmap for the device budget map may be
reallocated after the slave device depth is configured.

When the sbitmap is reallocated we use the result from
scsi_device_max_queue_depth() for the sbitmap size, but don't resize to
match the actual device queue depth.

Fix by resizing the sbitmap after reallocating the budget sbitmap. We do
this instead of init'ing the sbitmap to the device queue depth as the user
may want to change the queue depth later via sysfs or other.

Link: https://lore.kernel.org/r/1647423870-143867-1-git-send-email-john.garry@huawei.com
Fixes: edb854a3 ("scsi: core: Reallocate device's budget map on queue depth change")
Tested-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: NMing Lei <ming.lei@redhat.com>
Reviewed-by: NBart Van Assche <bvanassche@acm.org>
Signed-off-by: NJohn Garry <john.garry@huawei.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 63221571
...@@ -223,6 +223,8 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev, ...@@ -223,6 +223,8 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,
int ret; int ret;
struct sbitmap sb_backup; struct sbitmap sb_backup;
depth = min_t(unsigned int, depth, scsi_device_max_queue_depth(sdev));
/* /*
* realloc if new shift is calculated, which is caused by setting * realloc if new shift is calculated, which is caused by setting
* up one new default queue depth after calling ->slave_configure * up one new default queue depth after calling ->slave_configure
...@@ -245,6 +247,9 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev, ...@@ -245,6 +247,9 @@ static int scsi_realloc_sdev_budget_map(struct scsi_device *sdev,
scsi_device_max_queue_depth(sdev), scsi_device_max_queue_depth(sdev),
new_shift, GFP_KERNEL, new_shift, GFP_KERNEL,
sdev->request_queue->node, false, true); sdev->request_queue->node, false, true);
if (!ret)
sbitmap_resize(&sdev->budget_map, depth);
if (need_free) { if (need_free) {
if (ret) if (ret)
sdev->budget_map = sb_backup; sdev->budget_map = sb_backup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册