diff options
author | Brian Behlendorf <[email protected]> | 2012-10-18 12:37:32 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-10-18 13:36:44 -0700 |
commit | 1e0c2c2ccfb720be81051a43c405fad173775963 (patch) | |
tree | 649f0e94f390c28ddb4115c52407fa963ee1fe37 | |
parent | bcb15891ab394e11615eee08bba1fd85ac32e158 (diff) |
Linux 3.7 compat, __clear_close_on_exec() removed
Commit torvalds/linux@b8318b0 moved the __clear_close_on_exec()
function out of include/linux/fdtable.h and in to fs/file.c
making it unavailable to the SPL.
Now as it turns out we only used this function to tear down
some test infrastructure for the vn_getf()/vn_releasef() SPLAT
regression tests. Rather than implement even more autoconf
compatibilty code to handle this we just remove the test case.
This also allows us to drop three existing autoconf tests.
This does mean the SPLAT tests will no longer verify these
functions but historically they have never been a problem.
And if we feel we absolutely need this test coverage I'm
sure a more portable version of the test case could be added.
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #183
-rw-r--r-- | config/spl-build.m4 | 57 | ||||
-rw-r--r-- | include/linux/file_compat.h | 4 | ||||
-rw-r--r-- | module/splat/splat-vnode.c | 136 |
3 files changed, 0 insertions, 197 deletions
diff --git a/config/spl-build.m4 b/config/spl-build.m4 index eb644a188..957d46c48 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -42,9 +42,6 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [ SPL_AC_SET_NORMALIZED_TIMESPEC_INLINE SPL_AC_TIMESPEC_SUB SPL_AC_INIT_UTSNAME - SPL_AC_FDTABLE_HEADER - SPL_AC_FILES_FDTABLE - SPL_AC_CLEAR_CLOSE_ON_EXEC SPL_AC_UACCESS_HEADER SPL_AC_KMALLOC_NODE SPL_AC_MONOTONIC_CLOCK @@ -1191,60 +1188,6 @@ AC_DEFUN([SPL_AC_INIT_UTSNAME], [ ]) dnl # -dnl # 2.6.26 API change, -dnl # definition of struct fdtable relocated to linux/fdtable.h -dnl # -AC_DEFUN([SPL_AC_FDTABLE_HEADER], [ - SPL_CHECK_HEADER([linux/fdtable.h], [FDTABLE], [], []) -]) - -dnl # -dnl # 2.6.14 API change, -dnl # check whether 'files_fdtable()' exists -dnl # -AC_DEFUN([SPL_AC_FILES_FDTABLE], [ - AC_MSG_CHECKING([whether files_fdtable() is available]) - SPL_LINUX_TRY_COMPILE([ - #include <linux/sched.h> - #include <linux/file.h> - #ifdef HAVE_FDTABLE_HEADER - #include <linux/fdtable.h> - #endif - ],[ - struct files_struct *files = current->files; - struct fdtable *fdt __attribute__ ((unused)); - fdt = files_fdtable(files); - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -dnl # -dnl # 3.4.0 API change, -dnl # check whether '__clear_close_on_exec()' exists -dnl # -AC_DEFUN([SPL_AC_CLEAR_CLOSE_ON_EXEC], [ - AC_MSG_CHECKING([whether __clear_close_on_exec() is available]) - SPL_LINUX_TRY_COMPILE([ - #include <linux/fdtable.h> - ],[ - struct fdtable *fdt = NULL; - int fd = 0; - - __clear_close_on_exec(fd, fdt); - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_CLEAR_CLOSE_ON_EXEC, 1, - [__clear_close_on_exec() is available]) - ],[ - AC_MSG_RESULT(no) - ]) -]) - -dnl # dnl # 2.6.18 API change, dnl # added linux/uaccess.h dnl # diff --git a/include/linux/file_compat.h b/include/linux/file_compat.h index 27819d5e5..8664df672 100644 --- a/include/linux/file_compat.h +++ b/include/linux/file_compat.h @@ -89,9 +89,5 @@ extern kern_path_locked_t kern_path_locked_fn; # define spl_kern_path_locked(name, path) kern_path_locked_fn(name, path) #endif /* HAVE_KERN_PATH_LOCKED */ -#ifndef HAVE_CLEAR_CLOSE_ON_EXEC -#define __clear_close_on_exec(fd, fdt) FD_CLR(fd, fdt->close_on_exec) -#endif - #endif /* SPL_FILE_COMPAT_H */ diff --git a/module/splat/splat-vnode.c b/module/splat/splat-vnode.c index f5f010c9f..a57edf0de 100644 --- a/module/splat/splat-vnode.c +++ b/module/splat/splat-vnode.c @@ -54,10 +54,6 @@ #define SPLAT_VNODE_TEST6_NAME "vn_sync" #define SPLAT_VNODE_TEST6_DESC "Vn_sync Test" -#define SPLAT_VNODE_TEST7_ID 0x0907 -#define SPLAT_VNODE_TEST7_NAME "vn_getf" -#define SPLAT_VNODE_TEST7_DESC "vn_getf/vn_releasef Test" - #define SPLAT_VNODE_TEST_FILE "/etc/fstab" #define SPLAT_VNODE_TEST_FILE_AT "etc/fstab" #define SPLAT_VNODE_TEST_FILE_RW "/tmp/spl.vnode.tmp" @@ -394,135 +390,6 @@ out: return -rc; } /* splat_vnode_test6() */ -/* Basically a slightly modified version of sys_close() */ -static int -fd_uninstall(int fd) -{ - struct file *fp; - struct files_struct *files = current->files; -#ifdef HAVE_FILES_FDTABLE - struct fdtable *fdt; - - spin_lock(&files->file_lock); - fdt = files_fdtable(files); - - if (fd >= fdt->max_fds) - goto out_unlock; - - fp = fdt->fd[fd]; - if (!fp) - goto out_unlock; - - rcu_assign_pointer(fdt->fd[fd], NULL); - __clear_close_on_exec(fd, fdt); -#else - spin_lock(&files->file_lock); - if (fd >= files->max_fds) - goto out_unlock; - - fp = files->fd[fd]; - if (!fp) - goto out_unlock; - - files->fd[fd] = NULL; - FD_CLR(fd, files->close_on_exec); -#endif - /* Dropping the lock here exposes a minor race but it allows me - * to use the existing kernel interfaces for this, and for a test - * case I think that's reasonable. */ - spin_unlock(&files->file_lock); - put_unused_fd(fd); - return 0; - -out_unlock: - spin_unlock(&files->file_lock); - return -EBADF; -} /* fd_uninstall() */ - -static int -splat_vnode_test7(struct file *file, void *arg) -{ - char buf1[32] = "SPL VNode Interface Test File\n"; - char buf2[32] = ""; - struct file *lfp; - file_t *fp; - int rc, fd; - - if ((rc = splat_vnode_unlink_all(file, arg, SPLAT_VNODE_TEST7_NAME))) - return rc; - - /* Prep work needed to test getf/releasef */ - fd = get_unused_fd(); - if (fd < 0) { - splat_vprint(file, SPLAT_VNODE_TEST7_NAME, - "Failed to get unused fd (%d)\n", fd); - return fd; - } - - lfp = filp_open(SPLAT_VNODE_TEST_FILE_RW, O_RDWR|O_CREAT|O_EXCL, 0644); - if (IS_ERR(lfp)) { - put_unused_fd(fd); - rc = PTR_ERR(lfp); - splat_vprint(file, SPLAT_VNODE_TEST7_NAME, - "Failed to filp_open: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - return rc; - } - - /* Pair up the new fd and lfp in the current context, this allows - * getf to lookup the file struct simply by the known open fd */ - fd_install(fd, lfp); - - /* Actual getf()/releasef() test */ - fp = vn_getf(fd); - if (fp == NULL) { - rc = EINVAL; - splat_vprint(file, SPLAT_VNODE_TEST7_NAME, - "Failed to getf fd %d: (%d)\n", fd, rc); - goto out; - } - - rc = vn_rdwr(UIO_WRITE, fp->f_vnode, buf1, strlen(buf1), 0, - UIO_SYSSPACE, 0, RLIM64_INFINITY, 0, NULL); - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST7_NAME, - "Failed vn_rdwr write of test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - goto out; - } - - rc = vn_rdwr(UIO_READ, fp->f_vnode, buf2, strlen(buf1), 0, - UIO_SYSSPACE, 0, RLIM64_INFINITY, 0, NULL); - if (rc) { - splat_vprint(file, SPLAT_VNODE_TEST7_NAME, - "Failed vn_rdwr read of test file: %s (%d)\n", - SPLAT_VNODE_TEST_FILE_RW, rc); - goto out; - } - - if (strncmp(buf1, buf2, strlen(buf1))) { - rc = EINVAL; - splat_vprint(file, SPLAT_VNODE_TEST7_NAME, - "Failed strncmp data written does not match " - "data read\nWrote: %sRead: %s\n", buf1, buf2); - goto out; - } - - rc = 0; - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, "Wrote: %s", buf1); - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, "Read: %s", buf2); - splat_vprint(file, SPLAT_VNODE_TEST3_NAME, "Successfully wrote and " - "read expected data pattern to test file: %s\n", - SPLAT_VNODE_TEST_FILE_RW); -out: - vn_releasef(fd); - fd_uninstall(fd); - filp_close(lfp, 0); - vn_remove(SPLAT_VNODE_TEST_FILE_RW, UIO_SYSSPACE, RMFILE); - - return -rc; -} /* splat_vnode_test7() */ - splat_subsystem_t * splat_vnode_init(void) { @@ -552,8 +419,6 @@ splat_vnode_init(void) SPLAT_VNODE_TEST5_ID, splat_vnode_test5); SPLAT_TEST_INIT(sub, SPLAT_VNODE_TEST6_NAME, SPLAT_VNODE_TEST6_DESC, SPLAT_VNODE_TEST6_ID, splat_vnode_test6); - SPLAT_TEST_INIT(sub, SPLAT_VNODE_TEST7_NAME, SPLAT_VNODE_TEST7_DESC, - SPLAT_VNODE_TEST7_ID, splat_vnode_test7); return sub; } /* splat_vnode_init() */ @@ -563,7 +428,6 @@ splat_vnode_fini(splat_subsystem_t *sub) { ASSERT(sub); - SPLAT_TEST_FINI(sub, SPLAT_VNODE_TEST7_ID); SPLAT_TEST_FINI(sub, SPLAT_VNODE_TEST6_ID); SPLAT_TEST_FINI(sub, SPLAT_VNODE_TEST5_ID); SPLAT_TEST_FINI(sub, SPLAT_VNODE_TEST4_ID); |