From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: [PATCH] oxenstored: fix short-write issue Date: Tue, 27 Oct 2015 17:10:09 +0000 Message-ID: <1445965809-5144-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zr7lV-0002eA-QZ for xen-devel@lists.xenproject.org; Tue, 27 Oct 2015 17:10:29 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Ian Jackson , Samuel Thibault , Wei Liu , Ian Campbell , David Scott List-Id: xen-devel@lists.xenproject.org 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 Signed-off-by: Wei Liu --- Cc: David Scott Cc: Ian Campbell Cc: Ian Jackson 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