]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Supporting HGFS large IO/packet size
authorOliver Kurth <okurth@vmware.com>
Thu, 29 Aug 2019 22:47:06 +0000 (15:47 -0700)
committerOliver Kurth <okurth@vmware.com>
Thu, 29 Aug 2019 22:47:06 +0000 (15:47 -0700)
Tools side changes to take advantage of a negotiated larger HGFS IO
buffer when available in the Fusion or Workstation host.

open-vm-tools/vmhgfs-fuse/file.c
open-vm-tools/vmhgfs-fuse/filesystem.h
open-vm-tools/vmhgfs-fuse/session.c
open-vm-tools/vmhgfs-fuse/vmhgfs_version.h

index 2ca2d95d21ab8008ec209275371347f86eb72013..d6895e3d01af53bb89e5e8f773948ae2b3f7aca5 100644 (file)
@@ -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));
 
index 48af9376dda240e6fd45d1bc0a9cfd5dd740b8b1..1575c76d3033303007ab917053acb3eddd496181 100644 (file)
@@ -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',
index e4c156574ce1064c7079142b29aedc186f97108c..181423971b5b877ef65c312fa578b5e6e40eb178 100644 (file)
@@ -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;
index dc4961bf069afd33526d374def3746063c5d9d6d..4e21118433ce4e5dcbf4e6e572697106eaa8238d 100644 (file)
@@ -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_ */