ZFS snapdir readability (Crosspost)
Alan Somers
asomers at freebsd.org
Thu Nov 21 15:08:42 UTC 2019
On Thu, Nov 21, 2019 at 8:01 AM Borja Marcos <borjam at sarenet.es> wrote:
>
>
> > On 21 Nov 2019, at 15:57, Borja Marcos <borjam at sarenet.es> wrote:
> >
> > ZFS originally didn’t offer any mechanism to mount snapshots explicitly.
> Except by cloning.
>
> Hmm. Looking at
> https://github.com/zfsonfreebsd/ZoF/blob/projects/zfsbsd/cmd/mount_zfs/mount_zfs.c
>
> snippet 1
> ———————
>
> /* try to open the dataset to access the mount point */
> if ((zhp = zfs_open(g_zfs, dataset,
> ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT)) == NULL) {
> (void) fprintf(stderr, gettext("filesystem '%s' cannot be "
> "mounted, unable to open the dataset\n"), dataset);
> libzfs_fini(g_zfs);
> return (MOUNT_USAGE);
> }
> ——————
>
> snippet 2
> ————————
>
> /* treat all snapshots as legacy mount points */
> if (zfs_get_type(zhp) == ZFS_TYPE_SNAPSHOT)
> (void) strlcpy(prop, ZFS_MOUNTPOINT_LEGACY,
> ZFS_MAXPROPLEN);
> else
> (void) zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, prop,
> sizeof (prop), NULL, NULL, 0, B_FALSE);
> ———————————
>
> Does this really make sense? Workaround (setting its mountpoint as legacy)
> in order to break
> previous behavior? I don’t see the problem in cloning snapshots in order
> to mount them. But this
> looks like something that can bite back in the future!
>
No, you're misunderstanding something. Nothing weird is required to
manually mount a snapshot. You don't have to change its properties, nor
does it happen automatically. The code you're looking at only relates to
the in-memory copy of the mountpoint property, a property that snapshots
don't have.
-Alan
More information about the freebsd-fs
mailing list