From 6497dbbabb9506df8e16b60bf2cd396a8c6bb26b Mon Sep 17 00:00:00 2001
From: "Scott M. Kroll" <skroll@gmail.com>
Date: Fri, 15 Aug 2014 10:42:30 -0400
Subject: [PATCH 11/11] Fix vmhgfs module on kernels >= 3.16

* Use read_iter/write_iter file operations on kernels >= 3.16.
* Do not set aio_read/aio_write on kernels >= 3.16.
---
 open-vm-tools/modules/linux/vmhgfs/file.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/modules/linux/vmhgfs/file.c b/modules/linux/vmhgfs/file.c
index 825cebe..67606fd 100644
--- a/modules/linux/vmhgfs/file.c
+++ b/modules/linux/vmhgfs/file.c
@@ -76,6 +76,7 @@ static int HgfsGetOpenFlags(uint32 flags);
 static int HgfsOpen(struct inode *inode,
                     struct file *file);
 #if defined VMW_USE_AIO
+#  if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
 static ssize_t HgfsAioRead(struct kiocb *iocb,
                            const struct iovec *iov,
                            unsigned long numSegs,
@@ -84,6 +85,7 @@ static ssize_t HgfsAioWrite(struct kiocb *iocb,
                             const struct iovec *iov,
                             unsigned long numSegs,
                             loff_t offset);
+#  endif
 #else
 static ssize_t HgfsRead(struct file *file,
                         char __user *buf,
@@ -150,15 +152,20 @@ struct file_operations HgfsFileFileOperations = {
    .open       = HgfsOpen,
    .llseek     = HgfsSeek,
    .flush      = HgfsFlush,
-#if defined VMW_USE_AIO
+#ifdef VMW_USE_AIO
    .read       = do_sync_read,
    .write      = do_sync_write,
+#   if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
+   .read_iter = generic_file_read_iter,
+   .write_iter = generic_file_write_iter,
+#   else
    .aio_read   = HgfsAioRead,
    .aio_write  = HgfsAioWrite,
-#else
+#   endif
+#else /* !VMW_USE_AIO */
    .read       = HgfsRead,
    .write      = HgfsWrite,
-#endif
+#endif /* !VMW_USE_AIO */
    .fsync      = HgfsFsync,
    .mmap       = HgfsMmap,
    .release    = HgfsRelease,
@@ -748,6 +755,7 @@ out:
 
 
 #if defined VMW_USE_AIO
+#  if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
 /*
  *----------------------------------------------------------------------
  *
@@ -883,7 +891,7 @@ out:
    return result;
 }
 
-
+#   endif /* if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) */
 #else
 /*
  *----------------------------------------------------------------------
-- 
2.0.4

