Skip to contentSkip to conversation

vhost - cleanup

PATCH Applied Jeff Dike 2 participants 2 messages Mar 4, 2010 – Mar 7, 2010 virtio host (vhost)

lore
Share & tools
lore

Jeff Dike

author
#0 lore raw

PATCH 2/2 vhost - cleanup

commit 1191aa42193d030470dbd4ab17e4fb57772534ff

Author: Jeff Dike <[email protected]>
Date:   Thu Mar 4 14:51:20 2010 -0500

Delete a label and goto from vhost_net_set_backend

Inverting a test allows a label and goto to be eliminated.

drivers/vhost/net.c +5 -6
index 4ada4b4..7abb883 100644
@@ -518,13 +518,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 
 	/* start polling new socket */
 	oldsock = vq->private_data;
-	if (sock == oldsock)
-		goto done;
+	if (sock != oldsock){
+                vhost_net_disable_vq(n, vq);
+                rcu_assign_pointer(vq->private_data, sock);
+                vhost_net_enable_vq(n, vq);
+	}
 
-	vhost_net_disable_vq(n, vq);
-	rcu_assign_pointer(vq->private_data, sock);
-	vhost_net_enable_vq(n, vq);
-done:
 	if (oldsock) {
 		vhost_net_flush_vq(n, index);
 		fput(oldsock->file);
#1 lore raw
Quoted 9 lines · Jeff Dike

commit 1191aa42193d030470dbd4ab17e4fb57772534ff

Author: Jeff Dike <[email protected]>
Date:   Thu Mar 4 14:51:20 2010 -0500

Delete a label and goto from vhost_net_set_backend

Inverting a test allows a label and goto to be eliminated.

Thanks!
I am in fixes-only mode for 2.6.34, will queue this for the next release.

Quoted 23 lines
drivers/vhost/net.c +5 -6
index 4ada4b4..7abb883 100644
@@ -518,13 +518,12 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
 
 	/* start polling new socket */
 	oldsock = vq->private_data;
-	if (sock == oldsock)
-		goto done;
+	if (sock != oldsock){
+                vhost_net_disable_vq(n, vq);
+                rcu_assign_pointer(vq->private_data, sock);
+                vhost_net_enable_vq(n, vq);
+	}
 
-	vhost_net_disable_vq(n, vq);
-	rcu_assign_pointer(vq->private_data, sock);
-	vhost_net_enable_vq(n, vq);
-done:
 	if (oldsock) {
 		vhost_net_flush_vq(n, index);
 		fput(oldsock->file);