Skip to contentSkip to conversation

vhost: remove the dead branch

PATCH In review Zhi Yong Wu 2 participants 7 messages Nov 18, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 vhost: remove the dead branch

From: Zhi Yong Wu <[email protected]>

Since vhost_dev_init() forever return 0, some branches are never run, therefore need to be removed.

---
 drivers/vhost/net.c  |    5 -----
 drivers/vhost/scsi.c |    5 -----
 drivers/vhost/test.c |    5 -----
 3 files changed, 0 insertions(+), 15 deletions(-)
drivers/vhost/net.c +0 -5
index 831eb4f..0554785 100644
@@ -707,11 +707,6 @@ static int vhost_net_open(struct inode *inode, struct file *f)
 		n->vqs[i].sock_hlen = 0;
 	}
 	r = vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
-	if (r < 0) {
-		kfree(n);
-		kfree(vqs);
-		return r;
-	}
 
 	vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, POLLOUT, dev);
 	vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, POLLIN, dev);
drivers/vhost/scsi.c +0 -5
index e663921..9d5e18d 100644
@@ -1421,14 +1421,9 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
 
 	tcm_vhost_init_inflight(vs, NULL);
 
-	if (r < 0)
-		goto err_init;
-
 	f->private_data = vs;
 	return 0;
 
-err_init:
-	kfree(vqs);
 err_vqs:
 	vhost_scsi_free(vs);
 err_vs:
drivers/vhost/test.c +0 -5
index 339eae8..99cb960 100644
@@ -118,11 +118,6 @@ static int vhost_test_open(struct inode *inode, struct file *f)
 	vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];
 	n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick;
 	r = vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);
-	if (r < 0) {
-		kfree(vqs);
-		kfree(n);
-		return r;
-	}
 
 	f->private_data = n;
 
Signature · 1 line
1.7.6.5
#1 lore raw

PATCH 2/3 vhost: adjust vhost_dev_init() to be void

From: Zhi Yong Wu <[email protected]>

---
 drivers/vhost/net.c   |    4 ++--
 drivers/vhost/scsi.c  |    2 +-
 drivers/vhost/test.c  |    3 +--
 drivers/vhost/vhost.c |    4 +---
 drivers/vhost/vhost.h |    2 +-
 5 files changed, 6 insertions(+), 9 deletions(-)
drivers/vhost/net.c +2 -2
index 0554785..9a68409 100644
@@ -683,7 +683,7 @@ static int vhost_net_open(struct inode *inode, struct file *f)
 	struct vhost_net *n = kmalloc(sizeof *n, GFP_KERNEL);
 	struct vhost_dev *dev;
 	struct vhost_virtqueue **vqs;
-	int r, i;
+	int i;
 
 	if (!n)
 		return -ENOMEM;
@@ -706,7 +706,7 @@ static int vhost_net_open(struct inode *inode, struct file *f)
 		n->vqs[i].vhost_hlen = 0;
 		n->vqs[i].sock_hlen = 0;
 	}
-	r = vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
+	vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
 
 	vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, POLLOUT, dev);
 	vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, POLLIN, dev);
drivers/vhost/scsi.c +1 -1
index 9d5e18d..e02b7df 100644
@@ -1417,7 +1417,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
 		vqs[i] = &vs->vqs[i].vq;
 		vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
 	}
-	r = vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ);
+	vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ);
 
 	tcm_vhost_init_inflight(vs, NULL);
 
drivers/vhost/test.c +1 -2
index 99cb960..c2a54fb 100644
@@ -104,7 +104,6 @@ static int vhost_test_open(struct inode *inode, struct file *f)
 	struct vhost_test *n = kmalloc(sizeof *n, GFP_KERNEL);
 	struct vhost_dev *dev;
 	struct vhost_virtqueue **vqs;
-	int r;
 
 	if (!n)
 		return -ENOMEM;
@@ -117,7 +116,7 @@ static int vhost_test_open(struct inode *inode, struct file *f)
 	dev = &n->dev;
 	vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];
 	n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick;
-	r = vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);
+	vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);
 
 	f->private_data = n;
 
drivers/vhost/vhost.c +1 -3
index 69068e0..78987e4 100644
@@ -290,7 +290,7 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev)
 		vhost_vq_free_iovecs(dev->vqs[i]);
 }
 
-long vhost_dev_init(struct vhost_dev *dev,
+void vhost_dev_init(struct vhost_dev *dev,
 		    struct vhost_virtqueue **vqs, int nvqs)
 {
 	struct vhost_virtqueue *vq;
@@ -319,8 +319,6 @@ long vhost_dev_init(struct vhost_dev *dev,
 			vhost_poll_init(&vq->poll, vq->handle_kick,
 					POLLIN, dev);
 	}
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(vhost_dev_init);
 
drivers/vhost/vhost.h +1 -1
index 4465ed5..35eeb2a 100644
@@ -127,7 +127,7 @@ struct vhost_dev {
 	struct task_struct *worker;
 };
 
-long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs);
+void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs);
 long vhost_dev_set_owner(struct vhost_dev *dev);
 bool vhost_dev_has_owner(struct vhost_dev *dev);
 long vhost_dev_check_owner(struct vhost_dev *);
