From d4f7bf9cdd4fe4b4e050bf67d3ee76dba2d730ba Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Sat, 20 Jul 2019 23:19:57 +0200 Subject: [PATCH] vhost: remove redundant vdev == NULL checks in foreach_session() Historically the callbacks from vhost_dev_foreach_session() could be called with vdev argument == NULL, which would mean that device was removed after enqueuing the event and before consuming it. Now we keep track of pending asynchronous operations on each vhost device and don't allow removing it if there are any unconsumed events, so the the vdev == NULL checks are redundant. Remove them. Change-Id: I7aa3785080d20ed06e008c081d3f37a949228f5a Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466729 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Vitaliy Mysak Reviewed-by: Changpeng Liu --- lib/vhost/vhost.c | 2 +- lib/vhost/vhost_blk.c | 5 ----- lib/vhost/vhost_internal.h | 4 +--- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 1ef9436ef..d0e7edbda 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -373,7 +373,7 @@ static int vhost_session_set_coalescing(struct spdk_vhost_dev *vdev, struct spdk_vhost_session *vsession, void *ctx) { - if (vdev == NULL || vsession == NULL) { + if (vsession == NULL) { /* nothing to do */ return 0; } diff --git a/lib/vhost/vhost_blk.c b/lib/vhost/vhost_blk.c index a8b702a97..cc978d41b 100644 --- a/lib/vhost/vhost_blk.c +++ b/lib/vhost/vhost_blk.c @@ -563,11 +563,6 @@ vhost_session_bdev_remove_cb(struct spdk_vhost_dev *vdev, { struct spdk_vhost_blk_session *bvsession; - if (vdev == NULL) { - /* Nothing to do */ - return 0; - } - if (vsession == NULL) { /* All sessions have been notified, time to close the bdev */ struct spdk_vhost_blk_dev *bvdev = to_blk_dev(vdev); diff --git a/lib/vhost/vhost_internal.h b/lib/vhost/vhost_internal.h index ce0246258..ac958e33e 100644 --- a/lib/vhost/vhost_internal.h +++ b/lib/vhost/vhost_internal.h @@ -193,9 +193,7 @@ struct spdk_vhost_dev { /** * Synchronized vhost session event used for backend callbacks. * - * \param vdev vhost device. If the device has been deleted - * in the meantime, this function will be called one last - * time with vdev == NULL. + * \param vdev vhost device. * \param vsession vhost session. If all sessions have been * iterated through, this function will be called one last * time with vsession == NULL.