]> granicus.if.org Git - zfs/commitdiff
Remove vn_set_fs_pwd()/vn_set_pwd() (no need to be at / during insmod)
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 29 May 2019 23:18:14 +0000 (08:18 +0900)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 29 May 2019 23:18:14 +0000 (16:18 -0700)
Per suggestion from @behlendorf in #8777, remove vn_set_fs_pwd() and
vn_set_pwd() which are only used in zfs_ioctl.c:_init() while loading
zfs.ko.

The rest of initialization functions being called here after cwd set
to / don't depend on cwd of the process except for spa_config_load().
spa_config_load() uses a relative path ".//etc/zfs/zpool.cache" when
`rootdir` is non-NULL, which is "/etc/zfs/zpool.cache" given cwd is /,
so just unconditionally use the absolute path without "./", so that
`vn_set_pwd("/")` as well as the entire functions can be removed.
This is also what FreeBSD does.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
Closes #8826

config/kernel-spinlock.m4 [deleted file]
config/kernel.m4
include/spl/sys/vnode.h
module/spl/spl-vnode.c
module/zfs/spa_config.c
module/zfs/zfs_ioctl.c

diff --git a/config/kernel-spinlock.m4 b/config/kernel-spinlock.m4
deleted file mode 100644 (file)
index d6d6640..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-dnl #
-dnl # 2.6.36 API change,
-dnl # The 'struct fs_struct->lock' was changed from a rwlock_t to
-dnl # a spinlock_t to improve the fastpath performance.
-dnl #
-AC_DEFUN([ZFS_AC_KERNEL_FS_STRUCT_SPINLOCK], [
-       AC_MSG_CHECKING([whether struct fs_struct uses spinlock_t])
-       tmp_flags="$EXTRA_KCFLAGS"
-       EXTRA_KCFLAGS="-Werror"
-       ZFS_LINUX_TRY_COMPILE([
-               #include <linux/sched.h>
-               #include <linux/fs_struct.h>
-       ],[
-               static struct fs_struct fs;
-               spin_lock_init(&fs.lock);
-       ],[
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_FS_STRUCT_SPINLOCK, 1,
-                         [struct fs_struct uses spinlock_t])
-       ],[
-               AC_MSG_RESULT(no)
-       ])
-       EXTRA_KCFLAGS="$tmp_flags"
-])
index ef875efa872bd99a6dc456b616cd3f6a0f8ff7a7..2444b68eff91b003efa3f9065f46e7be8d26e5a7 100644 (file)
@@ -12,7 +12,6 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
        ZFS_AC_KERNEL_CTL_NAME
        ZFS_AC_KERNEL_PDE_DATA
        ZFS_AC_KERNEL_2ARGS_VFS_FSYNC
-       ZFS_AC_KERNEL_FS_STRUCT_SPINLOCK
        ZFS_AC_KERNEL_KUIDGID_T
        ZFS_AC_KERNEL_FALLOCATE
        ZFS_AC_KERNEL_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
index 71278b08c86716a5bcb1cf2ca93affa85d41510c..7bd278e4e13b7f05e1652eed70a072b37e7e7d75 100644 (file)
@@ -182,7 +182,6 @@ extern int vn_space(vnode_t *vp, int cmd, struct flock *bfp, int flag,
 extern file_t *vn_getf(int fd);
 extern void vn_releasef(int fd);
 extern void vn_areleasef(int fd, uf_info_t *fip);
-extern int vn_set_pwd(const char *filename);
 
 int spl_vn_init(void);
 void spl_vn_fini(void);
index 11b5e4e5a2f26f17c01233e0de16164a88c8c17c..d9056c964e5a5581a0adc553e0665316c3931666 100644 (file)
@@ -641,64 +641,6 @@ vn_areleasef(int fd, uf_info_t *fip)
 } /* releasef() */
 EXPORT_SYMBOL(areleasef);
 
-
-static void
-vn_set_fs_pwd(struct fs_struct *fs, struct path *path)
-{
-       struct path old_pwd;
-
-#ifdef HAVE_FS_STRUCT_SPINLOCK
-       spin_lock(&fs->lock);
-       old_pwd = fs->pwd;
-       fs->pwd = *path;
-       path_get(path);
-       spin_unlock(&fs->lock);
-#else
-       write_lock(&fs->lock);
-       old_pwd = fs->pwd;
-       fs->pwd = *path;
-       path_get(path);
-       write_unlock(&fs->lock);
-#endif /* HAVE_FS_STRUCT_SPINLOCK */
-
-       if (old_pwd.dentry)
-               path_put(&old_pwd);
-}
-
-int
-vn_set_pwd(const char *filename)
-{
-       struct path path;
-       mm_segment_t saved_fs;
-       int rc;
-
-       /*
-        * user_path_dir() and __user_walk() both expect 'filename' to be
-        * a user space address so we must briefly increase the data segment
-        * size to ensure strncpy_from_user() does not fail with -EFAULT.
-        */
-       saved_fs = get_fs();
-       set_fs(KERNEL_DS);
-
-       rc = user_path_dir(filename, &path);
-       if (rc)
-               goto out;
-
-       rc = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS);
-       if (rc)
-               goto dput_and_out;
-
-       vn_set_fs_pwd(current->fs, &path);
-
-dput_and_out:
-       path_put(&path);
-out:
-       set_fs(saved_fs);
-
-       return (-rc);
-} /* vn_set_pwd() */
-EXPORT_SYMBOL(vn_set_pwd);
-
 static int
 vn_cache_constructor(void *buf, void *cdrarg, int kmflags)
 {
index 8616abda37bdfd34f2e6cd6f090d123efc3ec0a3..6c0894338e255237b53c126e089fa01f6fe157c1 100644 (file)
@@ -93,8 +93,7 @@ spa_config_load(void)
         */
        pathname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
 
-       (void) snprintf(pathname, MAXPATHLEN, "%s%s",
-           (rootdir != NULL) ? "./" : "", spa_config_path);
+       (void) snprintf(pathname, MAXPATHLEN, "%s", spa_config_path);
 
        file = kobj_open_file(pathname);
 
index f30d0a89441496020001e91be5083d022c9b9c5e..c6b55d24f7ef093637b8146394b0509bb2bb4d8a 100644 (file)
@@ -7380,13 +7380,6 @@ _init(void)
 {
        int error;
 
-       error = -vn_set_pwd("/");
-       if (error) {
-               printk(KERN_NOTICE
-                   "ZFS: Warning unable to set pwd to '/': %d\n", error);
-               return (error);
-       }
-
        if ((error = -zvol_init()) != 0)
                return (error);