Re: [PATCH v7 2/3] tcm_vhost: Add helper to check if endpoint is setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 18, 2013 at 09:05:53AM +0800, Asias He wrote:
> Signed-off-by: Asias He <asias@xxxxxxxxxx>
> ---
>  drivers/vhost/tcm_vhost.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> index 88ebb79..8f05528 100644
> --- a/drivers/vhost/tcm_vhost.c
> +++ b/drivers/vhost/tcm_vhost.c
> @@ -111,6 +111,24 @@ static bool tcm_vhost_check_feature(struct vhost_scsi *vs, int feature)
>  	return ret;
>  }
>  
> +static bool tcm_vhost_check_endpoint(struct vhost_virtqueue *vq)
> +{
> +	bool ret = false;
> +
> +	/*
> +	* We can handle the vq only after the endpoint is setup by calling the
> +	* VHOST_SCSI_SET_ENDPOINT ioctl.
> +	*
> +	* TODO: Check that we are running from vhost_worker which acts
> +	* as read-side critical section for vhost kind of RCU.
> +	* See the comments in struct vhost_virtqueue in drivers/vhost/vhost.h
> +	*/
> +	if (rcu_dereference_check(vq->private_data, 1))
> +		ret = true;
> +
> +	return ret;
> +}
> +

You can't use RCU in this way. You need to actually
derefence. Instead, just move this within vq mutex
and do rcu_dereference_protected. document that this function
requires vq mutex.

>  static int tcm_vhost_check_true(struct se_portal_group *se_tpg)
>  {
>  	return 1;
> -- 
> 1.8.1.4
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux