Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d45004f9 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull vhost updates from Michael Tsirkin:
 "vhost: minor changes on top of 3.12-rc1

  This fixes module loading for vhost-scsi, and tweaks locking in vhost
  core a bit.  Both of these are not exactly release blockers but it's
  early in the cycle so I think it's a good idea to apply them now"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
  vhost-scsi: whitespace tweak
  vhost/scsi: use vmalloc for order-10 allocation
  vhost: wake up worker outside spin_lock
parents 509bf24d d3d665a6
Loading
Loading
Loading
Loading
+28 −15
Original line number Diff line number Diff line
@@ -1373,21 +1373,30 @@ static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features)
	return 0;
}

static void vhost_scsi_free(struct vhost_scsi *vs)
{
	if (is_vmalloc_addr(vs))
		vfree(vs);
	else
		kfree(vs);
}

static int vhost_scsi_open(struct inode *inode, struct file *f)
{
	struct vhost_scsi *vs;
	struct vhost_virtqueue **vqs;
	int r, i;
	int r = -ENOMEM, i;

	vs = kzalloc(sizeof(*vs), GFP_KERNEL);
	vs = kzalloc(sizeof(*vs), GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
	if (!vs) {
		vs = vzalloc(sizeof(*vs));
		if (!vs)
		return -ENOMEM;
			goto err_vs;
	}

	vqs = kmalloc(VHOST_SCSI_MAX_VQ * sizeof(*vqs), GFP_KERNEL);
	if (!vqs) {
		kfree(vs);
		return -ENOMEM;
	}
	if (!vqs)
		goto err_vqs;

	vhost_work_init(&vs->vs_completion_work, vhost_scsi_complete_cmd_work);
	vhost_work_init(&vs->vs_event_work, tcm_vhost_evt_work);
@@ -1407,14 +1416,18 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)

	tcm_vhost_init_inflight(vs, NULL);

	if (r < 0) {
		kfree(vqs);
		kfree(vs);
		return r;
	}
	if (r < 0)
		goto err_init;

	f->private_data = vs;
	return 0;

err_init:
	kfree(vqs);
err_vqs:
	vhost_scsi_free(vs);
err_vs:
	return r;
}

static int vhost_scsi_release(struct inode *inode, struct file *f)
@@ -1431,7 +1444,7 @@ static int vhost_scsi_release(struct inode *inode, struct file *f)
	/* Jobs can re-queue themselves in evt kick handler. Do extra flush. */
	vhost_scsi_flush(vs);
	kfree(vs->dev.vqs);
	kfree(vs);
	vhost_scsi_free(vs);
	return 0;
}

+3 −1
Original line number Diff line number Diff line
@@ -161,10 +161,12 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
	if (list_empty(&work->node)) {
		list_add_tail(&work->node, &dev->work_list);
		work->queue_seq++;
		spin_unlock_irqrestore(&dev->work_lock, flags);
		wake_up_process(dev->worker);
	}
	} else {
		spin_unlock_irqrestore(&dev->work_lock, flags);
	}
}
EXPORT_SYMBOL_GPL(vhost_work_queue);

void vhost_poll_queue(struct vhost_poll *poll)