From 2cf7f52bc42f215d4ef27d0fd75fc1b1417cb841 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 19 May 2011 11:44:07 -0700 Subject: [PATCH] Linux compat 2.6.39: mount_nodev() The .get_sb callback has been replaced by a .mount callback in the file_system_type structure. When using the new interface the caller must now use the mount_nodev() helper. Unfortunately, the new interface no longer passes the vfsmount down to the zfs layers. This poses a problem for the existing implementation because we currently save this pointer in the super block for latter use. It provides our only entry point in to the namespace layer for manipulating certain mount options. This needed to be done originally to allow commands like 'zfs set atime=off tank' to work properly. It also allowed me to keep more of the original Solaris code unmodified. Under Solaris there is a 1-to-1 mapping between a mount point and a file system so this is a fairly natural thing to do. However, under Linux they many be multiple entries in the namespace which reference the same filesystem. Thus keeping a back reference from the filesystem to the namespace is complicated. Rather than introduce some ugly hack to get the vfsmount and continue as before. I'm leveraging this API change to update the ZFS code to do things in a more natural way for Linux. This has the upside that is resolves the compatibility issue for the long term and fixes several other minor bugs which have been reported. This commit updates the code to remove this vfsmount back reference entirely. All modifications to filesystem mount options are now passed in to the kernel via a '-o remount'. This is the expected Linux mechanism and allows the namespace to properly handle any options which apply to it before passing them on to the file system itself. Aside from fixing the compatibility issue, removing the vfsmount has had the benefit of simplifying the code. This change which fairly involved has turned out nicely. Closes #246 Closes #217 Closes #187 Closes #248 Closes #231 --- Makefile.in | 1 + cmd/Makefile.in | 1 + cmd/mount_zfs/Makefile.in | 1 + cmd/mount_zfs/mount_zfs.c | 1 + cmd/sas_switch_id/Makefile.in | 1 + cmd/zdb/Makefile.in | 1 + cmd/zfs/Makefile.in | 1 + cmd/zinject/Makefile.in | 1 + cmd/zpios/Makefile.in | 1 + cmd/zpool/Makefile.in | 1 + cmd/zpool_id/Makefile.in | 1 + cmd/zpool_layout/Makefile.in | 1 + cmd/ztest/Makefile.in | 1 + cmd/zvol_id/Makefile.in | 1 + config/kernel-mount-nodev.m4 | 15 ++ config/kernel.m4 | 1 + configure | 80 +++++++ dracut/90zfs/Makefile.in | 1 + dracut/Makefile.in | 1 + etc/Makefile.in | 1 + etc/init.d/Makefile.in | 1 + etc/udev/Makefile.in | 1 + etc/udev/rules.d/Makefile.in | 1 + etc/zfs/Makefile.in | 1 + include/Makefile.in | 1 + include/libzfs.h | 1 + include/linux/Makefile.in | 1 + include/sys/Makefile.in | 1 + include/sys/fm/Makefile.in | 1 + include/sys/fm/fs/Makefile.in | 1 + include/sys/fs/Makefile.in | 1 + include/sys/zfs_vfsops.h | 6 +- include/sys/zfs_znode.h | 7 +- include/sys/zpl.h | 1 - lib/Makefile.in | 1 + lib/libavl/Makefile.in | 1 + lib/libefi/Makefile.in | 1 + lib/libnvpair/Makefile.in | 1 + lib/libspl/Makefile.in | 1 + lib/libspl/asm-generic/Makefile.in | 1 + lib/libspl/asm-i386/Makefile.in | 1 + lib/libspl/asm-x86_64/Makefile.in | 1 + lib/libspl/include/Makefile.in | 1 + lib/libspl/include/ia32/Makefile.in | 1 + lib/libspl/include/ia32/sys/Makefile.in | 1 + lib/libspl/include/rpc/Makefile.in | 1 + lib/libspl/include/sys/Makefile.in | 1 + lib/libspl/include/sys/dktp/Makefile.in | 1 + lib/libspl/include/sys/mntent.h | 4 +- lib/libspl/include/sys/sysevent/Makefile.in | 1 + lib/libspl/include/util/Makefile.in | 1 + lib/libunicode/Makefile.in | 1 + lib/libuutil/Makefile.in | 1 + lib/libzfs/Makefile.in | 1 + lib/libzfs/libzfs_dataset.c | 41 +++- lib/libzfs/libzfs_mount.c | 79 ++++++- lib/libzpool/Makefile.in | 1 + man/Makefile.in | 1 + man/man8/Makefile.in | 1 + module/zfs/zfs_acl.c | 3 +- module/zfs/zfs_dir.c | 2 +- module/zfs/zfs_ioctl.c | 17 +- module/zfs/zfs_vfsops.c | 219 ++++---------------- module/zfs/zfs_vnops.c | 4 +- module/zfs/zpl_export.c | 4 +- module/zfs/zpl_super.c | 20 +- module/zfs/zpl_xattr.c | 6 +- scripts/Makefile.in | 1 + scripts/zpios-profile/Makefile.in | 1 + scripts/zpios-test/Makefile.in | 1 + scripts/zpool-config/Makefile.in | 1 + scripts/zpool-layout/Makefile.in | 1 + zfs_config.h.in | 3 + 73 files changed, 347 insertions(+), 220 deletions(-) create mode 100644 config/kernel-mount-nodev.m4 diff --git a/Makefile.in b/Makefile.in index 830c43c6d..2fec9078e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -76,6 +76,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/Makefile.in b/cmd/Makefile.in index 988fefc7a..eb8c49cce 100644 --- a/cmd/Makefile.in +++ b/cmd/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/mount_zfs/Makefile.in b/cmd/mount_zfs/Makefile.in index 7081fe74c..690b0ff35 100644 --- a/cmd/mount_zfs/Makefile.in +++ b/cmd/mount_zfs/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c index 7173f5698..6a2e9ff36 100644 --- a/cmd/mount_zfs/mount_zfs.c +++ b/cmd/mount_zfs/mount_zfs.c @@ -96,6 +96,7 @@ static const option_map_t option_map[] = { { MNTOPT_QUIET, MS_SILENT, ZS_COMMENT }, #endif /* Custom zfs options */ + { MNTOPT_XATTR, MS_COMMENT, ZS_COMMENT }, { MNTOPT_NOXATTR, MS_COMMENT, ZS_COMMENT }, { MNTOPT_ZFSUTIL, MS_COMMENT, ZS_ZFSUTIL }, { NULL, 0, 0 } }; diff --git a/cmd/sas_switch_id/Makefile.in b/cmd/sas_switch_id/Makefile.in index e32e797be..a2d6430cd 100644 --- a/cmd/sas_switch_id/Makefile.in +++ b/cmd/sas_switch_id/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/zdb/Makefile.in b/cmd/zdb/Makefile.in index 18502eba5..0740352df 100644 --- a/cmd/zdb/Makefile.in +++ b/cmd/zdb/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/zfs/Makefile.in b/cmd/zfs/Makefile.in index 1a5f4d3b2..c2b0c6818 100644 --- a/cmd/zfs/Makefile.in +++ b/cmd/zfs/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/zinject/Makefile.in b/cmd/zinject/Makefile.in index dffcd2e84..ef106b016 100644 --- a/cmd/zinject/Makefile.in +++ b/cmd/zinject/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/zpios/Makefile.in b/cmd/zpios/Makefile.in index 29e63a84a..0a94f334b 100644 --- a/cmd/zpios/Makefile.in +++ b/cmd/zpios/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/zpool/Makefile.in b/cmd/zpool/Makefile.in index 1c1481c8c..faf33f8e1 100644 --- a/cmd/zpool/Makefile.in +++ b/cmd/zpool/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/zpool_id/Makefile.in b/cmd/zpool_id/Makefile.in index eed2156e4..f56c61598 100644 --- a/cmd/zpool_id/Makefile.in +++ b/cmd/zpool_id/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/zpool_layout/Makefile.in b/cmd/zpool_layout/Makefile.in index 3d4f36335..7027914e7 100644 --- a/cmd/zpool_layout/Makefile.in +++ b/cmd/zpool_layout/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/ztest/Makefile.in b/cmd/ztest/Makefile.in index e3718e510..30954f7af 100644 --- a/cmd/ztest/Makefile.in +++ b/cmd/ztest/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/cmd/zvol_id/Makefile.in b/cmd/zvol_id/Makefile.in index 5857046ad..ba0624d68 100644 --- a/cmd/zvol_id/Makefile.in +++ b/cmd/zvol_id/Makefile.in @@ -64,6 +64,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/config/kernel-mount-nodev.m4 b/config/kernel-mount-nodev.m4 new file mode 100644 index 000000000..9229d5b1b --- /dev/null +++ b/config/kernel-mount-nodev.m4 @@ -0,0 +1,15 @@ +dnl # +dnl # 2.6.39 API change +dnl # The .get_sb callback has been replaced by a .mount callback +dnl # in the file_system_type structure. When using the new +dnl # interface the caller must now use the mount_nodev() helper. +dnl # This updated callback and helper no longer pass the vfsmount. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV], [ + ZFS_CHECK_SYMBOL_EXPORT( + [mount_nodev], + [fs/super.c], + [AC_DEFINE(HAVE_MOUNT_NODEV, 1, + [mount_nodev() is available])], + []) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 8c4b06ac4..90dc6c000 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -39,6 +39,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE ZFS_AC_KERNEL_TRUNCATE_SETSIZE ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY + ZFS_AC_KERNEL_MOUNT_NODEV if test "$LINUX_OBJ" != "$LINUX"; then KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" diff --git a/configure b/configure index 49bfb63c9..497c9931b 100755 --- a/configure +++ b/configure @@ -14635,6 +14635,46 @@ fi EXTRA_KCFLAGS="$tmp_flags" + { $as_echo "$as_me:$LINENO: checking whether symbol mount_nodev is exported" >&5 +$as_echo_n "checking whether symbol mount_nodev is exported... " >&6; } + grep -q -E '[[:space:]]mount_nodev[[:space:]]' \ + $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null + rc=$? + if test $rc -ne 0; then + export=0 + for file in fs/super.c; do + grep -q -E "EXPORT_SYMBOL.*(mount_nodev)" "$LINUX/$file" 2>/dev/null + rc=$? + if test $rc -eq 0; then + export=1 + break; + fi + done + if test $export -eq 0; then + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + + else + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MOUNT_NODEV 1 +_ACEOF + + fi + else + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MOUNT_NODEV 1 +_ACEOF + + fi + + + if test "$LINUX_OBJ" != "$LINUX"; then KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" fi @@ -18869,6 +18909,46 @@ fi EXTRA_KCFLAGS="$tmp_flags" + { $as_echo "$as_me:$LINENO: checking whether symbol mount_nodev is exported" >&5 +$as_echo_n "checking whether symbol mount_nodev is exported... " >&6; } + grep -q -E '[[:space:]]mount_nodev[[:space:]]' \ + $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null + rc=$? + if test $rc -ne 0; then + export=0 + for file in fs/super.c; do + grep -q -E "EXPORT_SYMBOL.*(mount_nodev)" "$LINUX/$file" 2>/dev/null + rc=$? + if test $rc -eq 0; then + export=1 + break; + fi + done + if test $export -eq 0; then + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + + else + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MOUNT_NODEV 1 +_ACEOF + + fi + else + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MOUNT_NODEV 1 +_ACEOF + + fi + + + if test "$LINUX_OBJ" != "$LINUX"; then KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" fi diff --git a/dracut/90zfs/Makefile.in b/dracut/90zfs/Makefile.in index a88f4399f..49ed26264 100644 --- a/dracut/90zfs/Makefile.in +++ b/dracut/90zfs/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/dracut/Makefile.in b/dracut/Makefile.in index cf9446c76..9c55888ad 100644 --- a/dracut/Makefile.in +++ b/dracut/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/etc/Makefile.in b/etc/Makefile.in index 74cb03ced..06e5fbedd 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/etc/init.d/Makefile.in b/etc/init.d/Makefile.in index 9475c9c73..53f5457b6 100644 --- a/etc/init.d/Makefile.in +++ b/etc/init.d/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/etc/udev/Makefile.in b/etc/udev/Makefile.in index c2c2ec18e..f4754b8ff 100644 --- a/etc/udev/Makefile.in +++ b/etc/udev/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/etc/udev/rules.d/Makefile.in b/etc/udev/rules.d/Makefile.in index 67145b0a4..98b0d2fdb 100644 --- a/etc/udev/rules.d/Makefile.in +++ b/etc/udev/rules.d/Makefile.in @@ -62,6 +62,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/etc/zfs/Makefile.in b/etc/zfs/Makefile.in index 62bac1b3b..08d1b6a4e 100644 --- a/etc/zfs/Makefile.in +++ b/etc/zfs/Makefile.in @@ -62,6 +62,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/include/Makefile.in b/include/Makefile.in index d1533b75e..ddb20fcb9 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/include/libzfs.h b/include/libzfs.h index e0c695043..23422b2c9 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -436,6 +436,7 @@ extern int zfs_prop_get_userquota_int(zfs_handle_t *zhp, const char *propname, uint64_t *propvalue); extern int zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname, char *propbuf, int proplen, boolean_t literal); +extern uint64_t getprop_uint64(zfs_handle_t *, zfs_prop_t, char **); extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t); extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t); extern const char *zfs_prop_values(zfs_prop_t); diff --git a/include/linux/Makefile.in b/include/linux/Makefile.in index 269613190..631aade30 100644 --- a/include/linux/Makefile.in +++ b/include/linux/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/include/sys/Makefile.in b/include/sys/Makefile.in index 85f73afdc..954728cc8 100644 --- a/include/sys/Makefile.in +++ b/include/sys/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/include/sys/fm/Makefile.in b/include/sys/fm/Makefile.in index 00f3f9f69..05de923fb 100644 --- a/include/sys/fm/Makefile.in +++ b/include/sys/fm/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/include/sys/fm/fs/Makefile.in b/include/sys/fm/fs/Makefile.in index 3aa7c3e87..66b516bb2 100644 --- a/include/sys/fm/fs/Makefile.in +++ b/include/sys/fm/fs/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/include/sys/fs/Makefile.in b/include/sys/fs/Makefile.in index bf7f57e4e..ef905a718 100644 --- a/include/sys/fs/Makefile.in +++ b/include/sys/fs/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/include/sys/zfs_vfsops.h b/include/sys/zfs_vfsops.h index 7622f0308..ae5f811c0 100644 --- a/include/sys/zfs_vfsops.h +++ b/include/sys/zfs_vfsops.h @@ -42,7 +42,6 @@ struct zfs_sb; struct znode; typedef struct zfs_sb { - struct vfsmount *z_vfs; /* generic vfs struct */ struct super_block *z_sb; /* generic super_block */ struct zfs_sb *z_parent; /* parent fs */ objset_t *z_os; /* objset reference */ @@ -89,7 +88,7 @@ typedef struct zfs_sb { #define ZFS_SUPER_MAGIC 0x2fc12fc1 -#define ZSB_XATTR_USER 0x0001 /* Enable user xattrs */ +#define ZSB_XATTR 0x0001 /* Enable user xattrs */ /* @@ -182,6 +181,7 @@ extern int zfs_set_version(zfs_sb_t *zsb, uint64_t newvers); extern int zfs_sb_create(const char *name, zfs_sb_t **zsbp); extern void zfs_sb_free(zfs_sb_t *zsb); extern int zfs_check_global_label(const char *dsname, const char *hexsl); +extern boolean_t zfs_is_readonly(zfs_sb_t *zsb); extern int zfs_register_callbacks(zfs_sb_t *zsb); extern void zfs_unregister_callbacks(zfs_sb_t *zsb); @@ -190,7 +190,7 @@ extern int zfs_umount(struct super_block *sb); extern int zfs_remount(struct super_block *sb, int *flags, char *data); extern int zfs_root(zfs_sb_t *zsb, struct inode **ipp); extern int zfs_statvfs(struct dentry *dentry, struct kstatfs *statp); -extern int zfs_vget(struct vfsmount *vfsp, struct inode **ipp, fid_t *fidp); +extern int zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp); #ifdef __cplusplus } diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h index 2f9ca743d..6a0c6a4df 100644 --- a/include/sys/zfs_znode.h +++ b/include/sys/zfs_znode.h @@ -236,9 +236,8 @@ typedef struct znode { */ #define ZTOI(znode) (&((znode)->z_inode)) #define ITOZ(inode) (container_of((inode), znode_t, z_inode)) -#define VTOZSB(vfs) ((zfs_sb_t *)((vfs)->mnt_sb->s_fs_info)) -#define ZTOZSB(znode) ((zfs_sb_t *)(ZTOI(znode)->i_sb->s_fs_info)) -#define ITOZSB(inode) ((zfs_sb_t *)((inode)->i_sb->s_fs_info)) +#define ZTOZSB(znode) ((zfs_sb_t *)(ZTOI(znode)->i_sb->s_fs_info)) +#define ITOZSB(inode) ((zfs_sb_t *)((inode)->i_sb->s_fs_info)) #define S_ISDEV(mode) (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) @@ -306,7 +305,7 @@ typedef struct znode { #define CONTENT_MODIFIED (ATTR_MTIME | ATTR_CTIME) #define ZFS_ACCESSTIME_STAMP(zsb, zp) \ - if ((zsb)->z_atime && !((zsb)->z_vfs->mnt_flags & MNT_READONLY)) \ + if ((zsb)->z_atime && !(zfs_is_readonly(zsb))) \ zfs_tstamp_update_setup(zp, ACCESSED, NULL, NULL, B_FALSE); extern int zfs_init_fs(zfs_sb_t *, znode_t **); diff --git a/include/sys/zpl.h b/include/sys/zpl.h index 2770e59b2..0aacce8bd 100644 --- a/include/sys/zpl.h +++ b/include/sys/zpl.h @@ -51,7 +51,6 @@ extern const struct file_operations zpl_dir_file_operations; typedef struct zpl_mount_data { const char *z_osname; /* Dataset name */ void *z_data; /* Mount options string */ - struct vfsmount *z_vfs; /* VFS mount point */ } zpl_mount_data_t; extern const struct super_operations zpl_super_operations; diff --git a/lib/Makefile.in b/lib/Makefile.in index 418476087..107aa7678 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libavl/Makefile.in b/lib/libavl/Makefile.in index 9ab160e43..f7a6abd66 100644 --- a/lib/libavl/Makefile.in +++ b/lib/libavl/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libefi/Makefile.in b/lib/libefi/Makefile.in index 8116a2374..f2cb56011 100644 --- a/lib/libefi/Makefile.in +++ b/lib/libefi/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libnvpair/Makefile.in b/lib/libnvpair/Makefile.in index 318dcbd04..13e64b5dc 100644 --- a/lib/libnvpair/Makefile.in +++ b/lib/libnvpair/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/Makefile.in b/lib/libspl/Makefile.in index 09dd5245c..fa1ff51f1 100644 --- a/lib/libspl/Makefile.in +++ b/lib/libspl/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/asm-generic/Makefile.in b/lib/libspl/asm-generic/Makefile.in index 7e03433f2..6aeb054b8 100644 --- a/lib/libspl/asm-generic/Makefile.in +++ b/lib/libspl/asm-generic/Makefile.in @@ -62,6 +62,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/asm-i386/Makefile.in b/lib/libspl/asm-i386/Makefile.in index 85bebc9b3..c91a2bb7f 100644 --- a/lib/libspl/asm-i386/Makefile.in +++ b/lib/libspl/asm-i386/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/asm-x86_64/Makefile.in b/lib/libspl/asm-x86_64/Makefile.in index b6b9bed8f..7afeb56d8 100644 --- a/lib/libspl/asm-x86_64/Makefile.in +++ b/lib/libspl/asm-x86_64/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/include/Makefile.in b/lib/libspl/include/Makefile.in index b2de0ad14..5708683ff 100644 --- a/lib/libspl/include/Makefile.in +++ b/lib/libspl/include/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/include/ia32/Makefile.in b/lib/libspl/include/ia32/Makefile.in index d68fa7b74..7a6e4862e 100644 --- a/lib/libspl/include/ia32/Makefile.in +++ b/lib/libspl/include/ia32/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/include/ia32/sys/Makefile.in b/lib/libspl/include/ia32/sys/Makefile.in index 30b81de33..2637df9cb 100644 --- a/lib/libspl/include/ia32/sys/Makefile.in +++ b/lib/libspl/include/ia32/sys/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/include/rpc/Makefile.in b/lib/libspl/include/rpc/Makefile.in index 3b1270e58..9561e97a2 100644 --- a/lib/libspl/include/rpc/Makefile.in +++ b/lib/libspl/include/rpc/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/include/sys/Makefile.in b/lib/libspl/include/sys/Makefile.in index ccfefaa5d..503fefb5a 100644 --- a/lib/libspl/include/sys/Makefile.in +++ b/lib/libspl/include/sys/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/include/sys/dktp/Makefile.in b/lib/libspl/include/sys/dktp/Makefile.in index 9eed96c9d..40d4e0c44 100644 --- a/lib/libspl/include/sys/dktp/Makefile.in +++ b/lib/libspl/include/sys/dktp/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/include/sys/mntent.h b/lib/libspl/include/sys/mntent.h index 1cbdc3aeb..8fad65b56 100644 --- a/lib/libspl/include/sys/mntent.h +++ b/lib/libspl/include/sys/mntent.h @@ -88,8 +88,8 @@ #define MNTOPT_LOUD "loud" /* verbose mount */ #define MNTOPT_BIND "bind" /* remount part of a tree */ #define MNTOPT_RBIND "rbind" /* include subtrees */ -#define MNTOPT_XATTR "user_xattr" /* enable extended attributes */ -#define MNTOPT_NOXATTR "nouser_xattr" /* disable extended attributes */ +#define MNTOPT_XATTR "xattr" /* enable extended attributes */ +#define MNTOPT_NOXATTR "noxattr" /* disable extended attributes */ #define MNTOPT_COMMENT "comment" /* comment */ #define MNTOPT_ZFSUTIL "zfsutil" /* called by zfs utility */ diff --git a/lib/libspl/include/sys/sysevent/Makefile.in b/lib/libspl/include/sys/sysevent/Makefile.in index 83ce2b2fa..ed9f563cc 100644 --- a/lib/libspl/include/sys/sysevent/Makefile.in +++ b/lib/libspl/include/sys/sysevent/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libspl/include/util/Makefile.in b/lib/libspl/include/util/Makefile.in index 1339ebc48..2a2a0c16d 100644 --- a/lib/libspl/include/util/Makefile.in +++ b/lib/libspl/include/util/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libunicode/Makefile.in b/lib/libunicode/Makefile.in index 48a710020..6d1ffb432 100644 --- a/lib/libunicode/Makefile.in +++ b/lib/libunicode/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libuutil/Makefile.in b/lib/libuutil/Makefile.in index bd224872d..8678411c8 100644 --- a/lib/libuutil/Makefile.in +++ b/lib/libuutil/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libzfs/Makefile.in b/lib/libzfs/Makefile.in index d73e8eb8b..73ec60585 100644 --- a/lib/libzfs/Makefile.in +++ b/lib/libzfs/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 378bbc7b1..5f8847a93 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -1313,6 +1313,25 @@ zfs_setprop_error(libzfs_handle_t *hdl, zfs_prop_t prop, int err, } } +static boolean_t +zfs_is_namespace_prop(zfs_prop_t prop) +{ + switch (prop) { + + case ZFS_PROP_ATIME: + case ZFS_PROP_DEVICES: + case ZFS_PROP_EXEC: + case ZFS_PROP_SETUID: + case ZFS_PROP_READONLY: + case ZFS_PROP_XATTR: + case ZFS_PROP_NBMAND: + return (B_TRUE); + + default: + return (B_FALSE); + } +} + /* * Given a property name and value, set the property for the given dataset. */ @@ -1408,12 +1427,22 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval) if (do_prefix) ret = changelist_postfix(cl); - /* - * Refresh the statistics so the new property value - * is reflected. - */ - if (ret == 0) + if (ret == 0) { + /* + * Refresh the statistics so the new property + * value is reflected. + */ (void) get_stats(zhp); + + /* + * Remount the filesystem to propagate the change + * if one of the options handled by the generic + * Linux namespace layer has been modified. + */ + if (zfs_is_namespace_prop(prop) && + zfs_is_mounted(zhp, NULL)) + ret = zfs_mount(zhp, MNTOPT_REMOUNT, 0); + } } error: @@ -1530,7 +1559,7 @@ error: * True DSL properties are stored in an nvlist. The following two functions * extract them appropriately. */ -static uint64_t +uint64_t getprop_uint64(zfs_handle_t *zhp, zfs_prop_t prop, char **source) { nvlist_t *nv; diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 1dc58f924..6b70cbbec 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -315,6 +315,52 @@ do_unmount(const char *mntpt, int flags) return (rc ? EINVAL : 0); } +static int +zfs_add_option(zfs_handle_t *zhp, char *options, int len, + zfs_prop_t prop, char *on, char *off) +{ + char *source; + uint64_t value; + + /* Skip adding duplicate default options */ + if ((strstr(options, on) != NULL) || (strstr(options, off) != NULL)) + return (0); + + /* + * zfs_prop_get_int() to not used to ensure our mount options + * are not influenced by the current /etc/mtab contents. + */ + value = getprop_uint64(zhp, prop, &source); + + (void) strlcat(options, ",", len); + (void) strlcat(options, value ? on : off, len); + + return (0); +} + +static int +zfs_add_options(zfs_handle_t *zhp, char *options, int len) +{ + int error = 0; + + error = zfs_add_option(zhp, options, len, + ZFS_PROP_ATIME, MNTOPT_ATIME, MNTOPT_NOATIME); + error = error ? error : zfs_add_option(zhp, options, len, + ZFS_PROP_DEVICES, MNTOPT_DEVICES, MNTOPT_NODEVICES); + error = error ? error : zfs_add_option(zhp, options, len, + ZFS_PROP_EXEC, MNTOPT_EXEC, MNTOPT_NOEXEC); + error = error ? error : zfs_add_option(zhp, options, len, + ZFS_PROP_READONLY, MNTOPT_RO, MNTOPT_RW); + error = error ? error : zfs_add_option(zhp, options, len, + ZFS_PROP_SETUID, MNTOPT_SETUID, MNTOPT_NOSETUID); + error = error ? error : zfs_add_option(zhp, options, len, + ZFS_PROP_XATTR, MNTOPT_XATTR, MNTOPT_NOXATTR); + error = error ? error : zfs_add_option(zhp, options, len, + ZFS_PROP_NBMAND, MNTOPT_NBMAND, MNTOPT_NONBMAND); + + return (error); +} + /* * Mount the given filesystem. */ @@ -325,12 +371,16 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) char mountpoint[ZFS_MAXPROPLEN]; char mntopts[MNT_LINE_MAX]; libzfs_handle_t *hdl = zhp->zfs_hdl; - int rc; + int remount = 0, rc; - if (options == NULL) + if (options == NULL) { (void) strlcpy(mntopts, MNTOPT_DEFAULTS, sizeof (mntopts)); - else + } else { (void) strlcpy(mntopts, options, sizeof (mntopts)); + } + + if (strstr(mntopts, MNTOPT_REMOUNT) != NULL) + remount = 1; /* * If the pool is imported read-only then all mounts must be read-only @@ -338,6 +388,22 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) if (zpool_get_prop_int(zhp->zpool_hdl, ZPOOL_PROP_READONLY, NULL)) (void) strlcat(mntopts, "," MNTOPT_RO, sizeof (mntopts)); + /* + * Append default mount options which apply to the mount point. + * This is done because under Linux (unlike Solaris) multiple mount + * points may reference a single super block. This means that just + * given a super block there is no back reference to update the per + * mount point options. + */ + rc = zfs_add_options(zhp, mntopts, sizeof (mntopts)); + if (rc) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "default options unavailable")); + return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, + dgettext(TEXT_DOMAIN, "cannot mount '%s'"), + mountpoint)); + } + /* * Append zfsutil option so the mount helper allow the mount */ @@ -361,8 +427,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) * Determine if the mountpoint is empty. If so, refuse to perform the * mount. We don't perform this check if 'remount' is specified. */ - if (strstr(mntopts, MNTOPT_REMOUNT) == NULL && - !dir_is_empty(mountpoint)) { + if (!remount && !dir_is_empty(mountpoint)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "directory is not empty")); return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, @@ -403,6 +468,10 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) zhp->zfs_name)); } + /* remove the mounted entry before re-adding on remount */ + if (remount) + libzfs_mnttab_remove(hdl, zhp->zfs_name); + /* add the mounted entry into our cache */ libzfs_mnttab_add(hdl, zfs_get_name(zhp), mountpoint, mntopts); return (0); diff --git a/lib/libzpool/Makefile.in b/lib/libzpool/Makefile.in index 0245bb16a..db27fd5c1 100644 --- a/lib/libzpool/Makefile.in +++ b/lib/libzpool/Makefile.in @@ -63,6 +63,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/man/Makefile.in b/man/Makefile.in index 781ef4721..2353d7e16 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/man/man8/Makefile.in b/man/man8/Makefile.in index 2935d88d4..d153fb515 100644 --- a/man/man8/Makefile.in +++ b/man/man8/Makefile.in @@ -61,6 +61,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/module/zfs/zfs_acl.c b/module/zfs/zfs_acl.c index 0ae749e6b..40f792b6c 100644 --- a/module/zfs/zfs_acl.c +++ b/module/zfs/zfs_acl.c @@ -2136,8 +2136,7 @@ top: static int zfs_zaccess_dataset_check(znode_t *zp, uint32_t v4_mode) { - if ((v4_mode & WRITE_MASK) && - (ZTOZSB(zp)->z_vfs->mnt_flags & MNT_READONLY) && + if ((v4_mode & WRITE_MASK) && (zfs_is_readonly(ZTOZSB(zp))) && (!S_ISDEV(ZTOI(zp)->i_mode) || (S_ISDEV(ZTOI(zp)->i_mode) && (v4_mode & WRITE_MASK_ATTRS)))) { return (EROFS); diff --git a/module/zfs/zfs_dir.c b/module/zfs/zfs_dir.c index 0df7cc1f8..47550ec63 100644 --- a/module/zfs/zfs_dir.c +++ b/module/zfs/zfs_dir.c @@ -1045,7 +1045,7 @@ top: return (ENOENT); } - if (zsb->z_vfs->mnt_flags & MNT_READONLY) { + if (zfs_is_readonly(zsb)) { zfs_dirent_unlock(dl); return (EROFS); } diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 39c60915e..b50f02383 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -1107,8 +1107,9 @@ get_zfs_sb(const char *dsname, zfs_sb_t **zsbp) mutex_enter(&os->os_user_ptr_lock); *zsbp = dmu_objset_get_user(os); - if (*zsbp) { - mntget((*zsbp)->z_vfs); + if (*zsbp && (*zsbp)->z_sb) { + if (atomic_inc_not_zero(&((*zsbp)->z_sb->s_active))) + error = ESRCH; } else { error = ESRCH; } @@ -1119,7 +1120,7 @@ get_zfs_sb(const char *dsname, zfs_sb_t **zsbp) /* * Find a zfs_sb_t for a mounted filesystem, or create our own, in which - * case its z_vfs will be NULL, and it will be opened as the owner. + * case its z_sb will be NULL, and it will be opened as the owner. */ static int zfs_sb_hold(const char *name, void *tag, zfs_sb_t **zsbp, boolean_t writer) @@ -1149,8 +1150,8 @@ zfs_sb_rele(zfs_sb_t *zsb, void *tag) { rrw_exit(&zsb->z_teardown_lock, tag); - if (zsb->z_vfs) { - mntput(zsb->z_vfs); + if (zsb->z_sb) { + deactivate_super(zsb->z_sb); } else { dmu_objset_disown(zsb->z_os, zsb); zfs_sb_free(zsb); @@ -3239,7 +3240,7 @@ zfs_ioc_rollback(zfs_cmd_t *zc) resume_err = zfs_resume_fs(zsb, zc->zc_name); error = error ? error : resume_err; } - mntput(zsb->z_vfs); + deactivate_super(zsb->z_sb); } else { if (dsl_dataset_tryown(ds, B_FALSE, FTAG)) { error = dsl_dataset_clone_swap(clone, ds, B_TRUE); @@ -3724,7 +3725,7 @@ zfs_ioc_recv(zfs_cmd_t *zc) if (error == 0) error = zfs_resume_fs(zsb, tofs); error = error ? error : end_err; - mntput(zsb->z_vfs); + deactivate_super(zsb->z_sb); } else { error = dmu_recv_end(&drc); } @@ -4137,7 +4138,7 @@ zfs_ioc_userspace_upgrade(zfs_cmd_t *zc) } if (error == 0) error = dmu_objset_userspace_upgrade(zsb->z_os); - mntput(zsb->z_vfs); + deactivate_super(zsb->z_sb); } else { /* XXX kind of reading contents without owning */ error = dmu_objset_hold(zc->zc_name, FTAG, &os); diff --git a/module/zfs/zfs_vfsops.c b/module/zfs/zfs_vfsops.c index 257563887..e0987e919 100644 --- a/module/zfs/zfs_vfsops.c +++ b/module/zfs/zfs_vfsops.c @@ -122,22 +122,17 @@ zfs_sync(struct super_block *sb, int wait, cred_t *cr) } EXPORT_SYMBOL(zfs_sync); +boolean_t +zfs_is_readonly(zfs_sb_t *zsb) +{ + return (!!(zsb->z_sb->s_flags & MS_RDONLY)); +} +EXPORT_SYMBOL(zfs_is_readonly); + static void atime_changed_cb(void *arg, uint64_t newval) { - zfs_sb_t *zsb = arg; - struct super_block *sb = zsb->z_sb; - struct vfsmount *vfs = zsb->z_vfs; - - if (newval == TRUE) { - vfs->mnt_flags &= ~MNT_NOATIME; - sb->s_flags &= ~MS_NOATIME; - zsb->z_atime = TRUE; - } else { - vfs->mnt_flags |= MNT_NOATIME; - sb->s_flags |= MS_NOATIME; - zsb->z_atime = FALSE; - } + ((zfs_sb_t *)arg)->z_atime = newval; } static void @@ -145,11 +140,10 @@ xattr_changed_cb(void *arg, uint64_t newval) { zfs_sb_t *zsb = arg; - if (newval == TRUE) { - zsb->z_flags |= ZSB_XATTR_USER; - } else { - zsb->z_flags &= ~ZSB_XATTR_USER; - } + if (newval == TRUE) + zsb->z_flags |= ZSB_XATTR; + else + zsb->z_flags &= ~ZSB_XATTR; } static void @@ -169,84 +163,44 @@ readonly_changed_cb(void *arg, uint64_t newval) { zfs_sb_t *zsb = arg; struct super_block *sb = zsb->z_sb; - struct vfsmount *vfs = zsb->z_vfs; - if (newval) { - vfs->mnt_flags |= MNT_READONLY; + if (sb == NULL) + return; + + if (newval) sb->s_flags |= MS_RDONLY; - } else { - vfs->mnt_flags &= ~MNT_READONLY; + else sb->s_flags &= ~MS_RDONLY; - } } static void devices_changed_cb(void *arg, uint64_t newval) { - zfs_sb_t *zsb = arg; - struct super_block *sb = zsb->z_sb; - struct vfsmount *vfs = zsb->z_vfs; - - if (newval == FALSE) { - vfs->mnt_flags |= MNT_NODEV; - sb->s_flags |= MS_NODEV; - } else { - vfs->mnt_flags &= ~MNT_NODEV; - sb->s_flags &= ~MS_NODEV; - } } static void setuid_changed_cb(void *arg, uint64_t newval) { - zfs_sb_t *zsb = arg; - struct super_block *sb = zsb->z_sb; - struct vfsmount *vfs = zsb->z_vfs; - - if (newval == FALSE) { - vfs->mnt_flags |= MNT_NOSUID; - sb->s_flags |= MS_NOSUID; - } else { - vfs->mnt_flags &= ~MNT_NOSUID; - sb->s_flags &= ~MS_NOSUID; - } } static void exec_changed_cb(void *arg, uint64_t newval) { - zfs_sb_t *zsb = arg; - struct super_block *sb = zsb->z_sb; - struct vfsmount *vfs = zsb->z_vfs; - - if (newval == FALSE) { - vfs->mnt_flags |= MNT_NOEXEC; - sb->s_flags |= MS_NOEXEC; - } else { - vfs->mnt_flags &= ~MNT_NOEXEC; - sb->s_flags &= ~MS_NOEXEC; - } } -/* - * The nbmand mount option can be changed at mount time. - * We can't allow it to be toggled on live file systems or incorrect - * behavior may be seen from cifs clients - * - * This property isn't registered via dsl_prop_register(), but this callback - * will be called when a file system is first mounted - */ static void nbmand_changed_cb(void *arg, uint64_t newval) { zfs_sb_t *zsb = arg; struct super_block *sb = zsb->z_sb; - if (newval == TRUE) { + if (sb == NULL) + return; + + if (newval == TRUE) sb->s_flags |= MS_MANDLOCK; - } else { + else sb->s_flags &= ~MS_MANDLOCK; - } } static void @@ -270,58 +224,12 @@ acl_inherit_changed_cb(void *arg, uint64_t newval) int zfs_register_callbacks(zfs_sb_t *zsb) { - struct vfsmount *vfsp = zsb->z_vfs; struct dsl_dataset *ds = NULL; objset_t *os = zsb->z_os; - uint64_t nbmand; - boolean_t readonly = B_FALSE; - boolean_t setuid = B_TRUE; - boolean_t exec = B_TRUE; - boolean_t devices = B_TRUE; - boolean_t xattr = B_TRUE; - boolean_t atime = B_TRUE; - char osname[MAXNAMELEN]; int error = 0; - /* - * While Linux allows multiple vfs mounts per super block we have - * limited it artificially to one in zfs_fill_super. Thus it is - * safe for us to modify the vfs mount fails through the callbacks. - */ - if ((vfsp->mnt_flags & MNT_READONLY) || - !spa_writeable(dmu_objset_spa(os))) - readonly = B_TRUE; - - if (vfsp->mnt_flags & MNT_NOSUID) { - devices = B_FALSE; - setuid = B_FALSE; - } else { - if (vfsp->mnt_flags & MNT_NODEV) - devices = B_FALSE; - } - - if (vfsp->mnt_flags & MNT_NOEXEC) - exec = B_FALSE; - - if (vfsp->mnt_flags & MNT_NOATIME) - atime = B_FALSE; - - /* - * nbmand is a special property which may only be changed at - * mount time. Unfortunately, Linux does not have a VFS mount - * flag instead this is a super block flag. So setting this - * option at mount time will have to wait until we can parse - * the mount option string. For now we rely on the nbmand - * value stored with the object set. Additional mount option - * string to be handled: - * - * case: sensitive|insensitive|mixed - * zerocopy: on|off - */ - - dmu_objset_name(os, osname); - if ((error = dsl_prop_get_integer(osname, "nbmand", &nbmand, NULL))) - return (error); + if (zfs_is_readonly(zsb) || !spa_writeable(dmu_objset_spa(os))) + readonly_changed_cb(zsb, B_TRUE); /* * Register property callbacks. @@ -351,20 +259,11 @@ zfs_register_callbacks(zfs_sb_t *zsb) "aclinherit", acl_inherit_changed_cb, zsb); error = error ? error : dsl_prop_register(ds, "vscan", vscan_changed_cb, zsb); + error = error ? error : dsl_prop_register(ds, + "nbmand", nbmand_changed_cb, zsb); if (error) goto unregister; - /* - * Invoke our callbacks to set required flags. - */ - readonly_changed_cb(zsb, readonly); - setuid_changed_cb(zsb, setuid); - exec_changed_cb(zsb, exec); - devices_changed_cb(zsb, devices); - xattr_changed_cb(zsb, xattr); - atime_changed_cb(zsb, atime); - nbmand_changed_cb(zsb, nbmand); - return (0); unregister: @@ -384,6 +283,7 @@ unregister: (void) dsl_prop_unregister(ds, "aclinherit", acl_inherit_changed_cb, zsb); (void) dsl_prop_unregister(ds, "vscan", vscan_changed_cb, zsb); + (void) dsl_prop_unregister(ds, "nbmand", nbmand_changed_cb, zsb); return (error); } @@ -694,7 +594,7 @@ zfs_sb_create(const char *osname, zfs_sb_t **zsbp) * Should probably make this a kmem cache, shuffle fields, * and just bzero up to z_hold_mtx[]. */ - zsb->z_vfs = NULL; + zsb->z_sb = NULL; zsb->z_parent = zsb; zsb->z_max_blksz = SPA_MAXBLOCKSIZE; zsb->z_show_ctldir = ZFS_SNAPDIR_VISIBLE; @@ -840,9 +740,9 @@ zfs_sb_setup(zfs_sb_t *zsb, boolean_t mounting) * During replay we remove the read only flag to * allow replays to succeed. */ - readonly = zsb->z_vfs->mnt_flags & MNT_READONLY; + readonly = zfs_is_readonly(zsb); if (readonly != 0) - zsb->z_vfs->mnt_flags &= ~MNT_READONLY; + readonly_changed_cb(zsb, B_FALSE); else zfs_unlinked_drain(zsb); @@ -883,7 +783,10 @@ zfs_sb_setup(zfs_sb_t *zsb, boolean_t mounting) zsb->z_replay = B_FALSE; } } - zsb->z_vfs->mnt_flags |= readonly; /* restore readonly bit */ + + /* restore readonly bit */ + if (readonly != 0) + readonly_changed_cb(zsb, B_TRUE); } return (0); @@ -954,6 +857,9 @@ zfs_unregister_callbacks(zfs_sb_t *zsb) VERIFY(dsl_prop_unregister(ds, "vscan", vscan_changed_cb, zsb) == 0); + + VERIFY(dsl_prop_unregister(ds, "nbmand", + nbmand_changed_cb, zsb) == 0); } } EXPORT_SYMBOL(zfs_unregister_callbacks); @@ -1164,7 +1070,7 @@ zfsvfs_teardown(zfs_sb_t *zsb, boolean_t unmounting) * Evict cached data */ if (dmu_objset_is_dirty_anywhere(zsb->z_os)) - if (!(zsb->z_vfs->mnt_flags & MNT_READONLY)) + if (!zfs_is_readonly(zsb)) txg_wait_synced(dmu_objset_pool(zsb->z_os), 0); (void) dmu_objset_evict_dbufs(zsb->z_os); @@ -1181,17 +1087,6 @@ zfs_domount(struct super_block *sb, void *data, int silent) uint64_t recordsize; int error; - /* - * Linux allows multiple vfs mounts per super block. However, the - * zfs_sb_t only contains a pointer for a single vfs mount. This - * back reference in the long term could be extended to a list of - * vfs mounts if a hook were added to the kernel to notify us when - * a vfsmount is destroyed. Until then we must limit the number - * of mounts per super block to one. - */ - if (atomic_read(&sb->s_active) > 1) - return (EBUSY); - error = zfs_sb_create(osname, &zsb); if (error) return (error); @@ -1201,7 +1096,6 @@ zfs_domount(struct super_block *sb, void *data, int silent) goto out; zsb->z_sb = sb; - zsb->z_vfs = zmd->z_vfs; sb->s_fs_info = zsb; sb->s_magic = ZFS_SUPER_MAGIC; sb->s_maxbytes = MAX_LFS_FILESIZE; @@ -1298,47 +1192,18 @@ EXPORT_SYMBOL(zfs_umount); int zfs_remount(struct super_block *sb, int *flags, char *data) { - zfs_sb_t *zsb = sb->s_fs_info; - boolean_t readonly = B_FALSE; - boolean_t setuid = B_TRUE; - boolean_t exec = B_TRUE; - boolean_t devices = B_TRUE; - boolean_t atime = B_TRUE; - - if (*flags & MS_RDONLY) - readonly = B_TRUE; - - if (*flags & MS_NOSUID) { - devices = B_FALSE; - setuid = B_FALSE; - } else { - if (*flags & MS_NODEV) - devices = B_FALSE; - } - - if (*flags & MS_NOEXEC) - exec = B_FALSE; - - if (*flags & MS_NOATIME) - atime = B_FALSE; - /* - * Invoke our callbacks to set required flags. + * All namespace flags (MNT_*) and super block flags (MS_*) will + * be handled by the Linux VFS. Only handle custom options here. */ - readonly_changed_cb(zsb, readonly); - setuid_changed_cb(zsb, setuid); - exec_changed_cb(zsb, exec); - devices_changed_cb(zsb, devices); - atime_changed_cb(zsb, atime); - return (0); } EXPORT_SYMBOL(zfs_remount); int -zfs_vget(struct vfsmount *vfsp, struct inode **ipp, fid_t *fidp) +zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp) { - zfs_sb_t *zsb = VTOZSB(vfsp); + zfs_sb_t *zsb = sb->s_fs_info; znode_t *zp; uint64_t object = 0; uint64_t fid_gen = 0; diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 213971310..c32b2a39f 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -1122,7 +1122,7 @@ zfs_lookup(struct inode *dip, char *nm, struct inode **ipp, int flags, /* * If the xattr property is off, refuse the lookup request. */ - if (!(zsb->z_flags & ZSB_XATTR_USER)) { + if (!(zsb->z_flags & ZSB_XATTR)) { ZFS_EXIT(zsb); return (EINVAL); } @@ -2420,7 +2420,7 @@ top: aclp = NULL; /* Can this be moved to before the top label? */ - if (zsb->z_vfs->mnt_flags & MNT_READONLY) { + if (zfs_is_readonly(zsb)) { err = EROFS; goto out3; } diff --git a/module/zfs/zpl_export.c b/module/zfs/zpl_export.c index a38955600..4fe998437 100644 --- a/module/zfs/zpl_export.c +++ b/module/zfs/zpl_export.c @@ -73,8 +73,6 @@ static struct dentry * zpl_fh_to_dentry(struct super_block *sb, struct fid *fh, int fh_len, int fh_type) { - zfs_sb_t *zsb = sb->s_fs_info; - struct vfsmount *vfs = zsb->z_vfs; fid_t *fid = (fid_t *)fh; struct inode *ip; int len_bytes, rc; @@ -86,7 +84,7 @@ zpl_fh_to_dentry(struct super_block *sb, struct fid *fh, len_bytes < offsetof(fid_t, fid_data) + fid->fid_len) return ERR_PTR(-EINVAL); - rc = zfs_vget(vfs, &ip, fid); + rc = zfs_vget(sb, &ip, fid); if (rc != 0) return ERR_PTR(-rc); diff --git a/module/zfs/zpl_super.c b/module/zfs/zpl_super.c index 304f708c3..650e9c0d3 100644 --- a/module/zfs/zpl_super.c +++ b/module/zfs/zpl_super.c @@ -150,8 +150,7 @@ zpl_show_options(struct seq_file *seq, struct vfsmount *vfsp) * MNT_NOSUID, MNT_NODEV, MNT_NOEXEC, MNT_NOATIME, MNT_READONLY */ - if (zsb->z_flags & ZSB_XATTR_USER) - seq_printf(seq, ",%s", "xattr"); + seq_printf(seq, ",%s", zsb->z_flags & ZSB_XATTR ? "xattr" : "noxattr"); return (0); } @@ -167,14 +166,25 @@ zpl_fill_super(struct super_block *sb, void *data, int silent) return (error); } +#ifdef HAVE_MOUNT_NODEV +static struct dentry * +zpl_mount(struct file_system_type *fs_type, int flags, + const char *osname, void *data) +{ + zpl_mount_data_t zmd = { osname, data }; + + return mount_nodev(fs_type, flags, &zmd, zpl_fill_super); +} +#else static int zpl_get_sb(struct file_system_type *fs_type, int flags, const char *osname, void *data, struct vfsmount *mnt) { - zpl_mount_data_t zmd = { osname, data, mnt }; + zpl_mount_data_t zmd = { osname, data }; return get_sb_nodev(fs_type, flags, &zmd, zpl_fill_super, mnt); } +#endif /* HAVE_MOUNT_NODEV */ static void zpl_kill_sb(struct super_block *sb) @@ -213,6 +223,10 @@ const struct super_operations zpl_super_operations = { struct file_system_type zpl_fs_type = { .owner = THIS_MODULE, .name = ZFS_DRIVER, +#ifdef HAVE_MOUNT_NODEV + .mount = zpl_mount, +#else .get_sb = zpl_get_sb, +#endif /* HAVE_MOUNT_NODEV */ .kill_sb = zpl_kill_sb, }; diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c index f274407e5..cf52e720d 100644 --- a/module/zfs/zpl_xattr.c +++ b/module/zfs/zpl_xattr.c @@ -83,7 +83,7 @@ zpl_xattr_filldir(void *arg, const char *name, int name_len, xattr_filldir_t *xf = arg; if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) - if (!(ITOZSB(xf->inode)->z_flags & ZSB_XATTR_USER)) + if (!(ITOZSB(xf->inode)->z_flags & ZSB_XATTR)) return (0); if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) @@ -281,7 +281,7 @@ __zpl_xattr_user_get(struct inode *ip, const char *name, if (strcmp(name, "") == 0) return -EINVAL; - if (!(ITOZSB(ip)->z_flags & ZSB_XATTR_USER)) + if (!(ITOZSB(ip)->z_flags & ZSB_XATTR)) return -EOPNOTSUPP; xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name); @@ -302,7 +302,7 @@ __zpl_xattr_user_set(struct inode *ip, const char *name, if (strcmp(name, "") == 0) return -EINVAL; - if (!(ITOZSB(ip)->z_flags & ZSB_XATTR_USER)) + if (!(ITOZSB(ip)->z_flags & ZSB_XATTR)) return -EOPNOTSUPP; xattr_name = kmem_asprintf("%s%s", XATTR_USER_PREFIX, name); diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 1770e23cf..d457890e3 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -62,6 +62,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/scripts/zpios-profile/Makefile.in b/scripts/zpios-profile/Makefile.in index 725ba10e4..d1aa099b7 100644 --- a/scripts/zpios-profile/Makefile.in +++ b/scripts/zpios-profile/Makefile.in @@ -62,6 +62,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/scripts/zpios-test/Makefile.in b/scripts/zpios-test/Makefile.in index 4394d57f9..02aa93d52 100644 --- a/scripts/zpios-test/Makefile.in +++ b/scripts/zpios-test/Makefile.in @@ -62,6 +62,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/scripts/zpool-config/Makefile.in b/scripts/zpool-config/Makefile.in index 4b6f7b80e..afc7de76e 100644 --- a/scripts/zpool-config/Makefile.in +++ b/scripts/zpool-config/Makefile.in @@ -62,6 +62,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/scripts/zpool-layout/Makefile.in b/scripts/zpool-layout/Makefile.in index 8cff17232..4cfbc755a 100644 --- a/scripts/zpool-layout/Makefile.in +++ b/scripts/zpool-layout/Makefile.in @@ -62,6 +62,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/kernel-insert-inode-locked.m4 \ $(top_srcdir)/config/kernel-invalidate-bdev-args.m4 \ $(top_srcdir)/config/kernel-kobj-name-len.m4 \ + $(top_srcdir)/config/kernel-mount-nodev.m4 \ $(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \ $(top_srcdir)/config/kernel-rq-for-each_segment.m4 \ $(top_srcdir)/config/kernel-rq-is_sync.m4 \ diff --git a/zfs_config.h.in b/zfs_config.h.in index ee2f7941e..d244ac383 100644 --- a/zfs_config.h.in +++ b/zfs_config.h.in @@ -126,6 +126,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H +/* mount_nodev() is available */ +#undef HAVE_MOUNT_NODEV + /* open_bdev_exclusive() is available */ #undef HAVE_OPEN_BDEV_EXCLUSIVE