• Colin Ian King's avatar
    UBUNTU: SAUCE: Allow mounting datasets more than once (LP: #1759848) · 01d0aa14
    Colin Ian King authored
    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>
    01d0aa14
zpl_super.c 13.5 KB