lkml.org 
[lkml]   [2023]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 6/8] vhost-scsi: Add callback to stop and wait on works
    Date
    This moves the scsi code we use to stop new works from being queued
    and wait on running works to a helper which is used by the vhost layer
    when the vhost_task is being killed by a SIGKILL.

    Signed-off-by: Mike Christie <michael.christie@oracle.com>
    ---
    drivers/vhost/scsi.c | 23 +++++++++++++++--------
    1 file changed, 15 insertions(+), 8 deletions(-)

    diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
    index 40f9135e1a62..a0f2588270f2 100644
    --- a/drivers/vhost/scsi.c
    +++ b/drivers/vhost/scsi.c
    @@ -1768,6 +1768,19 @@ static int vhost_scsi_set_features(struct vhost_scsi *vs, u64 features)
    return 0;
    }

    +static void vhost_scsi_stop_dev_work(struct vhost_dev *dev)
    +{
    + struct vhost_scsi *vs = container_of(dev, struct vhost_scsi, dev);
    + struct vhost_scsi_target t;
    +
    + mutex_lock(&vs->dev.mutex);
    + memcpy(t.vhost_wwpn, vs->vs_vhost_wwpn, sizeof(t.vhost_wwpn));
    + mutex_unlock(&vs->dev.mutex);
    + vhost_scsi_clear_endpoint(vs, &t);
    + vhost_dev_stop(&vs->dev);
    + vhost_dev_cleanup(&vs->dev);
    +}
    +
    static int vhost_scsi_open(struct inode *inode, struct file *f)
    {
    struct vhost_scsi *vs;
    @@ -1821,7 +1834,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
    vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
    }
    vhost_dev_init(&vs->dev, vqs, nvqs, UIO_MAXIOV, VHOST_SCSI_WEIGHT, 0,
    - true, NULL, NULL);
    + true, NULL, vhost_scsi_stop_dev_work);

    vhost_scsi_init_inflight(vs, NULL);

    @@ -1843,14 +1856,8 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
    static int vhost_scsi_release(struct inode *inode, struct file *f)
    {
    struct vhost_scsi *vs = f->private_data;
    - struct vhost_scsi_target t;

    - mutex_lock(&vs->dev.mutex);
    - memcpy(t.vhost_wwpn, vs->vs_vhost_wwpn, sizeof(t.vhost_wwpn));
    - mutex_unlock(&vs->dev.mutex);
    - vhost_scsi_clear_endpoint(vs, &t);
    - vhost_dev_stop(&vs->dev);
    - vhost_dev_cleanup(&vs->dev);
    + vhost_dev_stop_work(&vs->dev);
    kfree(vs->dev.vqs);
    kfree(vs->vqs);
    kfree(vs->old_inflight);
    --
    2.25.1
    \
     
     \ /
      Last update: 2023-05-18 02:11    [W:4.314 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site