From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933000AbcITMbl (ORCPT ); Tue, 20 Sep 2016 08:31:41 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:33339 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932736AbcITMbg (ORCPT ); Tue, 20 Sep 2016 08:31:36 -0400 Message-ID: <1474374684.31504.21.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 035/192] [PATCH 036/135] tools: hv: report ENOSPC errors in hv_fcopy_daemon From: Ben Hutchings To: Olaf Hering , "K. Y. Srinivasan" Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Sasha Levin , Greg Kroah-Hartman Date: Tue, 20 Sep 2016 13:31:24 +0100 In-Reply-To: <20160912152200.389304148@linuxfoundation.org> References: <20160912152158.855601725@linuxfoundation.org> <20160912152200.389304148@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2016-09-12 at 18:59 +0200, Greg Kroah-Hartman wrote: > 4.4-stable review patch. If anyone has any objections, please let me know. > > ------------------ > > [ Upstream commit b4ed5d1682c6613988c2eb1de55df5ac9988afcc ] > > Currently some "Unspecified error 0x80004005" is reported on the Windows > side if something fails. Handle the ENOSPC case and return > ERROR_DISK_FULL, which allows at least Copy-VMFile to report a meaning > full error. [...] > @@ -98,14 +100,26 @@ done: > static int hv_copy_data(struct hv_do_fcopy *cpmsg) > { > ssize_t bytes_written; > + int ret = 0; > > bytes_written = pwrite(target_fd, cpmsg->data, cpmsg->size, > cpmsg->offset); > > - if (bytes_written != cpmsg->size) > - return HV_E_FAIL; > + filesize += cpmsg->size; > + if (bytes_written != cpmsg->size) { > + switch (errno) { [...] If pwrite() returns a non-negative value less than the requested size, errno is undefined. You need to keep trying to write the remaining bytes until it returns -1. Ben. -- Ben Hutchings Software Developer, Codethink Ltd.