mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-03-11 21:06:18 +03:00
zpl_super: prefer "new" mount API when available
This API has been available since kernel 5.2, and having it available (almost) everywhere should give us a lot more flexibility for mount management in the future. Sponsored-by: TrueNAS Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <rob.norris@truenas.com> Closes #18260
This commit is contained in:
parent
09c27a14a3
commit
f3d4c79496
33
config/kernel-fs-context.m4
Normal file
33
config/kernel-fs-context.m4
Normal file
@ -0,0 +1,33 @@
|
||||
dnl # SPDX-License-Identifier: CDDL-1.0
|
||||
dnl #
|
||||
dnl # 2.6.38 API change
|
||||
dnl # The .get_sb callback has been replaced by a .mount callback
|
||||
dnl # in the file_system_type structure.
|
||||
dnl #
|
||||
dnl # 5.2 API change
|
||||
dnl # The new fs_context-based filesystem API is introduced, with the old
|
||||
dnl # one (via file_system_type.mount) preserved as a compatibility shim.
|
||||
dnl #
|
||||
dnl # 7.0 API change
|
||||
dnl # Compatibility shim removed, so all callers must go through the mount API.
|
||||
dnl #
|
||||
AC_DEFUN([ZFS_AC_KERNEL_SRC_FS_CONTEXT], [
|
||||
ZFS_LINUX_TEST_SRC([fs_context], [
|
||||
#include <linux/fs.h>
|
||||
#include <linux/fs_context.h>
|
||||
],[
|
||||
static struct fs_context fs __attribute__ ((unused)) = { 0 };
|
||||
static struct fs_context *fsp __attribute__ ((unused));
|
||||
fsp = vfs_dup_fs_context(&fs);
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([ZFS_AC_KERNEL_FS_CONTEXT], [
|
||||
AC_MSG_CHECKING([whether fs_context exists])
|
||||
ZFS_LINUX_TEST_RESULT([fs_context], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_FS_CONTEXT, 1, [fs_context exists])
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
])
|
||||
@ -1,36 +0,0 @@
|
||||
dnl # SPDX-License-Identifier: CDDL-1.0
|
||||
dnl #
|
||||
dnl # 2.6.38 API change
|
||||
dnl # The .get_sb callback has been replaced by a .mount callback
|
||||
dnl # in the file_system_type structure.
|
||||
dnl #
|
||||
dnl # 7.0 API change
|
||||
dnl # The .mount callback has been removed, requiring all mount work
|
||||
dnl # to be done through the "new" mount API introduced in 5.2.
|
||||
dnl #
|
||||
AC_DEFUN([ZFS_AC_KERNEL_SRC_FST_MOUNT], [
|
||||
ZFS_LINUX_TEST_SRC([file_system_type_mount], [
|
||||
#include <linux/fs.h>
|
||||
|
||||
static struct dentry *
|
||||
mount(struct file_system_type *fs_type, int flags,
|
||||
const char *osname, void *data) {
|
||||
struct dentry *d = NULL;
|
||||
return (d);
|
||||
}
|
||||
|
||||
static struct file_system_type fst __attribute__ ((unused)) = {
|
||||
.mount = mount,
|
||||
};
|
||||
],[])
|
||||
])
|
||||
|
||||
AC_DEFUN([ZFS_AC_KERNEL_FST_MOUNT], [
|
||||
AC_MSG_CHECKING([whether fst->mount() exists])
|
||||
ZFS_LINUX_TEST_RESULT([file_system_type_mount], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_FST_MOUNT, 1, [fst->mount() exists])
|
||||
],[
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
])
|
||||
@ -75,7 +75,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
|
||||
ZFS_AC_KERNEL_SRC_DENTRY
|
||||
ZFS_AC_KERNEL_SRC_TRUNCATE_SETSIZE
|
||||
ZFS_AC_KERNEL_SRC_SECURITY_INODE
|
||||
ZFS_AC_KERNEL_SRC_FST_MOUNT
|
||||
ZFS_AC_KERNEL_SRC_FS_CONTEXT
|
||||
ZFS_AC_KERNEL_SRC_SB_DYING
|
||||
ZFS_AC_KERNEL_SRC_SET_NLINK
|
||||
ZFS_AC_KERNEL_SRC_SGET
|
||||
@ -199,7 +199,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
|
||||
ZFS_AC_KERNEL_DENTRY
|
||||
ZFS_AC_KERNEL_TRUNCATE_SETSIZE
|
||||
ZFS_AC_KERNEL_SECURITY_INODE
|
||||
ZFS_AC_KERNEL_FST_MOUNT
|
||||
ZFS_AC_KERNEL_FS_CONTEXT
|
||||
ZFS_AC_KERNEL_SB_DYING
|
||||
ZFS_AC_KERNEL_SET_NLINK
|
||||
ZFS_AC_KERNEL_SGET
|
||||
|
||||
@ -36,8 +36,7 @@
|
||||
#include <linux/iversion.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/vfs_compat.h>
|
||||
|
||||
#ifndef HAVE_FST_MOUNT
|
||||
#ifdef HAVE_FS_CONTEXT
|
||||
#include <linux/fs_context.h>
|
||||
#endif
|
||||
|
||||
@ -509,17 +508,15 @@ zpl_prune_sb(uint64_t nr_to_scan, void *arg)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef HAVE_FST_MOUNT
|
||||
#ifdef HAVE_FS_CONTEXT
|
||||
/*
|
||||
* In kernel 7.0, the file_system_type->mount() and
|
||||
* super_operations->remount_fs() callbacks have been removed, requiring all
|
||||
* users to convert to the "new" fs_context-based mount API introduced in 5.2.
|
||||
* Since kernel 5.2, the "new" fs_context-based mount API has been preferred
|
||||
* over the traditional file_system_type->mount() and
|
||||
* super_operations->remount_fs() callbacks, which were deprectate. In 7.0,
|
||||
* those callbacks were removed.
|
||||
*
|
||||
* This is the simplest compatibility shim possible to adapt the fs_context
|
||||
* interface to the old-style calls. Although this interface exists in almost
|
||||
* all versions of Linux currently supported by OpenZFS, we only use it when
|
||||
* the kernel-provided shims are unavailable, to avoid bugs in these new shims
|
||||
* affecting all OpenZFS deployments.
|
||||
* Currently, the old-style interface are the only ones we need, so this is
|
||||
* a simple compatibility shim to adapt the new API to the old-style calls.
|
||||
*/
|
||||
static int
|
||||
zpl_parse_monolithic(struct fs_context *fc, void *data)
|
||||
@ -577,7 +574,7 @@ const struct super_operations zpl_super_operations = {
|
||||
.put_super = zpl_put_super,
|
||||
.sync_fs = zpl_sync_fs,
|
||||
.statfs = zpl_statfs,
|
||||
#ifdef HAVE_FST_MOUNT
|
||||
#ifndef HAVE_FS_CONTEXT
|
||||
.remount_fs = zpl_remount_fs,
|
||||
#endif
|
||||
.show_devname = zpl_show_devname,
|
||||
@ -622,10 +619,10 @@ struct file_system_type zpl_fs_type = {
|
||||
#else
|
||||
.fs_flags = FS_USERNS_MOUNT,
|
||||
#endif
|
||||
#ifdef HAVE_FST_MOUNT
|
||||
.mount = zpl_mount,
|
||||
#else
|
||||
#ifdef HAVE_FS_CONTEXT
|
||||
.init_fs_context = zpl_init_fs_context,
|
||||
#else
|
||||
.mount = zpl_mount,
|
||||
#endif
|
||||
.kill_sb = zpl_kill_sb,
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user