Skip to content

Commit

Permalink
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/mst/vhost

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
  • Loading branch information
Linus Torvalds committed Sep 20, 2013
2 parents 509bf24 + d3d665a commit d45004f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
43 changes: 28 additions & 15 deletions drivers/vhost/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ static void tcm_vhost_release_cmd(struct se_cmd *se_cmd)
u32 i;
for (i = 0; i < tv_cmd->tvc_sgl_count; i++)
put_page(sg_page(&tv_cmd->tvc_sgl[i]));
}
}

tcm_vhost_put_inflight(tv_cmd->inflight);
percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
Expand Down Expand Up @@ -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);
if (!vs)
return -ENOMEM;
vs = kzalloc(sizeof(*vs), GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
if (!vs) {
vs = vzalloc(sizeof(*vs));
if (!vs)
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);
Expand All @@ -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)
Expand All @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion drivers/vhost/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ 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);
}
spin_unlock_irqrestore(&dev->work_lock, flags);
}
EXPORT_SYMBOL_GPL(vhost_work_queue);

Expand Down

0 comments on commit d45004f

Please sign in to comment.