Mercurial > illumos > git > illumos-joyent
changeset 24442:b15f209da3ca
12141 libbe cannot handle vfstab updates in NGZ
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: C Fraire <cfraire@me.com>
Approved by: Dan McDonald <danmcd@joyent.com>
author | Andy Fiddaman <omnios@citrus-it.co.uk> |
---|---|
date | Sun, 29 Dec 2019 02:17:36 +0000 |
parents | ab3477ec2ab2 |
children | fd424ac3379a 8eabac313333 |
files | usr/src/lib/libbe/common/be_create.c usr/src/lib/libbe/common/be_rename.c usr/src/lib/libbe/common/be_utils.c usr/src/lib/libbe/common/libbe_priv.h |
diffstat | 4 files changed, 54 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/lib/libbe/common/be_create.c Sat Jan 04 20:52:29 2020 +0200 +++ b/usr/src/lib/libbe/common/be_create.c Sun Dec 29 02:17:36 2019 +0000 @@ -24,6 +24,7 @@ * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014, 2015 by Delphix. All rights reserved. * Copyright (c) 2016 Martin Matuska. All rights reserved. + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -611,6 +612,8 @@ uuid_t parent_uu = { 0 }; char obe_root_ds[MAXPATHLEN]; char nbe_root_ds[MAXPATHLEN]; + char obe_root_container[MAXPATHLEN]; + char nbe_root_container[MAXPATHLEN]; char ss[MAXPATHLEN]; char *new_mp = NULL; char *obe_name = NULL; @@ -1095,8 +1098,14 @@ /* * Update new BE's vfstab. */ - if ((ret = be_update_vfstab(bt.nbe_name, bt.obe_zpool, bt.nbe_zpool, - &fld, new_mp)) != BE_SUCCESS) { + + be_make_root_container_ds(bt.obe_zpool, obe_root_container, + sizeof (obe_root_container)); + be_make_root_container_ds(bt.nbe_zpool, nbe_root_container, + sizeof (nbe_root_container)); + + if ((ret = be_update_vfstab(bt.nbe_name, obe_root_container, + nbe_root_container, &fld, new_mp)) != BE_SUCCESS) { be_print_err(gettext("be_copy: failed to " "update new BE's vfstab (%s)\n"), bt.nbe_name); goto done;
--- a/usr/src/lib/libbe/common/be_rename.c Sat Jan 04 20:52:29 2020 +0200 +++ b/usr/src/lib/libbe/common/be_rename.c Sun Dec 29 02:17:36 2019 +0000 @@ -69,6 +69,7 @@ be_fs_list_data_t fld = { 0 }; zfs_handle_t *zhp = NULL; char root_ds[MAXPATHLEN]; + char be_root_container[MAXPATHLEN]; char *mp = NULL; int zret = 0, ret = BE_SUCCESS; @@ -205,8 +206,16 @@ } /* Update BE's vfstab */ - if ((ret = be_update_vfstab(bt.nbe_name, bt.obe_zpool, bt.nbe_zpool, - &fld, mp)) != BE_SUCCESS) { + + /* + * Since the new and old BEs reside in the same pool (see above), + * the same variable can be used for the container for both. + */ + be_make_root_container_ds(bt.obe_zpool, be_root_container, + sizeof (be_root_container)); + + if ((ret = be_update_vfstab(bt.nbe_name, be_root_container, + be_root_container, &fld, mp)) != BE_SUCCESS) { be_print_err(gettext("be_rename: " "failed to update new BE's vfstab (%s)\n"), bt.nbe_name); goto done;
--- a/usr/src/lib/libbe/common/be_utils.c Sat Jan 04 20:52:29 2020 +0200 +++ b/usr/src/lib/libbe/common/be_utils.c Sun Dec 29 02:17:36 2019 +0000 @@ -24,7 +24,7 @@ * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright 2016 Toomas Soome <tsoome@me.com> * Copyright (c) 2015 by Delphix. All rights reserved. - * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. * Copyright (c) 2018, Joyent, Inc. */ @@ -517,6 +517,35 @@ } /* + * Function: be_make_root_container_ds + * Description: Generate string for the BE root container dataset given a pool + * name. + * Parameters: + * zpool - pointer zpool name. + * container_ds - pointer to buffer in which to return result + * container_ds_size - size of container_ds + * Returns: + * None + * Scope: + * Semi-private (library wide use only) + */ +void +be_make_root_container_ds(const char *zpool, char *container_ds, + int container_ds_size) +{ + char *root; + + be_make_container_ds(zpool, container_ds, container_ds_size); + + /* If the container DS ends with /ROOT, remove it. */ + + if ((root = strrchr(container_ds, '/')) != NULL && + strcmp(root + 1, BE_CONTAINER_DS_NAME) == 0) { + *root = '\0'; + } +} + +/* * Function: be_make_name_from_ds * Description: This function takes a dataset name and strips off the * BE container dataset portion from the beginning. The
--- a/usr/src/lib/libbe/common/libbe_priv.h Sat Jan 04 20:52:29 2020 +0200 +++ b/usr/src/lib/libbe/common/libbe_priv.h Sun Dec 29 02:17:36 2019 +0000 @@ -24,7 +24,7 @@ * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright 2016 Toomas Soome <tsoome@me.com> * Copyright (c) 2015 by Delphix. All rights reserved. - * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. */ #ifndef _LIBBE_PRIV_H @@ -175,6 +175,7 @@ void be_zfs_fini(void); void be_make_root_ds(const char *, const char *, char *, int); void be_make_container_ds(const char *, char *, int); +void be_make_root_container_ds(const char *, char *, int); char *be_make_name_from_ds(const char *, char *); int be_append_menu(char *, char *, char *, char *, char *); int be_remove_menu(char *, char *, char *);