From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:48160 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932291AbeDWWBL (ORCPT ); Mon, 23 Apr 2018 18:01:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AA60315009B for ; Mon, 23 Apr 2018 22:01:11 +0000 (UTC) Date: Mon, 23 Apr 2018 19:00:46 -0300 From: "Bruno E. O. Meneguele" To: Mohammed Gamal Cc: rhkernel-list@redhat.com, stable@vger.kernel.org, rhvirt-patches@redhat.com Subject: Re: [RHEL7.6 PATCH 22/37] Drivers: hv: vmbus: Fix a rescind issue Message-ID: <20180423220046.GA983@rhlt> References: <1524241783-22489-1-git-send-email-mgamal@redhat.com> <1524241783-22489-23-git-send-email-mgamal@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="G4iJoqBmSsgzjUCe" Content-Disposition: inline In-Reply-To: <1524241783-22489-23-git-send-email-mgamal@redhat.com> Sender: stable-owner@vger.kernel.org List-ID: --G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 20-04, Mohammed Gamal wrote: > The current rescind processing code will not correctly handle > the case where the host immediately rescinds a channel that has > been offerred. In this case, we could be blocked in the open call and > since the channel is rescinded, the host will not respond and we could > be blocked forever in the vmbus open call.i Fix this problem. >=20 > Signed-off-by: K. Y. Srinivasan > Cc: stable@vger.kernel.org > Signed-off-by: Greg Kroah-Hartman > (cherry picked from commit 7fa32e5ec28b1609abc0b797b58267f725fc3964) >=20 > Signed-off-by: Mohammed Gamal Just fyi, this patch was already applied by:=20 http://patchwork.lab.bos.redhat.com/patch/207318/ thus I'll drop it during this patchset integration to rhel tree. Thanks! > --- > drivers/hv/channel.c | 10 ++++++++-- > drivers/hv/channel_mgmt.c | 7 ++++--- > include/linux/hyperv.h | 1 + > 3 files changed, 13 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c > index 1c967f5..1d58986 100644 > --- a/drivers/hv/channel.c > +++ b/drivers/hv/channel.c > @@ -659,22 +659,28 @@ void vmbus_close(struct vmbus_channel *channel) > */ > return; > } > - mutex_lock(&vmbus_connection.channel_mutex); > /* > * Close all the sub-channels first and then close the > * primary channel. > */ > list_for_each_safe(cur, tmp, &channel->sc_list) { > cur_channel =3D list_entry(cur, struct vmbus_channel, sc_list); > - vmbus_close_internal(cur_channel); > if (cur_channel->rescind) { > + wait_for_completion(&cur_channel->rescind_event); > + mutex_lock(&vmbus_connection.channel_mutex); > + vmbus_close_internal(cur_channel); > hv_process_channel_removal( > cur_channel->offermsg.child_relid); > + } else { > + mutex_lock(&vmbus_connection.channel_mutex); > + vmbus_close_internal(cur_channel); > } > + mutex_unlock(&vmbus_connection.channel_mutex); > } > /* > * Now close the primary. > */ > + mutex_lock(&vmbus_connection.channel_mutex); > vmbus_close_internal(channel); > mutex_unlock(&vmbus_connection.channel_mutex); > } > diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c > index ec5454f..c21020b 100644 > --- a/drivers/hv/channel_mgmt.c > +++ b/drivers/hv/channel_mgmt.c > @@ -333,6 +333,7 @@ static struct vmbus_channel *alloc_channel(void) > return NULL; > =20 > spin_lock_init(&channel->lock); > + init_completion(&channel->rescind_event); > =20 > INIT_LIST_HEAD(&channel->sc_list); > INIT_LIST_HEAD(&channel->percpu_list); > @@ -898,6 +899,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channe= l_message_header *hdr) > /* > * Now wait for offer handling to complete. > */ > + vmbus_rescind_cleanup(channel); > while (READ_ONCE(channel->probe_done) =3D=3D false) { > /* > * We wait here until any channel offer is currently > @@ -913,7 +915,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channe= l_message_header *hdr) > if (channel->device_obj) { > if (channel->chn_rescind_callback) { > channel->chn_rescind_callback(channel); > - vmbus_rescind_cleanup(channel); > return; > } > /* > @@ -922,7 +923,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channe= l_message_header *hdr) > */ > dev =3D get_device(&channel->device_obj->device); > if (dev) { > - vmbus_rescind_cleanup(channel); > vmbus_device_unregister(channel->device_obj); > put_device(dev); > } > @@ -936,13 +936,14 @@ static void vmbus_onoffer_rescind(struct vmbus_chan= nel_message_header *hdr) > * 2. Then close the primary channel. > */ > mutex_lock(&vmbus_connection.channel_mutex); > - vmbus_rescind_cleanup(channel); > if (channel->state =3D=3D CHANNEL_OPEN_STATE) { > /* > * The channel is currently not open; > * it is safe for us to cleanup the channel. > */ > hv_process_channel_removal(rescind->child_relid); > + } else { > + complete(&channel->rescind_event); > } > mutex_unlock(&vmbus_connection.channel_mutex); > } > diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h > index 1552a5f..465d5db 100644 > --- a/include/linux/hyperv.h > +++ b/include/linux/hyperv.h > @@ -724,6 +724,7 @@ struct vmbus_channel { > u8 monitor_bit; > =20 > bool rescind; /* got rescind msg */ > + struct completion rescind_event; > =20 > u32 ringbuffer_gpadlhandle; > =20 > --=20 > 1.8.3.1 >=20 >=20 --G4iJoqBmSsgzjUCe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEdWo6nTbnZdbDmXutYdRkFR+RokMFAlreV4sACgkQYdRkFR+R okMFtgf9FsMnciQmPFLXT1nhJn1edF7ppj/fyN/xlMxwmjo9lZeZgdw7HxFdaB2Q xwwufwvnakfrscd9uUuVkZAFe1G+gXssNremwgAdkiZrvKwVRcnDdyx92+kM7kS5 1nCTpzs4xgH17MChsUPEICT6sNisWPxUHvoXnsxofASXtAJmRxHgDRPwm9nVnKfR 6nWkM10xYLv6wytduuLfXmNHEZ8BL/Jrxka/4V36B8SXRKzEz2x6kyTIL+AckYEi JE8gVnzuYBIwGbaK/28dsZ4Z1LakHJ29jZ6OQlWHSAIqArklj+wWz70R1XZ+GkTH /SOff2aPuoymxKQJ+aGKfzwcAz5JvQ== =KMea -----END PGP SIGNATURE----- --G4iJoqBmSsgzjUCe--