Commit 01d0aa14 authored by Colin Ian King's avatar Colin Ian King Committed by Stefan Bader

UBUNTU: SAUCE: Allow mounting datasets more than once (LP: #1759848)

BugLink: https://bugs.launchpad.net/bugs/1759848

Currently mounting an already mounted zfs dataset results in an
error, whereas it is typically allowed with other filesystems.
This causes some bad interactions with mount namespaces. Take
this sequence for example:

 - Create a dataset
 - Create a snapshot of the dataset
 - Create a clone of the snapshot
 - Create a new mount namespace
 - Rename the original dataset

The rename results in unmounting and remounting the clone in the
original mount namespace, however the remount fails because the
dataset is still mounted in the new mount namespace. (Note that
this means the mount in the new mount namespace is never being
unmounted, so perhaps the unmount/remount of the clone isn't
actually necessary.)

The problem here is a result of the way mounting is implemented
in the kernel module. Since it is not mounting block devices it
uses mount_nodev() instead of the usual mount_bdev(). However,
mount_nodev() is written for filesystems for which each mount is
a new instance (i.e. a new super block), and zfs should be able
to detect when a mount request can be satisfied using an existing
super block.

Change zpl_mount() to call sget() directly with it's own test
callback. Passing the objset_t object as the fs data allows
checking if a superblock already exists for the dataset, and in
that case we just need to return a new reference for the sb's
root dentry.

[ Sync'd from zfsutils-linux, from a patch by Seth Forshee and
  backported to zfs 0.6.5.6. Note that this also contains
  some zfstutils changes between 0.6.5.6-0ubuntu20 and
  0.6.5.6-0ubuntu24 which go also sync'd into this fix, which
  is expected part of the zfs sync'ing ]
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent bb6f99c1
......@@ -2,7 +2,7 @@ Meta: 1
Name: zfs
Branch: 1.0
Version: 0.6.5.6
Release: 0ubuntu20
Release: 0ubuntu24
Release-Tags: relext
License: CDDL
Author: OpenZFS on Linux
......@@ -140,6 +140,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -155,7 +156,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -1245,6 +1245,7 @@ m4_include([config/kernel-fallocate.m4])
m4_include([config/kernel-file-inode.m4])
m4_include([config/kernel-fmode-t.m4])
m4_include([config/kernel-follow-down-one.m4])
m4_include([config/kernel-fst-mount.m4])
m4_include([config/kernel-fsync.m4])
m4_include([config/kernel-generic_io_acct.m4])
m4_include([config/kernel-get-disk-ro.m4])
......@@ -1260,7 +1261,6 @@ m4_include([config/kernel-lookup-nameidata.m4])
m4_include([config/kernel-lseek-execute.m4])
m4_include([config/kernel-mk-request-fn.m4])
m4_include([config/kernel-mkdir-umode-t.m4])
m4_include([config/kernel-mount-nodev.m4])
m4_include([config/kernel-open-bdev-exclusive.m4])
m4_include([config/kernel-put-link.m4])
m4_include([config/kernel-security-inode-init.m4])
......
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 #
AC_DEFUN([ZFS_AC_KERNEL_FST_MOUNT], [
AC_MSG_CHECKING([whether fst->mount() exists])
ZFS_LINUX_TRY_COMPILE([
#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_MSG_RESULT(yes)
AC_DEFINE(HAVE_FST_MOUNT, 1, [fst->mount() exists])
],[
AC_MSG_RESULT(no)
])
])
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],
[AC_MSG_CHECKING([whether mount_nodev() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
mount_nodev(NULL, 0, NULL, NULL);
], [mount_nodev], [fs/super.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_MOUNT_NODEV, 1, [mount_nodev() is available])
], [
AC_MSG_RESULT(no)
])
])
......@@ -77,7 +77,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_TRUNCATE_SETSIZE
ZFS_AC_KERNEL_6ARGS_SECURITY_INODE_INIT_SECURITY
ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY
ZFS_AC_KERNEL_MOUNT_NODEV
ZFS_AC_KERNEL_FST_MOUNT
ZFS_AC_KERNEL_SHRINK
ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD
......
......@@ -21202,9 +21202,9 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mount_nodev() is available" >&5
$as_echo_n "checking whether mount_nodev() is available... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fst->mount() exists" >&5
$as_echo_n "checking whether fst->mount() exists... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.c
......@@ -21212,11 +21212,21 @@ cat confdefs.h - <<_ACEOF >conftest.c
#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,
};
int
main (void)
{
mount_nodev(NULL, 0, NULL, NULL);
;
return 0;
......@@ -21246,64 +21256,25 @@ _ACEOF
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
rc=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
rc=1
fi
rm -Rf build
if test $rc -ne 0; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define HAVE_FST_MOUNT 1" >>confdefs.h
else
if test "x$enable_linux_builtin" != xyes; then
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 :
rc=1
else :
rc=0
fi
else :
rc=0
fi
fi
if test $rc -ne 0; then :
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
else :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_MOUNT_NODEV 1" >>confdefs.h
fi
rm -Rf build
fi
fi
......@@ -30596,9 +30567,9 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mount_nodev() is available" >&5
$as_echo_n "checking whether mount_nodev() is available... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fst->mount() exists" >&5
$as_echo_n "checking whether fst->mount() exists... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.c
......@@ -30606,11 +30577,21 @@ cat confdefs.h - <<_ACEOF >conftest.c
#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,
};
int
main (void)
{
mount_nodev(NULL, 0, NULL, NULL);
;
return 0;
......@@ -30640,64 +30621,25 @@ _ACEOF
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
rc=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
rc=1
fi
rm -Rf build
if test $rc -ne 0; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "#define HAVE_FST_MOUNT 1" >>confdefs.h
else
if test "x$enable_linux_builtin" != xyes; then
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 :
rc=1
else :
rc=0
fi
else :
rc=0
fi
fi
if test $rc -ne 0; then :
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
else :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_MOUNT_NODEV 1" >>confdefs.h
fi
rm -Rf build
fi
fi
......
......@@ -129,6 +129,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -144,7 +145,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -129,6 +129,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -144,7 +145,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -111,6 +111,30 @@ zpl_bdi_setup_and_register(struct backing_dev_info *bdi, char *name)
}
#endif
/*
* 4.14 adds SB_* flag definitions, define them to MS_* equivalents
* if not set.
*/
#ifndef SB_RDONLY
#define SB_RDONLY MS_RDONLY
#endif
#ifndef SB_SILENT
#define SB_SILENT MS_SILENT
#endif
#ifndef SB_ACTIVE
#define SB_ACTIVE MS_ACTIVE
#endif
#ifndef SB_POSIXACL
#define SB_POSIXACL MS_POSIXACL
#endif
#ifndef SB_MANDLOCK
#define SB_MANDLOCK MS_MANDLOCK
#endif
/*
* 2.6.38 API change,
* LOOKUP_RCU flag introduced to distinguish rcu-walk from ref-walk cases.
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -130,6 +130,7 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-file-inode.m4 \
$(top_srcdir)/config/kernel-fmode-t.m4 \
$(top_srcdir)/config/kernel-follow-down-one.m4 \
$(top_srcdir)/config/kernel-fst-mount.m4 \
$(top_srcdir)/config/kernel-fsync.m4 \
$(top_srcdir)/config/kernel-generic_io_acct.m4 \
$(top_srcdir)/config/kernel-get-disk-ro.m4 \
......@@ -145,7 +146,6 @@ am__aclocal_m4_deps = $(top_srcdir)/config/always-no-bool-compare.m4 \
$(top_srcdir)/config/kernel-lseek-execute.m4 \
$(top_srcdir)/config/kernel-mk-request-fn.m4 \
$(top_srcdir)/config/kernel-mkdir-umode-t.m4 \
$(top_srcdir)/config/kernel-mount-nodev.m4 \
$(top_srcdir)/config/kernel-open-bdev-exclusive.m4 \
$(top_srcdir)/config/kernel-put-link.m4 \
$(top_srcdir)/config/kernel-security-inode-init.m4 \
......
......@@ -443,12 +443,56 @@ zpl_fill_super(struct super_block *sb, void *data, int silent)
return (error);
}
#ifdef HAVE_MOUNT_NODEV
static int
zpl_test_super(struct super_block *s, void *data)
{
zfs_sb_t *zsb = s->s_fs_info;
objset_t *os = data;
if (zsb == NULL)
return (0);
return (os == zsb->z_os);
}
static struct super_block *
zpl_mount_impl(struct file_system_type *fs_type, int flags, zfs_mntopts_t *zmo)
{
struct super_block *s;
objset_t *os;
int err;
err = dmu_objset_hold(zmo->z_osname, FTAG, &os);
if (err)
return (ERR_PTR(-err));
s = zpl_sget(fs_type, zpl_test_super, set_anon_super, flags, os);
dmu_objset_rele(os, FTAG);
if (IS_ERR(s))
return (ERR_CAST(s));
if (s->s_root == NULL) {
err = zpl_fill_super(s, zmo, flags & SB_SILENT ? 1 : 0);
if (err) {
deactivate_locked_super(s);
return (ERR_PTR(err));
}
s->s_flags |= SB_ACTIVE;
} else if ((flags ^ s->s_flags) & SB_RDONLY) {
deactivate_locked_super(s);
return (ERR_PTR(-EBUSY));
}
return (s);
}
#ifdef HAVE_FST_MOUNT
static struct dentry *
zpl_mount(struct file_system_type *fs_type, int flags,
const char *osname, void *data)
{
zfs_mntopts_t *zmo = zfs_mntopts_alloc();
struct super_block *sb;
int error;
error = zpl_parse_options((char *)osname, (char *)data, zmo, B_FALSE);
......@@ -456,8 +500,11 @@ zpl_mount(struct file_system_type *fs_type, int flags,
zfs_mntopts_free(zmo);
return (ERR_PTR(error));
}
sb = zpl_mount_impl(fs_type, flags, zmo);
if (IS_ERR(sb))
return (ERR_CAST(sb));
return (mount_nodev(fs_type, flags, zmo, zpl_fill_super));
return (dget(sb->s_root));
}
#else
static int
......@@ -465,6 +512,7 @@ zpl_get_sb(struct file_system_type *fs_type, int flags,
const char *osname, void *data, struct vfsmount *mnt)
{
zfs_mntopts_t *zmo = zfs_mntopts_alloc();
struct super_block *sb;
int error;
error = zpl_parse_options((char *)osname, (char *)data, zmo, B_FALSE);
......@@ -472,10 +520,15 @@ zpl_get_sb(struct file_system_type *fs_type, int flags,
zfs_mntopts_free(zmo);
return (error);
}
sb = zpl_mount_impl(fs_type, flags, zmo);
if (IS_ERR(sb))
return (ERR_CAST(sb));
(void) simple_set_mnt(mnt, sb);
return (get_sb_nodev(fs_type, flags, zmo, zpl_fill_super, mnt));
return (0);
}
#endif /* HAVE_MOUNT_NODEV */
#endif /* HAVE_FST_MOUNT */
static void
zpl_kill_sb(struct super_block *sb)
......@@ -542,10 +595,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
#ifdef HAVE_FST_MOUNT
.mount = zpl_mount,
#else
.get_sb = zpl_get_sb,
#endif /* HAVE_MOUNT_NODEV */
#endif /* HAVE_FST_MOUNT */
.kill_sb = zpl_kill_sb,
};
......@@ -162,6 +162,9 @@
/* sops->free_cached_objects() exists */
#undef HAVE_FREE_CACHED_OBJECTS
/* fst->mount() exists */
#undef HAVE_FST_MOUNT
/* fops->fsync() with range */
#undef HAVE_FSYNC_RANGE
......@@ -252,9 +255,6 @@
/* Define to 1 if you have the `mlockall' function. */
#undef HAVE_MLOCKALL
/* mount_nodev() is available */
#undef HAVE_MOUNT_NODEV
/* sops->nr_cached_objects() exists */
#undef HAVE_NR_CACHED_OBJECTS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment