]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
HGFS: Server packet abstraction part IX
authorVMware, Inc <>
Wed, 18 Sep 2013 03:24:08 +0000 (20:24 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:06:58 +0000 (22:06 -0700)
Adding in the new fields to indicate the size of the valid data, not the
size of the buffer. Previously, the two were combined which meant that
the buffer size was ultimately used instead making the data copies very
inefficient.

Another  transitional change to get this stuff moved over to handle the
total pack size and valid data sizes separately. Currently, VMCI has to
use the total packet sizes only and so maps in 16 pages and copies all
the data back and forth because it can't tell how much is actually
valid.  When I switch the VMCI transport header to support V2 it will
have the correct data size and packet ID - asynchronous will then work
too.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/hgfsServer/hgfsServer.c
open-vm-tools/lib/hgfsServer/hgfsServerPacketUtil.c
open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c
open-vm-tools/lib/include/hgfsServer.h

index b8bb1539c6cdf50496273a7474d4b594792582b0..fa0fdb5ad83052d2025ef91e204f629cd6656495 100644 (file)
@@ -8399,6 +8399,7 @@ HgfsServerDirWatchEvent(HgfsSharedFolderHandle sharedFolder, // IN: shared folde
    packet = Util_SafeCalloc(1, sizeof *packet);
    packet->state &= ~HGFS_STATE_CLIENT_REQUEST;
    packet->metaPacketSize = sizeNeeded;
+   packet->metaPacketDataSize = packet->metaPacketSize;
    packet->metaPacket = packetHeader;
    packet->dataPacketIsAllocated = TRUE;
    notifyFlags = 0;
index 7a3ad2e199086ddbdf6e4af862b9fc6b56219498..73b015f7469fe2a19d73b8c21a5af035c48a5b9e 100644 (file)
@@ -107,12 +107,21 @@ HSPU_GetReplyPacket(HgfsPacket *packet,                  // IN/OUT: Hgfs Packet
      /* Can we write directly into guest memory? */
       ASSERT_DEVEL(packet->metaPacket != NULL);
       if (packet->metaPacket != NULL) {
-         /* Use the pre-allocated metapacket buffer for the reply. */
+         /*
+          * Use the mapped metapacket buffer for the reply.
+          * This currently makes assumptions about the mapping -
+          * - It is mapped read -write
+          * - It is always large enough for any reply
+          * This will change as it is grossly inefficient as the maximum size
+          * is always mapped and copied no matter how much data it really contains.
+          */
          LOG(10, ("%s Using meta packet for reply packet\n", __FUNCTION__));
+         ASSERT_DEVEL(*replyPacketSize <= packet->metaPacketDataSize);
+         ASSERT_DEVEL(BUF_READWRITEABLE == packet->metaMappingType);
          ASSERT_DEVEL(*replyPacketSize <= packet->metaPacketSize);
 
          packet->replyPacket = packet->metaPacket;
-         packet->replyPacketSize = packet->metaPacketSize;
+         packet->replyPacketSize = packet->metaPacketDataSize;
          packet->replyPacketIsAllocated = FALSE;
       }
    } else {
@@ -183,7 +192,7 @@ HSPU_GetMetaPacket(HgfsPacket *packet,                   // IN/OUT: Hgfs Packet
                    size_t *metaPacketSize,               // OUT: Size of metaPacket
                    HgfsServerChannelCallbacks *chanCb)   // IN: Channel callbacks
 {
-   *metaPacketSize = packet->metaPacketSize;
+   *metaPacketSize = packet->metaPacketDataSize;
    if (packet->metaPacket != NULL) {
       return packet->metaPacket;
    }
@@ -199,7 +208,7 @@ HSPU_GetMetaPacket(HgfsPacket *packet,                   // IN/OUT: Hgfs Packet
                      packet->iov,
                      packet->iovCount,
                      0,
-                     packet->metaPacketSize,
+                     packet->metaPacketDataSize,
                      &packet->metaPacket,
                      &packet->metaPacketIsAllocated,
                      &packet->metaPacketMappedIov);
@@ -373,7 +382,7 @@ HSPU_PutMetaPacket(HgfsPacket *packet,                   // IN/OUT: Hgfs Packet
               packet->iov,
               packet->iovCount,
               0,
-              packet->metaPacketSize,
+              packet->metaPacketDataSize,
               &packet->metaPacket,
               &packet->metaPacketIsAllocated,
               &packet->metaPacketMappedIov);
index fd3d0445eeb774994548bd23f033236afd9e01f4..d7ff8cd4557eda0b06da8b11470b4f76fe7e99ff 100644 (file)
@@ -485,6 +485,7 @@ HgfsChannelGuestReceiveInternal(HgfsGuestConn *connData,  // IN: connection
    packet.iov[0].len = packetInSize;
    packet.iovCount = 1;
    packet.metaPacket = (void *)packetIn;
+   packet.metaPacketDataSize = packetInSize;
    packet.metaPacketSize = packetInSize;
    packet.replyPacket = packetOut;
    packet.replyPacketSize = *packetOutSize;
index 180f6e0511e87d1de08ae492251c52c3b65db9dd..818623bdda1fe98a8099c73d97c179fc9e8541c0 100644 (file)
@@ -60,12 +60,14 @@ typedef struct HgfsPacket {
    void *metaPacket;
    size_t metaPacketSize;
    uint32 metaPacketMappedIov;
+   size_t metaPacketDataSize;
    Bool metaPacketIsAllocated;
    MappingType metaMappingType;
 
    void *dataPacket;
    size_t dataPacketSize;
    uint32 dataPacketMappedIov;
+   size_t dataPacketDataSize;
    uint32 dataPacketIovIndex;
    Bool dataPacketIsAllocated;
    /* What type of mapping was established - readable/ writeable ? */