From: VMware, Inc <> Date: Thu, 15 Oct 2009 21:35:54 +0000 (-0700) Subject: Linux HGFS: remove pre-2.6.9 compatibility code X-Git-Tag: 2009.10.15-201664~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e003bedfdd13684b28734161aeece8387aaed966;p=thirdparty%2Fopen-vm-tools.git Linux HGFS: remove pre-2.6.9 compatibility code Drivers for older kernels come from lindrvlegacy component so let's get rid of unneeded code on main branches. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/modules/linux/shared/autoconf/maxbytes.c b/open-vm-tools/modules/linux/shared/autoconf/maxbytes.c deleted file mode 100644 index 095279c50..000000000 --- a/open-vm-tools/modules/linux/shared/autoconf/maxbytes.c +++ /dev/null @@ -1,38 +0,0 @@ -/********************************************************* - * Copyright (C) 2007 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *********************************************************/ - -#include -#include - -/* - * In 2.4.3, the s_maxbytes field was added to struct super_block. - * However, we can't simply condition on 2.4.3 as the field's starting point - * because the 2.4.2-2 kernel in RH7.1 also contained it, and if we don't set - * it, the generic write path in the page cache will fail. - */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 3) - -#include - -void test(void) -{ - struct super_block sb; - - sb.s_maxbytes = 0; -} -#endif diff --git a/open-vm-tools/modules/linux/shared/compat_wait.h b/open-vm-tools/modules/linux/shared/compat_wait.h index 280d45225..e4a27b16a 100644 --- a/open-vm-tools/modules/linux/shared/compat_wait.h +++ b/open-vm-tools/modules/linux/shared/compat_wait.h @@ -52,7 +52,8 @@ typedef struct wait_queue wait_queue_t; * 2.4.20-wolk4.0s. */ -#ifdef VMW_HAVE_EPOLL // { +#if defined(VMW_HAVE_EPOLL) || \ + LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9) // { #define compat_poll_wqueues struct poll_wqueues #else // } { #define compat_poll_wqueues poll_table diff --git a/open-vm-tools/modules/linux/vmhgfs/Makefile.kernel b/open-vm-tools/modules/linux/vmhgfs/Makefile.kernel index 0897f91fe..1db4c1816 100644 --- a/open-vm-tools/modules/linux/vmhgfs/Makefile.kernel +++ b/open-vm-tools/modules/linux/vmhgfs/Makefile.kernel @@ -25,10 +25,6 @@ INCLUDE += -I. EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) -EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/setnice.c, -DVMW_HAVE_SET_USER_NICE, ) -EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/epoll.c, -DVMW_HAVE_EPOLL, ) -EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/maxbytes.c, -DVMW_SB_HAS_MAXBYTES, ) -EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/cachecreate.c, -DVMW_KMEMCR_HAS_DTOR, ) EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/cachector.c, -DVMW_KMEMCR_CTOR_HAS_3_ARGS, ) EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/cachector1.c, -DVMW_KMEMCR_CTOR_HAS_2_ARGS, ) diff --git a/open-vm-tools/modules/linux/vmhgfs/dentry.c b/open-vm-tools/modules/linux/vmhgfs/dentry.c index 9783b0d90..3b087caba 100644 --- a/open-vm-tools/modules/linux/vmhgfs/dentry.c +++ b/open-vm-tools/modules/linux/vmhgfs/dentry.c @@ -34,13 +34,8 @@ #include "vm_assert.h" /* HGFS dentry operations. */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75) static int HgfsDentryRevalidate(struct dentry *dentry, struct nameidata *nd); -#else -static int HgfsDentryRevalidate(struct dentry *dentry, - int flags); -#endif /* HGFS dentry operations structure. */ struct dentry_operations HgfsDentryOperations = { @@ -73,15 +68,9 @@ struct dentry_operations HgfsDentryOperations = { *---------------------------------------------------------------------- */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75) static int HgfsDentryRevalidate(struct dentry *dentry, // IN: Dentry to revalidate struct nameidata *nd) // IN: Lookup flags & intent -#else -static int -HgfsDentryRevalidate(struct dentry *dentry, // IN: Dentry to revalidate - int flags) // IN: Lookup flags (e.g. LOOKUP_CONTINUE) -#endif { int error; LOG(6, (KERN_DEBUG "VMware hgfs: HgfsDentryRevalidate: calling " diff --git a/open-vm-tools/modules/linux/vmhgfs/filesystem.c b/open-vm-tools/modules/linux/vmhgfs/filesystem.c index 645b57e76..a1ae581f4 100644 --- a/open-vm-tools/modules/linux/vmhgfs/filesystem.c +++ b/open-vm-tools/modules/linux/vmhgfs/filesystem.c @@ -60,14 +60,6 @@ #include "rpcout.h" #include "hgfs.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 25) -#define KERNEL_25_FS 0 -#else -#define KERNEL_25_FS 1 -#endif - -#define HGFS_BD_THREAD_NAME "VMware hgfs backdoor handler" - /* Synchronization primitives. */ spinlock_t hgfsBigLock = SPIN_LOCK_UNLOCKED; @@ -102,29 +94,18 @@ static void HgfsResetOps(void); /* HGFS filesystem high-level operations. */ -#if KERNEL_25_FS /* { */ -# if defined VMW_GETSB_2618 +#if defined VMW_GETSB_2618 static int HgfsGetSb(struct file_system_type *fs_type, int flags, const char *dev_name, void *rawData, struct vfsmount *mnt); -# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 70) +#else static struct super_block *HgfsGetSb(struct file_system_type *fs_type, int flags, const char *dev_name, void *rawData); -# else -static struct super_block *HgfsGetSb(struct file_system_type *fs_type, - int flags, - char *dev_name, - void *rawData); -# endif -#else /* } { */ -static struct super_block *HgfsReadSuper24(struct super_block *sb, - void *rawData, - int flags); -#endif /* } */ +#endif /* HGFS filesystem type structure. */ static struct file_system_type hgfsType = { @@ -132,12 +113,8 @@ static struct file_system_type hgfsType = { .name = HGFS_NAME, .fs_flags = FS_BINARY_MOUNTDATA, -#if KERNEL_25_FS .get_sb = HgfsGetSb, .kill_sb = kill_anon_super, -#else - .read_super = HgfsReadSuper24, -#endif }; @@ -196,7 +173,6 @@ HgfsComputeBlockBits(unsigned long blockSize) static void HgfsInodeCacheCtor(COMPAT_KMEM_CACHE_CTOR_ARGS(slabElem)) // IN: slab item to initialize { -#ifdef VMW_EMBED_INODE HgfsInodeInfo *iinfo = (HgfsInodeInfo *)slabElem; /* @@ -205,7 +181,6 @@ HgfsInodeCacheCtor(COMPAT_KMEM_CACHE_CTOR_ARGS(slabElem)) // IN: slab item to in * much of the VFS inode members. */ inode_init_once(&iinfo->inode); -#endif } @@ -410,9 +385,7 @@ HgfsReadSuper(struct super_block *sb, // OUT: Superblock object * it. Note that we'll initialize it anyway, because the default value is * MAX_NON_LFS, which caps our filesize at 2^32 bytes. */ -#ifdef VMW_SB_HAS_MAXBYTES sb->s_maxbytes = MAX_LFS_FILESIZE; -#endif /* * These two operations will make sure that our block size and the bits @@ -462,7 +435,6 @@ HgfsReadSuper(struct super_block *sb, // OUT: Superblock object * HGFS filesystem high-level operations. */ -#if KERNEL_25_FS #if defined VMW_GETSB_2618 /* *----------------------------------------------------------------------------- @@ -510,51 +482,15 @@ HgfsGetSb(struct file_system_type *fs_type, *----------------------------------------------------------------------------- */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 70) static struct super_block * HgfsGetSb(struct file_system_type *fs_type, int flags, const char *dev_name, void *rawData) -#else -static struct super_block * -HgfsGetSb(struct file_system_type *fs_type, - int flags, - char *dev_name, - void *rawData) -#endif { return get_sb_nodev(fs_type, flags, rawData, HgfsReadSuper); } #endif -#else - - -/* - *----------------------------------------------------------------------------- - * - * HgfsReadSuper24 -- - * - * Compatibility wrapper for 2.4.x kernels read_super. - * Converts success to sb, and failure to NULL. - * - * Results: - * The initialized superblock on success - * NULL on failure - * - * Side effects: - * None - * - *----------------------------------------------------------------------------- - */ - -static struct super_block * -HgfsReadSuper24(struct super_block *sb, - void *rawData, - int flags) { - return HgfsReadSuper(sb, rawData, flags) ? NULL : sb; -} -#endif /* @@ -645,10 +581,6 @@ HgfsInitFileSystem(void) } LOG(4, (KERN_DEBUG "VMware hgfs: Module Loaded\n")); -#ifdef HGFS_ENABLE_WRITEBACK - LOG(4, (KERN_DEBUG "VMware hgfs: writeback cache enabled\n")); -#endif - return TRUE; } diff --git a/open-vm-tools/modules/linux/vmhgfs/fsutil.c b/open-vm-tools/modules/linux/vmhgfs/fsutil.c index 796322c69..e27b968e3 100644 --- a/open-vm-tools/modules/linux/vmhgfs/fsutil.c +++ b/open-vm-tools/modules/linux/vmhgfs/fsutil.c @@ -47,8 +47,6 @@ #include "hgfsProto.h" #include "vm_basic_types.h" -static struct inode *HgfsInodeLookup(struct super_block *sb, - ino_t ino); static void HgfsSetFileType(struct inode *inode, HgfsAttrInfo const *attr); static int HgfsUnpackGetattrReply(HgfsReq *req, @@ -64,90 +62,6 @@ static int HgfsPackGetattrRequest(HgfsReq *req, * Private function implementations. */ -/* - *---------------------------------------------------------------------- - * - * HgfsInodeLookup -- - * - * The equivalent of ilookup() in the Linux kernel. We have an HGFS - * specific implementation in order to hack around the lack of - * ilookup() on older kernels. - * - * Results: - * Pointer to the VFS inode using the current inode number if it - * already exists in the inode cache, NULL otherwise. - * - * Side effects: - * None - * - *---------------------------------------------------------------------- - */ - -static struct inode * -HgfsInodeLookup(struct super_block *sb, // IN: Superblock of this fs - ino_t ino) // IN: Inode number to look up -{ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 42) - return ilookup(sb, ino); -#else - struct inode *inode; - HgfsInodeInfo *iinfo; - - /* - * Note that returning NULL in both of these cases will make the - * caller think that no such inode exists, which is correct. In the first - * case, we failed to allocate an inode inside iget(), meaning the inode - * number didn't already exist in the inode cache. In the second case, the - * inode got marked bad inside read_inode, also indicative of a new inode - * allocation. - */ - inode = HgfsGetInode(sb, ino); - if (inode == NULL) { - LOG(4, (KERN_DEBUG "VMware hgfs: HgfsInodeLookup: iget ran out of " - "memory and returned NULL\n")); - return NULL; - } - if (is_bad_inode(inode)) { - LOG(4, (KERN_DEBUG "VMware hgfs: HgfsInodeLookup: inode marked bad\n")); - goto iput_and_exit; - } - - /* - * Our read_inode function should guarantee that if we're here, iinfo should - * have been allocated already. - */ - iinfo = INODE_GET_II_P(inode); - ASSERT(iinfo); - if (iinfo == NULL) { - LOG(4, (KERN_DEBUG "VMware hgfs: HgfsInodeLookup: found corrupt inode, " - "bailing out\n")); - goto iput_and_exit; - } - - /* - * It's HGFS's job to make sure this is set to TRUE in all inodes on which - * we hold a reference. If it is set to TRUE, we return the inode, just as - * ilookup() does. - * - * XXX: Note that there exists a race here and in HgfsIget (between the time - * that the inode is unlocked and isReferencedInode is set), but I'm hoping - * that it doesn't matter because anyone executing this code can't posibly - * be "CONFIG_PREEMPT=y". - */ - if (iinfo->isReferencedInode) { - goto exit; - } - - iput_and_exit: - iput(inode); - inode = NULL; - - exit: - return inode; -#endif -} - - /* *---------------------------------------------------------------------- * @@ -959,14 +873,14 @@ HgfsIget(struct super_block *sb, // IN: Superblock of this fs * XXX: Is this worth the value? We're mixing server-provided inode * numbers with our own randomly chosen inode numbers. * - * XXX: This logic is also racy. After our call to HgfsInodeLookup(), it's + * XXX: This logic is also racy. After our call to ilookup(), it's * possible another caller came in and grabbed that inode number, which * will cause us to collide in iget() and step on their inode. */ if (attr->mask & HGFS_ATTR_VALID_FILEID) { struct inode *oldInode; - oldInode = HgfsInodeLookup(sb, attr->hostFileId); + oldInode = ilookup(sb, attr->hostFileId); if (oldInode) { /* * If this inode's inode number was generated via iunique(), we @@ -1701,11 +1615,9 @@ HgfsSetUidGid(struct inode *parent, // IN: parent inode * * HgfsGetInode -- * - * This function replaces iget() and should be called instead of it. In newer - * kernels that have removed the iget() interface, GetInode() obtains an inode - * and if it is a new one, then initializes the inode by calling - * HgfsDoReadInode(). In older kernels that support the iget() interface, - * HgfsDoReadInode() is called by iget() internally. + * This function replaces iget() and should be called instead of it. + * HgfsGetInode() obtains an inode and, if it is a new one, initializes + * it calling HgfsDoReadInode(). * * Results: * A new inode object on success, NULL on error. @@ -1720,7 +1632,6 @@ struct inode * HgfsGetInode(struct super_block *sb, // IN: file system superblock object ino_t ino) // IN: inode number to assign to new inode { -#ifdef VMW_USE_IGET_LOCKED struct inode *inode; inode = iget_locked(sb, ino); @@ -1729,9 +1640,6 @@ HgfsGetInode(struct super_block *sb, // IN: file system superblock object unlock_new_inode(inode); } return inode; -#else - return iget(sb, ino); -#endif } @@ -1769,15 +1677,6 @@ HgfsDoReadInode(struct inode *inode) // IN: Inode to initialize * allocation and mark the inode "bad" if the allocation fails. This'll * make all subsequent operations on the inode fail, which is what we want. */ -#ifndef VMW_EMBED_INODE - iinfo = kmem_cache_alloc(hgfsInodeCache, GFP_KERNEL); - if (!iinfo) { - LOG(4, (KERN_DEBUG "VMware hgfs: HgfsDoReadInode: no memory for " - "iinfo!\n")); - make_bad_inode(inode); - return; - } -#endif INODE_SET_II_P(inode, iinfo); INIT_LIST_HEAD(&iinfo->files); iinfo->hostFileId = 0; diff --git a/open-vm-tools/modules/linux/vmhgfs/inode.c b/open-vm-tools/modules/linux/vmhgfs/inode.c index 377f1bacb..8361cbccf 100644 --- a/open-vm-tools/modules/linux/vmhgfs/inode.c +++ b/open-vm-tools/modules/linux/vmhgfs/inode.c @@ -27,8 +27,7 @@ #include #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && \ - LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) #include #endif @@ -51,26 +50,6 @@ #include "fsutil.h" #include "vm_assert.h" -/* - * The inode_operations structure changed in 2.5.18: - * before: - * . 'getattr' was defined but unused - * . 'revalidate' was defined and used - * after: - * 1) 'getattr' changed and became used - * 2) 'revalidate' was removed - * - * Note: Mandrake backported 1) but not 2) starting with 2.4.8-26mdk - * - * --hpreg - */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 18) -# define HGFS_GETATTR_ONLY 1 -#else -# undef HGFS_GETATTR_ONLY -#endif - - /* Private functions. */ static int HgfsDelete(struct inode *dir, struct dentry *dentry, @@ -93,7 +72,6 @@ static int HgfsPackSymlinkCreateRequest(struct dentry *dentry, HgfsReq *req); /* HGFS inode operations. */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75) static int HgfsCreate(struct inode *dir, struct dentry *dentry, int mode, @@ -101,13 +79,6 @@ static int HgfsCreate(struct inode *dir, static struct dentry *HgfsLookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd); -#else -static int HgfsCreate(struct inode *dir, - struct dentry *dentry, - int mode); -static struct dentry *HgfsLookup(struct inode *dir, - struct dentry *dentry); -#endif static int HgfsMkdir(struct inode *dir, struct dentry *dentry, int mode); @@ -122,8 +93,7 @@ static int HgfsRename(struct inode *oldDir, static int HgfsSymlink(struct inode *dir, struct dentry *dentry, const char *symname); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && \ - LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) static int HgfsPermission(struct inode *inode, int mask, struct nameidata *nameidata); @@ -131,11 +101,9 @@ static int HgfsPermission(struct inode *inode, static int HgfsPermission(struct inode *inode, int mask); #endif -#ifdef HGFS_GETATTR_ONLY static int HgfsGetattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); -#endif #define HGFS_CREATE_DIR_MASK (HGFS_CREATE_DIR_VALID_FILE_NAME | \ HGFS_CREATE_DIR_VALID_SPECIAL_PERMS | \ @@ -159,13 +127,8 @@ struct inode_operations HgfsDirInodeOperations = { .permission = HgfsPermission, .setattr = HgfsSetattr, -#ifdef HGFS_GETATTR_ONLY /* Optional */ .getattr = HgfsGetattr, -#else - /* Optional */ - .revalidate = HgfsRevalidate, -#endif }; /* HGFS inode operations structure for files. */ @@ -173,13 +136,8 @@ struct inode_operations HgfsFileInodeOperations = { .permission = HgfsPermission, .setattr = HgfsSetattr, -#ifdef HGFS_GETATTR_ONLY /* Optional */ .getattr = HgfsGetattr, -#else - /* Optional */ - .revalidate = HgfsRevalidate, -#endif }; /* @@ -986,18 +944,11 @@ HgfsTruncatePages(struct inode *inode, // IN: Inode whose page to truncate *---------------------------------------------------------------------- */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75) static int HgfsCreate(struct inode *dir, // IN: Parent dir to create in struct dentry *dentry, // IN: Dentry containing name to create int mode, // IN: Mode of file to be created struct nameidata *nd) // IN: Intent, vfsmount, ... -#else -static int -HgfsCreate(struct inode *dir, // IN: Parent dir to create in - struct dentry *dentry, // IN: Dentry containing name to create - int mode) // IN: Mode of file to be created -#endif { HgfsAttrInfo attr; int result; @@ -1067,16 +1018,10 @@ HgfsCreate(struct inode *dir, // IN: Parent dir to create in *---------------------------------------------------------------------- */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 75) static struct dentry * HgfsLookup(struct inode *dir, // IN: Inode of parent directory struct dentry *dentry, // IN: Dentry containing name to look up - struct nameidata *nd) // IN: Intent, vfsmount, ... -#else -static struct dentry * -HgfsLookup(struct inode *dir, // IN: Inode of parent directory - struct dentry *dentry) // IN: Dentry containing name to look up -#endif + struct nameidata *nd) // IN: Intent, vfsmount, ... { HgfsAttrInfo attr; struct inode *inode; @@ -1772,7 +1717,6 @@ out: *---------------------------------------------------------------------------- */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) static int HgfsAccessInt(struct dentry *dentry, // IN: dentry to check access for int mask) // IN: access mode requested. @@ -1812,7 +1756,6 @@ HgfsAccessInt(struct dentry *dentry, // IN: dentry to check access for } return ret; } -#endif /* @@ -1832,41 +1775,33 @@ HgfsAccessInt(struct dentry *dentry, // IN: dentry to check access for *---------------------------------------------------------------------- */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) && \ - LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) -static int -HgfsPermission(struct inode *inode, int mask, struct nameidata *nd) -#else static int -HgfsPermission(struct inode *inode, int mask) +HgfsPermission(struct inode *inode, + int mask +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) + , struct nameidata *nd #endif + ) { LOG(8, ("VMware hgfs: %s: inode->mode: %8x mask: %8x\n", __func__, inode->i_mode, mask)); /* * For sys_access, we go to the host for permission checking; * otherwise return 0. - * - * XXX When the kernel version is less than 2.6.0, we didn't have a good way - * to tell whether this is for sys_access. Simply returning 0 is not what we - * want. Need to fix it. */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) if (nd != NULL && (nd->flags & LOOKUP_ACCESS)) { /* For sys_access. */ #else if (mask & MAY_ACCESS) { /* For sys_access. */ #endif - struct dentry *dentry; - dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias); + struct dentry *dentry = list_entry(inode->i_dentry.next, + struct dentry, d_alias); return HgfsAccessInt(dentry, mask & (MAY_READ | MAY_WRITE | MAY_EXEC)); } -#endif return 0; } -#ifdef HGFS_GETATTR_ONLY /* *----------------------------------------------------------------------------- * @@ -1906,7 +1841,6 @@ HgfsGetattr(struct vfsmount *mnt, // Unused return 0; } -#endif /* * Public function implementations. diff --git a/open-vm-tools/modules/linux/vmhgfs/module.h b/open-vm-tools/modules/linux/vmhgfs/module.h index 5423ef84a..ea83ce169 100644 --- a/open-vm-tools/modules/linux/vmhgfs/module.h +++ b/open-vm-tools/modules/linux/vmhgfs/module.h @@ -76,21 +76,10 @@ extern int LOGLEVEL_THRESHOLD; * Macros for accessing members that are private to this code in * sb/inode/file structs. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 42) -#define HGFS_SET_SB_TO_COMMON(sb, common) do { (sb)->u.generic_sbp = (common); } while (0) -#define HGFS_SB_TO_COMMON(sb) ((HgfsSuperInfo *)(sb)->u.generic_sbp) -#else #define HGFS_SET_SB_TO_COMMON(sb, common) do { (sb)->s_fs_info = (common); } while (0) #define HGFS_SB_TO_COMMON(sb) ((HgfsSuperInfo *)(sb)->s_fs_info) -#endif -#ifdef VMW_EMBED_INODE #define INODE_GET_II_P(_inode) container_of(_inode, HgfsInodeInfo, inode) -#elif defined VMW_INODE_2618 -#define INODE_GET_II_P(inode) ((HgfsInodeInfo *)(inode)->i_private) -#else -#define INODE_GET_II_P(inode) ((HgfsInodeInfo *)(inode)->u.generic_ip) -#endif #if defined VMW_INODE_2618 #define INODE_SET_II_P(inode, info) do { (inode)->i_private = (info); } while (0) @@ -98,18 +87,6 @@ extern int LOGLEVEL_THRESHOLD; #define INODE_SET_II_P(inode, info) do { (inode)->u.generic_ip = (info); } while (0) #endif -/* 2.5.x kernels support nanoseconds timestamps. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 48) -#define HGFS_DECLARE_TIME(unixtm) time_t unixtm -#define HGFS_EQUAL_TIME(unixtm1, unixtm2) (unixtm1 == unixtm2) -#define HGFS_SET_TIME(unixtm,nttime) HgfsConvertFromNtTime(&unixtm, nttime) -#define HGFS_GET_TIME(unixtm) HgfsConvertToNtTime(unixtm, 0L) -#define HGFS_GET_CURRENT_TIME() HgfsConvertToNtTime(CURRENT_TIME, 0L) -/* - * Beware! This macro returns list of two elements. Do not add braces around. - */ -#define HGFS_PRINT_TIME(unixtm) unixtm, 0L -#else #define HGFS_DECLARE_TIME(unixtm) struct timespec unixtm #define HGFS_EQUAL_TIME(unixtm1, unixtm2) timespec_equal(&unixtm1, &unixtm2) #define HGFS_SET_TIME(unixtm,nttime) HgfsConvertFromNtTimeNsec(&unixtm, nttime) @@ -123,15 +100,6 @@ extern int LOGLEVEL_THRESHOLD; * Beware! This macro returns list of two elements. Do not add braces around. */ #define HGFS_PRINT_TIME(unixtm) unixtm.tv_sec, unixtm.tv_nsec -#endif - -/* - * The writeback support we're using (set_page_dirty()) was added in - * 2.5.12, so we only support writeback from then on. - */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 12) -#define HGFS_ENABLE_WRITEBACK -#endif /* * For files opened in our actual Host/Guest filesystem, the @@ -159,10 +127,8 @@ typedef struct HgfsSuperInfo { * HGFS specific per-inode data. */ typedef struct HgfsInodeInfo { -#ifdef VMW_EMBED_INODE /* Embedded inode. */ struct inode inode; -#endif /* Inode number given by the host. */ uint64 hostFileId; diff --git a/open-vm-tools/modules/linux/vmhgfs/page.c b/open-vm-tools/modules/linux/vmhgfs/page.c index 69d7e8e65..746165294 100644 --- a/open-vm-tools/modules/linux/vmhgfs/page.c +++ b/open-vm-tools/modules/linux/vmhgfs/page.c @@ -32,9 +32,7 @@ #include "compat_fs.h" #include "compat_kernel.h" #include "compat_pagemap.h" -#ifdef HGFS_ENABLE_WRITEBACK #include -#endif #include "cpName.h" #include "hgfsProto.h" @@ -76,12 +74,8 @@ static int HgfsDoWriteEnd(struct file *file, /* HGFS address space operations. */ static int HgfsReadpage(struct file *file, struct page *page); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 52) static int HgfsWritepage(struct page *page, struct writeback_control *wbc); -#else -static int HgfsWritepage(struct page *page); -#endif /* * Write aop interface has changed in 2.6.28. Specifically, @@ -128,9 +122,7 @@ struct address_space_operations HgfsAddressSpaceOperations = { .prepare_write = HgfsPrepareWrite, .commit_write = HgfsCommitWrite, #endif -#ifdef HGFS_ENABLE_WRITEBACK .set_page_dirty = __set_page_dirty_nobuffers, -#endif }; @@ -646,14 +638,9 @@ HgfsReadpage(struct file *file, // IN: File to read from *----------------------------------------------------------------------------- */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 52) static int HgfsWritepage(struct page *page, // IN: Page to write from struct writeback_control *wbc) // IN: Ignored -#else -static int -HgfsWritepage(struct page *page) // IN: Page to write from -#endif { struct inode *inode; HgfsHandle handle; @@ -759,9 +746,6 @@ HgfsDoWriteBegin(struct page *page, // IN: Page to be written unsigned pageFrom, // IN: Starting page offset unsigned pageTo) // IN: Ending page offset { -#ifndef HGFS_ENABLE_WRITEBACK - ASSERT(page); -#else loff_t offset; loff_t currentFileSize; @@ -788,7 +772,6 @@ HgfsDoWriteBegin(struct page *page, // IN: Page to be written kunmap_atomic(kaddr, KM_USER0); flush_dcache_page(page); } -#endif } @@ -819,18 +802,6 @@ HgfsPrepareWrite(struct file *file, // IN: Ignored { HgfsDoWriteBegin(page, pageFrom, pageTo); - /* - * Prior to 2.4.10, our caller expected to call page_address(page) between - * the calls to prepare_write() and commit_write(). This meant filesystems - * had to kmap() the page in prepare_write() and kunmap() it in - * commit_write(). In 2.4.10, the call to page_address() was replaced with - * __copy_to_user(), and while its not clear to me why this is safer, - * nfs_prepare_write() dropped the kmap()/kunmap() calls in the same patch, - * so the two events must be related. - */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 10) - kmap(page); -#endif return 0; } @@ -921,11 +892,6 @@ HgfsDoWriteEnd(struct file *file, // IN: File we're writing to currentFileSize = compat_i_size_read(inode); offset = (loff_t)page->index << PAGE_CACHE_SHIFT; - /* See comment in HgfsPrepareWrite. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 10) - kunmap(page); -#endif - if (writeTo > currentFileSize) { compat_i_size_write(inode, writeTo); } @@ -935,7 +901,6 @@ HgfsDoWriteEnd(struct file *file, // IN: File we're writing to SetPageUptodate(page); } -#ifdef HGFS_ENABLE_WRITEBACK /* * Check if this is a partial write to a new page, which was * initialized in HgfsDoWriteBegin. @@ -953,7 +918,7 @@ HgfsDoWriteEnd(struct file *file, // IN: File we're writing to set_page_dirty(page); return 0; } -#endif + /* * We've recieved a partial write to page that is not uptodate, so * do the write now while the page is still locked. Another diff --git a/open-vm-tools/modules/linux/vmhgfs/super.c b/open-vm-tools/modules/linux/vmhgfs/super.c index f6f26ffbe..49460c2cf 100644 --- a/open-vm-tools/modules/linux/vmhgfs/super.c +++ b/open-vm-tools/modules/linux/vmhgfs/super.c @@ -45,14 +45,8 @@ /* Hgfs filesystem superblock operations */ -#ifdef VMW_EMBED_INODE static struct inode *HgfsAllocInode(struct super_block *sb); static void HgfsDestroyInode(struct inode *inode); -#endif -#ifndef VMW_USE_IGET_LOCKED -static void HgfsReadInode(struct inode *inode); -#endif -static void HgfsClearInode(struct inode *inode); static void HgfsPutSuper(struct super_block *sb); #if defined VMW_STATFS_2618 static int HgfsStatfs(struct dentry *dentry, @@ -63,20 +57,13 @@ static int HgfsStatfs(struct super_block *sb, #endif struct super_operations HgfsSuperOperations = { -#ifdef VMW_EMBED_INODE .alloc_inode = HgfsAllocInode, .destroy_inode = HgfsDestroyInode, -#endif -#ifndef VMW_USE_IGET_LOCKED - .read_inode = HgfsReadInode, -#endif - .clear_inode = HgfsClearInode, .put_super = HgfsPutSuper, .statfs = HgfsStatfs, }; -#ifdef VMW_EMBED_INODE /* *----------------------------------------------------------------------------- * @@ -136,69 +123,6 @@ HgfsDestroyInode(struct inode *inode) // IN: The VFS inode kmem_cache_free(hgfsInodeCache, INODE_GET_II_P(inode)); } -#endif - - -#ifndef VMW_USE_IGET_LOCKED -/* - *----------------------------------------------------------------------------- - * - * HgfsReadInode -- - * - * Hgfs superblock 'read_inode' method. Called by the kernel to fill in a - * VFS inode, given its hgfs inode number. Needed by iget(). - * - * Results: - * None - * - * Side effects: - * None - * - *----------------------------------------------------------------------------- - */ - -static void -HgfsReadInode(struct inode *inode) // IN/OUT: VFS inode to fill in -{ - HgfsDoReadInode(inode); -} -#endif - - -/* - *----------------------------------------------------------------------------- - * - * HgfsClearInode -- - * - * Hgfs superblock 'clear_inode' method. Called by the kernel when it is - * about to destroy a VFS inode. - * - * Results: - * None - * - * Side effects: - * None - * - *----------------------------------------------------------------------------- - */ - -static void -HgfsClearInode(struct inode *inode) // IN: The VFS inode -{ -#ifdef VMW_EMBED_INODE - /* Do nothing. HgfsDestroyInode will do the dirty work. */ -#else - HgfsInodeInfo *iinfo; - - ASSERT(inode); - - /* The HGFS inode information may be partially constructed --hpreg */ - iinfo = INODE_GET_II_P(inode); - if (iinfo) { - kmem_cache_free(hgfsInodeCache, iinfo); - } -#endif -} /* *-----------------------------------------------------------------------------