]> git.proxmox.com Git - mirror_zfs.git/commitdiff
zpool import should honor overlay property
authorNed Bass <bass6@llnl.gov>
Thu, 26 Mar 2015 19:10:26 +0000 (12:10 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 27 Mar 2015 21:46:58 +0000 (14:46 -0700)
Make the 'zpool import' command honor the overlay property to allow
filesystems to be mounted on a non-empty directory. As it stands now
this property is only checked by the 'zfs mount' command.  Move the
check into 'zfs_mount()` in libzpool so the property is honored for all
callers.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3227

cmd/zfs/zfs_main.c
lib/libzfs/libzfs_mount.c

index 83f02666d24761366d1fa89711d4ba29fccf0fc8..84073435e2d769fa1c20899a21eec32ec150ebcf 100644 (file)
@@ -5641,7 +5641,6 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
        char mountpoint[ZFS_MAXPROPLEN];
        char shareopts[ZFS_MAXPROPLEN];
        char smbshareopts[ZFS_MAXPROPLEN];
-       char overlay[ZFS_MAXPROPLEN];
        const char *cmdname = op == OP_SHARE ? "share" : "mount";
        struct mnttab mnt;
        uint64_t zoned, canmount;
@@ -5748,19 +5747,6 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
                return (0);
        }
 
-       /*
-        * Overlay mounts are disabled by default but may be enabled
-        * via the 'overlay' property or the 'zfs mount -O' option.
-        */
-       if (!(flags & MS_OVERLAY)) {
-               if (zfs_prop_get(zhp, ZFS_PROP_OVERLAY, overlay,
-                           sizeof (overlay), NULL, NULL, 0, B_FALSE) == 0) {
-                       if (strcmp(overlay, "on") == 0) {
-                               flags |= MS_OVERLAY;
-                       }
-               }
-       }
-
        /*
         * At this point, we have verified that the mountpoint and/or
         * shareopts are appropriate for auto management. If the
index ac3b6822608ce1f2dd06d0bfed812eafe8311f01..0e3332e0e3ed6c017e6f2c5f3c8b1be10e309792 100644 (file)
@@ -388,6 +388,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
        struct stat buf;
        char mountpoint[ZFS_MAXPROPLEN];
        char mntopts[MNT_LINE_MAX];
+       char overlay[ZFS_MAXPROPLEN];
        libzfs_handle_t *hdl = zhp->zfs_hdl;
        int remount = 0, rc;
 
@@ -441,6 +442,19 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags)
                }
        }
 
+       /*
+        * Overlay mounts are disabled by default but may be enabled
+        * via the 'overlay' property or the 'zfs mount -O' option.
+        */
+       if (!(flags & MS_OVERLAY)) {
+               if (zfs_prop_get(zhp, ZFS_PROP_OVERLAY, overlay,
+                           sizeof (overlay), NULL, NULL, 0, B_FALSE) == 0) {
+                       if (strcmp(overlay, "on") == 0) {
+                               flags |= MS_OVERLAY;
+                       }
+               }
+       }
+
        /*
         * Determine if the mountpoint is empty.  If so, refuse to perform the
         * mount.  We don't perform this check if 'remount' is