Signature · 1 line
1.7.6.5
maintainer Acked-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] vhost: adjust vhost_dev_init() to be void

Quoted 3 lines · Zhi Yong Wu

From: Zhi Yong Wu <[email protected]>

Quoted 101 lines
---
 drivers/vhost/net.c   |    4 ++--
 drivers/vhost/scsi.c  |    2 +-
 drivers/vhost/test.c  |    3 +--
 drivers/vhost/vhost.c |    4 +---
 drivers/vhost/vhost.h |    2 +-
 5 files changed, 6 insertions(+), 9 deletions(-)
drivers/vhost/net.c +2 -2
index 0554785..9a68409 100644
@@ -683,7 +683,7 @@ static int vhost_net_open(struct inode *inode, struct file *f)
 	struct vhost_net *n = kmalloc(sizeof *n, GFP_KERNEL);
 	struct vhost_dev *dev;
 	struct vhost_virtqueue **vqs;
-	int r, i;
+	int i;
 
 	if (!n)
 		return -ENOMEM;
@@ -706,7 +706,7 @@ static int vhost_net_open(struct inode *inode, struct file *f)
 		n->vqs[i].vhost_hlen = 0;
 		n->vqs[i].sock_hlen = 0;
 	}
-	r = vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
+	vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
 
 	vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, POLLOUT, dev);
 	vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, POLLIN, dev);
drivers/vhost/scsi.c +1 -1
index 9d5e18d..e02b7df 100644
@@ -1417,7 +1417,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
 		vqs[i] = &vs->vqs[i].vq;
 		vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
 	}
-	r = vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ);
+	vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ);
 
 	tcm_vhost_init_inflight(vs, NULL);
 
drivers/vhost/test.c +1 -2
index 99cb960..c2a54fb 100644
@@ -104,7 +104,6 @@ static int vhost_test_open(struct inode *inode, struct file *f)
 	struct vhost_test *n = kmalloc(sizeof *n, GFP_KERNEL);
 	struct vhost_dev *dev;
 	struct vhost_virtqueue **vqs;
-	int r;
 
 	if (!n)
 		return -ENOMEM;
@@ -117,7 +116,7 @@ static int vhost_test_open(struct inode *inode, struct file *f)
 	dev = &n->dev;
 	vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];
 	n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick;
-	r = vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);
+	vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);
 
 	f->private_data = n;
 
drivers/vhost/vhost.c +1 -3
index 69068e0..78987e4 100644
@@ -290,7 +290,7 @@ static void vhost_dev_free_iovecs(struct vhost_dev *dev)
 		vhost_vq_free_iovecs(dev->vqs[i]);
 }
 
-long vhost_dev_init(struct vhost_dev *dev,
+void vhost_dev_init(struct vhost_dev *dev,
 		    struct vhost_virtqueue **vqs, int nvqs)
 {
 	struct vhost_virtqueue *vq;
@@ -319,8 +319,6 @@ long vhost_dev_init(struct vhost_dev *dev,
 			vhost_poll_init(&vq->poll, vq->handle_kick,
 					POLLIN, dev);
 	}
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(vhost_dev_init);
 
drivers/vhost/vhost.h +1 -1
index 4465ed5..35eeb2a 100644
@@ -127,7 +127,7 @@ struct vhost_dev {
 	struct task_struct *worker;
 };
 
-long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs);
+void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs, int nvqs);
 long vhost_dev_set_owner(struct vhost_dev *dev);
 bool vhost_dev_has_owner(struct vhost_dev *dev);
 long vhost_dev_check_owner(struct vhost_dev *);
Signature · 1 line
1.7.6.5
#3 lore raw

PATCH 3/3 vhost: fix the wrong log descriptions

In reply to Zhi Yong Wu

From: Zhi Yong Wu <[email protected]>

---
 drivers/vhost/vhost.c  |    2 +-
 drivers/vhost/vringh.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/vhost/vhost.c +1 -1
index 78987e4..568d20f 100644
@@ -1241,7 +1241,7 @@ int vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
 
 	/* If their number is silly, that's an error. */
 	if (unlikely(head >= vq->num)) {
-		vq_err(vq, "Guest says index %u > %u is available",
+		vq_err(vq, "Guest says index %u > %u is unavailable",
 		       head, vq->num);
 		return -EINVAL;
 	}
drivers/vhost/vringh.c +1 -1
index 5174eba..86ef6c4 100644
@@ -57,7 +57,7 @@ static inline int __vringh_get_head(const struct vringh *vrh,
 	}
 
 	if (head >= vrh->vring.num) {
-		vringh_bad("Guest says index %u > %u is available",
+		vringh_bad("Guest says index %u > %u is unavailable",
 			   head, vrh->vring.num);
 		return -EINVAL;
 	}
Signature · 1 line
1.7.6.5
#4 lore raw

Re: [PATCH 3/3] vhost: fix the wrong log descriptions

Quoted 3 lines · Zhi Yong Wu

From: Zhi Yong Wu <[email protected]>

This one does not make sense to me.
Heads in avail ring are heads which according to Guest are available by definition.

Quoted 33 lines
---
 drivers/vhost/vhost.c  |    2 +-
 drivers/vhost/vringh.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/vhost/vhost.c +1 -1
index 78987e4..568d20f 100644
@@ -1241,7 +1241,7 @@ int vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
 
 	/* If their number is silly, that's an error. */
 	if (unlikely(head >= vq->num)) {
-		vq_err(vq, "Guest says index %u > %u is available",
+		vq_err(vq, "Guest says index %u > %u is unavailable",
 		       head, vq->num);
 		return -EINVAL;
 	}
drivers/vhost/vringh.c +1 -1
index 5174eba..86ef6c4 100644
@@ -57,7 +57,7 @@ static inline int __vringh_get_head(const struct vringh *vrh,
 	}
 
 	if (head >= vrh->vring.num) {
-		vringh_bad("Guest says index %u > %u is available",
+		vringh_bad("Guest says index %u > %u is unavailable",
 			   head, vrh->vring.num);
 		return -EINVAL;
 	}
Signature · 1 line
1.7.6.5
#5 lore raw

Re: [PATCH 3/3] vhost: fix the wrong log descriptions

Quoted 8 lines · Michael S. Tsirkin
Quoted 3 lines · Zhi Yong Wu

From: Zhi Yong Wu <[email protected]>

This one does not make sense to me.
Heads in avail ring are heads which according to Guest are available by definition.

ok, please ignore this patch

Quoted 35 lines
Quoted 35 lines

---
 drivers/vhost/vhost.c  |    2 +-
 drivers/vhost/vringh.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/vhost/vhost.c +1 -1
index 78987e4..568d20f 100644
@@ -1241,7 +1241,7 @@ int vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
 
      /* If their number is silly, that's an error. */
      if (unlikely(head >= vq->num)) {
-             vq_err(vq, "Guest says index %u > %u is available",
+             vq_err(vq, "Guest says index %u > %u is unavailable",
                     head, vq->num);
              return -EINVAL;
      }
drivers/vhost/vringh.c +1 -2
index 5174eba..86ef6c4 100644
@@ -57,7 +57,7 @@ static inline int __vringh_get_head(const struct vringh *vrh,
      }
 
      if (head >= vrh->vring.num) {
-             vringh_bad("Guest says index %u > %u is available",
+             vringh_bad("Guest says index %u > %u is unavailable",
                         head, vrh->vring.num);
              return -EINVAL;
      }
--

1.7.6.5

Signature · 3 lines
Regards,

Zhi Yong Wu
maintainer Acked-by on v1 1/3
#6 lore raw
In reply to Zhi Yong Wu
Quoted 6 lines · Zhi Yong Wu

From: Zhi Yong Wu <[email protected]>

Since vhost_dev_init() forever return 0, some branches are never run, therefore need to be removed.

Quoted 59 lines
---
 drivers/vhost/net.c  |    5 -----
 drivers/vhost/scsi.c |    5 -----
 drivers/vhost/test.c |    5 -----
 3 files changed, 0 insertions(+), 15 deletions(-)
drivers/vhost/net.c +0 -5
index 831eb4f..0554785 100644
@@ -707,11 +707,6 @@ static int vhost_net_open(struct inode *inode, struct file *f)
 		n->vqs[i].sock_hlen = 0;
 	}
 	r = vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX);
-	if (r < 0) {
-		kfree(n);
-		kfree(vqs);
-		return r;
-	}
 
 	vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, POLLOUT, dev);
 	vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, POLLIN, dev);
drivers/vhost/scsi.c +0 -5
index e663921..9d5e18d 100644
@@ -1421,14 +1421,9 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
 
 	tcm_vhost_init_inflight(vs, NULL);
 
-	if (r < 0)
-		goto err_init;
-
 	f->private_data = vs;
 	return 0;
 
-err_init:
-	kfree(vqs);
 err_vqs:
 	vhost_scsi_free(vs);
 err_vs:
drivers/vhost/test.c +0 -5
index 339eae8..99cb960 100644
@@ -118,11 +118,6 @@ static int vhost_test_open(struct inode *inode, struct file *f)
 	vqs[VHOST_TEST_VQ] = &n->vqs[VHOST_TEST_VQ];
 	n->vqs[VHOST_TEST_VQ].handle_kick = handle_vq_kick;
 	r = vhost_dev_init(dev, vqs, VHOST_TEST_VQ_MAX);
-	if (r < 0) {
-		kfree(vqs);
-		kfree(n);
-		return r;
-	}
 
 	f->private_data = n;
 
Signature · 1 line
1.7.6.5