diff options
author | Tomohiro Kusumi <[email protected]> | 2019-05-30 08:18:14 +0900 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-05-29 16:18:14 -0700 |
commit | fe0c9f409a1914ad5e5ea5b7cf14a8991e6c1126 (patch) | |
tree | a9976b7a6a85f4094e595a7271643648ffd2314e /module | |
parent | 1e724f4f346486f27d57051df73361b0dacf5632 (diff) |
Remove vn_set_fs_pwd()/vn_set_pwd() (no need to be at / during insmod)
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 <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes #8826
Diffstat (limited to 'module')
-rw-r--r-- | module/spl/spl-vnode.c | 58 | ||||
-rw-r--r-- | module/zfs/spa_config.c | 3 | ||||
-rw-r--r-- | module/zfs/zfs_ioctl.c | 7 |
3 files changed, 1 insertions, 67 deletions
diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index 11b5e4e5a..d9056c964 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -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) { diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c index 8616abda3..6c0894338 100644 --- a/module/zfs/spa_config.c +++ b/module/zfs/spa_config.c @@ -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); diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index f30d0a894..c6b55d24f 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -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); |