From 3709dfd674de7058785d8906a84203dee559e9af Mon Sep 17 00:00:00 2001 From: GangCao Date: Tue, 27 Mar 2018 01:50:44 -0400 Subject: [PATCH] bdev: update the function to get the QoS setting Instead of accessing the qos_channel pointer on the bdev, always have the QoS parameter on the allocated memory of qos_channel structure. The bdev->qos_channel is set to NULL in the destroy operation, and the destroy is through the async message which could be executed later after the poller function within which the bdev->qos_channel is accessed (thus a NULL pointer dereferenced). In this case, assign the memory address of the allcoated qos_channel to the function as the parameter to solve this issue. Change-Id: I2fdb53cb0a6a29fb41ab28362f8e068d21ee5d12 Signed-off-by: GangCao Reviewed-on: https://review.gerrithub.io/405438 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Shuhei Matsumoto --- lib/bdev/bdev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index fcc981973..e97beb9f5 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -998,25 +998,25 @@ spdk_bdev_config_json(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w) } static void -spdk_bdev_qos_get_max_ios_per_timeslice(struct spdk_bdev *bdev) +spdk_bdev_qos_get_max_ios_per_timeslice(struct spdk_bdev_channel *qos_ch) { - uint64_t qos_max_ios_per_timeslice = 0; + uint64_t qos_max_ios_per_timeslice = 0; + struct spdk_bdev *bdev = qos_ch->bdev; qos_max_ios_per_timeslice = bdev->ios_per_sec * SPDK_BDEV_QOS_TIMESLICE_IN_USEC / SPDK_BDEV_SEC_TO_USEC; - bdev->qos_channel->qos_max_ios_per_timeslice = spdk_max(qos_max_ios_per_timeslice, - SPDK_BDEV_QOS_MIN_IO_PER_TIMESLICE); + qos_ch->qos_max_ios_per_timeslice = spdk_max(qos_max_ios_per_timeslice, + SPDK_BDEV_QOS_MIN_IO_PER_TIMESLICE); } static int spdk_bdev_channel_poll_qos(void *arg) { struct spdk_bdev_channel *ch = arg; - struct spdk_bdev *bdev = ch->bdev; /* Reset for next round of rate limiting */ ch->io_submitted_this_timeslice = 0; - spdk_bdev_qos_get_max_ios_per_timeslice(bdev); + spdk_bdev_qos_get_max_ios_per_timeslice(ch); _spdk_bdev_qos_io_submit(ch); @@ -1134,7 +1134,7 @@ spdk_bdev_qos_channel_create(struct spdk_bdev *bdev) } bdev->qos_channel->flags |= BDEV_CH_QOS_ENABLED; - spdk_bdev_qos_get_max_ios_per_timeslice(bdev); + spdk_bdev_qos_get_max_ios_per_timeslice(bdev->qos_channel); bdev->qos_channel->qos_poller = spdk_poller_register( spdk_bdev_channel_poll_qos, bdev->qos_channel,