Date: Mon, 19 Nov 2018 02:16:20 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r340593 - head/lib/libbe Message-ID: <201811190216.wAJ2GKpS092150@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Mon Nov 19 02:16:20 2018 New Revision: 340593 URL: https://svnweb.freebsd.org/changeset/base/340593 Log: libbe(3): Properly account for altroot when creating new BEs Previously we would blindly copy the 'mountpoint' property, which includes the altroot. The altroot needs to be snipped off prior to setting it on the new BE, though, or you'll end up with a new BE and a mountpoint of /mnt with altroot=/mnt MFC after: 3 days Modified: head/lib/libbe/be.c head/lib/libbe/be_impl.h Modified: head/lib/libbe/be.c ============================================================================== --- head/lib/libbe/be.c Mon Nov 19 02:12:08 2018 (r340592) +++ head/lib/libbe/be.c Mon Nov 19 02:16:20 2018 (r340593) @@ -305,6 +305,7 @@ be_deep_clone_prop(int prop, void *cb) zprop_source_t src; char pval[BE_MAXPATHLEN]; char source[BE_MAXPATHLEN]; + char *val; dccb = cb; /* Skip some properties we don't want to touch */ @@ -324,7 +325,15 @@ be_deep_clone_prop(int prop, void *cb) if (src != ZPROP_SRC_LOCAL) return (ZPROP_CONT); - nvlist_add_string(dccb->props, zfs_prop_to_name(prop), (char *)pval); + /* Augment mountpoint with altroot, if needed */ + val = pval; + if (prop == ZFS_PROP_MOUNTPOINT && *dccb->altroot != '\0') { + if (pval[strlen(dccb->altroot)] == '\0') + strlcpy(pval, "/", sizeof(pval)); + else + val = pval + strlen(dccb->altroot); + } + nvlist_add_string(dccb->props, zfs_prop_to_name(prop), val); return (ZPROP_CONT); } @@ -367,6 +376,10 @@ be_deep_clone(zfs_handle_t *ds, void *data) dccb.zhp = ds; dccb.props = props; + if (zpool_get_prop(isdc->lbh->active_phandle, ZPOOL_PROP_ALTROOT, + dccb.altroot, sizeof(dccb.altroot), NULL, true) != 0 || + strcmp(dccb.altroot, "-") == 0) + *dccb.altroot = '\0'; if (zprop_iter(be_deep_clone_prop, &dccb, B_FALSE, B_FALSE, ZFS_TYPE_FILESYSTEM) == ZPROP_INVAL) return (-1); Modified: head/lib/libbe/be_impl.h ============================================================================== --- head/lib/libbe/be_impl.h Mon Nov 19 02:12:08 2018 (r340592) +++ head/lib/libbe/be_impl.h Mon Nov 19 02:16:20 2018 (r340593) @@ -55,6 +55,7 @@ struct libbe_deep_clone { struct libbe_dccb { zfs_handle_t *zhp; nvlist_t *props; + char altroot[MAXPATHLEN]; }; typedef struct prop_data {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811190216.wAJ2GKpS092150>