From: Oliver Kurth Date: Thu, 29 Aug 2019 22:47:06 +0000 (-0700) Subject: Supporting HGFS large IO/packet size X-Git-Tag: stable-11.1.0~248 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2fbd0bf7ecbb68e1f74c42d271258affd644e24;p=thirdparty%2Fopen-vm-tools.git Supporting HGFS large IO/packet size Tools side changes to take advantage of a negotiated larger HGFS IO buffer when available in the Fusion or Workstation host. --- diff --git a/open-vm-tools/vmhgfs-fuse/file.c b/open-vm-tools/vmhgfs-fuse/file.c index 2ca2d95d2..d6895e3d0 100644 --- a/open-vm-tools/vmhgfs-fuse/file.c +++ b/open-vm-tools/vmhgfs-fuse/file.c @@ -659,6 +659,34 @@ out: } +/* + *---------------------------------------------------------------------- + * + * HgfsMaxIOSize -- + * + * Get the maximum IO size based on the agreed maximum packet size. + * + * Results: + * The maximum IO size. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +static uint32 +HgfsMaxIOSize(void) +{ + uint32 maxIOSize = gState->maxPacketSize - HGFS_HEADER_SIZE_MAX; + + if (maxIOSize > 0 && maxIOSize < HgfsLargeIoMax(FALSE)) { + return maxIOSize; + } + return HgfsLargeIoMax(FALSE); +} + + /* *---------------------------------------------------------------------- * @@ -686,6 +714,7 @@ HgfsRead(struct fuse_file_info *fi, // IN: File info struct char *buffer = buf; loff_t curOffset = offset; size_t nextCount, remainingCount = count; + uint32 maxIOSize = HgfsMaxIOSize(); ASSERT(NULL != fi); ASSERT(NULL != buf); @@ -694,8 +723,7 @@ HgfsRead(struct fuse_file_info *fi, // IN: File info struct fi->fh, count, offset)); do { - nextCount = (remainingCount > HgfsLargeIoMax(FALSE)) ? - HgfsLargeIoMax(FALSE) : remainingCount; + nextCount = (remainingCount > maxIOSize) ? maxIOSize : remainingCount; LOG(4, ("Issue DoRead(0x%"FMT64"x 0x%"FMTSZ"x bytes @ 0x%"FMT64"x)\n", fi->fh, nextCount, curOffset)); result = HgfsDoRead(fi->fh, buffer, nextCount, curOffset); @@ -872,6 +900,7 @@ HgfsWrite(struct fuse_file_info *fi, // IN: File info structure loff_t curOffset = offset; size_t nextCount, remainingCount = count; ssize_t bytesWritten = 0; + uint32 maxIOSize = HgfsMaxIOSize(); ASSERT(NULL != buf); ASSERT(NULL != fi); @@ -880,9 +909,7 @@ HgfsWrite(struct fuse_file_info *fi, // IN: File info structure fi->fh, count, offset)); do { - nextCount = (remainingCount > HgfsLargeIoMax(FALSE)) ? - HgfsLargeIoMax(FALSE) : remainingCount; - + nextCount = (remainingCount > maxIOSize) ? maxIOSize : remainingCount; LOG(4, ("Issue DoWrite(0x%"FMT64"x 0x%"FMTSZ"x bytes @ 0x%"FMT64"x)\n", fi->fh, nextCount, curOffset)); diff --git a/open-vm-tools/vmhgfs-fuse/filesystem.h b/open-vm-tools/vmhgfs-fuse/filesystem.h index 48af9376d..1575c76d3 100644 --- a/open-vm-tools/vmhgfs-fuse/filesystem.h +++ b/open-vm-tools/vmhgfs-fuse/filesystem.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013 VMware, Inc. All rights reserved. + * Copyright (C) 2013,2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -37,6 +37,7 @@ typedef struct HgfsFuseState { Bool sessionEnabled; uint64 sessionId; uint8 headerVersion; + uint32 maxPacketSize; /* * When mount a subdirectory of hgfs shared directory, basePath holds * the prefix to the root. e.g. 'mount.vmhgfs .host:/shared/sub /hgfs', diff --git a/open-vm-tools/vmhgfs-fuse/session.c b/open-vm-tools/vmhgfs-fuse/session.c index e4c156574..181423971 100644 --- a/open-vm-tools/vmhgfs-fuse/session.c +++ b/open-vm-tools/vmhgfs-fuse/session.c @@ -96,6 +96,7 @@ HgfsCreateSessionProcessResult(const char *result, // IN: Reply packet uint64 sessionId = HGFS_INVALID_SESSION_ID; uint8 headerVersion = HGFS_HEADER_VERSION_1; Bool sessionIdPresent = FALSE; + uint32 maxPacketSize = HgfsLargePacketMax(TRUE); uint32 information; HgfsHandle requestId; @@ -145,12 +146,14 @@ HgfsCreateSessionProcessResult(const char *result, // IN: Reply packet */ sessionId = createSessionReply->sessionId; sessionIdPresent = TRUE; + maxPacketSize = createSessionReply->maxPacketSize; } out: gState->sessionId = sessionId; gState->headerVersion = headerVersion; gState->sessionEnabled = sessionIdPresent; + gState->maxPacketSize = maxPacketSize; LOG(4, ("Exit(%d)\n", status)); return status; @@ -336,6 +339,7 @@ HgfsDestroySessionProcessResult(const char *result, // IN: Reply packet out: gState->sessionId = HGFS_INVALID_SESSION_ID; gState->sessionEnabled = FALSE; + gState->maxPacketSize = HgfsLargePacketMax(TRUE); LOG(4, ("Exit(%d)\n", status)); return status; diff --git a/open-vm-tools/vmhgfs-fuse/vmhgfs_version.h b/open-vm-tools/vmhgfs-fuse/vmhgfs_version.h index dc4961bf0..4e2111843 100644 --- a/open-vm-tools/vmhgfs-fuse/vmhgfs_version.h +++ b/open-vm-tools/vmhgfs-fuse/vmhgfs_version.h @@ -25,8 +25,8 @@ #ifndef _VMHGFS_VERSION_H_ #define _VMHGFS_VERSION_H_ -#define VMHGFS_DRIVER_VERSION 1.6.11.0 -#define VMHGFS_DRIVER_VERSION_COMMAS 1,6,11,0 -#define VMHGFS_DRIVER_VERSION_STRING "1.6.11.0" +#define VMHGFS_DRIVER_VERSION 1.6.12.0 +#define VMHGFS_DRIVER_VERSION_COMMAS 1,6,12,0 +#define VMHGFS_DRIVER_VERSION_STRING "1.6.12.0" #endif /* _VMHGFS_VERSION_H_ */