ZFS snapdir readability (Crosspost)

Borja Marcos borjam at sarenet.es
Thu Nov 21 15:01:43 UTC 2019



> 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!








Borja.




More information about the freebsd-fs mailing list