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

[Xen-devel] [PATCH] oxenstored: fix short-write issue

When oxenstored wrote to the ring, it wrote a chunk of contiguous data.
Originally when it tried to write across ring boundary, it returned a
short-write when there is still room.  That led to stalling mini-os's
xenstore thread at times.

Fix this by calling write function for a second time when the first
write completes partially.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Cc: David Scott <dave@xxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

Ian, backport candidate for as far as you can manage.
 tools/ocaml/libs/xb/xb.ml | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/ocaml/libs/xb/xb.ml b/tools/ocaml/libs/xb/xb.ml
index 50944b5..0730d13 100644
--- a/tools/ocaml/libs/xb/xb.ml
+++ b/tools/ocaml/libs/xb/xb.ml
@@ -91,10 +91,12 @@ let write_fd back con s len =
        Unix.write back.fd s 0 len
 let write_mmap back con s len =
-       let ws = Xs_ring.write back.mmap s len in
-       if ws > 0 then
+       let ws = ref (Xs_ring.write back.mmap s len) in
+       if !ws < len then
+               ws := !ws + Xs_ring.write back.mmap (String.sub s !ws (len - 
!ws)) (len - !ws);
+       if !ws > 0 then
                back.eventchn_notify ();
-       ws
+       !ws
 let write con s len =
        match con.backend with

Xen-devel mailing list



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