WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH] xenbus: avoid zero returns from read()

To: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Subject: [Xen-devel] Re: [PATCH] xenbus: avoid zero returns from read()
From: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Date: Thu, 09 Sep 2010 10:40:58 -0400
Cc: "Jun Zhu \(Intern\)" <Jun.Zhu@xxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 09 Sep 2010 07:42:52 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB62@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: National Security Agency
References: <4C8809E2.9010502@xxxxxxxxxxxxx> <433DDF91DFB08148BAD3FDB6FDDA314C9F35F3BB62@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Thunderbird/3.1.2
On 09/09/2010 05:27 AM, Jun Zhu (Intern) wrote:
> Is it related to the following patch? The following patch fixes the problem 
> of queue deletion.

Yes, this would have caused a zero return due to an empty item being left
in the queue. It's likely my patch is not needed with this one applied; we
are already careful to avoid adding zero-length elements to the queue,
which was my original idea for the cause.

> diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c
> index 64b3be4..763e90d 100644
> --- a/drivers/xen/xenfs/xenbus.c
> +++ b/drivers/xen/xenfs/xenbus.c
> @@ -143,7 +143,7 @@ static ssize_t xenbus_file_read(struct file *filp,
>                 i += sz - ret;
>                 rb->cons += sz - ret;
>  
> -               if (ret != sz) {
> +               if (ret != 0) {
>                         if (i == 0)
>                                 i = -EFAULT;
>                         goto out;
> 
> Jun Zhu
> Citrix Systems UK
> ________________________________________
> From: Daniel De Graaf [dgdegra@xxxxxxxxxxxxx]
> Sent: 08 September 2010 18:10
> To: Jeremy Fitzhardinge
> Cc: xen-devel; Jun Zhu (Intern)
> Subject: [PATCH] xenbus: avoid zero returns from read()
> 
> It is possible to get a zero return from read() in instances where the
> queue is not empty but has no elements with data to deliver to the user.
> Since a zero return from read is an error indicator, resume waiting or
> return -EAGAIN (for a nonblocking fd) in this case.
> 
> Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
> 
> ---
> diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c
> index 88c87c9..0ddef43 100644
> --- a/drivers/xen/xenfs/xenbus.c
> +++ b/drivers/xen/xenfs/xenbus.c
> @@ -121,6 +121,7 @@ static ssize_t xenbus_file_read(struct file *filp,
>         int ret;
> 
>         mutex_lock(&u->reply_mutex);
> +again:
>         while (list_empty(&u->read_buffers)) {
>                 mutex_unlock(&u->reply_mutex);
>                 if (filp->f_flags & O_NONBLOCK)
> @@ -159,6 +160,8 @@ static ssize_t xenbus_file_read(struct file *filp,
>                                         struct read_buffer, list);
>                 }
>         }
> +       if (i == 0)
> +               goto again;
> 
>  out:
>         mutex_unlock(&u->reply_mutex);


-- 
Daniel De Graaf
National Security Agency

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>