From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932933AbbLNW3x (ORCPT ); Mon, 14 Dec 2015 17:29:53 -0500 Received: from p3plsmtps2ded04.prod.phx3.secureserver.net ([208.109.80.198]:54463 "EHLO p3plsmtps2ded04.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753659AbbLNW2X (ORCPT ); Mon, 14 Dec 2015 17:28:23 -0500 x-originating-ip: 72.167.245.219 From: "K. Y. Srinivasan" To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com Cc: "K. Y. Srinivasan" Subject: [PATCH RESEND 03/27] tools: hv: report ENOSPC errors in hv_fcopy_daemon Date: Mon, 14 Dec 2015 16:01:34 -0800 Message-Id: <1450137718-26366-3-git-send-email-kys@microsoft.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1450137718-26366-1-git-send-email-kys@microsoft.com> References: <1450137698-26327-1-git-send-email-kys@microsoft.com> <1450137718-26366-1-git-send-email-kys@microsoft.com> X-CMAE-Envelope: MS4wfHH6iDonfJw9CcGhY3YCY901K5anvvFkU9YearuS/IE0eMubsXlfHmmU9udizns57MGvcgZSKk5W5GrMqgv6b/sKsgkodQR/5flotvYN54pkQ2cmJpaM wCVEs3b/0bAIDxjf6K9RII0qylMV44mmcn4VXOOn1BKXkzNoKnNXaZsVCF43PD0LNcnsk/uk4DhZEFWUneou3hdJPtUXiE4WD3AthPtlZSmbu2SVNMPCrA4q uVWt5Y8J8alToW0hMkES/3rHAKeKxozR72BIngFOjnRqJ3c2NIn9XB42iwz86Vdz4Zy63Z1JELEX0WSMU9N6zM5ga8V9RjBKNehNpngrr6W7WUNrH9gTl+Ty sryZqSynT9T+b1x2Vf2Z/EYWvDYoY8KSetrzOvyjXhDBUUpYLG90yO/CMm0nJC0Z7SHd0kgw Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Olaf Hering 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. Signed-off-by: Olaf Hering Signed-off-by: K. Y. Srinivasan --- include/uapi/linux/hyperv.h | 1 + tools/hv/hv_fcopy_daemon.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/hyperv.h b/include/uapi/linux/hyperv.h index e4c0a35..e347b24 100644 --- a/include/uapi/linux/hyperv.h +++ b/include/uapi/linux/hyperv.h @@ -313,6 +313,7 @@ enum hv_kvp_exchg_pool { #define HV_INVALIDARG 0x80070057 #define HV_GUID_NOTFOUND 0x80041002 #define HV_ERROR_ALREADY_EXISTS 0x80070050 +#define HV_ERROR_DISK_FULL 0x80070070 #define ADDR_FAMILY_NONE 0x00 #define ADDR_FAMILY_IPV4 0x01 diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c index 5480e4e..f1d7426 100644 --- a/tools/hv/hv_fcopy_daemon.c +++ b/tools/hv/hv_fcopy_daemon.c @@ -37,12 +37,14 @@ static int target_fd; static char target_fname[W_MAX_PATH]; +static unsigned long long filesize; static int hv_start_fcopy(struct hv_start_fcopy *smsg) { int error = HV_E_FAIL; char *q, *p; + filesize = 0; p = (char *)smsg->path_name; snprintf(target_fname, sizeof(target_fname), "%s/%s", (char *)smsg->path_name, (char *)smsg->file_name); @@ -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) { + case ENOSPC: + ret = HV_ERROR_DISK_FULL; + break; + default: + ret = HV_E_FAIL; + break; + } + syslog(LOG_ERR, "pwrite failed to write %llu bytes: %ld (%s)", + filesize, (long)bytes_written, strerror(errno)); + } - return 0; + return ret; } static int hv_copy_finished(void) -- 1.7.4.1