xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] oxenstored: fix short-write issue
@ 2015-10-27 17:10 Wei Liu
  2015-10-27 17:21 ` Samuel Thibault
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Wei Liu @ 2015-10-27 17:10 UTC (permalink / raw)
  To: Xen-devel
  Cc: Ian Jackson, Samuel Thibault, Wei Liu, Ian Campbell, David Scott

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@ens-lyon.org>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: David Scott <dave@recoil.org>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>

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
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-11-02 14:27 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 17:10 [PATCH] oxenstored: fix short-write issue Wei Liu
2015-10-27 17:21 ` Samuel Thibault
2015-10-27 17:21 ` Andrew Cooper
2015-10-27 17:26   ` Samuel Thibault
2015-10-27 17:28   ` Samuel Thibault
2015-10-27 17:31     ` Samuel Thibault
2015-10-27 17:31     ` Andrew Cooper
2015-10-28 13:34       ` David Scott
2015-10-28 13:47         ` Samuel Thibault
2015-10-28 14:00         ` Andrew Cooper
2015-10-28 14:04 ` David Vrabel
2015-11-02 13:44 ` Ian Campbell
2015-11-02 14:10   ` Andrew Cooper
2015-11-02 14:24     ` Ian Campbell
2015-11-02 14:27       ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).