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

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


  • To: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>, Jeremy Fitzhardinge <jeremy@xxxxxxxx>
  • From: "Jun Zhu (Intern)" <Jun.Zhu@xxxxxxxxxx>
  • Date: Thu, 9 Sep 2010 10:27:41 +0100
  • Accept-language: en-US
  • Acceptlanguage: en-US
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 09 Sep 2010 02:30:44 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: ActPoquAiwgufpL3Q3Cwu4uSGS2yBQAXpRIu
  • Thread-topic: [PATCH] xenbus: avoid zero returns from read()

Is it related to the following patch? The following patch fixes the problem of 
queue deletion.

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);

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.