Skip to content

Commit d45004f

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/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
2 parents 509bf24 + d3d665a commit d45004f

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

drivers/vhost/scsi.c

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static void tcm_vhost_release_cmd(struct se_cmd *se_cmd)
461461
u32 i;
462462
for (i = 0; i < tv_cmd->tvc_sgl_count; i++)
463463
put_page(sg_page(&tv_cmd->tvc_sgl[i]));
464-
}
464+
}
465465

466466
tcm_vhost_put_inflight(tv_cmd->inflight);
467467
percpu_ida_free(&se_sess->sess_tag_pool, se_cmd->map_tag);
@@ -1373,21 +1373,30 @@ static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features)
13731373
return 0;
13741374
}
13751375

1376+
static void vhost_scsi_free(struct vhost_scsi *vs)
1377+
{
1378+
if (is_vmalloc_addr(vs))
1379+
vfree(vs);
1380+
else
1381+
kfree(vs);
1382+
}
1383+
13761384
static int vhost_scsi_open(struct inode *inode, struct file *f)
13771385
{
13781386
struct vhost_scsi *vs;
13791387
struct vhost_virtqueue **vqs;
1380-
int r, i;
1388+
int r = -ENOMEM, i;
13811389

1382-
vs = kzalloc(sizeof(*vs), GFP_KERNEL);
1383-
if (!vs)
1384-
return -ENOMEM;
1390+
vs = kzalloc(sizeof(*vs), GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
1391+
if (!vs) {
1392+
vs = vzalloc(sizeof(*vs));
1393+
if (!vs)
1394+
goto err_vs;
1395+
}
13851396

13861397
vqs = kmalloc(VHOST_SCSI_MAX_VQ * sizeof(*vqs), GFP_KERNEL);
1387-
if (!vqs) {
1388-
kfree(vs);
1389-
return -ENOMEM;
1390-
}
1398+
if (!vqs)
1399+
goto err_vqs;
13911400

13921401
vhost_work_init(&vs->vs_completion_work, vhost_scsi_complete_cmd_work);
13931402
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)
14071416

14081417
tcm_vhost_init_inflight(vs, NULL);
14091418

1410-
if (r < 0) {
1411-
kfree(vqs);
1412-
kfree(vs);
1413-
return r;
1414-
}
1419+
if (r < 0)
1420+
goto err_init;
14151421

14161422
f->private_data = vs;
14171423
return 0;
1424+
1425+
err_init:
1426+
kfree(vqs);
1427+
err_vqs:
1428+
vhost_scsi_free(vs);
1429+
err_vs:
1430+
return r;
14181431
}
14191432

14201433
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)
14311444
/* Jobs can re-queue themselves in evt kick handler. Do extra flush. */
14321445
vhost_scsi_flush(vs);
14331446
kfree(vs->dev.vqs);
1434-
kfree(vs);
1447+
vhost_scsi_free(vs);
14351448
return 0;
14361449
}
14371450

drivers/vhost/vhost.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work)
161161
if (list_empty(&work->node)) {
162162
list_add_tail(&work->node, &dev->work_list);
163163
work->queue_seq++;
164+
spin_unlock_irqrestore(&dev->work_lock, flags);
164165
wake_up_process(dev->worker);
166+
} else {
167+
spin_unlock_irqrestore(&dev->work_lock, flags);
165168
}
166-
spin_unlock_irqrestore(&dev->work_lock, flags);
167169
}
168170
EXPORT_SYMBOL_GPL(vhost_work_queue);
169171

0 commit comments

Comments
 (0)